1. usbfs生命周期
在linux-2.6中加入,在linux-3.3移除,同时/proc/bus/usb移到/dev/bus/usb下。
2. usbfs挂载流程
3. usbfs 加载
在Linux内核中确定已经选择以下项:
Device Drivers --->
[*] USB Support --->
[*] USB device filesystem(DEPRECATED)
系统启动后,查看/proc/bus/usb/devices文件,对文件内容进行分析
$cat /proc/bus/usb/devices
如果没有该文件,有可能是由于没有加载usb文件系统,
通过在/etc/fstab文件中添加如下一行:
none /proc/bus/usb usbfs defaults
或手动mount,
$mount -t usbfs none /proc/bus/usb
或者
sudo mount -t usbfs usbfs /proc/bus/usb/
4. 查看设备信息
例:
[root@A3352-WB128LI opt]#cat /proc/bus/usb/devices
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00Dev#= 1 Spd=480 MxCh= 1
B: Alloc= 0/800 us ( 0%), #Int= 0,#Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.02
S: Manufacturer=Linux 3.2.0 musb-hcd
S: Product=MUSB HDRC host driver
S: SerialNumber=musb-hdrc.1
C:* #Ifs=1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#=0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.11 Cls=00(>ifc ) Sub=00 Prot=00MxPS=64 #Cfgs= 1
P: Vendor=10c4 ProdID=8468 Rev= 1.00
S: Manufacturer=GT-GOLDTEL-CDINVS
S: Product=INVS100-H1_Ver20141125_IDCardReaderDevice
S: SerialNumber=锝捹亼浈愩牱铚
C:* #Ifs=1 Cfg#= 1 Atr=c0 MxPwr=300mA
I:* If#=0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00Prot=00 Driver=(none)
E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=1ms
E: Ad=01(O) Atr=03(Int.) MxPS= 64 Ivl=2ms
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00Dev#= 1 Spd=480 MxCh= 1
B: Alloc= 0/800 us ( 0%), #Int= 0,#Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.02
S: Manufacturer=Linux 3.2.0 musb-hcd
S: Product=MUSB HDRC host driver
S: SerialNumber=musb-hdrc.0
C:* #Ifs=1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#=0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4Ivl=256ms
每行由一个字符的ID来标识:
T =Topology (etc.)
B = Bandwidth (只用于USB host控制器 它被虚拟为root hubs)
D = Device 描述信息.
P = Product ID 信息.
S = String 描述.
C = Configuration 描述信息(* = 活动配置)
I = Interface 描述信息.
E = Endpoint 描述信息.
/proc/bus/usb/devices 输出格式:
Legend:
d = 十进制数 (用spaces or 0's开头)
x = 十六进制数 (用spaces or 0's开头)
s = string
拓扑信息:
T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd
| | | | | | | | |__MaxChildren(最在子节点)
| | | | | | | |__Device Speed in Mbps(设备速度,单位是Mbps)
| | | | | | |__DeviceNumber(设备号)
| | | | | |__Count of devices at this level(本层次的设备数)
| | | | |__Connector/Port on Parent for this device(本设备在父节点的接口)
| | | |__Parent DeviceNumber(父设备号)
| | |__Level in topology for this bus(本BUS的拓扑层次)
| |__Bus number(总线号)
|__Topology info tag(拓扑信息标识)
带宽信息:
B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd
| | | |__Number if isochronous requests(同步请求号)
| | |__Number of interrupt requests(中断请求号)
| |__Total Bandwidth allocated to this bus(分到本bus的总带宽)
|__Bandwidth info tag(带宽信息标识)
设备描述信息与产品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(设备的USB版本)
|__Device info tag #1(设备标识#1)
其中
P: Vendor=xxxx ProdID=xxxx Rev=xx.xx
| | | |__Product revision number(产品修订号)
| | |__Product ID code(产品ID编码)
| |__Vendor ID code(厂家ID编码)
|__Device info tag #2(设备标识#2)
字符串描述信息:
S: Manufacturer=ssss
| |__Manufacturer of this device as read from the device.(从设备读得的生产者)
|__String info tag(字符信息标识)
S: Product=ssss
| |__从设备读得的产品信息,除去那些USB主控制器产生的字符串,格式 "USB *HCI Root Hub".
|__String info tag(字符信息标识)
S: SerialNumber=ssss
| |__从设备读得的设备Serial Number ,除去那些USB主控制器产生的字符串, 代表主控制器
| 在系统中唯一标识 (当前是 I/O 或 memory-mapped base 地址).
|__String info tag(字符信息标识)
配置描述信息:
C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA
| | | | |__MaxPower in mA(最大功率,mA)
| | | |__Attributes(属性)
| | |__ConfiguratioNumber(配置数)
| |__NumberOfInterfaces(接口数)
|__Config info tag(配置信息标识)
接口描述信息 (每配置可以是多个):
I: If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=ssss
| | | | | | | |__Driver name(驱动名)
| | | | | | |__InterfaceProtocol(接口协议)
| | | | | |__InterfaceSubClass(接口子类)
| | | | |__InterfaceClass(接口类)
| | | |__NumberOfEndpoints(端点号)
| | |__AlternateSettingNumber(接口设置号)
| |__InterfaceNumber(接口号)
|__Interface info tag(接口信息标识)
端点描述信息(每接口可以是多个):
E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddms
E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=dddms
| | | | |__Interval(间隔)
| | | |__EndpointMaxPacketSize(端点最大包大小)
| | |__Attributes(EndpointType)(端点属性)
| |__EndpointAddress(I=In,O=Out) (端点地址)
|__Endpoint info tag(端点信息标识)
[root@A3352-WB128LI opt]#find /proc/bus/
/proc/bus/
/proc/bus/input
/proc/bus/input/handlers
/proc/bus/input/devices
/proc/bus/usb
/proc/bus/usb/002
/proc/bus/usb/002/002
/proc/bus/usb/002/001
/proc/bus/usb/001
/proc/bus/usb/001/001
/proc/bus/usb/devices
[root@A3352-WB128LI opt]#lsusb /proc/bus/usb/002/002
Bus 001Device 001: ID 1d6b:0002
Bus 002Device 001: ID 1d6b:0002
Bus 002 Device 002: ID 10c4:8468
参考资料:
http://www.cnblogs.com/leino11121/archive/2011/04/21/2381918.html