https://github.com/surban/usb-gadget
Expose standard or fully custom USB peripherals (gadgets) through a USB device controller (UDC) on Linux using Rust.
https://github.com/surban/usb-gadget
linux rust udc usb usb-device usb-functionfs usb-gadget
Last synced: 9 months ago
JSON representation
Expose standard or fully custom USB peripherals (gadgets) through a USB device controller (UDC) on Linux using Rust.
- Host: GitHub
- URL: https://github.com/surban/usb-gadget
- Owner: surban
- License: apache-2.0
- Created: 2023-09-27T21:57:39.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-06T10:08:18.000Z (over 1 year ago)
- Last Synced: 2025-06-06T18:11:50.375Z (10 months ago)
- Topics: linux, rust, udc, usb, usb-device, usb-functionfs, usb-gadget
- Language: Rust
- Homepage: https://crates.io/crates/usb-gadget
- Size: 126 KB
- Stars: 115
- Watchers: 4
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
usb-gadget
==========
[](https://crates.io/crates/usb-gadget)
[](https://docs.rs/usb-gadget)
[](https://github.com/surban/usb-gadget/blob/master/LICENSE)
This library allows implementation of USB peripherals, so called **USB gadgets**,
on Linux devices that have a USB device controller (UDC).
Both, pre-defined USB functions and fully custom implementations of the USB
interface are supported.
The following pre-defined USB functions, implemented by kernel drivers, are available:
* network interface
* CDC ECM
* CDC ECM (subset)
* CDC EEM
* CDC NCM
* RNDIS
* serial port
* CDC ACM
* generic
* human interface device (HID)
* mass-storage device (MSD)
* printer device
* musical instrument digital interface (MIDI)
* audio device (UAC2)
* video device (UVC)
In addition fully custom USB functions can be implemented in user-mode Rust code.
Support for OS-specific descriptors and WebUSB is also provided.
Features
--------
This crate provides the following optional features:
* `tokio`: enables async support for custom USB functions on top of the Tokio runtime.
Requirements
------------
The minimum support Rust version (MSRV) is 1.73.
A USB device controller (UDC) supported by Linux is required. Normally, standard
PCs *do not* include an UDC.
A Raspberry Pi 4 contains an UDC, which is connected to its USB-C port.
The following Linux kernel configuration options should be enabled for full functionality:
* `CONFIG_USB_GADGET`
* `CONFIG_USB_CONFIGFS`
* `CONFIG_USB_CONFIGFS_SERIAL`
* `CONFIG_USB_CONFIGFS_ACM`
* `CONFIG_USB_CONFIGFS_NCM`
* `CONFIG_USB_CONFIGFS_ECM`
* `CONFIG_USB_CONFIGFS_ECM_SUBSET`
* `CONFIG_USB_CONFIGFS_RNDIS`
* `CONFIG_USB_CONFIGFS_EEM`
* `CONFIG_USB_CONFIGFS_MASS_STORAGE`
* `CONFIG_USB_CONFIGFS_F_FS`
* `CONFIG_USB_CONFIGFS_F_HID`
* `CONFIG_USB_CONFIGFS_F_PRINTER`
* `CONFIG_USB_CONFIGFS_F_MIDI`
* `CONFIG_USB_CONFIGFS_F_UAC2`
* `CONFIG_USB_CONFIGFS_F_UVC`
root permissions are required to configure USB gadgets on Linux and
the `configfs` filesystem needs to be mounted.
License
-------
usb-gadget is licensed under the [Apache 2.0 license].
[Apache 2.0 license]: https://github.com/surban/usb-gadget/blob/master/LICENSE
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in usb-gadget by you, shall be licensed as Apache 2.0, without any
additional terms or conditions.