Expand description
§dfu-core
A sans-IO, no_std-compatible core library implementing the DFU protocol state machine.
The library drives the full DFU protocol logic — including DFU 1.1 and the STM32 DfuSe
extension — but never touches USB directly. Instead, you supply a transport by implementing
DfuIo (or DfuAsyncIo), and the library tells you exactly which control transfers to
perform and in what order. This makes it runtime-agnostic and usable in no_std environments.
If you are looking for a ready-to-use CLI tool or a higher-level crate that already has a USB backend wired up, see:
dfu-nusb— recommended, built onnusbdfu-libusb— built onlibusb
§Feature Flags
| Feature | Description |
|---|---|
| (none) | no_std core: state machine, DfuIo, DfuSansIo, FunctionalDescriptor, MemoryPage, mem |
std | Adds MemoryLayout, std::error::Error impls, DfuProtocol::new(), and DfuSync |
async | Adds DfuAsyncIo and DfuAsync (implies std) |
§API Overview
Implement one of these traits to provide the USB transport:
trait DfuIo— synchronous transport (control reads, control writes, USB reset)trait DfuAsyncIo— async transport, same operations plus asleepmethod (requires featureasync)
Choose your level of abstraction for the protocol logic:
struct DfuSync— high-level synchronous wrapper; calldownload(),download_all(), ordownload_from_slice()and it handles the rest (requires featurestd)struct DfuAsync— high-level async wrapper, mirrorsDfuSync(requires featureasync)struct DfuSansIo— low-level sans-IO state machine forno_stdor when you need explicit control over each USB transaction; returns typed command objects (UsbWriteControl,UsbReadControl) that you execute yourself
Supporting types:
enum DfuProtocol— selects between DFU 1.1 (Dfu) and STM32 DfuSe (Dfuse)struct FunctionalDescriptor— parsed from the extra bytes of a USB DFU functional descriptor; drives protocol decisions (transfer size, detach behaviour, manifestation tolerance)type MemoryPageandtype mem— primitives representing the memory layout of the device (analogous tocharandstr)struct MemoryLayout— owned, heap-allocated memory layout that can parse the STM32 memory layout interface string (requires featurestd)
§Features
-
no_stdcompatible - sync and async compatible
- write a firmware into a device (DFU download)
- read a firmware from a device (DFU upload)
- minimal dependencies
- uses a state machine to ensure implementations are correct
§DFU Specifications
This crate is based on the following specifications:
§License
MIT OR Apache-2.0
Modules§
- asynchronous
async - Generic asynchronous implementation.
- detach
- Commands to detach the device.
- download
- Commands to download a firmware into the device.
- functional_
descriptor - Functional descriptor.
- get_
status - Commands to get the status of the device.
- memory_
layout - Memory layout.
- synchronous
std - Generic synchronous implementation.
Structs§
- DfuSans
Io - Use this struct to create state machines to make operations on the device.
- UsbRead
Control - Usb read request
- UsbWrite
Control - Usb write request
Enums§
- DfuProtocol
- The DFU protocol variant in use
- Error
- State
- DFU State.
- Status
- DFU Status.
Traits§
- Chained
Command - A trait for commands that be chained into another.
- DfuIo
- Trait to implement lower level communication with a USB device.