我正在嵌入式设备上运行此 ( http://www.linux-usb.org/gadget/usb.c ) Gadget FS 用户模式驱动程序。
当我将其连接到 Windows 时,我收到的 GET_DESCRIPTOR
设置请求如下:
80 06 03 03 09 04 FF 00
80 06 00 03 00 00 FF 00
80 06 02 03 09 04 FF 00
80 06 03 03 09 04 FF 00
80 06 00 03 00 00 FF 00
80 06 02 03 09 04 00
`bmRequestType`: 0x80 Device-to-host transfer direction
`bRequest`: 0x06 GET_DESCRIPTOR
`wValueH` : 0x03 Descriptor Type 'String'
`wValueL` : Descriptor Index
`wIndex` : 0x04 0x09 Language ID "US-English" for Descriptor Types "String", 0x00 for others
`wLength` : Length of the requested descriptor
这些是我连接设备时来自 Linux 主机的设置请求。 80 06 00 03 00 00 FF 00 80 06 02 03 09 04 FF 00 80 06 01 03 09 04 FF 00 80 06 03 03 09 04 FF 00 80 06 ee 03 00 00 00 04
最后一个使我的 GadgetFS 实现停止。描述符类型为 3,表示请求“String”类型的描述符,但在 wIndex
中未提供语言 ID (0x00 0x00)。另外,描述符索引是 0xEE,但为什么一个设备会有 238 个字符串描述符呢?
另请注意所请求描述符的长度:0x0400 (1024)。
这是我使用的驱动程序实现 (linux-usb.org) 中处理设置请求的代码摘录:
case USB_REQ_GET_DESCRIPTOR: //0x06
if (setup->bRequestType != USB_DIR_IN) //USB_DIR_IN = 0x80
goto stall;
switch (value >> 8) // wValueH: Descriptor Type
{
case USB_DT_STRING: // 0x03 Type = "String"
{
tmp = value & 0x0ff; // wValueL : Descriptor Index
struct usb_gadget_strings strings = {
0x0409, /* "en-us" */
m_aUsbStringtab
};
index = 0x0409
if (tmp != 0 && index != strings.language) //This makes it STALL when connected to a linux
goto stall;
如果有人能帮助我,我将非常感激!
最佳答案
因此,在 Linux 上,描述符索引为 0xEE、长度为 1024 的设置请求不是由 Linux 上的 libusb 发送的,而是由 mtp-probe(libmtp,媒体传输协议(protocol)的一部分)发送的。
关于linux - 来自 Linux 主机或 Windows 主机的 USB 设置请求不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19723924/