Skip to content

Add platform dfu to restart the STM32 into USB DFU - #25

Merged
evoggy merged 1 commit into
mainfrom
evoggy/platform-dfu
Oct 7, 2026
Merged

evoggy merged 1 commit into
mainfrom
evoggy/platform-dfu

Conversation

@evoggy

@evoggy evoggy commented Oct 2, 2026

Copy link
Copy Markdown
Member

Adds cfcli platform dfu, which restarts the STM32 into its ROM bootloader so it can be flashed
over USB DFU, without holding the power button.

Depends on bitcraze/crazyflie2-nrf-firmware#126, which adds the nRF51 command this sends.

How it works

platform dfu sends 0xFF 0xFE 0x07 to the nRF51, the same way sleep, wakeup and
power-off send their commands. The nRF51 then power-cycles the STM32 with BOOT0 high, and cfcli
waits up to 5 s for it to show up on USB as 0483:df11:

$ cfcli platform dfu
STM32 is in USB DFU mode (0483:df11)
When done, restart it into its firmware with: cfcli platform reboot
  • Radio only. The STM32 firmware does not pass these commands on to the nRF51 from USB, so a
    usb:// URI is refused with an error instead of silently doing nothing.
  • When no DFU device appears, the command fails. Either the Crazyflie is not connected over
    USB, or its nRF51 firmware does not have the command yet (older firmware ignores it). The
    message points at cfcli platform reboot in case the STM32 did restart.
  • docs/platform.md has a new section for the command.

Testing

On a Crazyflie 2.1 Brushless running nRF51 firmware with #126, connected over the radio and USB:

  1. cfcli platform dfu succeeded, and the DFU device was listed by dfu-util -l with all four alt
    settings.
  2. The STM32 bootloader was flashed with dfu-util and read back to match.
  3. cfcli platform reboot brought the Crazyflie back to its firmware.

cargo test passes.

Sends the nRF51 the command that power-cycles the STM32 with BOOT0 high
(bitcraze/crazyflie2-nrf-firmware#126), the same as holding the power
button from off, and waits for the STM32 to show up on USB as 0483:df11.

The nRF51 only gets the command over the radio, so a usb:// URI is
refused up front. If no DFU device appears, the command fails and points
at platform reboot to get the STM32 back into its firmware.
@evoggy
evoggy force-pushed the evoggy/platform-dfu branch from 7c1e8d9 to f371321 Compare October 7, 2026 17:09
@evoggy
evoggy merged commit 0a2d9eb into main Oct 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant