2013-11-01 140 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,媒體傳輸協議的一部分)發送的。