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

  Рет қаралды 71,655

Matej Blagšič

Matej Blagšič

Күн бұрын

In this video I show you 4 ways to flash firmware onto STM32 using 3 different interfaces. Demonstration is on Fedora 34 but all tools are available on all platforms.
Code and configuration in the video:
github.com/prtzl/Embedded_vid...
Timestamps:
0:00 Introduction
1:56 Project introduction
3:13 ST-LINK: STM32CubeProgrammer (gui)
5:39 ST-LINK: ST-Flash (terminal)
11:16 JLINK (terminal)
14:50 JLINK automated download using Make
20:18 JLINK launch in vscode
21:06 ST-LINK: ST-Flash using Make launched with vscode
22:38 UART using STM32 built in bootloader
33:59 UART configuration using Make
36:19 UART launch with vscode
Links:
STM32CubeProgrammer: www.st.com/en/development-too...
ST-FLASH: github.com/stlink-org/stlink
ST-LINK convert to JLINk: www.segger.com/products/debug...
JLINK software: www.segger.com/downloads/jlink/
UART flasher: sourceforge.net/p/stm32flash/...

Пікірлер: 64
@TimmyWhiskers
@TimmyWhiskers 2 жыл бұрын
Programming and flashing STM32 from VSCode is a dream come true. Thank You!
@haydenbraxton8095
@haydenbraxton8095 2 жыл бұрын
Super thorough video! Thanks for this.
@Abdullu
@Abdullu 15 күн бұрын
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 2 жыл бұрын
Inspiring, I just must test this, thanks a lot for the through demonstration. Cheers.
@majdkassem767
@majdkassem767 2 жыл бұрын
Thank you for sharing your experience
@berkay8406
@berkay8406 11 ай бұрын
You're amazing, nice work!
@mzalewski
@mzalewski Жыл бұрын
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! 😀
11 ай бұрын
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 2 ай бұрын
couldn't you boot0 yourself to safety?
@aleksey_vomarba
@aleksey_vomarba Жыл бұрын
Very useful video, thank you very much! It helped me very much!
@zhitailiu3876
@zhitailiu3876 2 жыл бұрын
Thanks for this great video, it help me a lot!
@hieucdtspk
@hieucdtspk Жыл бұрын
It's a great tutorial, thank so much!
@xxxzeranxxx
@xxxzeranxxx 5 ай бұрын
I think you should add sponsor feature to your channel) It will be fair to reward you for such a great job )
@jainvibhore1997
@jainvibhore1997 Жыл бұрын
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?
@IsrarSayed
@IsrarSayed 8 ай бұрын
Which Pin of Microcontroller you are connecting to RTS ?
@VillageShorts36
@VillageShorts36 3 ай бұрын
hi i have a sti7111 board but uart is block can we open uart with stm32 ?
@tauraimirimi2844
@tauraimirimi2844 2 жыл бұрын
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 3 жыл бұрын
Please.Can you help me explain how to activate a xor mode
@Aldo85ita
@Aldo85ita Ай бұрын
Thank you very much for this video! Did you make a video about how to flash stm32 by stm32flash utility over i2c?
@sruthins4143
@sruthins4143 Сағат бұрын
How to do through CAN?
@user-fj5pv5zo3x
@user-fj5pv5zo3x Жыл бұрын
افرین
@Tome4kkkk
@Tome4kkkk Жыл бұрын
Those interfaces are often more expensive in Poland than the development board. Does neither of these method work with just a plain microusb cable?
Жыл бұрын
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.
@xThirdOpsx
@xThirdOpsx Жыл бұрын
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
Жыл бұрын
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 Жыл бұрын
@ 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?
Жыл бұрын
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 Жыл бұрын
@ 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.
@user-cq1bu5ym9e
@user-cq1bu5ym9e 4 ай бұрын
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 3 ай бұрын
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
@psnyder9442
@psnyder9442 2 жыл бұрын
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.
2 жыл бұрын
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 2 жыл бұрын
@ 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!
@JeffHykin
@JeffHykin 2 жыл бұрын
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.
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 2 жыл бұрын
@ 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
@bozidarnemec7578
@bozidarnemec7578 Жыл бұрын
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.
Жыл бұрын
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 2 жыл бұрын
can we upload firmware through spi ? If yes, how?
2 жыл бұрын
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.
@sinushkin
@sinushkin 2 жыл бұрын
Thank you a lot! what will happen if you regenerate project from CubeMx? Will it rewrite you Makefile with your custom jflash task?
2 жыл бұрын
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 2 жыл бұрын
@ 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.
@tanvirmahmud1048
@tanvirmahmud1048 2 жыл бұрын
Hey I have a Pre compiled .bin file. Now I want to upload that file in STM32. How i can do
2 жыл бұрын
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 2 жыл бұрын
Can you share that .bin file?
2 жыл бұрын
You can run make or build with ide.
@herantd
@herantd 7 ай бұрын
If your on MacOS, just remove '-e' before 'si 1' and before 'r'
@alexchabanenko6347
@alexchabanenko6347 7 ай бұрын
спасибо
@farukhalilagic2070
@farukhalilagic2070 3 жыл бұрын
I guess you do this for your living. Do you use cube mx in your professional projects ?
3 жыл бұрын
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.
@pabloolguin818
@pabloolguin818 2 жыл бұрын
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!!
2 жыл бұрын
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!
2 жыл бұрын
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 2 жыл бұрын
@ 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!
@user-pq6do7mb9x
@user-pq6do7mb9x Жыл бұрын
Pozdrav Mateja. Mozes li mi odma odgovoriti na nekoliko pitanja hitno je?
Жыл бұрын
Moze. A raje po anglesko da je za sve.
@user-pq6do7mb9x
@user-pq6do7mb9x Жыл бұрын
@ Hvala Matej ali problem je rijesen.Veliko hvala da ste pokazali spremnost da pomognete.
@cantaff0rd2
@cantaff0rd2 6 ай бұрын
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 4 ай бұрын
Try set CPUTAPID 0 in your .cfg
@wegi9621
@wegi9621 5 ай бұрын
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.
Debugging STM32 in VSCODE with stlink and jlink | VIDEO 45
17:33
Matej Blagšič
Рет қаралды 41 М.
Extracting and Modifying Firmware with JTAG
21:03
Matt Brown
Рет қаралды 36 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 9 МЛН
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 13 МЛН
Cool Items! New Gadgets, Smart Appliances 🌟 By 123 GO! House
00:18
123 GO! HOUSE
Рет қаралды 17 МЛН
Scientific Concepts You're Taught in School Which are Actually Wrong
14:36
I Melted Wood With Friction
8:44
The Action Lab
Рет қаралды 856 М.
Installing the STM32 USB Bootloader, Easily! [SEE DESCRIPTION]
8:02
Caleb Marting
Рет қаралды 262 М.
The Rise of Unix. The Seeds of its Fall.
16:51
Asianometry
Рет қаралды 480 М.
The mind behind Linux | Linus Torvalds | TED
21:31
TED
Рет қаралды 6 МЛН
Why You NEED a DRIVER (for hacking games)
8:03
cazz
Рет қаралды 444 М.
STM32 UART BootLoader HowTo
10:25
Web learning
Рет қаралды 67 М.
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 1,4 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 58 МЛН
Look, this is the 97th generation of the phone?
0:13
Edcers
Рет қаралды 4,3 МЛН
iPhone socket cleaning #Fixit
0:30
Tamar DB (mt)
Рет қаралды 15 МЛН
Зачем ЭТО электрику? #секрет #прибор #энерголикбез
0:56
Александр Мальков
Рет қаралды 631 М.