| Crates.io | usbh-scsi |
| lib.rs | usbh-scsi |
| version | 0.1.0 |
| created_at | 2025-10-01 05:29:16.950446+00 |
| updated_at | 2025-10-01 05:29:16.950446+00 |
| description | A library to communicate with scsi to usb devices from a host |
| homepage | |
| repository | https://github.com/BjornTheProgrammer/elf2flash/tree/main/crates/usbh-scsi |
| max_upload_size | |
| id | 1862108 |
| size | 51,892 |
A userspace library for sending SCSI commands to USB Mass Storage devices via the Bulk-Only Transport (BOT) protocol.
Unlike traditional approaches, this crate does not depend on the operating
system’s block device or filesystem layers. Instead, it provides a pure-Rust
API for constructing and executing standard SCSI command blocks directly over
USB, making it portable across all platforms supported by rusb.
rusb).INQUIRY,
READ CAPACITY (10), READ(10), and WRITE(10).commands — strongly-typed definitions of SCSI commands and the
CommandBlock trait for generating Command Descriptor Blocks (CDBs).storage — device discovery, opening/closing devices, bulk I/O, and
SCSI command execution over USB BOT. Includes UsbBlockDevice for
sector-oriented reads/writes.Add to your Cargo.toml:
cargo add usbh-scsi
use usbh_scsi::storage::UsbMassStorage;
use usbh_scsi::commands::inquiry::InquiryCommand;
use usbh_scsi::commands::cbw::Direction;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
// Enumerate all attached MSC devices
let mut devices = UsbMassStorage::list()?;
if let Some(closed) = devices.pop() {
// Open the first one
let mut dev = closed.open()?;
// Send an INQUIRY command
let cmd = InquiryCommand::new(0);
let mut buf = [0u8; 36];
dev.execute_command(1, buf.len() as u32, Direction::In, &cmd, Some(&mut buf))?;
println!("INQUIRY data: {:?}", &buf);
}
Ok(())
}
usbh-scsi if you want raw SCSI access to USB devices
(e.g. discovering capacity, issuing reads/writes, or building custom tooling).usbh-fatfs if you want a
filesystem-aware interface for working directly with FAT partitions on
USB devices.Works on any platform supported by rusb.