F411 (and F401) bootloaders

User avatar
Hackswell
Posts: 21
Joined: Sat Mar 14, 2020 9:04 pm
Location: State of Confusion

F411 (and F401) bootloaders

Post by Hackswell »

Ok... I'm a bit confused as to the differences in these STM32-F411 bootloaders (similar for F401).

* (Hardware) STM32 BOOTLOADER [dfu] (pre-installed on stm32 chip) [available after holding KEY for 1/2 second and releasing] [USB]

*STM32 HID Bootloader (pre-installed) [default bootloader] [ST-LINK?]
*STM32duino-bootloader [available on github from mfgr]

Where are each of these three stored in memory... just in case I erase one (COUGH) and need to re-install it? Can all three co-exist? Or just the first two? If the STM32duino bootloader cannot coexist, which bootloader(s) does it replace?

Thank you very much!


STM32 Bootloader:
-----------------------
usb 7-4: New USB device found, idVendor=0483, idProduct=df11
usb 7-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 7-4: Product: STM32 BOOTLOADER
usb 7-4: Manufacturer: STMicroelectronics
usb 7-4: SerialNumber: 359437543336

HID Bootloader:
-------------------
usb 7-4: New USB device found, idVendor=0483, idProduct=572a
usb 7-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 7-4: Product: WeAct STM32 HID Bootloader
usb 7-4: Manufacturer: WeAct
usb 7-4: SerialNumber: 359437543336
hid-generic 0003 : 0483 : 572A.0012 : hiddev0,hidraw3 :
USB HID v1.11 Device [WeAct WeAct STM32 HID Bootloader] on usb-0000 : 00 : 16.0-4/input0
Last edited by Hackswell on Thu Mar 19, 2020 3:33 am, edited 3 times in total.

ag123
Posts: 467
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: F411 (and F401) bootloaders

Post by ag123 »

stm32 has a built-in dfu usb boot loader. (F401, F411)
the way it works is you need to set boot0, basically pressing that button that the vendor placed as boot0 on the board. next press and release reset.
a second later you can release boot0.
it should now be in the dfu mode waiting for upload
you need to find a way to check if it is connecting as a usb dfu device. e.g .in windows i'm not sure if you would see it in device manager.
on linux i run a dfu-util -l and it should list the devices

and with that it should be possible to install firmware on the board. e.g. in windows you may want to use stm32cubeprogrammer which support all the various internal boot modes
https://www.st.com/en/development-tools ... eprog.html

any other things like hid bootloader or roger's ('stm32duino bootloader') - it originates from the leaflabs maple boot loader and roger made much improvements, and this one is for stm32f103 pill boards only (the original board that uses it is actually the maple mini https://www.leaflabs.com/maple) . those are additional firmware that you need to install on the board.

for more information about the stm32 built-in boot loader, take a look at some documents on ST's web site
https://www.st.com/resource/en/applicat ... ronics.pdf

User avatar
Hackswell
Posts: 21
Joined: Sat Mar 14, 2020 9:04 pm
Location: State of Confusion

Re: F411 (and F401) bootloaders

Post by Hackswell »

I've updated my original post. Thanks so much.

So, the DFU is on the stm chip itself?

And the HID (ST-LINK) and STMduino are _software_ flash loaders, correct? Only one can be installed at a time, correct? If using the Arduino IDE, I'd probably be better off with STMduino, correct?

And to flash either of those, I'd use the dfu-tool (I'm on linux)?

ag123
Posts: 467
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: F411 (and F401) bootloaders

Post by ag123 »

yup, all true, you won't 'accidentally' erase the internal boot loader it is in ROM
roger's boot loader only works on stm32f103, so there is only the HID bootloader for F4xx if you want to use that.
for the software/firmware bootloaders you install them at 0x8000000 (start of flash address)
then firmware (your sketch) is compiled for a different address e.g. 0x8002000 and sits just after the boot loader.
the software boot tloaders are more for convenience than that a need, accordingly HID bootloaders doesn't need a separate driver on windows.
but you need a utility to flash firmware still.

for the internal boot loader you built your sketch to install at 0x8000000 (start of flash), you can use all that flash whatever you want
in Arduino IDE that is done by choosing the boot loader. in actual implementation, there are ld scripts (find them in the variant folders, it is there) that specify the start address and size of flash

to flash an any firmware (including the software / firmware (e.g. HID) bootloaders) you can either use any ot the internal boot loaders methods (see ST documentation) or use a st-link v2 (or any other SWD / JTAG dongle that works for stm32) to install the firmware.

in linux the tool is dfu-util to install firmware with the internal usb dfu boot loader
http://dfu-util.sourceforge.net/

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
to list the available dfu devices it is

Code: Select all

dfu-util -l
there are various tools in windows including the stm32cubeprogrammer described earlier it supports all the internal boot loader methods and st-link v2

if you use an st-link v2, in linux the utilities are like st-flash:
https://github.com/texane/stlink
or you can use a jtag/swd debugger like openocd
http://openocd.org/

BennehBoy
Posts: 47
Joined: Sat Jan 04, 2020 2:38 am

Re: F411 (and F401) bootloaders

Post by BennehBoy »

Hackswell wrote:
Thu Mar 19, 2020 3:31 am
And the HID (ST-LINK)
The HID bootloader is a software bootloader, it does NOT require ST-LINK (although you may use ST-LINK to actually flash the bootloader to the device). When activated it allows the device to be flashed via USB Serial (CDC). This means you must have USB Serial enabled in the IDE when you compile any sketch since the code which is used to recognise an upload request is handled within the CDC code for the core (both Roger's and STM's), the core listens for a 'magic' sequence on USB Serial and if it is detected will enable the bootloader (1EAF is the keyword). HID bootloader requires NO drivers on the host machine since it is recognised as a generic Human Interface Device.

Most F4 devices have a built in hardware DFU bootloader, a driver is required on the host device to use this. These are activated physically via the BOOT pins.

Since DFU was not available for F1 in hardware Maple provided a software DFU bootloader for the maple mini, this requires a host driver. This is activated by a magic word over USBSerial or by the BOOT pins.

Roger (and others) later improved upon the Maple bootloader and created the STM32duino bootloader which uses less flash, this also requires a host driver. This is activated by a magic word over USBSerial or by the BOOT pins.

stevestrong
Posts: 268
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 5
Location: Munich, Germany
Contact:

Re: F411 (and F401) bootloaders

Post by stevestrong »

Hackswell wrote:
Thu Mar 19, 2020 1:24 am
*STM32duino-bootloader [available on github from mfgr]
Can you please post a link to this? I could not find it.

User avatar
Hackswell
Posts: 21
Joined: Sat Mar 14, 2020 9:04 pm
Location: State of Confusion

Re: F411 (and F401) bootloaders

Post by Hackswell »

stevestrong wrote:
Thu Mar 19, 2020 8:52 am
Hackswell wrote:
Thu Mar 19, 2020 1:24 am
*STM32duino-bootloader [available on github from mfgr]
Can you please post a link to this? I could not find it.
https://github.com/WeActTC/STM32duino-bootloader
"WeActTC / STM32duino-bootloader
forked from rogerclarkmelbourne/STM32duino-bootloader"

stevestrong
Posts: 268
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 5
Location: Munich, Germany
Contact:

Re: F411 (and F401) bootloaders

Post by stevestrong »

But this is only for F103, not F4x1 MCUs.

User avatar
Hackswell
Posts: 21
Joined: Sat Mar 14, 2020 9:04 pm
Location: State of Confusion

Re: F411 (and F401) bootloaders

Post by Hackswell »

stevestrong wrote:
Fri Mar 20, 2020 8:54 am
But this is only for F103, not F4x1 MCUs.
D'0h! I feel the dumb now.

ag123
Posts: 467
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: F411 (and F401) bootloaders

Post by ag123 »

use the internal boot loader for a start, i got pretty used to it
there really isn't need for additional boot loaders on F4xx
connect usb cable, press both reset + boot0, release reset, release boot0 1 sec later
http://dfu-util.sourceforge.net/

Code: Select all

dfu-util -l

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
this is good enough for the occasional install. for more convenience, use a st-link v2 (no need to touch boot0, but you may need to connect the reset pin) or a serial-uart dongle (uart requires meddling with the boot0 and reset pins as well, but it is possible to use the dtr / rts pins to reset / boot0 for that purpose)
https://github.com/jsnyder/stm32loader
http://tumanako.sourceforge.net/wiki/in ... U_Flashing

Post Reply

Return to “STM32F4 based boards”