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

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 มิ.ย. 2024
  • 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/development-too...
    20-pin to 10-pin 1.27mm Adapter: www.olimex.com/Products/ARM/J...
    [Software]
    STM32CubeIDE: www.st.com/en/development-too...
    ST-Link Utility: www.st.com/en/development-too...
    ID: QIBvbJtYjWuHiTG0uCoK
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 132

  • @slazy9219
    @slazy9219 ปีที่แล้ว +3

    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 ปีที่แล้ว +8

    Thanks Phil! I'm just getting into STM32 and custom board design and your videos have been really helpful.

  • @satchell78
    @satchell78 4 ปีที่แล้ว +4

    The Eclipse IDE has come a long way. Thanks Phil, awesome stuff!

    • @PhilsLab
      @PhilsLab  4 ปีที่แล้ว +6

      Thank you! Yeah, I’m pretty happy ST took over TrueStudio and merged all the CubeMX stuff into their IDE.

  • @kenwallace6493
    @kenwallace6493 3 ปีที่แล้ว

    Yes indeed, very clear and useful. The debugger is complex with a steep learning curve. This helps.

  • @lucianopavarotti4715
    @lucianopavarotti4715 3 ปีที่แล้ว +1

    Great video, clear explanation with simple software and hardware example! Thank you for sharing the knowledge!

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      Thank you very much!

  • @adaminsanoff
    @adaminsanoff 4 ปีที่แล้ว +1

    I enjoy watching your videos after a long working day.

    • @PhilsLab
      @PhilsLab  4 ปีที่แล้ว

      Thanks, Adam!

  • @deeperblues4189
    @deeperblues4189 3 ปีที่แล้ว +1

    Spot on information for a newbie to the STM32 tools. Many thanks Phil!

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      Awesome, thank you for watching!

  • @jonathanfulcher602
    @jonathanfulcher602 4 ปีที่แล้ว +10

    This is exactly what I needed. Thanks!

  • @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.

  • @fabioalmeida4700
    @fabioalmeida4700 2 ปีที่แล้ว

    You explain so well, congrats, and continue the good work.

    • @PhilsLab
      @PhilsLab  2 ปีที่แล้ว

      Thank you, Fabio.

  • @jackiewang7725
    @jackiewang7725 2 ปีที่แล้ว

    Thanks a lot! 5:42 is very important. I originally thought my debugger is broken.

  • @johnadriani7467
    @johnadriani7467 4 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      Thank you very much, John!

  • @saadtiwana
    @saadtiwana 3 ปีที่แล้ว

    You make some of the best videos!
    You have yourself another subscriber!

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      Thank you, Saad!

  • @electrodonkey
    @electrodonkey 4 ปีที่แล้ว +1

    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 ปีที่แล้ว +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.

  • @brendanhayes-oberst1398
    @brendanhayes-oberst1398 2 ปีที่แล้ว

    the best stm32 tutorials on youtube

    • @PhilsLab
      @PhilsLab  2 ปีที่แล้ว

      Thank you, Brendan!

  • @myidentity222
    @myidentity222 4 ปีที่แล้ว

    Thank you very much Phil, this will solve my problem,,,

    • @PhilsLab
      @PhilsLab  4 ปีที่แล้ว

      Very glad to hear that!

  • @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 :)

  • @jlesquer
    @jlesquer 4 ปีที่แล้ว +1

    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.

  • @MrZomhad
    @MrZomhad 4 ปีที่แล้ว

    Very useful! Thanks and cheers!

    • @PhilsLab
      @PhilsLab  4 ปีที่แล้ว +1

      Awesome, I'm glad to hear that!

  • @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).

  • @kd4pba
    @kd4pba 2 ปีที่แล้ว

    Super helpful!

  • @ubotics27
    @ubotics27 2 ปีที่แล้ว

    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

  • @refusneant
    @refusneant 3 ปีที่แล้ว

    You save me a lot of time thanks

    • @PhilsLab
      @PhilsLab  2 ปีที่แล้ว

      Glad to hear that, thanks!

  • @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.

  • @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!

  • @dhruslab9563
    @dhruslab9563 2 ปีที่แล้ว

    Hi sir,
    great content but in your flight controller respiratory there are 2 firmwares , can you please specify which firmware will go to which micro controller? which one is uploaded to F4 (Navic)mcu and which will be uploaded to F7(The main flight controller).

  • @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 ปีที่แล้ว +1

      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 :/

  • @FinneyDale
    @FinneyDale 3 ปีที่แล้ว +2

    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.

  • @domoledlight
    @domoledlight ปีที่แล้ว

    very usefull video

  • @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.

  • @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!

  • @shrikantvaishnav1077
    @shrikantvaishnav1077 3 ปีที่แล้ว

    Thankyou Phil..

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว +1

      Thank you for watching!

  • @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.

  • @abdelaliboussetta1450
    @abdelaliboussetta1450 4 ปีที่แล้ว

    Thank you!

    • @PhilsLab
      @PhilsLab  4 ปีที่แล้ว

      My pleasure!

  • @puits-de-science
    @puits-de-science 4 ปีที่แล้ว

    A treat !

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      Thank you!

  • @Electromechaniac
    @Electromechaniac 10 วันที่ผ่านมา

    Hello! Could You describe the model/producer (maybe part number) of white connectors? Thanks a lot!

  • @TopicsInControlSystems
    @TopicsInControlSystems 3 ปีที่แล้ว

    Good video! Is there a way to program multiple STM32F303 parts on a board using a multi-drop SWD or other interface?

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      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!

  • @theoneandonlymattp
    @theoneandonlymattp 6 หลายเดือนก่อน

    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.

  • @jonathanfulcher602
    @jonathanfulcher602 4 ปีที่แล้ว

    What Gps chip are you using? Is it available in on-offs?

  • @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 ปีที่แล้ว +1

      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.

  • @KingdomChablo
    @KingdomChablo ปีที่แล้ว

    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.

  • @omeranar8769
    @omeranar8769 3 ปีที่แล้ว

    how can i change/modify variable's values while code runinng.

  • @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 .

  • @kumarm1780
    @kumarm1780 2 ปีที่แล้ว

    St- link V2 will it work for STM32H7 series as debugger?

  • @konturgestalter
    @konturgestalter 3 ปีที่แล้ว

    perfect

  • @Rtech98
    @Rtech98 4 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      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.

  • @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.

  • @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?

  • @marroukihatem817
    @marroukihatem817 4 ปีที่แล้ว

    thanx

  • @NOTHINGbutGOAT
    @NOTHINGbutGOAT 3 หลายเดือนก่อน

    How do i setup a ground control station for this??

  • @farosrohmangeloraramadan3897
    @farosrohmangeloraramadan3897 4 ปีที่แล้ว

    cool xt30 socket

  • @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!

  • @michaelzlprime
    @michaelzlprime 3 ปีที่แล้ว +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  3 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      @@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.

  • @sreeragmt2255
    @sreeragmt2255 3 ปีที่แล้ว

    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  3 ปีที่แล้ว

      Hi Sreerag, do you have any schematics I could look at?

  • @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 ปีที่แล้ว +1

      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 😀

  • @kailimedia
    @kailimedia ปีที่แล้ว

    Can swd do boundary scan like jtag?

  • @RaamakrishnanNS
    @RaamakrishnanNS 2 ปีที่แล้ว

    Hi Phil, Can this ST-Link also be used for STM 8 bit controllers? or is it specific to STM32 controllers?

    • @PhilsLab
      @PhilsLab  2 ปีที่แล้ว

      Hi, I believe so - but never tried myself.

  • @younesthabet
    @younesthabet 2 ปีที่แล้ว

    @5:45 why you choose Serial Wire instead of JTAG4/5 !? and what is the difference between them!?

    • @PhilsLab
      @PhilsLab  2 ปีที่แล้ว +1

      SWD typically only requires 2 signal pins and works perfectly fine for these applications.

  • @FinneyDale
    @FinneyDale 3 ปีที่แล้ว

    I got it.

  • @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  3 ปีที่แล้ว

      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 3 ปีที่แล้ว

      @@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.

  • @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).

  • @wassimz20
    @wassimz20 3 ปีที่แล้ว

    Hello. Do you suggest to but st-link V2 or V3?

    • @PhilsLab
      @PhilsLab  3 ปีที่แล้ว

      I've still got the 'old' V2 and it's sufficient for pretty much all devices I work on.

  • @obriska
    @obriska 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      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).

  • @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.

  • @carlosgarcialalicata
    @carlosgarcialalicata ปีที่แล้ว

    Why do people use smt32s? Aren't ESP better for 90% of cases?

  • @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.

  • @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!

  • @godislove3709
    @godislove3709 2 ปีที่แล้ว

    You forgot to close gp1 gp2 on board

  • @user-xi8bt1gh5z
    @user-xi8bt1gh5z 10 หลายเดือนก่อน

    🍮🍮🍮🍮🍮🍮🍯🍯🍯🍯🥤🥤🥤🥤🧁🧁🧁