USB集腋成裘:从Linux PC角度看sys.usb.config为adb时的Android设备

以下为USBMON抓到的USB BUS的枚举过程,简单的分析做下记录

Get Device Descriptor:
ffff8803ce0bdd80 1433311560 S Ci:3:028:0 s 80 06 0100 0000 0008 8 <
ffff8803ce0bdd80 1433311713 C Ci:3:028:0 0 8 = 12010002 00000040
ffff8801bbb2d9c0 1433311772 S Ci:3:028:0 s 80 06 0100 0000 0012 18 <
ffff8801bbb2d9c0 1433311891 C Ci:3:028:0 0 18 = 12010002 00000040 49194800 ffff0203 0401
struct {
BYTE bLength; // 描述符的长度,以字节为单位 :0x12
BYTE bDescriptorType; // 设备描述符类型,0x01
WORD bcdUSB; // 设备支持的USB协议版本,BCD码 :0002
BYTE bDeviceClass; // 设备类代码(由USB-IF分配) 00
BYTE bDeviceSubClass; // 子类代码 00
BYTE bDeviceProtocol; // 协议码 00
BYTE bMaxPacketSize0; // 端点0的最大包长度(仅为8,16,32,64) 40
WORD idVendor; // 厂商ID(由USB-IF分配)  4919
WORD idProduct; // 产品ID(由制造商定义) 4800
WORD bcdDevice; // 设备发行号(BCD码) ffff
BYTE iManufacture; // 描述厂商信息的字符串描述符的索引值 02
BYTE iProduct; // 描述产品信息的字符串描述符的索引值 :0x03
BYTE iSerialNumber; // 描述设备序列号信息的字符串描述符的索引值:0x04
BYTE bNumConfigurations; // 可能的配置描述符的数目 :0x01
} device_descriptor


Get Configuration Descriptor:
ffff8801bbb2d9c0 1433311952 S Ci:3:028:0 s 80 06 0200 0000 0009 9 <
ffff8801bbb2d9c0 1433312071 C Ci:3:028:0 0 9 = 09022000 010100c0 fa
ffff8801bbb2d9c0 1433312123 S Ci:3:028:0 s 80 06 0200 0000 0020 32 <
ffff8801bbb2d9c0 1433312244 C Ci:3:028:0 0 32 = 09022000 010100c0 fa090400 0002ff42 01050705 01020002 00070581 02000200
struct {
BYTE bLength; // 描述符的长度,以字节为单位: 09
BYTE bDescriptorType; // 配置描述符类型 :0x02
WORD wTotalLength; // 配置信息的总长 :0020
BYTE bNumInterfaces; // 该配置所支持的接口数目: 01
BYTE bConfigurationValue; // 被SetCongiguration()请求用做参数来选定该配置: 01
BYTE bConfiguration; // 描述该配置的字符串描述符的索引值 : 00
BYTE bmAttributes; // 配置特性: c0 bmAttributes :b7:备用,b6:自供电,b5:远程唤醒,b4--b0:备用
BYTE MaxPower; // 该配置下的总线电源耗费量,以2mA为一个单位: fa
}configuration_descriptor;

Get String Descriptors:

ffff8801bbb2d9c0 1433312302 S Ci:3:028:0 s 80 06 0300 0000 00ff 255 <
ffff8801bbb2d9c0 1433312382 C Ci:3:028:0 0 4 = 04030904
Offset     Field             Size     Value     Description
0     bLength     1     Number     Size of Descriptor in Bytes
1     bDescriptorType 1     Constant String Descriptor (0x03)
2     wLANGID[0]     2     number      Supported Language Code Zero(e.g. 0x0409 English - United States)


ffff8801bbb2d9c0 1433312430 S Ci:3:028:0 s 80 06 0303 0409 00ff 255 <
ffff8801bbb2d9c0 1433312525 C Ci:3:028:0 0 12 = 0c034100 45004f00 46005800 ("AEOFX")

ffff8801bbb2d9c0 1433312570 S Ci:3:028:0 s 80 06 0302 0409 00ff 255 <
ffff8801bbb2d9c0 1433312663 C Ci:3:028:0 0 14 = 0e034100 6d006100 7a006f00 6e00 ("Amazon")
ffff8801bbb2d9c0 1433312707 S Ci:3:028:0 s 80 06 0304 0409 00ff 255 <
ffff8801bbb2d9c0 1433312800 C Ci:3:028:0 0 34 = 22034700 30004d00 30004800 46003000 36003500 33003900 33003000 30003000("G0m0HF065393000")

SET_CONFIGURATION:

ffff8803ce0bdb40 1433313470 S Co:3:028:0 s 00 09 0001 0000 0000 0
ffff8803ce0bdb40 1433335118 C Co:3:028:0 0 0

ffff8801bbb2da80 1433335230 S Ci:3:028:0 s 80 06 0305 0409 00ff 255 <
ffff8801bbb2da80 1433341653 C Ci:3:028:0 0 28 = 1c034100 44004200 20004900 6e007400 65007200 66006100 63006500("ADB Interface")
ffff8803c027f3c0 1434161774 S Ci:3:028:0 s 80 06 0300 0000 0100 256 <
ffff8803c027f3c0 1434161888 C Ci:3:028:0 0 4 = 04030904
ffff8803c027f3c0 1434161915 S Ci:3:028:0 s 80 06 0304 0409 0100 256 <
ffff8803c027f3c0 1434161988 C Ci:3:028:0 0 34 = 22034700 30004d00 30004800 46003000 36003500 33003900 33003000 30003000("G0m0HF065393000")

开始Bulk input and output
ffff8801bbb2de40 1434162082 S Bi:3:028:1 -115 24 <
ffff8801bbb2dc00 1434162135 S Bo:3:028:1 -115 24 = 434e584e 00000001 00100000 07000000 32020000 bcb1a7b1
ffff8801bbb2dc00 1434162185 C Bo:3:028:1 0 24 >
ffff8801bbb2d840 1434162238 S Bo:3:028:1 -115 7 = 686f7374 3a3a00
ffff8801bbb2d840 1434162293 C Bo:3:028:1 0 7 >
ffff8801bbb2de40 1434163470 C Bi:3:028:1 0 24 = 434e584e 00000001 00100000 52000000 1d1e0000 bcb1a7b1
ffff8801bba48b40 1434163488 S Bi:3:028:1 -115 82 <
ffff8801bba48b40 1434163564 C Bi:3:028:1 0 82 = 64657669 63653a3a 726f2e70 726f6475 63742e6e 616d653d 666f785f 36736c3b
ffff8801bba48b40 1434163585 S Bi:3:028:1 -115 24 <



相关的知识点:

usb communication protocol相关的知识: http://www.beyondlogic.org/usbnutshell/usb6.shtml

usbmon.txt

   URB tag  :标志
   TimeStamp:毫秒数
   Event Type:  S - submission,
                 C - callback,
                 E - submission error.

   URBType:BusNo:DeviceAddr:EndPointNum
          Ci Co   Control input and output
          Zi Zo   Isochronous input and output
          Ii Io   Interrupt input and output
          Bi Bo   Bulk input and output
   URB Status: 0为没有错误。-XXX是错误码

你可能感兴趣的:(Android开发)