/sys/kernel/debug/usb/devices解析
1.概述
USB设备通过debugfs导出/sys/kernel/debug/usb/devices显示内核已知的每个USB设备及其配置描述符。此文件对于用户模式下的状态查看
工具非常方便,可以扫描文本格式并忽略大部分文本。 设备特定文件中提供了更详细的设备状态(包括类和供应商状态)。
此文件与poll()系统调用结合使用,还可用于检测何时添加或删除设备:
int fd;
struct pollfd pfd; fd = open("/sys/kernel/debug/usb/devices", O_RDONLY);
pfd = { fd, POLLIN, };
for (;;) {
/* The first time through, this call will return immediately. */
poll(&pfd, , -); /* To see what's changed, compare the file's previous and current
contents or scan the filesystem. (Scanning is more precise.) */
}
请注意,此行为旨在用于信息获取和调试目的。 例如,使用诸如udev或HAL之类的程序来初始化设备或启动用户模式助手程序会更合适。
2.文件格式
每个T:行(拓扑信息:Lev,Prnt,Port,Cnt)的前4列中的数字可用于构建USB拓扑图。
每行标记有该行的单字符ID:
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.
历史遗留:d = 十进制数(可能有前导空格或0) x = 十六进制数(可能有前导空格或0) s = string
1)拓扑信息:
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如下, 插入端口4的设备将显示Port = 03。
1.5 Mbit/s for low speed USB
Mbit/s for full speed USB
Mbit/s for high speed USB (added for USB 2.0); also used for Wireless USB, which has no fixed speed
Mbit/s for SuperSpeed USB (added for USB 3.0)
2)带宽信息:
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
3)设备描述符信息和产品ID信息:
D: Ver=x.xx Cls=xx(s) Sub=xx Prot=xx MxPS=dd #Cfgs=dd
P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
D: 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 #
P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
| | | |__Product revision number
| | |__Product ID code
| |__Vendor ID code
|__Device info tag #
4)字符串描述符信息:
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 tag S: 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 tag S: 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 tag
5)配置描述符信息:
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设备可能具有多种配置,每种配置的行为都不同。 例如,总线供电的配置可能比自供电配置的能力低得多。 一次只能激活一个设备配
置; 大多数设备只有一个配置。
每个配置都包含一个或多个接口。 每个接口都提供不同的“功能”,通常绑定到不同的USB设备驱动程序。 一个常见的例子是带有用于回放的
音频接口的USB扬声器,以及用于软件音量控制的HID接口。
:6)接口描述符信息:
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
一个给定接口可以具有一个或多个“可选”设置。 例如,默认设置可能不会使用少量的周期性带宽。 要使用大部分总线带宽,驱动程序必须
选择非默认的altsetting。
一次只能有一个接口的设置处于活动状态,并且一次只能有一个驱动程序绑定到接口。 大多数设备每个接口只有一个可用设置。
7)端点描述符信息:
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
所有周期性(中断或等时)端点的间隔都是非零的。 对于高速端点,传输间隔可以以微秒而不是毫秒来度量。
对于高速周期端点,EndpointMaxPacketSize反映了每微帧数据传输大小。 对于“高带宽”端点,每个端点可以反映两个或三个数据包(每125
个用户最多3个字节)。
使用Linux-USB堆栈,定期带宽保留使用URB提供的传输间隔和大小,这可能小于端点描述符中的传输间隔和大小。
3.此文件的使用例子
例如,如果用户或脚本仅对拓扑信息感兴趣,请使用类似的内容
grep ^T: /sys/kernel/debug/usb/devices 仅用于拓扑行。
grep -i ^[tdp]: /sys/kernel/debug/usb/devices 这样的命令可用于仅列出以方括号中的字符开头的行,其中有效字符为TDPCIE。 使用稍
微更强大的脚本,它可以显示任何选定的行(例如,只显示T,D和P行)并更改其输出格式。 (procusb Perl脚本是这个想法的开始。它将
仅列出从/sys/kernel/debug/usb/devices中选择的行[从TBDPSCIE中选择]或“All”行。)
拓扑行可用于生成系统根集线器上USB设备的图形/图示。
接口行可用于确定每个设备使用的驱动程序,以及被激活的可选设置。
配置行可用于列出系统的USB设备正在使用的最大功率(以毫安为单位)。 例如:/sys/kernel/debug/usb/devices.
eg:
T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
B: Alloc= / us ( %), #Int= , #Iso=
D: Ver= 1.00 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor= ProdID= Rev= 0.00
S: Product=USB UHCI Root Hub
S: SerialNumber=dce0
C:* #Ifs= Cfg#= Atr= MxPwr= 0mA
I: If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=255ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
D: Ver= 1.00 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor= ProdID= Rev= 1.00
C:* #Ifs= Cfg#= Atr=e0 MxPwr=100mA
I: If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=255ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd=1.5 MxCh=
D: Ver= 1.00 Cls=(>ifc ) Sub= Prot= MxPS= #Cfgs=
P: Vendor=04b4 ProdID= Rev= 0.00
C:* #Ifs= Cfg#= Atr= MxPwr=100mA
I: If#= Alt= #EPs= Cls=(HID ) Sub= Prot= Driver=mouse
E: Ad=(I) Atr=(Int.) MxPS= Ivl= 10ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
D: Ver= 1.00 Cls=(>ifc ) Sub= Prot= MxPS= #Cfgs=
P: Vendor= ProdID= Rev= 1.08
S: Manufacturer=Peracom Networks, Inc.
S: Product=Peracom USB to Serial Converter
C:* #Ifs= Cfg#= Atr=a0 MxPwr=100mA
I: If#= Alt= #EPs= Cls=(>ifc ) Sub= Prot= Driver=serial
E: Ad=(I) Atr=(Bulk) MxPS= Ivl= 16ms
E: Ad=(O) Atr=(Bulk) MxPS= Ivl= 16ms
E: Ad=(I) Atr=(Int.) MxPS= Ivl= 8ms
从中选择仅T:和I:行(例如,使用procusb ti),我们有:
T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
T: Bus= Lev= Prnt= Port=00 Cnt= Dev#= Spd= MxCh= 接在父设备的0号端口上, 而且自己有4个下行端口
I: If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd=1.5 MxCh=
I: If#= Alt= #EPs= Cls=(HID ) Sub= Prot= Driver=mouse
T: Bus= Lev= Prnt= Port=02 Cnt= Dev#= Spd= MxCh= 接在父设备的2号端口上,自己没有下行端口
I: If#= Alt= #EPs= Cls=(>ifc ) Sub= Prot= Driver=serial
得出拓扑:
+------------------+
| PC/root_hub ()| Dev# =
+------------------+ (nn) is Mbps.
Level | CN. | CN. | [CN = connector/port #]
+------------------+
/
/
+-----------------------+
Level | Dev#: -port hub ()|
+-----------------------+
|CN. |CN. |CN. |CN. |
+-----------------------+
\ \____________________
\_____ \
\ \
+--------------------+ +--------------------+
Level | Dev# : mouse (1.5)| | Dev# : serial ()|
+--------------------+ +--------------------+
下面是我这个Renesas开发板的:
# cat /sys/kernel/debug/usb/devices T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
B: Alloc= / us ( %), #Int= , #Iso=
D: Ver= 2.00 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor=1d6b ProdID= Rev= 4.14
S: Manufacturer=Linux 4.14. ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=ee080100.usb
C:* #Ifs= Cfg#= Atr=e0 MxPwr= 0mA
I:* If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=256ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
B: Alloc= / us ( %), #Int= , #Iso=
D: Ver= 2.00 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor=1d6b ProdID= Rev= 4.14
S: Manufacturer=Linux 4.14. ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=ee0a0100.usb
C:* #Ifs= Cfg#= Atr=e0 MxPwr= 0mA
I:* If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=256ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
B: Alloc= / us ( %), #Int= , #Iso=
D: Ver= 1.10 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor=1d6b ProdID= Rev= 4.14
S: Manufacturer=Linux 4.14. ohci_hcd
S: Product=Generic Platform OHCI controller
S: SerialNumber=ee080000.usb
C:* #Ifs= Cfg#= Atr=e0 MxPwr= 0mA
I:* If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=255ms T: Bus= Lev= Prnt= Port= Cnt= Dev#= Spd= MxCh=
B: Alloc= / us ( %), #Int= , #Iso=
D: Ver= 1.10 Cls=(hub ) Sub= Prot= MxPS= #Cfgs=
P: Vendor=1d6b ProdID= Rev= 4.14
S: Manufacturer=Linux 4.14. ohci_hcd
S: Product=Generic Platform OHCI controller
S: SerialNumber=ee0a0000.usb
C:* #Ifs= Cfg#= Atr=e0 MxPwr= 0mA
I:* If#= Alt= #EPs= Cls=(hub ) Sub= Prot= Driver=hub
E: Ad=(I) Atr=(Int.) MxPS= Ivl=255ms
https://01.org/linuxgraphics/gfx-docs/drm/driver-api/usb/usb.html#dev-bus-usb-bbb-ddd
/sys/kernel/debug/usb/devices解析的更多相关文章
- /sys/kernel/debug/gpio
在使用GPIO的时候,有时候不知道GPIO的状态,也不知道在内核中GPIO是否申请成功. 可以通过/sys/kernel/debug/gpio这个文件来查看.这个文件显示了申请成功的GPIO的输入输出 ...
- 关于热插拔usb hotplug /proc/sys/kernel mdev udev b...
转:http://www.360doc.com/content/10/0527/18/9922_29835045.shtml 这篇文章说的很好http://blog.chinaunix.net/u1/ ...
- Linux Kernel - Debug Guide (Linux内核调试指南 )
http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...
- 解决三星官方移植的内核默认是没有打开支持V4L USB devices
在linux比较新的kernel,都标配了各类摄像头的驱动支持,不用我们自己移植驱动,只需通过make menuconfig配置内核支持我们所需的摄像头类型即可.以下是在三星官方内核中配置V ...
- linux kernel的cmdline参数解析原理分析【转】
转自:https://blog.csdn.net/skyflying2012/article/details/41142801 版权声明:本文为博主kerneler辛苦原创,未经允许不得转载. htt ...
- 『翻译』Access USB Devices on the Web
https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web Access USB Devices o ...
- /proc/sys/kernel/sysrq /proc/sysrq-trigger----强制重启/触发器
LINUX远程强制重启/proc/sys/kernel/sysrq /proc/sysrq-trigger----触发器 ttp://blog.csdn.net/beckdon/article/det ...
- WARNING: /sys/kernel/mm/transparent_hugepage/enabled is
安装MONGODB 3.0.6的时候提示警告信息,如下: 2015-09-09T11:04:35.011+0800 I CONTROL [initandlisten] ** WARNING: /sys ...
- 利用 /proc/sys/kernel/core_pattern隐藏系统后门
ref:https://xz.aliyun.com/t/1098/ 这里所说的core_pattern 指的是:/proc/sys/kernel/core_pattern. 我们知道在Linux系统中 ...
随机推荐
- Android 自定义View - 饼图
最近有看到一个自定义等分圆的View,自己尝试做了一个类似的,效果图如下图(1)所示: 图(1) 实现方法:自定义View-ColorCircle,需要的知道的值有圆的半径,等分个数以及扇形颜色. / ...
- python webdriver 登录163邮箱发邮件加附件, 外加数据和程序分离,配置文件的方式
配置文件:UiObjectMapSendMap.ini用来存放配置信息 GetOptionSendMail.py 用来读取配信息 #encoding=utf-8from selenium.webdri ...
- zabbix server监控报主机 Lack of free swap space
zabbix server监控报主机 Lack of free swap space,因为交换空间不足引起.该主机内存为3G,正常交换空间大小为物理内存2倍左右. #查看已有内存及交换空间 free ...
- SQL学习笔记二之MySQL的数据库操作
阅读目录 一 系统数据库 二 创建数据库 三 数据库相关操作 一 系统数据库 information_schema: 虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限 ...
- (转载)找圆算法((HoughCircles)总结与优化
Opencv内部提供了一个基于Hough变换理论的找圆算法,HoughCircle与一般的拟合圆算法比起来,各有优势:优势:HoughCircle对噪声点不怎么敏感,并且可以在同一个图中找出多个圆 ...
- 20145319 return-to-libc攻击实验
20145319 Return-to-libc攻击实验 一 实验内容 return-to-libc实验是一个基于缓冲区溢出攻击实验的基础上的一种攻击实验 缓冲区溢出攻击相关知识: 原理:通过一段包含s ...
- usb_submit_urb
hub_irq() --> usb_submit_urb() usb_start_wait_urb() --> usb_submit_urb() 一旦urb被USB驱动程序正确地创建和初始 ...
- 想转行学Java,却又担心自己半路出家成不了大牛
想转行学Java,却又担心自己半路出家成不了大牛 很多人看好Java编程的高薪前景,在自己职业生涯迷茫的时候,想转行学Java,却又担心自己半路出家成不了大牛,赚不到钱,本文就为大家分析一下,转行学J ...
- C# 后台模块 Word 模板操作
public static string CreateWord() { //********************************************** //来自博客http://bl ...
- 51Nod 1737 配对(树的重心)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1737 题意: 思路: 树的重心. 树的重心就是其所以子树的最大的子树结点 ...