Linux下的lsusb命令详解

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, --verbose
      Increase verbosity (show descriptors)
  -s [[bus]:][devnum]
      Show only devices with specified device and/or
      bus numbers (in decimal)
  -d vendor:[product]
      Show only devices with the specified vendor and
      product ID numbers (in hexadecimal)
  -D device
      Selects which device lsusb will examine
  -t, --tree
      Dump the physical USB device hierarchy as a tree
  -V, --version
      Show version of program
  -h, --help
      Show 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                18
  bDescriptorType         1
  bcdUSB               3.20
  bDeviceClass            9 Hub
  bDeviceSubClass         0
  bDeviceProtocol         3
  bMaxPacketSize0         9
  idVendor           0x05e3 Genesys Logic, Inc.
  idProduct          0x0620
  bcdDevice           93.07
  iManufacturer           1 GenesysLogic
  iProduct                2 USB3.2 Hub
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x001f
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes           19
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0002  1x 2 bytes
        bInterval               8
        bMaxBurst               0
Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             4
  wHubCharacteristic 0x0000
    Ganged power switching
    Ganged overcurrent protection
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent    576 milli Ampere
  bHubDecLat          0.4 micro seconds
  wHubDelay          1508 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 lowspeed L1
   Port 2: 0000.02a0 lowspeed L1
   Port 3: 0000.02a0 lowspeed L1
   Port 4: 0000.0223 lowspeed L1 enable connect
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength       0x002a
  bNumDeviceCaps          3
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000006
      BESL Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000e
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   1
      Lowest fully-functional device speed is Full Speed (12Mbps)
    bU1DevExitLat           8 micro seconds
    bU2DevExitLat         190 micro seconds
  Container ID Device Capability:
    bLength                20
    bDescriptorType        16
    bDevCapabilityType      4
    bReserved               0
    ContainerID             {1d4ad794-693b-1d4e-aa9c-41f9e689b316}
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x000d
  Self Powered
  U1 Enabled
  U2 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.

在这里插入图片描述

机械和电子标准

在这里插入图片描述

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

iNBC

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值