USB Gadget
A USB Linux Gadget is a device which has a UDC (USB Device Controller) and can
be connected to a USB Host to extend it with additional functions like a serial
A gadget is seen by its host as a set of configurations, each of which contains
a number of interfaces which, from the gadget’s perspective, are known as
functions, each function representing e.g. a serial connection or a SCSI disk.
Linux provides a number of functions for gadgets to use.
USB Linux Gadget是USB设备控制器作为从设备,连接到USB Host,通过 USB 来模拟其它类型的设备,比如UAC、UVC、HID设备、串口等等
CDC类
USB的CDC类是USB通信设备类 (Communication Device Class)的简称。CDC类是USB组织定义的一类专门给各种通信设备(电信通信设备和中速网络通信设备)使用的USB子类
CDC,USB Driver支持以下子类: ECM、NCM、ACM、OBEX、设备管理。
Configfs
Documentation/filesystems/configfs.rst
configfs is a ram-based filesystem that provides the converse of
sysfs’s functionality. Where sysfs is a filesystem-based view of
kernel objects, configfs is a filesystem-based manager of kernel
objects, or config_items.
Userspace-driven Kernel Object Configuration
configfs是一个基于ram的文件系统,通过对该文件系统的操作实现对内核对象的配置
Documentation/filesystems/configfs.rst
不只是USB可以通过configfs进行配置,有些子系统也可以。理论上只要实现了configfs接口的应该都行
driver/usb/gadget/configfs.c:
通过configfs_register_subsystem(&gadget_subsys);,在configfs中注册了usb gadget子系统
使用configfs配置usb gadget
作者: Shell