GithubHelp home page GithubHelp logo

surban / usb-gadget Goto Github PK

View Code? Open in Web Editor NEW
46.0 2.0 4.0 124 KB

Expose standard or fully custom USB peripherals (gadgets) through a USB device controller (UDC) on Linux using Rust.

Home Page: https://crates.io/crates/usb-gadget

License: Apache License 2.0

Rust 99.80% Shell 0.20%
linux rust udc usb usb-device usb-functionfs usb-gadget

usb-gadget's Introduction

usb-gadget

crates.io page docs.rs page Apache 2.0 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)

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

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.

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.

usb-gadget's People

Contributors

surban avatar windoze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

usb-gadget's Issues

How to use

Hi there,

Seems like a silly question but I've managed to create a HID device using the hid function builder.

But I can't see a way of writing to it... Is it just a case of opening the filepath on the OS for that hid device or whatever and writing to it? Or is there a way to write to it from within this module?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.