proc_usb_info.txt
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:15k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /proc/bus/usb filesystem output
  2. ===============================
  3. (version 2002.03.18)
  4. The /proc filesystem for USB devices provides /proc/bus/usb/drivers
  5. and /proc/bus/usb/devices, as well as /proc/bus/usb/BBB/DDD files.
  6. **NOTE**: If /proc/bus/usb appears empty, and a host controller
  7.   driver has been linked, then you need to mount the
  8.   filesystem.  Issue the command (as root):
  9.       mount -t usbfs none /proc/bus/usb
  10.   An alternative and more permanent method would be to add
  11.       none  /proc/bus/usb  usbfs  defaults  0  0
  12.   to /etc/fstab.  This will mount usbfs at each reboot.
  13.   You can then issue `cat /proc/bus/usb/devices` to extract
  14.   USB device information, and user mode drivers can use usbfs 
  15.   to interact with USB devices.
  16.   There are a number of mount options supported by usbfs.
  17.   Consult the source code (linux/drivers/usb/inode.c) for
  18.   information about those options.
  19. **NOTE**: The filesystem has been renamed from "usbdevfs" to
  20.   "usbfs", to reduce confusion with "devfs".  You may
  21.   still see references to the older "usbdevfs" name.
  22. For more information on mounting the usbfs file system, see the
  23. "USB Device Filesystem" section of the USB Guide. The latest copy 
  24. of the USB Guide can be found at http://www.linux-usb.org/
  25. THE /proc/bus/usb/BBB/DDD FILES:
  26. --------------------------------
  27. Each connected USB device has one file.  The BBB indicates the bus
  28. number.  The DDD indicates the device address on that bus.  Both
  29. of these numbers are assigned sequentially, and can be reused, so
  30. you can't rely on them for stable access to devices.  For example,
  31. it's relatively common for devices to re-enumerate while they are
  32. still connected (perhaps someone jostled their power supply, hub,
  33. or USB cable), so a device might be 002/027 when you first connect
  34. it and 002/048 sometime later.
  35. These files can be read as binary data.  The binary data consists
  36. of first the device descriptor, then the descriptors for each
  37. configuration of the device.  That information is also shown in
  38. text form by the /proc/bus/usb/devices file, described later.
  39. These files may also be used to write user-level drivers for the USB
  40. devices.  You would open the /proc/bus/usb/BBB/DDD file read/write,
  41. read its descriptors to make sure it's the device you expect, and then
  42. bind to an interface (or perhaps several) using an ioctl call.  You
  43. would issue more ioctls to the device to communicate to it using
  44. control, bulk, or other kinds of USB transfers.  The IOCTLs are
  45. listed in the <linux/usbdevice_fs.h> file, and at this writing the
  46. source code (linux/drivers/usb/devio.c) is the primary reference
  47. for how to access devices through those files.
  48. Note that since by default these BBB/DDD files are writable only by
  49. root, only root can write such user mode drivers.  You can selectively
  50. grant read/write permissions to other users by using "chmod".  Also,
  51. usbfs mount options such as "devmode=0666" may be helpful.
  52. THE /proc/bus/usb/drivers FILE:
  53. -------------------------------
  54. Each of the USB device drivers linked into your kernel (statically,
  55. or dynamically using "modprobe") is listed in the "drivers" file.
  56. Here's an example from one system:
  57.          usbdevfs
  58.          hub
  59.   0- 15: usblp
  60.          usbnet
  61.          serial
  62.          usb-storage
  63.          pegasus
  64. If you see this file, "usbdevfs" and "hub" will always be listed,
  65. since those are part of the "usbcore" framework.
  66. Drivers that use the USB major number (180) to provide character devices
  67. will include a range of minor numbers, as shown above for the "usblp"
  68. (actually "printer.o") module.  USB device drivers can of course use any
  69. major number, but it's easy to use the USB range since there's explicit
  70. support for subdividing it in the USB device driver framework.
  71. THE /proc/bus/usb/devices FILE:
  72. -------------------------------
  73. In /proc/bus/usb/devices, each device's output has multiple
  74. lines of ASCII output.
  75. I made it ASCII instead of binary on purpose, so that someone
  76. can obtain some useful data from it without the use of an
  77. auxiliary program.  However, with an auxiliary program, the numbers
  78. in the first 4 columns of each "T:" line (topology info:
  79. Lev, Prnt, Port, Cnt) can be used to build a USB topology diagram.
  80. Each line is tagged with a one-character ID for that line:
  81. T = Topology (etc.)
  82. B = Bandwidth (applies only to USB host controllers, which are
  83.     virtualized as root hubs)
  84. D = Device descriptor info.
  85. P = Product ID info. (from Device descriptor, but they won't fit
  86.     together on one line)
  87. S = String descriptors.
  88. C = Configuration descriptor info. (* = active configuration)
  89. I = Interface descriptor info.
  90. E = Endpoint descriptor info.
  91. =======================================================================
  92. /proc/bus/usb/devices output format:
  93. Legend:
  94.   d = decimal number (may have leading spaces or 0's)
  95.   x = hexadecimal number (may have leading spaces or 0's)
  96.   s = string
  97. Topology info:
  98. T:  Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd
  99. |   |      |      |       |       |      |        |       |__MaxChildren
  100. |   |      |      |       |       |      |        |__Device Speed in Mbps
  101. |   |      |      |       |       |      |__DeviceNumber
  102. |   |      |      |       |       |__Count of devices at this level
  103. |   |      |      |       |__Connector/Port on Parent for this device
  104. |   |      |      |__Parent DeviceNumber
  105. |   |      |__Level in topology for this bus
  106. |   |__Bus number
  107. |__Topology info tag
  108.     Speed may be:
  109.      1.5 Mbit/s for low speed USB
  110. 12 Mbit/s for full speed USB
  111. 480 Mbit/s for high speed USB (added for USB 2.0)
  112. Bandwidth info:
  113. B:  Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd
  114. |   |                       |         |__Number of isochronous requests
  115. |   |                       |__Number of interrupt requests
  116. |   |__Total Bandwidth allocated to this bus
  117. |__Bandwidth info tag
  118.     Bandwidth allocation is an approximation of how much of one frame
  119.     (millisecond) is in use.  It reflects only periodic transfers, which
  120.     are the only transfers that reserve bandwidth.  Control and bulk
  121.     transfers use all other bandwidth, including reserved bandwidth that
  122.     is not used for transfers (such as for short packets).
  123.     
  124.     The percentage is how much of the "reserved" bandwidth is scheduled by
  125.     those transfers.  For a low or full speed bus (loosely, "USB 1.1"),
  126.     90% of the bus bandwidth is reserved.  For a high speed bus (loosely,
  127.     "USB 2.0") 80% is reserved.
  128. Device descriptor info & Product ID info:
  129. D:  Ver=x.xx Cls=xx(s) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
  130. P:  Vendor=xxxx ProdID=xxxx Rev=xx.xx
  131. where
  132. D:  Ver=x.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
  133. |   |        |             |      |       |       |__NumberConfigurations
  134. |   |        |             |      |       |__MaxPacketSize of Default Endpoint
  135. |   |        |             |      |__DeviceProtocol
  136. |   |        |             |__DeviceSubClass
  137. |   |        |__DeviceClass
  138. |   |__Device USB version
  139. |__Device info tag #1
  140. where
  141. P:  Vendor=xxxx ProdID=xxxx Rev=xx.xx
  142. |   |           |           |__Product revision number
  143. |   |           |__Product ID code
  144. |   |__Vendor ID code
  145. |__Device info tag #2
  146. String descriptor info:
  147. S:  Manufacturer=ssss
  148. |   |__Manufacturer of this device as read from the device.
  149. |      For USB host controller drivers (virtual root hubs) this may
  150. |      be omitted, or (for newer drivers) will identify the kernel
  151. |      version and the driver which provides this hub emulation.
  152. |__String info tag
  153. S:  Product=ssss
  154. |   |__Product description of this device as read from the device.
  155. |      For older USB host controller drivers (virtual root hubs) this
  156. |      indicates the driver; for newer ones, it's a product (and vendor)
  157. |      description that often comes from the kernel's PCI ID database.
  158. |__String info tag
  159. S:  SerialNumber=ssss
  160. |   |__Serial Number of this device as read from the device.
  161. |      For USB host controller drivers (virtual root hubs) this is
  162. |      some unique ID, normally a bus ID (address or slot name) that
  163. |      can't be shared with any other device.
  164. |__String info tag
  165. Configuration descriptor info:
  166. C:* #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA
  167. | | |       |       |      |__MaxPower in mA
  168. | | |       |       |__Attributes
  169. | | |       |__ConfiguratioNumber
  170. | | |__NumberOfInterfaces
  171. | |__ "*" indicates the active configuration (others are " ")
  172. |__Config info tag
  173.     
  174.     USB devices may have multiple configurations, each of which act
  175.     rather differently.  For example, a bus-powered configuration
  176.     might be much less capable than one that is self-powered.  Only
  177.     one device configuration can be active at a time; most devices
  178.     have only one configuration.
  179.     Each configuration consists of one or more interfaces.  Each
  180.     interface serves a distinct "function", which is typically bound
  181.     to a different USB device driver.  One common example is a USB
  182.     speaker with an audio interface for playback, and a HID interface
  183.     for use with software volume control.
  184. Interface descriptor info (can be multiple per Config):
  185. I:  If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=ssss
  186. |   |      |      |       |             |      |       |__Driver name
  187. |   |      |      |       |             |      |          or "(none)"
  188. |   |      |      |       |             |      |__InterfaceProtocol
  189. |   |      |      |       |             |__InterfaceSubClass
  190. |   |      |      |       |__InterfaceClass
  191. |   |      |      |__NumberOfEndpoints
  192. |   |      |__AlternateSettingNumber
  193. |   |__InterfaceNumber
  194. |__Interface info tag
  195.     A given interface may have one or more "alternate" settings.
  196.     For example, default settings may not use more than a small
  197.     amount of periodic bandwidth.  To use significant fractions
  198.     of bus bandwidth, drivers must select a non-default altsetting.
  199.     
  200.     Only one setting for an interface may be active at a time, and
  201.     only one driver may bind to an interface at a time.  Most devices
  202.     have only one alternate setting per interface.
  203. Endpoint descriptor info (can be multiple per Interface):
  204. E:  Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddms
  205. |   |        |            |         |__Interval (max) between transfers
  206. |   |        |            |__EndpointMaxPacketSize
  207. |   |        |__Attributes(EndpointType)
  208. |   |__EndpointAddress(I=In,O=Out)
  209. |__Endpoint info tag
  210.     The interval is nonzero for all periodic (interrupt or isochronous)
  211.     endpoints.  For high speed endpoints the transfer interval may be
  212.     measured in microseconds rather than milliseconds.
  213.     For high speed periodic endpoints, the "MaxPacketSize" reflects
  214.     the per-microframe data transfer size.  For "high bandwidth"
  215.     endpoints, that can reflect two or three packets (for up to
  216.     3KBytes every 125 usec) per endpoint.
  217.     With the Linux-USB stack, periodic bandwidth reservations use the
  218.     transfer intervals and sizes provided by URBs, which can be less
  219.     than those found in endpoint descriptor.
  220. =======================================================================
  221. If a user or script is interested only in Topology info, for
  222. example, use something like "grep ^T: /proc/bus/usb/devices"
  223. for only the Topology lines.  A command like
  224. "grep -i ^[tdp]: /proc/bus/usb/devices" can be used to list
  225. only the lines that begin with the characters in square brackets,
  226. where the valid characters are TDPCIE.  With a slightly more able
  227. script, it can display any selected lines (for example, only T, D,
  228. and P lines) and change their output format.  (The "procusb"
  229. Perl script is the beginning of this idea.  It will list only
  230. selected lines [selected from TBDPSCIE] or "All" lines from
  231. /proc/bus/usb/devices.)
  232. The Topology lines can be used to generate a graphic/pictorial
  233. of the USB devices on a system's root hub.  (See more below
  234. on how to do this.)
  235. The Interface lines can be used to determine what driver is
  236. being used for each device.
  237. The Configuration lines could be used to list maximum power
  238. (in milliamps) that a system's USB devices are using.
  239. For example, "grep ^C: /proc/bus/usb/devices".
  240. Here's an example, from a system which has a UHCI root hub,
  241. an external hub connected to the root hub, and a mouse and
  242. a serial converter connected to the external hub.
  243. T:  Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
  244. B:  Alloc= 28/900 us ( 3%), #Int=  2, #Iso=  0
  245. D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
  246. P:  Vendor=0000 ProdID=0000 Rev= 0.00
  247. S:  Product=USB UHCI Root Hub
  248. S:  SerialNumber=dce0
  249. C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
  250. I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
  251. E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms
  252. T:  Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 4
  253. D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
  254. P:  Vendor=0451 ProdID=1446 Rev= 1.00
  255. C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
  256. I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
  257. E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=255ms
  258. T:  Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=1.5 MxCh= 0
  259. D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
  260. P:  Vendor=04b4 ProdID=0001 Rev= 0.00
  261. C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
  262. I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=mouse
  263. E:  Ad=81(I) Atr=03(Int.) MxPS=   3 Ivl= 10ms
  264. T:  Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
  265. D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
  266. P:  Vendor=0565 ProdID=0001 Rev= 1.08
  267. S:  Manufacturer=Peracom Networks, Inc.
  268. S:  Product=Peracom USB to Serial Converter
  269. C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
  270. I:  If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
  271. E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl= 16ms
  272. E:  Ad=01(O) Atr=02(Bulk) MxPS=  16 Ivl= 16ms
  273. E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=  8ms
  274. Selecting only the "T:" and "I:" lines from this (for example, by using
  275. "procusb ti"), we have:
  276. T:  Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
  277. T:  Bus=00 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 4
  278. I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
  279. T:  Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=1.5 MxCh= 0
  280. I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=mouse
  281. T:  Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
  282. I:  If#= 0 Alt= 0 #EPs= 3 Cls=00(>ifc ) Sub=00 Prot=00 Driver=serial
  283. Physically this looks like (or could be converted to):
  284.                       +------------------+
  285.                       |  PC/root_hub (12)|   Dev# = 1
  286.                       +------------------+   (nn) is Mbps.
  287.     Level 0           |  CN.0   |  CN.1  |   [CN = connector/port #]
  288.                       +------------------+
  289.                           /
  290.                          /
  291.             +-----------------------+
  292.   Level 1   | Dev#2: 4-port hub (12)|
  293.             +-----------------------+
  294.             |CN.0 |CN.1 |CN.2 |CN.3 |
  295.             +-----------------------+
  296.                            ____________________
  297.                  _____                          
  298.                                                  
  299.                +--------------------+      +--------------------+
  300.   Level 2      | Dev# 3: mouse (1.5)|      | Dev# 4: serial (12)|
  301.                +--------------------+      +--------------------+
  302. Or, in a more tree-like structure (ports [Connectors] without
  303. connections could be omitted):
  304. PC:  Dev# 1, root hub, 2 ports, 12 Mbps
  305. |_ CN.0:  Dev# 2, hub, 4 ports, 12 Mbps
  306.      |_ CN.0:  Dev #3, mouse, 1.5 Mbps
  307.      |_ CN.1:
  308.      |_ CN.2:  Dev #4, serial, 12 Mbps
  309.      |_ CN.3:
  310. |_ CN.1:
  311.                          ### END ###