2013-11-01 93 views
0

我在嵌入式设备上运行此(http://www.linux-usb.org/gadget/usb.c)Gadget FS用户模式驱动程序。USB设置请求不同来自Linux主机或Windows主机

当我将它连接到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 FF 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实现STALL。描述符类型为3,表示请求类型为“字符串”的描述符,但在wIndex中没有提供语言标识(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; 

我会很感激,如果有人可以帮助我!

回答

0

在linux上如此外观上,描述符索引为0xEE且长度为1024的安装请求不是由linux上的libusb发送的,而是由mtp-probe(libmtp,媒体传输协议的一部分)发送的。