Linux USB gadget configured through configfs
Overview
USB Linux 小工具是一种具有 UDC(USB 设备控制器)的设备,可连接到 USB 主机,以扩展其附加功能,如串行端口或大容量存储功能。
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 port or a mass storage capability.
主机将gadget视为一组配置,每个配置都包含若干接口,从gadget的角度看,这些接口被称为功能,每个功能代表一个串行连接或 SCSI 磁盘等。
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 为gadget提供了许多功能。
Linux provides a number of functions for gadgets to use.
创建gadget意味着要决定有哪些配置,以及每个配置将提供哪些功能。
Creating a gadget means deciding what configurations there will be and which functions each configuration will provide.
Configfs(请参阅 Configfs - 用户空间驱动的内核对象配置)可以很好地将上述决定告知内核。本文档将介绍如何做到这一点。 (Configfs - Userspace-driven Kernel Object Configuration — The Linux Kernel documentation)
Configfs (please see Configfs - Userspace-driven Kernel Object Configuration) lends itself nicely for the purpose of telling the kernel about the above mentioned decision. This document is about how to do it.
Configfs(请参阅 Configfs - 用户空间驱动的内核对象配置)可以很好地将上述决定告知内核。本文档将介绍如何做到这一点。
本文还将介绍如何将 configfs 集成到gadget中。
It also describes how configfs integration into gadget is designed.
Requirements
为使其正常工作,configfs 必须可用,因此 .config 中的 CONFIGFS_FS 必须为 "y "或 "m"。目前,USB_LIBCOMPOSITE 选择 CONFIGFS_FS。
In order for this to work configfs must be available, so CONFIGFS_FS must be 'y' or 'm' in .config. As of this writing USB_LIBCOMPOSITE selects CONF