Expand description
§dfu-libusb
Flash firmware to USB devices using the DFU (Device Firmware Upgrade) protocol.
Built on dfu-core for the protocol implementation and rusb for USB
access via libusb.
§Features
- DFU 1.1 and DFUSe protocol support
- Works with any
rusb::UsbContext - Open a device by VID/PID or supply your own
DeviceHandleviaDfuLibusb::from_usb_device
§Usage
[dependencies]
dfu-libusb = "0.6"use rusb::Context;
use dfu_libusb::DfuLibusb;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let context = Context::new()?;
let firmware = std::fs::read("firmware.bin")?;
let size = firmware.len() as u32;
let mut dfu = DfuLibusb::open(&context, 0x1234, 0x5678, 0, 0)?;
dfu.download(std::io::Cursor::new(firmware), size)?;
Ok(())
}See the download example for a more complete program
with a progress bar, wait-for-device, and post-flash reset; and
describe to inspect a device’s functional descriptor.
§License
MIT OR Apache-2.0