我正在尝试制作一个具有批量输入和批量输出功能的 USB 小工具,用于 Linux 操作系统中的串行通信。但我在设置设备描述符时遇到困难。我特别想决定参数,例如有多少个端点以及它们的地址是什么,但我无法做到。
目录下 /sys/内核/config/usb_gadget/ 我创建g1文件夹使用mkdir g1命令
在此之后,我看到了这个,
UDC bDeviceSubClass bcdUSB idProduct os_desc
bDeviceClass bMaxPacketSize0 configs idVendor strings
bDeviceProtocol bcdDevice functions max_speed
我将参数设置为该网站https://docs.kernel.org/usb/gadget_configfs.html
之后,我将我的开发板连接到我的 Ubuntu PC,我看到了以下描述符lsusb -d 2020:1111 -v 命令
Bus 003 Device 045: ID 2020:1111 VIA Labs, Inc. USB2.0 Hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x2020
idProduct 0x1111
bcdDevice 0.00
iManufacturer 1 Manufacturer
iProduct 2 Product
iSerial 3 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0020
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0016
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x0000010e
BESL Link Power Management (LPM) Supported
BESL value 256 us
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000f
Device can operate at Low Speed (1Mbps)
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 511 micro seconds
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0001
Self Powered
到目前为止一切都很好。
问题是这个描述符中有 2 个端点,我想将数量增加到 4 并写入我给自己的端点地址。我想要做的例子是:端点将是 EP2(OUT) EP4(OUT) EP6(IN) EP8(IN) 而不是 EP1(OUT) EP1(IN) 0x81, 0x01,我想设置每个地址分别为0x02、0x04、0x86、0x88,我该怎么做?
谢谢,最诚挚的问候。