lsusb命令详解
参考:
1、https://zhuanlan.zhihu.com/p/142403866
2、https://blog.csdn.net/phmatthaus/article/details/124198879
简介
USB,是英文Universal Serial Bus(通用串行总线)的缩写,是一个外部总线标准,早期用于规范电脑与外部设备的连接和通讯。
USB连接自从首次推出到现在已经有23年,这种技术在全球电子行业中的扩展速度前所未有。USB现在已经拥有超过30亿端口的年出货量,是迄今为止最常用的接口技术,笔记本电脑、平板电脑、智能手机和其他各种设备都依赖于这种技术来进行功率和数据传输。今天USB已经远远超出其最初提供的功能,所支持的数据速率和功率水平都提高了几个数量级。而且,由于这种不断发展的推动,USB技术已经比任何其他连接解决方案都更加普及。
在Linux上,我们可以使用lsusb来列出USB设备和它的属性。
安装
如果无法运行 lsusb,使用以下命令安装:
Debian
apt install usbutils
CentOS
yum -y install usbutils
语法
lsusb [选项]
选项
-v, --verbose:显示USB设备的详细信息。
-vv:显示USB设备的完整信息。
-s:仅显示指定的总线和(或)设备号的设备。
-d:仅显示指定厂商和产品编号的设备。
-D:设备路径。不扫描/proc/bus/usb,而以指定的设备路径取代。
-t, --tree:以树状结构显示物理USB设备的层次。
-V, --version:显示命令的版本信息。
-h, --help:显示命令用法和帮助信息。
$lsusb
Usage: lsusb [options]...
List USB devices-v, --verboseIncrease verbosity (show descriptors)-s [[bus]:][devnum]Show only devices with specified device and/orbus numbers (in decimal)-d vendor:[product]Show only devices with the specified vendor andproduct ID numbers (in hexadecimal)-D deviceSelects which device lsusb will examine-t, --treeDump the physical USB device hierarchy as a tree-V, --versionShow version of program-h, --helpShow usage and help
常用实例1:lsusb
lsusb命令及其返回实例如下所示:
Bus 002 Device 003: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 002 Device 002: ID 05e3:0620 Genesys Logic, Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046b:ff10 American Megatrends, Inc. Virtual Keyboard and Mouse
Bus 001 Device 003: ID 046b:ff01 American Megatrends, Inc.
Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
含义
- Bus 002 : 指明设备连接到哪条总线。
- Device 003 : 表明这是连接到总线上的第二台设备。
- ID : 设备的ID,包括厂商的ID和产品的ID,格式 厂商ID:产品ID。
- Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter:生产商名字和设备名
常用实例2:lsusb -v
lsusb -v命令及其返回实例如下所示(由于设备较多,通过-d参数指定具体厂商的设备):
命令:
lsusb -v -d 05e3:0620
返回:
Bus 002 Device 002: ID 05e3:0620 Genesys Logic, Inc.
Device Descriptor:bLength 18bDescriptorType 1bcdUSB 3.20bDeviceClass 9 HubbDeviceSubClass 0bDeviceProtocol 3bMaxPacketSize0 9idVendor 0x05e3 Genesys Logic, Inc.idProduct 0x0620bcdDevice 93.07iManufacturer 1 GenesysLogiciProduct 2 USB3.2 HubiSerial 0bNumConfigurations 1Configuration Descriptor:bLength 9bDescriptorType 2wTotalLength 0x001fbNumInterfaces 1bConfigurationValue 1iConfiguration 0bmAttributes 0xe0Self PoweredRemote WakeupMaxPower 0mAInterface Descriptor:bLength 9bDescriptorType 4bInterfaceNumber 0bAlternateSetting 0bNumEndpoints 1bInterfaceClass 9 HubbInterfaceSubClass 0bInterfaceProtocol 0 Full speed (or root) hubiInterface 0Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x83 EP 3 INbmAttributes 19Transfer Type InterruptSynch Type NoneUsage Type FeedbackwMaxPacketSize 0x0002 1x 2 bytesbInterval 8bMaxBurst 0
Hub Descriptor:bLength 12bDescriptorType 42nNbrPorts 4wHubCharacteristic 0x0000Ganged power switchingGanged overcurrent protectionbPwrOn2PwrGood 50 * 2 milli secondsbHubContrCurrent 576 milli AmperebHubDecLat 0.4 micro secondswHubDelay 1508 nano secondsDeviceRemovable 0x00Hub Port Status:Port 1: 0000.02a0 lowspeed L1Port 2: 0000.02a0 lowspeed L1Port 3: 0000.02a0 lowspeed L1Port 4: 0000.0223 lowspeed L1 enable connect
Binary Object Store Descriptor:bLength 5bDescriptorType 15wTotalLength 0x002abNumDeviceCaps 3USB 2.0 Extension Device Capability:bLength 7bDescriptorType 16bDevCapabilityType 2bmAttributes 0x00000006BESL Link Power Management (LPM) SupportedSuperSpeed USB Device Capability:bLength 10bDescriptorType 16bDevCapabilityType 3bmAttributes 0x00wSpeedsSupported 0x000eDevice can operate at Full Speed (12Mbps)Device can operate at High Speed (480Mbps)Device can operate at SuperSpeed (5Gbps)bFunctionalitySupport 1Lowest fully-functional device speed is Full Speed (12Mbps)bU1DevExitLat 8 micro secondsbU2DevExitLat 190 micro secondsContainer ID Device Capability:bLength 20bDescriptorType 16bDevCapabilityType 4bReserved 0ContainerID {1d4ad794-693b-1d4e-aa9c-41f9e689b316}
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x000dSelf PoweredU1 EnabledU2 Enabled
找出连接了多少USB设备
使用下面的命令:
命令:
find /dev/bus/
返回:
/dev/bus/
/dev/bus/usb
/dev/bus/usb/002
/dev/bus/usb/002/003
/dev/bus/usb/002/002
/dev/bus/usb/002/001
/dev/bus/usb/001
/dev/bus/usb/001/004
/dev/bus/usb/001/003
/dev/bus/usb/001/002
/dev/bus/usb/001/001
以树层级结构输出USB设备
使用 -t选项来用树形结构来输出USB设备信息。
命令:
$ lsusb -t
返回:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M|__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M|__ Port 4: Dev 3, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M|__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M|__ Port 8: Dev 3, If 0, Class=Hub, Driver=hub/5p, 480M|__ Port 4: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M|__ Port 4: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
附录:
USB技术标准
目前USB支持5种数据信号速率,USB设备应该在其外壳或者有时是自身上正确标明其使用的速率。USB-IF进行设备认证并为通过兼容测试并支付许可费用的设备提供基本速率(低速和全速)和高速的特殊商标许可。
- 1.5 Mbps的低速速率。主要用于低速率[人机接口设备],例如键盘、鼠标、游戏杆等等。
- 12 Mbps的全速速率。在USB 2.0之前是曾经是最高速率,后起的更高速率的高速接口应该兼容全速速率。多个全速设备间可以按照先到先得法则划分带宽;使用多个等时设备时会超过带宽上限也并不罕见。所有的USB连接端口支持全速速率。
- 480 Mbps的高速速率。并非所有的USB 2.0设备都是高速的。高速设备插入全速连接端口时应该与全速兼容。而高速连接端口具有所谓事务翻译器(Transaction Translator)功能,能够隔离全速、低速设备与高速之间数据流,但是不会影响供电和串联深度。
- 5Gbps的超高速速率。相较于现有USB 2.0的480Mbps最高理论速度,USB 3.0可支持到5.0Gbps,是USB 2.0的10倍。若将USB 3.0应用到外置硬盘、U盘或蓝光刻录机等存储设备,将可大幅缩短数据传输时间。
- 10Gbps的超高速速率+。USB 3.1 Gen2最高10Gbps理论速度,是USB 3.0的两倍。
- USB4规范已于2019年9月3日正式公布, 规格和草案阶段相同. 归纳如下:
- 物理接口只有 USB Type-C 一种.
- 传输速率 40 Gbps.
- 向下兼容 USB 3.2 / USB 2.0 和 Thunderbolt 3.