Having a problem with bootloader after uploading code

Bootloader for STM32F103 and STM32F4xx micro-controllers
No special driver is required. Support for Windows, Linux and Mac Operating System
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Having a problem with bootloader after uploading code

Post by ag123 »

If in doubt, buy/use a st-link v2
https://www.adafruit.com/product/2548
https://octopart.com/search?q=st-link+v2
connect the wires appropriately, no button presses are needed.
otherwise like mentioned prior, on the stm32f401/f411 'black pills' the finger dance normally is
- press both reset and boot0
- hold boot0, release reset
- release boot0 2 sec later
then run your stm32 cube programmer to program it, that should work as well from Arduino IDE
make sure stm32 cube programmer is properly installed and linked up

the more seasoned tinkerers can use dfu-util, it works in linux, but may be more troublesome in windows.
http://dfu-util.sourceforge.net/
Last edited by ag123 on Sat Jan 22, 2022 9:03 pm, edited 1 time in total.
parisianos
Posts: 11
Joined: Tue Jan 18, 2022 11:17 pm

Re: Having a problem with bootloader after uploading code

Post by parisianos »

Thank you dear friend. For me not work the reset DFU. I tried many times with BOOT and Reset without succes
Now I don't have the STM32 BOOTLOADER.
Before failed I haved the port Com into device manager too
And now I don't know what can I do.
Thank you a lot
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Having a problem with bootloader after uploading code

Post by ag123 »

if you see a com port, that is most likely your sketch (i.e. stm32duino)
the finger dance need to be done properly.
more formally.

- set boot0
- then reset (the mcu - not your pc)

it would drop into DFU boot loader mode (on stm32f4xx - e.g. f401/f411 etc)
some PCs has trouble with that, it has something to do with the crystal frequency, f401/f411 blackpills uses a 25mhz crystal.
Accordingly, that may be too high for the built-in bootloader to make a correct guess.
That may mess up usb that can't cope with it.
if you can't get around this, a st-link v2 would fix it. program it using swd pins

oh and you need to select the correct bootloader in Arduino IDE if you are using that. not the 'HID' bootloader etc.
selecting the 'wrong' bootloader in arduino ide, will program it to the wrong address.
parisianos
Posts: 11
Joined: Tue Jan 18, 2022 11:17 pm

Re: Having a problem with bootloader after uploading code

Post by parisianos »

Thank you ag123
BOOT and Reset not work.
Please have you a good link for st-ilnk and SWD pins uploading code ???
I will searche too
Thank you
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Having a problem with bootloader after uploading code

Post by ag123 »

if your board looks like this
https://stm32-base.org/boards/STM32F401 ... -Pill-V3.0
there is a set of pins named
  • GND
  • SWSCK
  • SWDIO
  • 3V3
these pins need to be connected to the corresponding pins on the ST-Link V2 dongle.
it may be better if the reset pins is connected across to the dongle as well. (needed in some situations)
Adafruit sells one of them
https://www.adafruit.com/product/2548
then the originals looked like this, they are stocked by the likes of digikey, farnell (element14.com) etc as well
https://www.st.com/en/development-tools/st-link-v2.html

and STM32 cube programmer is the tool to use for programming it
https://www.st.com/en/development-tools ... eprog.html
this should be integrated with arduino ide if you installed the core and cube programmer properly.

there are open sourced utilities like this
https://github.com/stlink-org/stlink
this works well in linux, but on windows issues may vary

st-link v2 is not only used for programming, its main purpose is actually debug !
you may find it helpful at some point if you need to do on chip debug.
oh and if you get a ST Nucleo or ST Discovery boards, st-link is mostly already built on board in a separate chip. Often a stm32f103.

a useful thing about st-link v2 is it doesn't need the boot pins to program the sketch, some people likes this due to the convenience.
once connected you won't need to 'touch' the board, simply program away on the ide.
parisianos
Posts: 11
Joined: Tue Jan 18, 2022 11:17 pm

Re: Having a problem with bootloader after uploading code

Post by parisianos »

Thank you for all your infos ag123.
I have STM32 BOOTLOADER into Peripheral Universal Serial Bus. What this mean ?
I am more agile with Arduino IDE and I am only recent applicate to STM32 cards. May I programmed with St-link into Arduino ? I suppose is the STM32CubeProgrammer(SWD) in the config ?
Thank you again for your help
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Having a problem with bootloader after uploading code

Post by GonzoG »

If you see "STM32 BOOTLOADER" in device manager, then your board has booted into DFU mode and you can upload program to board via USB.
You can connect with STMCubeProgrammer or upload from Arduino IDE selecting "STM32CubeProgrammer (DFU)" as an upload method.

If you want to use ST-Link, you don't need to boot MCU into DFU mode. Just connect ST-link to board (you might need to connect reset pin do ST-link also), select "STM32CubeProgrammer (SWD)" as an upload method, click "upload" in Arduino IDE.
parisianos
Posts: 11
Joined: Tue Jan 18, 2022 11:17 pm

Re: Having a problem with bootloader after uploading code

Post by parisianos »

Thank you GonzoG. The problem is that I can't upload program in DFU mode. This is my problem from the beginning. Little strange
And the STMCube Programmer don't see the card. In all modes. Strange too
Thank you
parisianos
Posts: 11
Joined: Tue Jan 18, 2022 11:17 pm

Re: Having a problem with bootloader after uploading code

Post by parisianos »

Hi everybody
I tested upload with ST-link and the code is ok. It works. But I saw that the monitor not works for debug. Have you some ideas ?
Thank you
Post Reply

Return to “STM32 HID bootloader”