Using a DFU bootloader – e.g. on STM32 F2/F3/F4 based flight controllers

Disclosure: This post may contain affiliate links, meaning I get a commission if you decide to make a purchase through my links, at no cost to you.

By | September 2, 2016

All STM32F3 based flight controller boards and various other hardware using a STM32F3 CPU can be upgraded using the DFU protocol over an USB connection. This DFU bootloader resides in the ROM of the STM32 core and is not erasable, so this bootloader is un-brickable (yay!).

In order to flash those boards one needs a special tool that talks to the DFU bootloader using special USB commands. One of these programs is called dfu-util. It is available for Windows, Linux, and Mac machines.

As the tool runs on Windows and Linux, i wrote down instructions for both operating systems, scroll down for the Linux version 😉

Installing dfu-util on Windows

In order to install dfu-util on windows some requirements have to be satisfied. First of all dfu-util uses the WinUSB library to talk to the USB device. Therefore the first steps involve installing WinUSB. Thankfully there is a nice toolchain called Zadig that installs this driver for you. Visit the Zadig website and download the appropriate version for your machine.

Next, boot your STM32F3 board into the bootloader mode by shorting the BOOT pin before connecting any battery or USB cable. There should be no blinking lights if the device entered the bootloader mode sucessfully (permanent on is ok). Start up Zadig and select “STM32 BOOTLOADER” and click install driver. Zadig will now install WinUSB for you.

Now visit the dfu-util releases website and download the latest zip for your windows version. We will use dfu-util-0.9-win64.zip. Extract the zip file to a folder of your choice (we will use the Desktop directory). Now let’s test the installation: Click on Start -> Run and enter cmd.exe. A commandline window should appear. Now enter the following text:

cd Desktop
cd dfu-util-0.9-win64
dfu-util -l

this should show some information as seen below. If you get an error like could not open device try to re-insert the USB connector with the shorted BOOT jumper again.

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
 This program is Free Software and has ABSOLUTELY NO WARRANTY
 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=2200, devnum=4, cfg=1, intf=0, path="1-2.1", alt=1, n
 ame="@Option Bytes  /0x1FFFF800/01*016 e", serial="206C354E2037"
 Found DFU: [0483:df11] ver=2200, devnum=4, cfg=1, intf=0, path="1-2.1", alt=0, n
 ame="@Internal Flash  /0x08000000/128*0002Kg", serial="206C354E2037"

Done. Now you can proceed to flash your hardware…

Installing dfu-util on Linux

First of all make sure to have the appropriate libusb development headers installed:

sudo apt-get install libusb-1.0-0-dev

Next, download and install the latest sources:

git clone git://git.code.sf.net/p/dfu-util/dfu-util
cd dfu-util
./autogen.sh
./configure
make
sudo make install

Done. Now you can proceed to flash your hardware…