Detailed explanation of lsusb command under Linux

Posted by james19 on Mon, 24 Jan 2022 16:22:30 +0100

Detailed explanation of lsusb command under Linux

Reference link: https://zhuanlan.zhihu.com/p/142403866

USB, the abbreviation of Universal Serial Bus in English, is an external bus standard. In the early days, it was used to standardize the connection and communication between computers and external devices.

It has been 23 years since USB connection was first introduced. The expansion speed of this technology in the global electronics industry is unprecedented. USB now has an annual shipment of more than 3 billion ports and is by far the most commonly used interface technology. Laptops, tablets, smartphones and other devices rely on this technology for power and data transmission. Today, USB has far exceeded its original functions, and the data rate and power level supported have been increased by several orders of magnitude. Moreover, driven by this continuous development, USB technology has become more popular than any other connection solution.

On Linux, we can use lsusb to list USB devices and their properties.

1, Lsusb: what is lsusb

In its manual, lsusb is defined as:

A tool that displays USB bus information in and connected to the system.

How to run lsusb?

To run lsusb, you can enter lsusb directly in the command terminal.

$ lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 17ef:4811 Lenovo Integrated Webcam [R5U877]
Bus 008 Device 002: ID 0a5c:217f Broadcom Corp. Bluetooth Controller

lsusb will display the device information and driver information connected to the USB bus.

The following describes how to understand the output. I grabbed the last line output above:

Bus 008 Device 002 : ID 0a5c:217f Broadcom Corp. Bluetooth Controller
  • Bus 008: indicates which bus the device is connected to
  • Device 002: indicates that this is the second device connected to the bus
  • ID: the ID of the device
  • Broadcom Corp. Bluetooth Controller: manufacturer name and device name

After inserting the USB device, you can use the dmesg command to see the debugging information output by the Linux kernel when the USB device is loaded.

The following is an example. We can see that the device uses USB2 at the same time 0 root hub driver and USB 1.1 root hub driver.  dmesg | grep -i usb

$ dmesg |grep -i usb

[ 0.353138] usbcore: registered new interface driver usbfs
[ 0.353150] usbcore: registered new interface driver hub
[ 0.353182] usbcore: registered new device driver usb
[ 0.730026] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.730116] ehci_hcd 0000:00:1a.7: new USB bus registered, assigned bus number 1
[ 0.748019] ehci_hcd 0000:00:1a.7: USB 2.0 started, EHCI 1.00
[ 0.748169] hub 1-0:1.0: USB hub found
[ 0.748336] ehci_hcd 0000:00:1d.7: new USB bus registered, assigned bus number 2
[ 0.768019] ehci_hcd 0000:00:1d.7: USB 2.0 started, EHCI 1.00
[ 0.768147] hub 2-0:1.0: USB hub found
[ 0.768236] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.768251] uhci_hcd: USB Universal Host Controller Interface driver

2, lsusb -v: how to list USB details

Use the - v option to turn on the details of the USB device. Here is an example.

$ lsusb -v

Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 5
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0×83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0×0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0×03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0×0040 1x 64 bytes
bInterval 1

3, find /dev/bus: find out how many USB devices are connected

Use the following command:

$ find /dev/bus

Then you will see an output like the following:

/dev/bus
/dev/bus/usb
/dev/bus/usb/008
/dev/bus/usb/008/002
/dev/bus/usb/008/001
/dev/bus/usb/007
/dev/bus/usb/007/001
/dev/bus/usb/006
/dev/bus/usb/006/001
/dev/bus/usb/005
/dev/bus/usb/005/001
/dev/bus/usb/004
/dev/bus/usb/004/001
/dev/bus/usb/003
/dev/bus/usb/003/001
/dev/bus/usb/002
/dev/bus/usb/002/004
/dev/bus/usb/002/003
/dev/bus/usb/002/001
/dev/bus/usb/001
/dev/bus/usb/001/001

4, lsusb -D /dev/bus/usb/008/002: details of specific devices can be printed

The following is an example of a Broadcom Bluetooth device.

$ lsusb -D /dev/bus/usb/008/002

Device: ID 0a5c:217f Broadcom Corp. Bluetooth Controller
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 224 Wireless
bDeviceSubClass 1 Radio Frequency
bDeviceProtocol 1 Bluetooth
bMaxPacketSize0 64
idVendor 0x0a5c Broadcom Corp.
idProduct 0x217f Bluetooth Controller
bcdDevice 3.60
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 216
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0×81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0×0010 1x 16 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0×82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0×0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0×02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0×0040 1x 64 bytes
bInterval 1

5, lsusb -v -s: use the - s option to filter devices

sudo lsusb -v -s [BUS_NUMBER]:[DEVICE_NUMBER]

For example:

sudo lsusb -v -s 002:006

6, lsusb -t: output USB devices in tree hierarchy

Use the - t option to output USB device information in a tree structure

$ lsusb -t

/: Bus 08.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 07.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 06.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 05.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 04.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 03.Port 1: Dev 1, Class=root\_hub, Driver=uhci_hcd/2p, 12M
/: Bus 02.Port 1: Dev 1, Class=root\_hub, Driver=ehci_hcd/6p, 480M
|__ Port 1: Dev 4, If 0, Class=stor., Driver=usb-storage, 480M
|__ Port 6: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
|__ Port 6: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
/: Bus 01.Port 1: Dev 1, Class=root\_hub, Driver=ehci_hcd/6p, 480M

The numbers 12M and 480M} refer to the transfer rate of USB type.

  • 12M means that the rate of USB 1.0 / 1.1 is 12Mbit/s
  • 480M means that the speed of USB 2.0 is 480Mbit/s

If you find 5.0G, it means you have a USB 3.0 type interface. It has a transmission rate of 5.0Gbit/s.

Linux from / var / lib / usutils / USB IDS identifies the details of the USB device. Or you can visit Linux-USB.org Get the latest list of USB ID s.

Summary:

You can use the lsusb command to diagnose the USB device on your system. For more comprehensive command information, enter man lsusb to view its manual.

Appendix:

USB technology standard

At present, USB supports five data signal rates. USB devices should correctly indicate their use rate on their shell or sometimes themselves. USB-IF Carry out equipment certification and provide special trademark licenses for basic speed (low speed and full speed) and high speed for equipment passing compatibility test and paying license fee.

  • Low speed of 1.5 Mbps. It is mainly used for low speed [man-machine interface equipment], such as keyboard, mouse, joystick, etc.
  • 12 Mbps full speed. Before USB 2.0, it was once the highest speed, and the later high-speed interface with higher speed should be compatible with full speed. Bandwidth can be divided among multiple full speed devices according to the first come, first served rule; It is not uncommon to exceed the bandwidth limit when using multiple isochronous devices. All USB ports support full speed.
  • 480 Mbps high speed. Not all USB 2.0 devices are high-speed. High speed devices should be compatible with full speed when plugged into the full speed connection port. The high-speed connection port has the so-called Transaction Translator function, which can isolate the data flow between full-speed, low-speed equipment and high-speed, but will not affect the power supply and series depth.
  • Ultra high speed rate of 5Gbps. Compared with the 480Mbps maximum theoretical speed of existing USB 2.0, USB 3.0 can support up to 5.0Gbps, which is 10 times that of USB 2.0. If USB 3.0 is applied to storage devices such as external hard disk, USB flash disk or Blu ray recorder, the data transmission time can be greatly shortened.
  • 10Gbps ultra high speed rate +. USB 3.1 Gen2 has a maximum theoretical speed of 10Gbps, which is twice that of USB 3.0.
  • USB4 specification has been officially published on September 3, 2019, and the specification is the same as the draft stage It can be summarized as follows:
  • There is only USB Type-C physical interface
  • Transmission rate 40 Gbps
  • Downward compatibility with USB 3.2 / USB 2.0 and Thunderbolt 3

Mechanical and electronic standards