2010年6月4日 星期五

debug USB - use usbmon, usbfs


dump urb data

  1. 編kernel時,在driver/usb/下選擇usb monitor
  2. mount -t debugfs debugfs /sys/kernel/debug
  3. 之後在此目錄下就會看到usbmon目錄
  4. 可以在此dump出urb的資料(ascii)

  • 可以使用/dev/usbmon[XX]來dump出raw data,之後自己寫程式去parse
  • 詳細文件參考Documentation/usb/usbmon.txt

查看linux上所有USB裝置的詳細資訊



  1. mount -t usbfs usbfs /proc/bus/usb/
  2. cat /proc/bus/usb/devices
  3. 各攔位介紹
    1. http://www.linux-usb.org/USB-guide/c607.html
  4. 詳細文件: Documentation/usb/proc_usb_info.txt

/proc/bus/usb/devices各欄位資料

  • T開頭(topology)
    • Bus: which bus the device is on
    • Lev: the level of the device
      • level 00 for the root hub
      • level 01 for any device attached to the root hub
      • level 02 for devices attached to hubs at level 01, and so on.
    • Prnt: the parent device for this device
      • always 00 for the root hub
      • 01 for the devices attached to the root hub
    • Port: the port on the parent device
      • starting at 00 for the first port on each device.
      • Prnt/Port is unique per bus.
    • Cnt: what number device this is, based on the enumeration order within that level of the topology, starting at 01 for the first device.
    • Dev#: what number device this is, irrespective of level, based on the bus enumeration order. This is unique per bus
    • Spd: what speed this device is running at, in Mbps (either 1.5 or 12 with the current version of USB).
    • MxCh: how many devices can be connected to this device
      • 00 for anything except a hub.
    • Driver: which device driver is being used for this device
      • an entry of (none) indicates that no driver is being used.
  • D開頭(device descriptor)
    • Ver: which USB specification version the device claims to meet.
    • Cls: which device class the device is claiming to meet, in both hexadecimal and as a string.
      • A Cls entry of 00(>ifc) indicates that the device class specification compliance is interface dependent, and the interface descriptor should be read for device class information.
    • Sub: which sub-class (within the Cls entry), the device meets.
    • Prot: which protocol within a class or sub-class the device claims to meet.
    • MxPS: how big the packets from Endpoint 0 are.
    • #Cfgs: how many configurations this device has.
  • P開頭(pid/vid)
    • Vendor: the Vendor Identification code for the device
    • ProdID: the Product Identification code for the device.
    • Rev: the product revision number.
  • S開頭: vendor and product strings that the device returned.
  • C開頭(configuration descriptor)

    • the number of C:lines per device is given by #Cfgs, and the entry followed by an asterisk is the current configuration.

    • #If: how many interfaces the device has.

    • Cfg#: which configuration is being described.

    • Atr: hexadecimal indication of the device attributes

      • 0x80 for bus-powered

      • 0x40 for self-powered

      • 0x20 for remote wake-up capable

    • MxPwr: maximum power draw for this device configuration, in milliamps(mA).

  • I開頭(interface descriptor)

    • If#: which interface is being described within a given device configuration.

    • Alt: which alternate setting of this interface is being described.

    • #EPs: how many endpoints there are within the alternate setting for this endpoint.

    • Cls: which class the alternate setting of the interface corresponds to, in both hexadecimal and as a character string.

    • Sub: which sub-class the alternate setting of the interface belongs to.

    • Prot: which interface protocol (within a class and sub-class tuple) the alternate setting of the interface conforms to.

    • Driver: which of the various USB drivers has claimed this interface.

  • E開頭(endpoint descriptor)

    • Endpoint 0 is not displayed.

    • Ad: endpoint address, with a letter to indicate whether the endpoint is an In or Out endpoint.

    • Atr: the attribute (transfer type) associated with the endpoint, followed by a string translating the transfer type.

    • MxPS: maximum packet size this endpoint is capable of sending or receiving, as appropriate.

    • Ivl: the interval, in milliseconds, between polling of interrupt endpoints.

      • ignored for bulk and control transfers, and is set to 1 for isochronous transfers.







=================================================

example

root@ocgod-ubuntu9:/proc/bus/usb# cat devices

T: Bus=05 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 2.06
S: Manufacturer=Linux 2.6.28-18-generic uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:00:10.3
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

T: Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 2.06
S: Manufacturer=Linux 2.6.28-18-generic uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:00:10.2
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

T: Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 2.06
S: Manufacturer=Linux 2.6.28-18-generic uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:00:10.1
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 34/900 us ( 4%), #Int= 3, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 2.06
S: Manufacturer=Linux 2.6.28-18-generic uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:00:10.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=13ba ProdID=0017 Rev= 0.01
S: Product=Generic USB K/B
C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=24ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=82(I) Atr=03(Int.) MxPS= 5 Ivl=10ms

T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=1.5 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=04d9 ProdID=0499 Rev= 2.90
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms

T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 8
B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 2.06
S: Manufacturer=Linux 2.6.28-18-generic ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=0000:00:10.4
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms

沒有留言: