STM32 + SWD + ST-Link + CubeIDE | Debugging on Custom Hardware Tutorial - Phil's Lab #4

  Рет қаралды 102,518

Phil’s Lab

Phil’s Lab

Күн бұрын

Guide on how to connect, check, program, and debug your custom STM32-based hardware via SWD and the ST-Link debugger utilising STM32CubeIDE.
If you have any questions or suggestions for future videos, please let me know in the comments!
[Timestamps]
00:00 Introduction
00:28 ST-Link
01:08 Hardware Connections
02:11 ST-Link Utility (Checking that we can connect to STM32 MCU)
03:37 STM32CubeIDE (Programming and debugging software package)
05:22 Enabling SWD
06:04 Setting up an external high-speed crystal (HSE)
07:10 Additional peripheral selection
08:50 LED blinking test code
09:44 Building code and checking for compiler errors
10:02 Debug configuration, debugging, and flashing via ST-Link
11:26 Running, pausing, and setting breakpoints
12:20 Hardware running code
[Hardware]
ST-Link/V2 Debugger: www.st.com/en/...
20-pin to 10-pin 1.27mm Adapter: www.olimex.com...
[Software]
STM32CubeIDE: www.st.com/en/...
ST-Link Utility: www.st.com/en/...
ID: QIBvbJtYjWuHiTG0uCoK

Пікірлер: 131
@slazy9219
@slazy9219 Жыл бұрын
You really are an inspiration bro! Found you through your KiCad course, your videos really help me alot. I want to dive deeper into STM32 boards. Wish you the best for 2023
@disposedtrolley
@disposedtrolley 4 жыл бұрын
Thanks Phil! I'm just getting into STM32 and custom board design and your videos have been really helpful.
@satchell78
@satchell78 4 жыл бұрын
The Eclipse IDE has come a long way. Thanks Phil, awesome stuff!
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you! Yeah, I’m pretty happy ST took over TrueStudio and merged all the CubeMX stuff into their IDE.
@jonathanfulcher602
@jonathanfulcher602 4 жыл бұрын
This is exactly what I needed. Thanks!
@deeperblues4189
@deeperblues4189 3 жыл бұрын
Spot on information for a newbie to the STM32 tools. Many thanks Phil!
@PhilsLab
@PhilsLab 3 жыл бұрын
Awesome, thank you for watching!
@adaminsanoff
@adaminsanoff 4 жыл бұрын
I enjoy watching your videos after a long working day.
@PhilsLab
@PhilsLab 4 жыл бұрын
Thanks, Adam!
@kenwallace6493
@kenwallace6493 3 жыл бұрын
Yes indeed, very clear and useful. The debugger is complex with a steep learning curve. This helps.
@lucianopavarotti4715
@lucianopavarotti4715 4 жыл бұрын
Great video, clear explanation with simple software and hardware example! Thank you for sharing the knowledge!
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you very much!
@edwinvp
@edwinvp 2 жыл бұрын
Thank you for this very nice video! Your video provided the hints I was looking for. I've got a working "hello blinky LED" program now. One note in case of my board, I had to press the RESET button on the board before ST link application would recognize the target.
@johnadriani7467
@johnadriani7467 4 жыл бұрын
Realy cool.. realy clearly good voice .. is not to fast yor trutoreal everything is good to understand.. you are a very good teacher
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you very much, John!
@michaelzlprime
@michaelzlprime 4 жыл бұрын
Going from the Arduino IDE to a fully-featured, debug-enabled IDE, is like switching from a kids bike to a sport's car
@PhilsLab
@PhilsLab 4 жыл бұрын
Exactly! It's incredibly hard to ever go back to such a basic environment after you've been exposed to something as cool as a debug-enabled IDE.
@TheRainHarvester
@TheRainHarvester 3 жыл бұрын
But do you lose all the Arduino libraries? ( I'd hate to port all the lcd display code.)
@SessoDeluca
@SessoDeluca 3 жыл бұрын
Thats why i watch these videos. I dont like Arduino IDE
@jobaptist
@jobaptist 3 жыл бұрын
arduino is shit
@TheRainHarvester
@TheRainHarvester 3 жыл бұрын
@@jobaptist I've developed multi core graphics code with threaded debuggers in kernel mode. But for such simple projects, Arduino ide is desirable because I don't have to bother with re-porting libraries or figuring out bit twiddling to enable interrupts, or timers and clocks. I do wish Arduino ide had a debugger, but the trade off is fine for me because, overall, it takes less time to get my Arduino project finished.
@jackiewang7725
@jackiewang7725 3 жыл бұрын
Thanks a lot! 5:42 is very important. I originally thought my debugger is broken.
@brendanhayes-oberst1398
@brendanhayes-oberst1398 2 жыл бұрын
the best stm32 tutorials on youtube
@PhilsLab
@PhilsLab 2 жыл бұрын
Thank you, Brendan!
@saadtiwana
@saadtiwana 3 жыл бұрын
You make some of the best videos! You have yourself another subscriber!
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you, Saad!
@rgwynnjones
@rgwynnjones 2 жыл бұрын
Thanks Phil, great pacing and very useful to help me get started with STM and ST-Link, coming from other embedded tools like TI/CCS, Arduino,VS-Code/ESP32 etc.
@PhilsLab
@PhilsLab 2 жыл бұрын
Thank you very much, Richard!
@theoneandonlymattp
@theoneandonlymattp 8 ай бұрын
Hi Phil, is it possible to connect to a board using the STM32 debugger and pull the software off or atleast see the software on the chip? as i have been sent a board by a customer who has had an issue with there and it's suspected the chip has lost its data but is unsure.
@ronaldo0grande
@ronaldo0grande 4 жыл бұрын
very clear explanation like ever. I just dont understand why you have to set 168mhz. But sounds like is something to have in mind
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you! You can essentially set the clock frequency to your liking, I just usually set the frequency to the chip’s maximum frequency to get the greatest performance out of it. For the STM32F405RGT6 the max. frequency is 168MHz (as also shown in CubeIDE), but will of course vary for each chip (e.g. some H7’s can go up to 480MHz).
@electrodonkey
@electrodonkey 4 жыл бұрын
Hi Phil, really good job for doing these videos, they are concise and well made! I enjoy the content and apreciate your effort! Do you consider making a video about the prototyping phase - breadboard and/or simulation?
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you very much! I was planning on making a video (or series) on going from initial idea through to final product. Now just need an idea haha!
@paulusheystee5051
@paulusheystee5051 4 жыл бұрын
@@PhilsLab Well, I might have a good idea for you.
@fabioalmeida4700
@fabioalmeida4700 2 жыл бұрын
You explain so well, congrats, and continue the good work.
@PhilsLab
@PhilsLab 2 жыл бұрын
Thank you, Fabio.
@Electromechaniac
@Electromechaniac 2 ай бұрын
Hello! Could You describe the model/producer (maybe part number) of white connectors? Thanks a lot!
@nickbolton9435
@nickbolton9435 Жыл бұрын
1:31: This caused me a couple of hours frustration; that you can't power MCUs from pin 1 on a [real] ST-LINK/V2. The part where you said "It's just a reference voltage" was something I wish had been made clearer in the docs. I then realised I had to use pin 19 (non-ISOL device only) to power my board at 3.3 V. The confusing part is that pin 1 needs to also be connected, as well as pin 19.
@hUgO6191
@hUgO6191 3 жыл бұрын
Can you help me out with something? When I use ST-Link I can connect to my board however when I try to debug with STM32CubeIDE I get an error ST-Link not found.
@NOTHINGbutGOAT
@NOTHINGbutGOAT 6 ай бұрын
How do i setup a ground control station for this??
@Rtech98
@Rtech98 4 жыл бұрын
Quick question, do you need that device in order to program an STM32? I'm using an STM32 along with a Bluetooth module to make my Bluetooth headphones, but I was planning on using UART and not SWD.
@PhilsLab
@PhilsLab 4 жыл бұрын
You don't need the ST-Link to program (all?) STM32s. By pulling the BOOT0 pin high, you can usually flash the device via UART, USB (if available), etc.
@Rtech98
@Rtech98 4 жыл бұрын
Phil S Gotcha makes sense, thanks for the help.
@FinneyDale
@FinneyDale 3 жыл бұрын
Great channel. I've learned a lot from your videos. I have a v2 debugger (cheap clone). I have no problems connecting to my stm32 with it. I decided to upgrade to a genuine v3. I got the mini. I was interested in the SWV and virtual comm port (starting to regret this purchase). The V3 looks healthy and took a firmware upgrade but my target refuses to connect. Because it came only with a 1.27 cable, I'm using a jtag adapter to connect to the 2.54 pins on the target. Problem is the the ground detect pin is not accessible - so I just used ground - and am wondering if this is my problem. My other connections are SWDIO, SWCLK, and SWV (not required). I am powering the target through the separate usb. Anyway, I noticed in the comments that you're using v2 but am hoping that one of your followers might have some insight. Thanks for making these videos. Plan b is to butcher the cable but I really don't want to do that.
@muratkancaoglu3284
@muratkancaoglu3284 Жыл бұрын
I bought a V3SET original from its website during free-shipping times. They have UART, SPI connectors but no regular ARM10 so i need adapter as well. Kinda shocked these options on board (and missing cover on bottom which i 3D printed). I haven't tested it but they have jumpers described in manuals (UM2448). If everything fails there's probably a broken link on cable.
@piyush513
@piyush513 3 жыл бұрын
Hello sir, big fan!! Please make video on designing a ST-Link with custom software which can be incorporated in one of projects.
@younesthabet
@younesthabet 2 жыл бұрын
@5:45 why you choose Serial Wire instead of JTAG4/5 !? and what is the difference between them!?
@PhilsLab
@PhilsLab 2 жыл бұрын
SWD typically only requires 2 signal pins and works perfectly fine for these applications.
@armincal9834
@armincal9834 2 жыл бұрын
I have a custom Chinese board which has an Stm32f105RC. The designer has decided to put 4 SWD pins on it. I want to program it using a Chinese clone St-link v2. But Cube can't find the mcu even tho it's power led is on. I guess I am connecting things wrong. My question is, how come swd needs 4 pins(on the board) but the stm32 socket on my debugger has 10 pins?
@javidnoor8402
@javidnoor8402 2 жыл бұрын
Hi Phil, i hope you are doing well .is it possible to read hex from Stm32 and write in to new Stm32 with St-link v2 .i just want to understand can we copy this Hex and write in to blank stm32 .my one board damage and want to copy that hex file in to new fresh stm32 .
@kailimedia
@kailimedia Жыл бұрын
Can swd do boundary scan like jtag?
@laabonimukerjee1724
@laabonimukerjee1724 3 жыл бұрын
this was really helpful! Thanks a lot! Hoping you have a related playlist :)))
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you, glad to hear that! Yes, I have a few vids on STM32 hardware design and programming :)
@brendanhayes-oberst1398
@brendanhayes-oberst1398 2 жыл бұрын
Do you have a video where you make this particular pcb?
@PhilsLab
@PhilsLab 2 жыл бұрын
I have a video showing the basic design steps for this PCB (Flight Control System Design).
@jlesquer
@jlesquer 4 жыл бұрын
Good video!! At last something without arduino stuff ;) thanks for sharing!
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you! Haha yeah, breaking away from Arduino stuff opened up a whole new world.
@ubotics27
@ubotics27 3 жыл бұрын
Great videos well done Phils. I’m currently having some issues with STM32H7 chip on a board I designed, and I don’t seem to find resources on how to program the chip directly with STLink/V2 programmer via SWD. Can you suggest me any help? as I haven’t been able to downloaded any code to the chip. Thanks
@omeranar8769
@omeranar8769 4 жыл бұрын
how can i change/modify variable's values while code runinng.
@VincentNeemie
@VincentNeemie Жыл бұрын
Hello Phil, how are you doing? Are you only able to debug and read the code in the stm if you are the creator of the code? or can anyone review and edit as long as they have physical access to the chip board? Thank you in advance!
@kumarm1780
@kumarm1780 2 жыл бұрын
St- link V2 will it work for STM32H7 series as debugger?
@cmfanz
@cmfanz 3 жыл бұрын
@phil, great work. Love your channel. Could you make a video on debugging using jtag using your st link connector and a demo on writing and reading from the microcontroller registers using the jtag tap pins? The reason is I ask this is because this a common use-case in the industry and a lot of entry level engineers will benefit from knowing this.
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you very much! I'm afraid I don't really use JTAG for these projects and have only been using SWD so far, so probably am not experienced enough to make a video on that :/
@kd4pba
@kd4pba 2 жыл бұрын
Super helpful!
@jonathanfulcher602
@jonathanfulcher602 4 жыл бұрын
What Gps chip are you using? Is it available in on-offs?
@myidentity222
@myidentity222 4 жыл бұрын
Thank you very much Phil, this will solve my problem,,,
@PhilsLab
@PhilsLab 4 жыл бұрын
Very glad to hear that!
@sreeragmt2255
@sreeragmt2255 4 жыл бұрын
Hi phil thanks for the video . I have a doubt regarding SWD, st link utility is not detecting my custom made ST32f429 board , its showing target cannot be connected. Please help me on this.
@PhilsLab
@PhilsLab 4 жыл бұрын
Hi Sreerag, do you have any schematics I could look at?
@KingdomChablo
@KingdomChablo 2 жыл бұрын
Hi Phil, just another question about the power inputs. I see you have many voltage sources(More than 2 usb and that lipo source) but my question is, can you plug in all the sources at once? Also if you were to plug in 2 usb, how would 2 5v inputs safely work? What if i wanted to monitor battery while i plug usb to monitor via serial port?
@PhilsLab
@PhilsLab Жыл бұрын
Hi Darren, the power inputs are essentially 'OR'-ed with diodes, so it's safe to plug in multiple power sources at the same time, as only one will be active at any time.
@obriska
@obriska 4 жыл бұрын
I would argue that STM32CubeProgrammer is more current tool than st-link utility for flashing and other development/hacking activities. In fact, it is the only way for those who are not using Windows.
@PhilsLab
@PhilsLab 4 жыл бұрын
Yes, I’d agree with that as well. I pretty much exclusively use SWD + CubeIDE, so the other programs are just for quick checks (for me).
@tron1098
@tron1098 Жыл бұрын
Thank you so much! This helped me get going with the MIKROE board, the documentation of MikroSDK and their forum were barely helpful
@PhilsLab
@PhilsLab Жыл бұрын
Glad to hear that, thanks for watching!
@RaamakrishnanNS
@RaamakrishnanNS 3 жыл бұрын
Hi Phil, Can this ST-Link also be used for STM 8 bit controllers? or is it specific to STM32 controllers?
@PhilsLab
@PhilsLab 3 жыл бұрын
Hi, I believe so - but never tried myself.
@user-qp4gs4ky8h
@user-qp4gs4ky8h 3 жыл бұрын
Hallo Phili! Thanks for your great video! Could you please tell me whether this board was delivered by JLCPCB with all of the electriconic components already being soldered? Thank you!
@PhilsLab
@PhilsLab 3 жыл бұрын
Hi Sam, This board was actually made by PCBWay - and yeah all components were soldered on when I got them.
@carlosgarcialalicata
@carlosgarcialalicata Жыл бұрын
Why do people use smt32s? Aren't ESP better for 90% of cases?
@seankayll9017
@seankayll9017 3 жыл бұрын
Thanks, this is just what I needed. Just to be clear, is this the method for programming a freshly soldered vanilla STM32 chip ie. not one that has had a bootloader previously flashed?
@PhilsLab
@PhilsLab 3 жыл бұрын
All STM32 chips come with a bootloader already flashed. Some STM32s however only support certain ways of flashing firmware (e.g. USB, UART, etc.) - but all will of course do SWD.
@seankayll9017
@seankayll9017 3 жыл бұрын
@@PhilsLab Thanks Phil.
@MrZomhad
@MrZomhad 4 жыл бұрын
Very useful! Thanks and cheers!
@PhilsLab
@PhilsLab 4 жыл бұрын
Awesome, I'm glad to hear that!
@refusneant
@refusneant 3 жыл бұрын
You save me a lot of time thanks
@PhilsLab
@PhilsLab 3 жыл бұрын
Glad to hear that, thanks!
@TopicsInControlSystems
@TopicsInControlSystems 4 жыл бұрын
Good video! Is there a way to program multiple STM32F303 parts on a board using a multi-drop SWD or other interface?
@PhilsLab
@PhilsLab 4 жыл бұрын
Thanks! I'm not sure if that's possible via SWD. It should be possible via JTAG I think but not entirely sure of that either!
@mohamedfaroukbouklihacene819
@mohamedfaroukbouklihacene819 4 жыл бұрын
thank you for this verry useful share!..i have a question please...won't you use a RTOS (FreeRTOS for example) when implementing the real code hundling all destinated board functionalities? thank you!
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you! Yes, I'm currently using FreeRTOS for this. I hope to make some more videos about that as well.
@mohamedfaroukbouklihacene819
@mohamedfaroukbouklihacene819 4 жыл бұрын
thanks! i hope that too!... good luck!
@muhammedoglubey2502
@muhammedoglubey2502 3 жыл бұрын
Hello Phil! I have a question about powering the board, i have been using Bluepill board for a while now, and i never had to plug in the USB cable to power it, SW was always sufficient and it also powered my sensors, my question to you is why do you have to plug USB for power?
@PhilsLab
@PhilsLab 3 жыл бұрын
Hi Mohammed! Typically the ST-Link does not (and shouldn't) provide power to the board but rather sense the working voltage of the target board. Therefore, for custom designs you should always provide external power.
@muhammedoglubey2502
@muhammedoglubey2502 3 жыл бұрын
@@PhilsLab Thank you for the answer Phil 😀
@domoledlight
@domoledlight Жыл бұрын
very usefull video
@PhilsLab
@PhilsLab Жыл бұрын
Thanks!
@Simcadepro
@Simcadepro 4 жыл бұрын
HI Phil, tell me is there any way to debug a 256MU806 (dsPIC33EP) by using the ST-link V2? or which device and software would give me access to the 256MU806...Much appreciate the help, thank you for your content it has helped to understand.
@PhilsLab
@PhilsLab 4 жыл бұрын
Hi Takumi, I'm afraid I don't think you'll be able to use the ST-Link to debug anything other than ST microcontrollers. PIC-specific debuggers are here: www.microchip.com/DevelopmentTools/Listing/a063fb83-a427-45b7-afa0-71cc9e8f8c44 Maybe the Black Magic Probe (github.com/blacksphere/blackmagic/wikigithub.com/blacksphere/blackmagic/wiki) will let you debug PICs with some tweaking?
@Simcadepro
@Simcadepro 4 жыл бұрын
@@PhilsLab howsit gent thank you for replying, i spent a few night researching on Mplab debugging programmer the Pickit 4 this device will work with MPLAB X IDE. the pickit3 and below are limited to the microchip on the market, again thank you and thank you for amazing content.
@puits-de-science
@puits-de-science 4 жыл бұрын
A treat !
@PhilsLab
@PhilsLab 4 жыл бұрын
Thank you!
@shrikantvaishnav1077
@shrikantvaishnav1077 3 жыл бұрын
Thankyou Phil..
@PhilsLab
@PhilsLab 3 жыл бұрын
Thank you for watching!
@wassimz20
@wassimz20 4 жыл бұрын
Hello. Do you suggest to but st-link V2 or V3?
@PhilsLab
@PhilsLab 4 жыл бұрын
I've still got the 'old' V2 and it's sufficient for pretty much all devices I work on.
@mariglenzgjana8691
@mariglenzgjana8691 4 жыл бұрын
hi, whats the name of your board and what is that for ?
@PhilsLab
@PhilsLab 4 жыл бұрын
This is an early version of my flight control board. There is another video on my channel going into a bit more detail.
@konturgestalter
@konturgestalter 3 жыл бұрын
perfect
@farosrohmangeloraramadan3897
@farosrohmangeloraramadan3897 4 жыл бұрын
cool xt30 socket
@abdelaliboussetta1450
@abdelaliboussetta1450 4 жыл бұрын
Thank you!
@PhilsLab
@PhilsLab 4 жыл бұрын
My pleasure!
@FinneyDale
@FinneyDale 3 жыл бұрын
I got it.
@marroukihatem817
@marroukihatem817 4 жыл бұрын
thanx
@KingdomChablo
@KingdomChablo 3 жыл бұрын
can you use an arduino ide?
@PhilsLab
@PhilsLab 3 жыл бұрын
I believe you can use the Arduino IDE, there is this plugin (?) called: STM32Duino (github.com/stm32duino) that'll let you program the devices via the IDE if you wish.
@godislove3709
@godislove3709 2 жыл бұрын
You forgot to close gp1 gp2 on board
@pawanv86
@pawanv86 4 жыл бұрын
Don't you need an antenna!? 😦
@PhilsLab
@PhilsLab 4 жыл бұрын
There's a GPS antenna connector (SMA) on the board. Wasn't using GPS for this video so didn't attach it.
@pawanv86
@pawanv86 4 жыл бұрын
@@PhilsLab I thought it was a transmitter connector that you forgot to attenuate. You definitely know what you are doing! Great videos, thanks a lot!
@user-xi8bt1gh5z
@user-xi8bt1gh5z Жыл бұрын
🍮🍮🍮🍮🍮🍮🍯🍯🍯🍯🥤🥤🥤🥤🧁🧁🧁
How To Write A Driver (STM32, I2C, Datasheet) - Phil's Lab #30
38:21
WHO CAN RUN FASTER?
00:23
Zhong
Рет қаралды 39 МЛН
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 10 МЛН
My Cheetos🍕PIZZA #cooking #shorts
00:43
BANKII
Рет қаралды 24 МЛН
Они так быстро убрались!
01:00
Аришнев
Рет қаралды 3 МЛН
Remote Debugging ARM Chip with SWD/JTAG - Hardware Wallet Research #3
12:20
SWD Debug Issues check list
11:12
Web learning
Рет қаралды 12 М.
Debugging STM32 in VSCODE with stlink and jlink | VIDEO 45
17:33
Matej Blagšič
Рет қаралды 42 М.
KiCad STM32 + RF + USB Hardware Design - Phil's Lab #5
44:01
Phil’s Lab
Рет қаралды 343 М.
Supercharge Your STM32 Nucleo Projects with Segger J-Link
8:17
PR TechTalk
Рет қаралды 4,2 М.
92. Program STM32 using STM32 Cube Programmer formally ST-LINK utility
7:33
MicroPeta by Nizar Mohideen
Рет қаралды 3 М.
6 Horribly Common PCB Design Mistakes
10:40
Predictable Designs
Рет қаралды 189 М.
📱магазин техники в 2014 vs 2024
0:41
djetics
Рет қаралды 903 М.
Google Pixel 9/Pro/Fold Impressions: They've Finally Done It?
13:25
Marques Brownlee
Рет қаралды 6 МЛН