色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

Linux中如何查看usb設備信息

瀏覽:7日期:2023-10-05 21:01:20
目錄一、cat設備節點獲取信息1、usb設備在總線上的信息2、特定設備的詳細信息二、使用debugfs1、掛載 debugfs 到 /sys/kernel/debug 路徑下2、執行上述步驟之后3、cat 設備節點總結

下面的信息都是在VMware中運行Ubuntu12-04系統上執行的。

同樣該命令也支持在嵌入式系統中進行USB調試。

一、cat設備節點獲取信息

在一些嵌入式開發中需要調試USB功能,經常會cat /sys 下的相關設備節點來查看某些信息,比如說我們可以看到 /sys/bus/usb/devices 目錄有多個子目錄。

進入到某個子目錄可以看到usb設備更加詳細的信息(可以理解為設備描述符)。

1、usb設備在總線上的信息// usb設備在總線上的信息root@ubuntu:/sys/kernel/debug# cd /sys/bus/usb/devicesroot@ubuntu:/sys/bus/usb/devices# lltotal 0drwxr-xr-x 2 root root 0 Nov 26 21:21 ./drwxr-xr-x 4 root root 0 Nov 26 21:21 ../lrwxrwxrwx 1 root root 0 Nov 26 21:21 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-0:1.0/lrwxrwxrwx 1 root root 0 Dec 15 23:10 1-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/lrwxrwxrwx 1 root root 0 Dec 15 23:18 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-0:1.0/lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2:1.0/lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/

其中 usbx/第x個總線,x-y:a.b/的目錄格式,x表示總線號,y表示端口,a表示配置,b表示接口。

具體解釋可以參照如下:

The names that begin with 'usb' refer to USB controllers. More accurately, they refer to the 'root hub' associated with each controller. The number is the USB bus number. In the example there is only one controller, so its bus is number 1. Hence the name 'usb1'.'1-0:1.0' is a special case. It refers to the root hub's interface. This acts just like the interface in an actual hub an almost every respect; see below.All the other entries refer to genuine USB devices and their interfaces. The devices are named by a scheme like this: bus-port.port.port ...In other words, the name starts with the bus number followed by a '-'. Then comes the sequence of port numbers for each of the intermediate hubs along the path to the device.For example, '1-1' is a device plugged into bus 1, port 1. It happens to be a hub, and '1-1.3' is the device plugged into port 3 of that hub. That device is another hub, and '1-1.3.1' is the device plugged into its port 1.The interfaces are indicated by suffixes having this form: :config.interfaceThat is, a ':' followed by the configuration number followed by '.' followed by the interface number. In the above example, each of the devices is using configuration 1 and this configuration has only a single interface, number 0. So the interfaces show up as; 1-1:1.0 1-1.3:1.0 1-1.3.1:1.0A hub will never have more than a single interface; that's part of the USB spec. But other devices can and do have multiple interfaces (and sometimes multiple configurations). Each interface gets its own entry in sysfs and can have its own driver.2、特定設備的詳細信息

進入到某個目錄中去,可以看到該設備的詳細信息,可用cat命令獲取信息。

// usb設備的詳細信息root@ubuntu:/sys/bus/usb/devices/usb1# lltotal 0drwxr-xr-x 6 root root 0 Nov 26 21:21 ./drwxr-xr-x 4 root root 0 Nov 26 21:21 ../drwxr-xr-x 10 root root 0 Nov 26 21:21 1-0:1.0/drwxr-xr-x 5 root root 0 Dec 15 23:10 1-1/-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized_default-rw-r--r-- 1 root root 4096 Dec 15 23:40 avoid_reset_quirk-r--r--r-- 1 root root 4096 Nov 26 21:21 bcdDevice-rw-r--r-- 1 root root 4096 Nov 26 21:21 bConfigurationValue-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceClass-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceProtocol-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceSubClass-r--r--r-- 1 root root 4096 Dec 15 23:40 bmAttributes-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPacketSize0-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPower-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumConfigurations-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumInterfaces-r--r--r-- 1 root root 4096 Nov 26 21:21 busnum-r--r--r-- 1 root root 4096 Dec 15 23:40 configuration-r--r--r-- 1 root root 65553 Nov 26 21:21 descriptors-r--r--r-- 1 root root 4096 Dec 15 23:40 dev-r--r--r-- 1 root root 4096 Nov 26 21:21 devnum-r--r--r-- 1 root root 4096 Dec 15 23:40 devpathlrwxrwxrwx 1 root root 0 Nov 27 20:06 driver -> ../../../../../bus/usb/drivers/usb/drwxr-xr-x 3 root root 0 Dec 15 23:40 ep_00/-r--r--r-- 1 root root 4096 Nov 26 21:21 idProduct-r--r--r-- 1 root root 4096 Nov 26 21:21 idVendor-r--r--r-- 1 root root 4096 Dec 15 23:40 ltm_capable-r--r--r-- 1 root root 4096 Nov 26 21:21 manufacturer-r--r--r-- 1 root root 4096 Dec 15 23:40 maxchilddrwxr-xr-x 2 root root 0 Nov 26 21:21 power/-r--r--r-- 1 root root 4096 Nov 26 21:21 product-r--r--r-- 1 root root 4096 Dec 15 23:40 quirks-r--r--r-- 1 root root 4096 Nov 26 21:21 removable--w------- 1 root root 4096 Dec 15 23:40 remove-r--r--r-- 1 root root 4096 Nov 26 21:21 serial-r--r--r-- 1 root root 4096 Nov 26 21:21 speedlrwxrwxrwx 1 root root 0 Nov 26 21:21 subsystem -> ../../../../../bus/usb/-rw-r--r-- 1 root root 4096 Nov 26 21:21 uevent-r--r--r-- 1 root root 4096 Dec 15 23:40 urbnum-r--r--r-- 1 root root 4096 Dec 15 23:40 version二、使用debugfs1、掛載 debugfs 到 /sys/kernel/debug 路徑下root@ubuntu:mount -t debugfs none /sys/kernel/debug2、執行上述步驟之后

在 /sys/kernel/debug 就會生成如下的文件

root@ubuntu:/sys/bus/usb/devices# cd /sys/kernel/debug/root@ubuntu:/sys/kernel/debug# lltotal 0drwx------ 22 root root 0 Nov 26 21:21 ./drwxr-xr-x 7 root root 0 Nov 26 21:21 ../drwxr-xr-x 2 root root 0 Nov 26 21:21 acpi/drwxr-xr-x 32 root root 0 Dec 4 16:30 bdi/drwxr-xr-x 2 root root 0 Nov 26 21:21 bluetooth/drwxr-xr-x 2 root root 0 Nov 26 21:21 cleancache/drwxr-xr-x 2 root root 0 Nov 26 21:21 dma_buf/drwxr-xr-x 4 root root 0 Nov 26 21:21 dri/drwxr-xr-x 2 root root 0 Nov 26 21:21 dynamic_debug/drwxr-xr-x 2 root root 0 Nov 26 21:21 extfrag/drwxr-xr-x 2 root root 0 Nov 26 21:21 frontswap/-r--r--r-- 1 root root 0 Nov 26 21:21 gpiodrwxr-xr-x 3 root root 0 Nov 26 21:21 hid/drwxr-xr-x 2 root root 0 Nov 26 21:21 kprobes/drwxr-xr-x 3 root root 0 Nov 26 21:21 kvm-guest/drwxr-xr-x 2 root root 0 Nov 26 21:21 mce/drwxr-xr-x 2 root root 0 Nov 26 21:21 pinctrl/-r--r--r-- 1 root root 0 Nov 26 21:21 pwmdrwxr-xr-x 2 root root 0 Nov 26 21:21 regmap/drwxr-xr-x 3 root root 0 Nov 26 21:21 regulator/-rw-r--r-- 1 root root 0 Nov 26 21:21 sched_features-r--r--r-- 1 root root 0 Nov 26 21:21 sleep_time-r--r--r-- 1 root root 0 Nov 26 21:21 suspend_statsdrwxr-xr-x 7 root root 0 Nov 26 21:21 tracing/drwxr-xr-x 3 root root 0 Nov 26 21:21 usb/drwxr-xr-x 2 root root 0 Nov 26 21:21 virtio-ports/-r--r--r-- 1 root root 0 Nov 26 21:21 vmmemctl-r--r--r-- 1 root root 0 Nov 26 21:21 wakeup_sourcesdrwxr-xr-x 2 root root 0 Nov 26 21:21 x86/3、cat 設備節點

執行下述命令之后會以特定格式打印目前USB總線上所有USB設備的信息如下:

root@ubuntu:/sys/kernel/debug# cat usb/devices T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2B: Alloc= 17/900 us ( 2%), #Int= 1, #Iso= 0D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1P: Vendor=1d6b ProdID=0001 Rev= 3.13S: Manufacturer=Linux 3.13.0-32-generic uhci_hcdS: Product=UHCI Host ControllerS: SerialNumber=0000:02:00.0C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mAI:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hubE: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255msT: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1P: Vendor=0e0f ProdID=0003 Rev= 1.03S: Manufacturer=VMwareS: Product=VMware Virtual USB MouseC:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mAI:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhidE: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1msT: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1P: Vendor=0e0f ProdID=0002 Rev= 1.00S: Product=VMware Virtual USB HubC:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mAI:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hubE: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255msT: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6B: Alloc= 0/800 us ( 0%), #Int= 1, #Iso= 0D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1P: Vendor=1d6b ProdID=0002 Rev= 3.13S: Manufacturer=Linux 3.13.0-32-generic ehci_hcdS: Product=EHCI Host ControllerS: SerialNumber=0000:02:03.0C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mAI:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hubE: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256msT: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1P: Vendor=0bda ProdID=0129 Rev=39.60S: Manufacturer=GenericS: Product=USB2.0-CRWS: SerialNumber=20100201396000000C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mAI:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0msE: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0msE: Ad=83(I) Atr=03(Int.) MxPS= 3 Ivl=64ms

至于信息的詳細解析可以參照 Linux源代碼中 Documentation/usb/proc_usb_info.txt 文件。

現摘錄其中對該格式的詳細解釋:

Each line is tagged with a one-character ID for that line:T = Topology (etc.)B = Bandwidth (applies only to USB host controllers, which are virtualized as root hubs)D = Device descriptor info.P = Product ID info. (from Device descriptor, but they won't fit together on one line)S = String descriptors.C = Configuration descriptor info. (* = active configuration)I = Interface descriptor info.E = Endpoint descriptor info.Legend: d = decimal number (may have leading spaces or 0's) x = hexadecimal number (may have leading spaces or 0's) s = stringTopology info:T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd| | | | | | |||__MaxChildren| | | | | | ||__Device Speed in Mbps| | | | | | |__DeviceNumber| | | | | |__Count of devices at this level| | | | |__Connector/Port on Parent for this device| | | |__Parent DeviceNumber| | |__Level in topology for this bus| |__Bus number|__Topology info tag Speed may be:1.5 Mbit/s for low speed USB 12 Mbit/s for full speed USB 480 Mbit/s for high speed USB (added for USB 2.0); also used for Wireless USB, which has no fixed speed 5000 Mbit/s for SuperSpeed USB (added for USB 3.0) For reasons lost in the mists of time, the Port number is always too low by 1. For example, a device plugged into port 4 will show up with 'Port=03'.Bandwidth info:B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd| | | |__Number of isochronous requests| | |__Number of interrupt requests| |__Total Bandwidth allocated to this bus|__Bandwidth info tag Bandwidth allocation is an approximation of how much of one frame (millisecond) is in use. It reflects only periodic transfers, which are the only transfers that reserve bandwidth. Control and bulk transfers use all other bandwidth, including reserved bandwidth that is not used for transfers (such as for short packets). The percentage is how much of the 'reserved' bandwidth is scheduled by those transfers. For a low or full speed bus (loosely, 'USB 1.1'), 90% of the bus bandwidth is reserved. For a high speed bus (loosely, 'USB 2.0') 80% is reserved.Device descriptor info & Product ID info:D: Ver=x.xx Cls=xx(s) Sub=xx Prot=xx MxPS=dd #Cfgs=ddP: Vendor=xxxx ProdID=xxxx Rev=xx.xxwhereD: Ver=x.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd| || | | | |__NumberConfigurations| || | | |__MaxPacketSize of Default Endpoint| || | |__DeviceProtocol| || |__DeviceSubClass| ||__DeviceClass| |__Device USB version|__Device info tag #1whereP: Vendor=xxxx ProdID=xxxx Rev=xx.xx| | | |__Product revision number| | |__Product ID code| |__Vendor ID code|__Device info tag #2String descriptor info:S: Manufacturer=ssss| |__Manufacturer of this device as read from the device.| For USB host controller drivers (virtual root hubs) this may| be omitted, or (for newer drivers) will identify the kernel| version and the driver which provides this hub emulation.|__String info tagS: Product=ssss| |__Product description of this device as read from the device.| For older USB host controller drivers (virtual root hubs) this| indicates the driver; for newer ones, it's a product (and vendor)| description that often comes from the kernel's PCI ID database.|__String info tagS: SerialNumber=ssss| |__Serial Number of this device as read from the device.| For USB host controller drivers (virtual root hubs) this is| some unique ID, normally a bus ID (address or slot name) that| can't be shared with any other device.|__String info tagConfiguration descriptor info:C:* #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA| | | | | |__MaxPower in mA| | | | |__Attributes| | | |__ConfiguratioNumber| | |__NumberOfInterfaces| |__ '*' indicates the active configuration (others are ' ')|__Config info tag USB devices may have multiple configurations, each of which act rather differently. For example, a bus-powered configuration might be much less capable than one that is self-powered. Only one device configuration can be active at a time; most devices have only one configuration. Each configuration consists of one or more interfaces. Each interface serves a distinct 'function', which is typically bound to a different USB device driver. One common example is a USB speaker with an audio interface for playback, and a HID interface for use with software volume control.Interface descriptor info (can be multiple per Config):I:* If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=ssss| | | | | | | | |__Driver name| | | | | | | | or '(none)'| | | | | | | |__InterfaceProtocol| | | | | | |__InterfaceSubClass| | | | | |__InterfaceClass| | | | |__NumberOfEndpoints| | | |__AlternateSettingNumber| | |__InterfaceNumber| |__ '*' indicates the active altsetting (others are ' ')|__Interface info tag A given interface may have one or more 'alternate' settings. For example, default settings may not use more than a small amount of periodic bandwidth. To use significant fractions of bus bandwidth, drivers must select a non-default altsetting. Only one setting for an interface may be active at a time, and only one driver may bind to an interface at a time. Most devices have only one alternate setting per interface.Endpoint descriptor info (can be multiple per Interface):E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddss| || | |__Interval (max) between transfers| || |__EndpointMaxPacketSize| ||__Attributes(EndpointType)| |__EndpointAddress(I=In,O=Out)|__Endpoint info tag The interval is nonzero for all periodic (interrupt or isochronous) endpoints. For high speed endpoints the transfer interval may be measured in microseconds rather than milliseconds. For high speed periodic endpoints, the 'MaxPacketSize' reflects the per-microframe data transfer size. For 'high bandwidth' endpoints, that can reflect two or three packets (for up to 3KBytes every 125 usec) per endpoint. With the Linux-USB stack, periodic bandwidth reservations use the transfer intervals and sizes provided by URBs, which can be less than those found in endpoint descriptor.總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Linux
主站蜘蛛池模板: 天堂mv亚洲mv在线播放9蜜 | 婷婷丁香久久 | 狠狠色丁香九九婷婷综合五月 | 日韩性视频网站 | 一级一级一片免费 | 免费亚洲黄色 | 免费特黄 | 欧洲国产伦久久久久久久 | 15—17女人毛片| 看真人一级毛片 | 亚洲日本视频在线观看 | 亚洲成 人a影院青久在线观看 | 欧美日韩精品乱国产 | 国产精品视频久久久久 | 中文字幕视频免费在线观看 | 97久久天天综合色天天综合色 | 中国一级特黄剌激爽毛片 | 古代级a毛片在线 | 亚洲国产网址 | 91精品欧美综合在线观看 | 亚洲国产精品久久综合 | 欧美一级久久久久久久久大 | 亚洲天堂影院在线观看 | 日韩国产欧美成人一区二区影院 | yy6080午夜国产免费福利 | 欧美日韩第三页 | 亚洲va老文色欧美黄大片人人 | 欧美一级特黄aa大片在线观看免费 | 国产在线观看精品一区二区三区91 | 亚洲美女视频 | 国产高清免费影视在线观看 | 欧美一级毛片大片免费播放 | 一区二区欧美视频 | 亚洲第一网色综合久久 | 亚洲一区二区三区免费视频 | 久久精品一区 | 欧美成a | 国产美女毛片 | 全高清特级毛片 | 久久精品免费观看 | 国产一级一片免费播放 |