1.lsusb:查看系统当前连接的所有USB设备
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/520e7b97b6ecabff9b65bb0f0e9939f1.png)
2.cat /sys/kernel/debug/usb/devices : 每个USB设备及其配置描述符
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 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= 5.04
S: Manufacturer=Linux 5.4.86-android11-2-g9b3456a83314-dirty xhci-hcd
S: Product=xHCI Host Controller
S: SerialNumber=xhci-hcd.0.auto
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 4
D: Ver= 2.10 Cls=09(hub ) Sub=00 Prot=02 MxPS=64 #Cfgs= 1
P: Vendor=2109 ProdID=2817 Rev=90.13
S: Manufacturer=VIA Labs, Inc.
S: Product=USB2.0 Hub
S: SerialNumber=000000000
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=01 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=256ms
I:* If#= 0 Alt= 1 #EPs= 1 Cls=09(hub ) Sub=00 Prot=02 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=256ms
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 11 Spd=480 MxCh= 0
HUB上的设备
D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0bda ProdID=b812 Rev= 2.10
S: Manufacturer=Realtek
S: Product=802.11ac NIC
S: SerialNumber=123456
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 5 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=87(I) Atr=03(Int.) MxPS= 64 Ivl=500us
E: Ad=08(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
3.cat /proc/bus/input/devices :查看连接的输入设备信息
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b58e852bdec3ddc3e6515852e3f5c4b2.png)
4.cat sys/bus/usb/devices/2-1.1/ :查看对应USB设备的详细信息,例如 2-1.1:1.0 命名规则是:roothub-port:configuration.interface.)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/fc01eb90275dac9d4f476b9004c3fccb.png)
5.cat /sys/bus/usb/devices/2-1.1:1.0/bInterfaceClass :查看当前设备所支持的特性,例如: 01 表示支持audio
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/bcc07714b08c8be42ace6a45abb5980e.png)
6.只查看连接设备的端口信息:
# ls /sys/bus/usb/drivers/usb/
1-1 1-1.2 1-1.2.3.1 1-1.3.1 2-1 2-1.2.3 uevent usb1
1-1.1 1-1.2.3 1-1.3 1-1.3.3 2-1.2 bind unbind usb2
7.查看主次设备号:
# cat /sys/bus/usb/devices/1-1.4/uevent
MAJOR=189
MINOR=9
DEVNAME=bus/usb/001/010
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=bda/b812/210
TYPE=0/0/0
BUSNUM=001
DEVNUM=010
8.代码位置
\system\core\libusbhost\usbhost.c
\frameworks\base\services\core\jni\com_android_server_UsbHostManager.cpp
\frameworks\base\core\java\android\hardware\usb\UsbInterface.java
\frameworks\base\services\usb\java\com\android\server\usb\UsbHostManager.java
\frameworks\base\services\usb\java\com\android\server\usb\UsbService.java