Expand description
Implements DFU operations for USB devices.
Based on the nusb native Rust stack
for USB communication, this crate provides a simple interface for
discovering DFU-capable devices and performing DFU operations.
It is designed for use in host applications that need to update firmware on embedded devices via USB DFU.
It is intended to work on Windows, Linux, and macOS.
On Windows, WinUSB must be installed for the target device. This can be
done via Zadig, implementing a WCID descriptor
in your device, or using wdi-rs
to install the WinUSB driver programmatically (requires elevation).
§Features
- Upload (read) data from DFU devices
- Download (write) data to DFU devices
- Erase flash memory (page-wise and mass erase)
- Device discovery with filtering by DFU type (e.g. internal flash)
- Error handling with detailed DFU and USB errors
- Async API
- Customizable USB timeout
§Usage
use dfu_rs::{DEFAULT_USB_TIMEOUT, DfuType, search_for_dfu};
if let Some(device) = search_for_dfu(DEFAULT_USB_TIMEOUT, None).await?.first() {
// Read the first 16KB from the device
let data = device.upload(0x08000000, 16 * 1024).await?;
println!("Uploaded data: {:X?}", &data[..16]); // Print first 16 bytes
}See Device for more examples.
Structs§
- Device
- DFU Device representation
- Device
Info - USB device information
- DfuInfo
- Information about a DFU interface
Enums§
- DfuType
- DFU Type enumeration - each USB DFU device can represent different memory regions, represented by this object
- Error
- Error type
- State
- DFU Device State codes
- Status
- DFU Status codes
- UsbStack
Error
Constants§
Functions§
- search_
for_ dfu - Enumerates the USB bus and searches for DFU-capable devices.