Flashing STM32 with ST-LINK, JLINK and UART Bootloader, cross platform | VIDEO 44

Sdílet
Vložit
  • čas přidán 11. 09. 2024

Komentáře • 65

  • @TimmyWhiskers
    @TimmyWhiskers Před 3 lety +5

    Programming and flashing STM32 from VSCode is a dream come true. Thank You!

  • @mzalewski
    @mzalewski Před rokem +1

    Thank for section about programming using UART!
    I just disabled SWD (I set all pins as inputs 🤦‍♂) on processor by mistake and UART is the only option to reprogram it. You are my savior! 😀

    •  Před rokem +2

      I did that as well heh, so some degree. I just used JLink and connect under reset. Since the pins only set themselves to input when the code boots, you can connect the debugger to the core right after reset. Debugger and their tools saved me that time :)

    • @tariqsingh3747
      @tariqsingh3747 Před 3 měsíci

      couldn't you boot0 yourself to safety?

  • @haydenbraxton8095
    @haydenbraxton8095 Před 3 lety +1

    Super thorough video! Thanks for this.

  • @xxxzeranxxx
    @xxxzeranxxx Před 7 měsíci

    I think you should add sponsor feature to your channel) It will be fair to reward you for such a great job )

  • @Abdullu
    @Abdullu Před 2 měsíci +1

    For Debian 12: If you installed "stlink-tools/bookworm-backports" and when executing "st-info --probe" you get "ERROR usb.c: Could not open USB device 0x0483:0x3748, access error." ... then execute (with elevated privileges) "udevadm trigger", then "udevadm control --reload-rules" ... this will reload udev rules installed with the apt package without requiring a reboot. These udev rules allow all regular users to interact with ST-LINK hardware debugger USB devices, including the "clone sticks".

  • @Cptnbond
    @Cptnbond Před 2 lety

    Inspiring, I just must test this, thanks a lot for the through demonstration. Cheers.

  • @majdkassem767
    @majdkassem767 Před 2 lety

    Thank you for sharing your experience

  • @berkay8406
    @berkay8406 Před rokem

    You're amazing, nice work!

  • @aleksey_vomarba
    @aleksey_vomarba Před rokem

    Very useful video, thank you very much! It helped me very much!

  • @IsrarSayed
    @IsrarSayed Před 10 měsíci +1

    Which Pin of Microcontroller you are connecting to RTS ?

  • @hieucdtspk
    @hieucdtspk Před rokem

    It's a great tutorial, thank so much!

  • @Aldo85ita
    @Aldo85ita Před 2 měsíci

    Thank you very much for this video! Did you make a video about how to flash stm32 by stm32flash utility over i2c?

  • @VillageShorts36
    @VillageShorts36 Před 5 měsíci

    hi i have a sti7111 board but uart is block can we open uart with stm32 ?

  • @user-fj5pv5zo3x
    @user-fj5pv5zo3x Před rokem

    افرین

  • @jainvibhore1997
    @jainvibhore1997 Před rokem

    Great tutorial, I was wondering if it was possible to upload the binaries over USB with something like maple bootloader installed on cheap bluepill boards?

  • @JeffHykin
    @JeffHykin Před 2 lety

    What terminal prompt are you using?
    I really like the grayed out username@host on the right!
    And great video. Showing *how* and where the original info is in the manuals/docs was phenomenal.

    •  Před 2 lety +2

      Thank you for the comment, I'm glad you found my video usefull.
      As for the terminal prompt ... I was in the process of building a better one (as you can see in all the videos, even ditros change). Only constant is zsh, which is my shell of choice. I played around the raw .zshrc config adding info to the right part of the promt. Here I moved usual username and hostname to the right with grey colors, so that there is more space for the current path. Later I moved the username:hostname back to the left with rainbow colors, but I added git info (when in git repository) to the right.
      I don't have that exact config anymore, but I configured this with snippets from the forums (search for "zsh right prompt") and you'll figure out the syntax and where to change the contents and color. I recommend Luke Smith's channel and his config: github.com/LukeSmithxyz/voidrice/blob/master/.config/zsh/.zshrc
      Nowdays I use starship.rs/ and I love the two line promt - now there is SPACE for the command line even with a long directory path. I even added git info, nix, etc. You can find it in my repository for fedora config (distro does not matter): github.com/prtzl/fedora-config.

    • @JeffHykin
      @JeffHykin Před 2 lety

      @ thanks for the detailed response! I'll definitely search that
      I also use Zsh (spaceship-prompt), I've been looking at upgrading to starship but haven't made the switch yet. I've also been watching the warp terminal project

  • @Tome4kkkk
    @Tome4kkkk Před rokem

    Those interfaces are often more expensive in Poland than the development board. Does neither of these method work with just a plain microusb cable?

    •  Před rokem

      All methods using STLINK or JLink utilities are available for the devboards using onboard debugger. With JLink you are limited to debuggers up to version 2.1. It does not work with newer stlink v3.

  • @user-cq1bu5ym9e
    @user-cq1bu5ym9e Před 6 měsíci

    Hello, Thank you for your this tutorial.
    Do you have the pinout of your stm32 with the ftdi chip? i'm putting DTR to boot0, RX => TX(uC), TX => RX(uC) what else am i missing?
    Thanks

    • @user-cq1bu5ym9e
      @user-cq1bu5ym9e Před 5 měsíci

      I didn't end up using the dtr pin, i just set boot0 = 1 and boot1 = 0, and use the stm32flash utility and it worked (nucleo-F401RE), this is the command :
      stm32flash.exe -w led_blinking_F4.elf -v -g 0x0 -b 9600 COM10

  • @sruthins4143
    @sruthins4143 Před měsícem

    How to do through CAN?

  • @alexchabanenko6347
    @alexchabanenko6347 Před 8 měsíci

    спасибо

  • @dummag4126
    @dummag4126 Před 20 dny

    why not with usb?

  • @xThirdOpsx
    @xThirdOpsx Před 2 lety

    Thanks a lot for this video.
    One question: in the uart example you show the use of the dtr and rts pins, but the uart interface on any stm only requires rx and tx, and dtr and rts only go to the ftdi chip or whatever other uart-usb bridge one has. Is my understanding of the circuit correct? Does this also mean that if I choose a usb-uart bridge that doesnt have those control signals I won't be able to flash the stm32? Thanks

    •  Před 2 lety

      That's correct.
      In the video I used a ft232 chip on a breadboard which has dtr(connected to boot0) and rst available. Some uart cables/adapters omit dtr pin, like the official ftdi cables, that just have cts instead of dtr. Cta cannot be used as output, so for flashing it's useless.
      Well, you can also get the device into boot mode by switching pins manualy and therefore you can omit options that use that pin.

    • @xThirdOpsx
      @xThirdOpsx Před 2 lety

      @ Thanks! So basically you are taking advantage of the fact that the dtr lines goes high right before starting transmitting the new firmware and goes low when finished, which is exactly how you want the boot0 pin to behave, so you just tie them together, is this correct?

    •  Před 2 lety

      Partly. In the video I configure the particular ftdi chip to have the dtr low at idle - this would make the stm32 use default boot from flash.
      Then I toggle the dtr line along with rts using the stm32flash command, which puts the mcu into bootloader mode and out again after flashing.
      So if your ftdi/serial cable does not have dtr, then remove the ping toggling options of dtr and rts and perform the bootloader yourself and also the device reset after flashing as well.
      That reminds me to look into cables with dtr exposed instead of cts.

    • @xThirdOpsx
      @xThirdOpsx Před 2 lety +1

      @ Ok now after reading the stm32flash docs it's more clear what you are doing. I will not use an ftdi chip in my design so I will have to possibly place an inverter gate in dtr and rts, will check the datasheet for the default logic level. One last thing I need to verify is that stm32flash is able to use those signals regardless of the uart ic in use. Seems pretty obvious that this pin toggling action should work with any uart ic that has those signal. Personally I will use the CH340C.

  • @psnyder9442
    @psnyder9442 Před 2 lety +1

    I have been helped a lot by several of your videos, thank you very much for your clear explanations. I now have completed my s/w development on an STM32F411RE and wish to use it standalone, that is, with no laptop connected.
    Do I have the correct understanding that if I use the STM32CUBEProgrammer to program my flash memory using the project .bin file created by STM32CUBE IDE as you describe, that I can disconnect my laptop, connect a dedicated board power supply, and my code will run as intended? I am unclear, for example, if that project .bin file includes all of the setup actions such as interrupt vectors, clock and peripheral initialization. I understand that I will need to consult the manual to configure the jumpers to allow this to happen, but I can probably figure that out on my own. Thank you.

    •  Před 2 lety

      Hi, I'm glad that my videos have helped you.
      When you flash your board, more often than not, you flash your program in .bin format, which includes everything (functions, static data, constants, system init, etc.), you write it into internal flash memory which is non-volatile. This means, that even after disconnecting power, the contents of your application will be left intact. Therefore you can flash your board with either Cubeprogrammer or with newer stlink v2s you can just drag and drop the binary into the mounted stlink drive and the device will flash itself. After that on every power on , the board will start your application.
      Thank you for watching.

    • @psnyder9442
      @psnyder9442 Před 2 lety +1

      @ I took your advice and it worked! Then, I powered by an external ps and it powered-up and ran my code. Then, I powered down and reconnected to ST-LINK and could continue development. Wonderful, thanks again!

  • @farukhalilagic2070
    @farukhalilagic2070 Před 3 lety

    I guess you do this for your living. Do you use cube mx in your professional projects ?

    •  Před 3 lety +1

      I also use Cube for work. Other companies have their versions like Cypress Psoc creator so it's common to use such tools. If nothing more you save time for initialization and also removes possibility for such bugs.

  • @herantd
    @herantd Před 8 měsíci

    If your on MacOS, just remove '-e' before 'si 1' and before 'r'

  • @bozidarnemec7578
    @bozidarnemec7578 Před rokem

    Hello Matej. Great tutorial. Can you please help me. I am programm the STM32G030 with st-flash (release 1.7.0) on raspberry pi4 and tool st-link-v2 (orginal ST or clone). Usaly it is not working, programm process interrupts because the tool find wrong processor id, or the programming result is OK "jolly good", but insite the processor is nothing written. what can be wrong? how i can "stable" programm the STM32 with raspberry pi 4 and st-link-v2? please help me thank you.

    •  Před rokem

      I cannot find a problem just by your description. Your mcu should have id of 0x466 and is supposed to be supported on stlink. Can you try st-probe to get some info?
      Also, do you have all the libraries? Did the build succeed with no major warnings or errors? Have you installed all the correct libraries?
      Also, do you have the correct image for your mcu? Did it build correctly?
      There is a possibility that either the mcu is dead or the programmer is not working 100%. I have one dead f4 discovery board. I tried using stlink (original), then the open source tool, I also tried reflashing the debugging with jlink and using external debugger to confirm that none of them worked. If you have that option, you can try (using windows) to convert a debugger to jlink and try with that as well.
      Also you can try using stlink (open source) to erase the whole memory and try flashing again - create new dummy project that you know should work for this mcu.

  • @stuff2learn07
    @stuff2learn07 Před 2 lety

    can we upload firmware through spi ? If yes, how?

    •  Před 2 lety

      I'm not sure, but you can check built in dfu bootloader specification datasheet and find your mcu family. It will have at least uart but some also have usb and i2c, maybe spi as well.

  • @tauraimirimi2844
    @tauraimirimi2844 Před 3 lety

    great video. am trying to fiddle with stm32s after pics and avrs. also looking for diy flasher coz i hve battery bms from 48v telecom bat boards.

  • @hsenaed6894
    @hsenaed6894 Před 3 lety

    Please.Can you help me explain how to activate a xor mode

  • @sinushkin
    @sinushkin Před 2 lety

    Thank you a lot! what will happen if you regenerate project from CubeMx? Will it rewrite you Makefile with your custom jflash task?

    •  Před 2 lety

      I can't belive I did not mentioned this, because I have a feeling I did in at least one video, but I cannot find it.
      I have also tested this now as well, but the answer is still NO. It will update certain sections, where you add new peripherals and it would add include paths, but if you delete some parts of it, it won't write them back or correct them. Only if you delete the makefile, it will create a new one. Make sure to use git for your project, even if just localy, to prevent any accidental damage to the makefile.

    • @sinushkin
      @sinushkin Před 2 lety +1

      @ ok, thank you. I just thought that put flash tasks to make file is wrong (ideologically) vscode can cascade tasks. For example you can create task make, flash and combine them into another build'n'flash. And use it in preLaunch. In this case you can leave makefile prestine.

  • @user-pq6do7mb9x
    @user-pq6do7mb9x Před rokem

    Pozdrav Mateja. Mozes li mi odma odgovoriti na nekoliko pitanja hitno je?

    •  Před rokem

      Moze. A raje po anglesko da je za sve.

    • @user-pq6do7mb9x
      @user-pq6do7mb9x Před rokem +1

      @ Hvala Matej ali problem je rijesen.Veliko hvala da ste pokazali spremnost da pomognete.

  • @tanvirmahmud1048
    @tanvirmahmud1048 Před 3 lety

    Hey I have a Pre compiled .bin file. Now I want to upload that file in STM32.
    How i can do

    •  Před 3 lety

      You can do it as shown in the video for the stlink/jlink that you have, or uart. Just insert the path to the binary file into your download command.

    • @shahzaibshamim6524
      @shahzaibshamim6524 Před 3 lety

      Can you share that .bin file?

    •  Před 3 lety

      You can run make or build with ide.

  • @pabloolguin818
    @pabloolguin818 Před 2 lety

    Hi,
    Thank you for you channel. I really helpfull to me. I would like to know how I configure VSCode terminal with this colors and git location. If you can to tell me how to configure it I'm will be greatful.
    Greetings from Chile!!

    •  Před 2 lety

      Thank you for kind words. I'm glad you find my videos useful.
      I'm using zsh with starship on my system. This is what gives me a two line prompr with current directory, git info and more. Vscode uses your default shell, so when I launch a terminal in vscode, it runs zsh, which is configured with starship and other addons. Search on internet for starship.rs . It also works with bash and fish and is easy to configure.
      Cheers!

    •  Před 2 lety

      Oh, you can also find my starship and zsh config (the colors and git info) im my github repository github.com/prtzl/fedora-config inside dotfiles directory (starship.toml and zsh.rc)

    • @pabloolguin818
      @pabloolguin818 Před 2 lety

      @ Thank you! I will try to configure it. Also, I would like to work with FFT. Do you know how can I use CMSIS library to calculate FFT with DSP of STM32F446ze?.
      Thank you very much again!

  • @cantaff0rd2
    @cantaff0rd2 Před 8 měsíci

    Hi. Nice series. Do you perhaps know why I am getting this error?
    /usr/local/share/stlink/chips: No such file or directory
    2024-01-12T18:30:05 WARN common.c: unknown chip id! 0x413
    Failed to connect to target
    Failed to parse flash type or unrecognized flash type
    I have tried different methods but it also seems to want something from /usr/local/share/stlink/chips and that path does not exist on my station. Do you know what could be wrong? Thanks

    • @e.m.451
      @e.m.451 Před 6 měsíci

      Try set CPUTAPID 0 in your .cfg

  • @wegi9621
    @wegi9621 Před 7 měsíci

    Really I don't understand where is the sense replace ST-LINK firmware to J-LINK. Bcos I understand the big heart of J-LINK factory with releasse firmware for STM32 was a step, when STM added to their own products like NUCLEO, Discovery and so on integrated ST-LINK with very huge builded firmware as MSC, VCP and ST-LINK. So J-LINK releassed their firmware when J-LINK was a worthless option in comparision to ST-LINK. Also we need remember how expensive is this J-LINK shit. So we shouldn't bother J-LINK with this. It's a waste of the time.

  • @zhitailiu3876
    @zhitailiu3876 Před 2 lety

    Thanks for this great video, it help me a lot!