Back to resources
Chip programming
Firmware
HIL

Flashing the STM32H753 over USB DFU with a BenchPod

How the BenchPod flashes an STM32H753 through the USB DFU loader in the chip's ROM: DfuSe step by step, the three wires to a NUCLEO-H753ZI, and bench results.

Edward Viaene · November 23, 2026 · 9 min read

The STM32H753 is a Cortex-M7 microcontroller with 2 MB of flash. Like every STM32, it carries a bootloader in ROM that ST programs at the factory. With the BOOT0 pin high at reset, the chip starts that bootloader instead of your program, and it shows up on USB as a DFU device: you can write the flash with nothing but a USB cable, no ST-LINK and no debug header. On a NUCLEO-H753ZI the cable goes to the user USB connector, CN13.

A BenchPod can be the USB host for that. Instead of you running dfu-util on a laptop, the pod enumerates the board, reads its flash layout, erases, writes and starts the new image, all from a test script or an AI agent. This article is part of a series, one per chip we have run on real hardware: the overview of how the BenchPod flashes microcontrollers lists them all. It covers how USB DFU and ST's DfuSe extension work, how the pod implements it, the wiring, and what we measured.

USB DFU in one paragraph

DFU (Device Firmware Upgrade) is a standard USB class for exactly this job. A device in DFU mode shows one DFU interface (class 0xFE, subclass 0x01, protocol 0x02) and answers a handful of control requests on endpoint 0. There are no bulk endpoints. The host moves the image with DFU_DNLOAD requests, one block per request, and after every block it asks DFU_GETSTATUS. The reply holds an error code, a state and a poll timeout (bwPollTimeout): how long the host should wait before asking again. While the device programs the block it reports dfuDNBUSY; when it is ready for the next one it reports dfuDNLOAD-IDLE. A DFU_DNLOAD with zero length ends the download, and the device then manifests the new firmware.

The interface descriptor is followed by a DFU functional descriptor with the device's attributes and wTransferSize, the largest block it takes in one request.

What ST adds: DfuSe

Plain DFU has no notion of addresses: the image is a stream. STM32 chips need to say where it goes and to erase flash sectors first, so ST extended the protocol. It is called DfuSe, and the functional descriptor announces it with a DFU version of 0x011A.

One alternate setting per memory. The ROM loader lists several alternate settings on the same DFU interface, one for each memory (internal flash, option bytes and so on). Each has a string descriptor that describes the memory layout, in a fixed format:

@Internal Flash  /0x08000000/04*016Kg,01*064Kg,07*128Kg

That reads as: the memory starts at 0x08000000, with 4 sectors of 16 KB, 1 sector of 64 KB and 7 sectors of 128 KB. The letter after the size says what the sectors allow: readable, erasable, writable (g means all three). This particular string is the layout of a different STM32 family, used here to show the format; every part reports its own.

Commands in block 0. DfuSe repurposes block number 0 of DFU_DNLOAD. A block 0 download with 5 bytes is a command, not data: one command byte and a 4-byte little-endian address.

CommandByteWhat it does
Set Address Pointer0x21Sets the address where the next data block goes
Erase0x41Erases the flash sector that contains the address

Data from block 2. Data blocks start at block number 2. Block n is written at the address pointer plus (n - 2) times the transfer size.

DfuSe block numbering: block 0 carries the Erase and Set Address Pointer commands, data blocks start at block 2 and land one transfer size apart, starting at the address pointer.
DfuSe block numbering: block 0 carries the Erase and Set Address Pointer commands, data blocks start at block 2 and land one transfer size apart, starting at the address pointer.

So a host that writes a 1024-byte-block image to 0x08000000 sets the pointer to that address with one command, then sends blocks 2, 3, 4 and so on, and each lands 1024 bytes after the one before. Each command and each data block is followed by DFU_GETSTATUS polling, because erasing and programming flash takes the ROM real time.

The sequence the pod runs

The pod runs a complete DfuSe download as a state machine on its MCU. The phases it reports are start, descriptors, layout, erase, address, write, leave and done.

The DfuSe sequence between the pod and the STM32H753 ROM loader, from reading the descriptors to the zero-length download that makes the board boot the image.
The DfuSe sequence between the pod and the STM32H753 ROM loader, from reading the descriptors to the zero-length download that makes the board boot the image.
  1. Descriptors. The pod reads the configuration descriptor, finds the DFU interface and its functional descriptor, and notes the transfer size and whether the loader speaks DfuSe. It reads the string descriptor of the interface and parses the memory layout from it. One detail any DFU host has to handle: ST's ROM loader lists all its alternate settings first (one per memory) and places the DFU functional descriptor after the last of them, which the DFU spec allows. A host must scan the whole configuration descriptor for it. The pod takes the first DFU interface in its alternate setting 0 and keeps scanning through that interface's other alternate settings until the functional descriptor appears.
  2. A known state. The pod reads the status. If the loader is in an error state it clears it; if it is mid-transfer it aborts, so the download starts from dfuIDLE.
  3. Fit check. Every sector the image would touch has to be inside erasable, writable flash in that layout. If part of the image falls outside, the job stops with a layout error before anything is erased.
  4. Erase. One Erase command per sector the image covers, from the sector that holds the start address on. The pod polls the status after each and waits as long as the loader asks.
  5. Address and data. Set Address Pointer to the start address, then the image in blocks of the loader's transfer size, from block 2, with a status poll after each.
  6. Leave. The pod sets the pointer to the start address once more, then sends a zero-length DFU_DNLOAD. The loader leaves DFU mode and the board boots the image. The loader may drop off the bus before it answers that last request, so the pod treats that as success.

The pod keeps its patience bounded: it caps a single wait at 200 ms even if the loader's poll timeout is longer, and gives a busy loader 20 seconds before it reports a timeout. Every descriptor and status the loader sends is checked, since the board is under test. If the loader reports an error, the job ends with that error.

How the pod runs it

Who does what: the host sends the image over the network, the pod's MCU acts as USB host and runs DfuSe, and three wires connect the pod's USB port to the board's user USB connector.
Who does what: the host sends the image over the network, the pod's MCU acts as USB host and runs DfuSe, and three wires connect the pod's USB port to the board's user USB connector.
  • The host (the Python SDK, the CLI or the MCP server) reads a .hex, .dfu or .bin file. A .hex or .dfu file carries its own addresses and is converted to a binary with a start address; for a .bin the address is 0x08000000 by default. The host uploads the image into the pod's memory and starts the job. The SDK picks the DFU mode by itself, from the device that enumerates.
  • The pod's MCU is the USB host. It enumerates the board, runs the DfuSe state machine above in the background, and reports progress in blocks. Once the image is in the pod, the USB side does not depend on network latency.
  • The board runs nothing of yours: the ROM loader is all that is awake.

Wiring a NUCLEO-H753ZI

Three wires from the pod's USB host port to the Nucleo's user USB connector, CN13:

Pod USB host portNUCLEO-H753ZI CN13
D+D+
D-D-
GNDGND

Today's pods host on their USB-C connector through a breakout (port usb_c), as the USB docs page describes. While the pod hosts a board its own USB console and USB network are off, so reach it over the LAN or the cloud. The breakout rig does not supply VBUS to the board, so power the Nucleo as you normally would and keep the grounds common.

To make the chip start its ROM loader, BOOT0 must be high when it comes out of reset. Check the board's user manual for where BOOT0 is brought out and how to tie it high; then reset the board, and it enumerates on CN13 as a DFU device. Without BOOT0 high the board runs its own program and nothing enumerates as DFU. The pod flashes a board that is already in its loader; it does not put the board there.

Bench results

We ran this on a NUCLEO-H753ZI on the pod's USB host port, wired as above to CN13:

  • usb_flash in dfu mode against the STM32H753's ROM loader passed, and the board then booted the image that had been written.
  • The ROM DfuSe path runs at about 10 KB/s. The ROM loader sets that pace, with its sector erases and the status polling between blocks. DfuSe is the slow one of the USB flash methods: a UF2 write to a real Raspberry Pi Pico runs at about 77 KB/s.

Using it

The loader and the flash logic need firmware 4.0.3 or later: USB host mode and usb_flash arrived in that release.

From Python, with the pytest package:

from embeddedci.benchpod import BenchPod

with BenchPod("192.168.1.50") as bp:
    # Board in its ROM loader (BOOT0 high at reset), wired to the pod's USB host port.
    r = bp.usb_flash("build/app.hex")
    print(r.mode, r.reason)

The SDK starts host mode, waits for the device, and picks dfu from the board that enumerated. A .bin takes an address: bp.usb_flash("app.bin", address=0x08000000). leave=False keeps the board in its loader at the end instead of starting the image. A failure raises an error that carries the pod's result.

From the command line:

benchpod usb-flash app.hex
benchpod usb-flash app.bin --address 0x08000000

The CLI needs a direct link to the pod, its network address, not the cloud; over embeddedci.com use the SDK or the MCP server. From an AI agent, the MCP server's usb_flash tool takes the file, and an optional address and leave. The board has to be in its bootloader already.

Underneath all three is one JSON command, after the image is staged with load_bin ("psram": true) into the pod's memory:

{"cmd": "usb_host", "enabled": true, "port": "usb_c", "timeout_s": 120}
{"cmd": "usb_flash", "mode": "dfu", "address": "0x08000000", "len": 131072}
{"cmd": "usb_flash"}

The last command reads the state: the phase, blocks done out of the total, and at the end ok or the reason it failed. abort stops a running flash. The reference is in the API docs, and the USB page lists which modes are tested on real hardware. DfuSe on the STM32H753 is one of them; plain DFU 1.1 loaders without DfuSe are not tested yet. Every chip and method we have verified is in How the BenchPod flashes microcontrollers.