最終更新:2022-08-24 (水) 19:58:00 (582d)
Linux/USBガジェット/API
ドキュメント
Linux/USBガジェット/configfs
- Linux 3.11~ (2013/09/02)
- Userspace-driven kernel object configuration.
- interface that allows definition of arbitrary functions and configurations to define an application specific USB composite device from userspace.
- The gadget framework is transitioning to use configfs for its configuration
- USB and the Real World (ELC 2014)
# Setup the device (configfs) modprobe libcomposite mkdir -p config mount none config -t configfs cd config/usb_gadget/ mkdir g1 cd g1 # Setup functionfs mkdir functions/ffs.usb0 ln -s functions/ffs.usb0 configs/c.1 cd ../../../ mkdir -p ffs mount usb0 ffs -t functionfs cd ffs ../ffs-test 64 & # from the Linux kernel, with mods! sleep 3 cd .. # Enable the USB device echo musb-hdrc.0.auto >config/usb_gadget/g1/UDC
ディレクトリ構造
- configfs/デバイス/UDC?
- configfs/デバイス/bDeviceClass?
- configfs/デバイス/bDeviceProtocol?
- configfs/デバイス/bDeviceSubClass?
- configfs/デバイス/bMaxPacketSize0?
- configfs/デバイス/bcdDevice?
- configfs/デバイス/bcdUSB?
- configfs/デバイス/configs?
- configfs/デバイス/functions?
- configfs/デバイス/idProduct?
- configfs/デバイス/idVendor?
- configfs/デバイス/os_desc?
- configfs/デバイス/strings?
FunctionFS
- Linux 2.6.35 (2010/08/01)
- Compositable version of gadgetfs
- rewrite of GadgetFS to support userspace gadget functions that canbe combined into a USB composite gadget.
- 使い方はGadgetFSと同じ。カーネルに実装されているファンクションと独自の実装を同時に動かすことができる。
- ディスクリプタを設定するのに、ep0に書き込む方法とconfigfsを使う方法がある。
GadgetFS (Linux 2.6.0~)
- Linux 2.6.0 (2003/12/17)
- original monolithic kernel driver that provides an interface to implement userspace gadget drivers
概要
- Linux/dev/gadget/<USBコントローラ名>を読み書き
- Provides User-Mode API
- Each endpoint presented as single I/O file descriptor
- Normal read() and write() calls
- Async I/O supported
- Configuration and descriptors written into files