dfu-rs 0.2.1

Device Firmware Update crate for hosts, using nusb and exposing a simple async API.
Documentation

dfu-rs

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.

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 the docs for more examples.