DFU Bootloader Details

The STM32F405 chip has a built in ROM bootloader that cannot be disabled or erased, this makes it a fool-proof way to always be able to recover your microcontroller code. It's not as easy to use as UF2, but it isnt too difficult either.

The ROM bootloader looks for signal on the serial RX line as well as USB, so make sure no GPS or other serial/uart data device is connected to RX while you are trying to bootload the device!

Enabling DFU bootloader mode

Enabling the DFU bootloader is super easy. Simply connect the BOOT0 (B0) pin to 3.3V logic. Then press the reset button or power cycle while the board is connected to your computer USB port

After you've hit reset, you can remove the BOOT0 jumper - it's only checked on powerup

Check for USB Bootloader device

In Windows, you will see the device show up as STM32 BOOTLOADER under Universal Serial Bus devices

In MacOS X

Visit the AppleMenu->About This Mac->System Report

Select USB and look for the item labeled STM32 BOOTLOADER

Programming Firmware

Windows

The easiest way by far to program under windows is to download STM32CubeProg. It's a graphical programmer, does not require Zadig or special command line invocation

You'll need to make an ST.com account is the only downside.

When you start it up, it'll look like this.

In the top right, below the Not Connected message, find the dropdown to the left of the Connect button

Select USB

OK if the device is plugged in and the bootloader is running, it will show up under the USB configuration pane. If not, enter bootloader mode by connecting BOOT0 to 3.3V and resetting, and click the refresh button.

Once it appears as a valid Port, click Connect

You should see the Device info pane in the bottom right is updated with info about what chip was found!

Click the 3-lines below the STM32 logo in the top left, to expand the menu.

Then click Erasing & Programming

Click Browse to open the firmware files you want to program

You can program .hex or .bin files, it does not seem to support .dfu

Don't change the Start Address

Make sure Verify Programming and Run after Programmingare clicked, but Skip flash erase is not

Then click Start Programming

It will take a few seconds to erase and reprogram the chip.

It's normal to get a Warning Connection is lost alert

Click away until you get the File download complete alert

That's it! You can close STM32 CubeProg

Mac (and Linux)

For Mac users, install dfu-util with brew

dfu-util can only program .bin and .dfu files. It cannot program .hex files (but there are tools to convert .hex's to .bin's)

Then upload the firmware with the command

dfu-util -a 0 --dfuse-address 0x08000000 -D firmware.bin

Don't change the address value, only the firmware filename!

Or, if you have a dfu file - use

dfu-util -a 0 -D firmware.dfu

This guide was first published on Nov 05, 2019. It was last updated on Nov 05, 2019. This page (DFU Bootloader Details) was last updated on Nov 18, 2019.