Introduction
Device Firmware Upgrade (DFU) is a standard from the USB Implementers Forum for updating a USB device’s firmware over its USB connection. The same specification defines a file format: the firmware image followed by a short suffix that says which device it is for, so the flashing tool can refuse to load it into the wrong one. Many microcontrollers, among them most STM32 chips, have a DFU bootloader built in.
STMicroelectronics uses an extended form, DfuSe, which also puts a prefix in front of the image and can hold several images, each with the flash address it belongs at.
Structure
The file is the raw firmware followed by a 16-byte suffix. Numbers in the suffix are
little-endian. The signature is the letters UFD, “DFU” backwards, because
the suffix is meant to be read from the end of the file. A vendor or product ID of
0xFFFF means the file is not tied to one. The last four bytes are a CRC-32
of everything before them.
0firmware image (in DfuSe, a prefix and target sections)varies−16bcdDevice, the firmware release number2 bytes−14idProduct and idVendor4 bytes−10bcdDFU, the DFU version2 bytes−8signatureUFD3 bytes−5suffix length, 161 byte−4CRC4 bytes
Links
Software
- dfu-util, which flashes devices, with
dfu-suffixanddfu-prefixto add and check suffixes (Windows, macOS, Linux) - STM32CubeProgrammer (Windows, macOS, Linux)
Reference
- USB-IF document library, which holds the Device Firmware Upgrade class specification