Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:DfuSe file (.dfu)

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

STMicroelectronics' DfuSe firmware container (.dfu): an 11-byte 'DfuSe' prefix, one or more 'Target' images each holding address+size elements, and the 16-byte DFU suffix ('UFD' signature, CRC32) that plain USB DFU files also carry.

Overview

The .dfu files for STM32 system bootloaders (read by dfu-util and ST's DfuSeDemo) wrap one or more memory images. Plain USB DFU 1.1 files are just the raw firmware followed by the 16-byte DFU suffix; DfuSe files put the DfuSe prefix, target and element headers in front of the same suffix. dfu-util's header says the DfuSe extensions follow DfuSe 1.1a and the file format is described in ST document UM0391 (the document itself was not read).

Layout

All multi-byte fields are little endian.

  1. DfuSe prefix (11 bytes): ASCII 'DfuSe', format version byte (dfu-util only accepts 0x01), a 32-bit total file size (Unverified: not parsed by dfu-util; name taken from ST documentation memory), and byte 10 = number of targets.
  2. Per target, a 274-byte target prefix: ASCII 'Target', bAlternateSetting at byte 6 (the USB alternate interface that selects the memory), byte 7 non-zero if the target is named, a 255-byte name string from byte 11, a 32-bit target size at 266 and a 32-bit element count at 270.
  3. Per element: 8-byte header (32-bit start address, 32-bit size) followed by that many data bytes. Elements of a target follow each other directly.
  4. DFU suffix (16 bytes, last in the file).

DFU suffix

The last 16 bytes, shared with plain DFU files: bcdDevice (2), idProduct (2), idVendor (2), bcdDFU (2, 0x0100 or 0x011A for DfuSe: Unverified), the bytes 'U','F','D' stored so that the file reads 'UFD' at offset 8, the suffix length (16), then a 32-bit CRC. The CRC is the common reflected CRC-32 table algorithm seeded with 0xFFFFFFFF and NOT inverted at the end, computed over every byte of the file except the final 4. Vendor, product and device ids of 0xFFFF are wildcards in dfu-util. A suffix is accepted only if signature and CRC both match.

Identification

A file ending in 55 46 44 10 plus 4 CRC bytes has a DFU suffix; if it starts with 'DfuSe' it is a DfuSe container whose element addresses (for example 0x08000000 for STM32 flash) show the target memory. Other prefixes dfu-util knows: an 8-byte TI/Stellaris 'LMDFU' prefix and a 16-byte NXP LPC unencrypted prefix (first byte 0x1a).

Code & repositories

  • https://gitlab.com/dfu-util/dfu-util @ f9a537c93935d9d536b5ea29b54a226160b2b111 · license: GPL-2.0-or-later (declared by the contributor for the files used; GitHub reports GPL-2.0+ for the repository)
    dfu-util: DfuSe and DFU suffix reading and writing (src/dfuse.c, src/dfu_file.c), GPL-2.0-or-later.
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-03-18

Pitfalls

Element sizes are not checked against the target size field by dfu-util; it only checks that an element fits in the remaining bytes and warns about leftover bytes.