proc_usb_info.txt 15 KB

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