A high-performance, asynchronous USB Host driver implementation written in Rust for embedded systems and operating system kernels.
- π Async/Await Support: Built from the ground up with async primitives for non-blocking USB operations
- β‘ Lock-Free Design: Ring-based architecture using TRB (Transfer Request Block) for zero-lock async operations
- π― xHCI Controller Support: Complete implementation of the xHCI (Extensible Host Controller Interface) specification
- π± USB Standards Compliance: Full support for USB 1.1, 2.0, and 3.x devices (Full, High, and SuperSpeed)
-
π§ No-STD Compatible: Designed for
#![no_std]
environments with minimal memory footprint - π₯οΈ User-Space libusb Backend: Optional libusb backend for testing and development in user-space environments
- Control Transfers: Device setup, configuration, and standard requests
- Bulk Transfers: High-throughput data transfer for storage devices
- Interrupt Transfers: Periodic data transfer for HID devices
- Isochronous Transfers: Real-time streaming for audio/video devices
- π Device Enumeration: Automatic discovery and enumeration of connected USB devices
- π Descriptor Parsing: Complete parsing of device, configuration, interface, and endpoint descriptors
- π Interface Management: Easy interface claiming and endpoint access
- π·οΈ String Descriptors: Full support for manufacturer, product, and serial number strings
- Executor Agnostic: Works with any async executor or can be used synchronously
- DMA-Aware: Efficient memory management with DMA coherency support
- Event-Driven: Interrupt-based event handling for optimal performance
- Modular Design: Clean separation between host controller and USB interface layers
- Multi-Backend Support: Supports both direct hardware access (xHCI) and user-space testing (libusb)
CrabUSB uses an innovative lock-free design based on TRB rings where each TRB represents an async task. The future queries the ring to obtain async results without requiring a specific executor, making it highly flexible and performant.
The driver supports multiple backends:
- xHCI Backend: Direct hardware access for embedded systems and OS kernels
-
libusb Backend: User-space testing and development using libusb (enable with
libusb
feature)
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Application βββββΊβ USB Interface βββββΊβ Backend β
β β β (usb-if) β β Selection β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ ββββββββββββββββ
β Descriptors β β xHCI / libusbβ
β & Transfers β β Drivers β
ββββββββββββββββ ββββββββββββββββ