USB devices troubleshooting under Linux

Karina
2 min readApr 30, 2020

--

Yesterday I was playing around with plugging in/out usb2ethernet adapter to VM under libvirt and suddenly it stopped getting interface. Later I found out that this was my mistake in udev rules (I blocked it via authorized property and forgot to unblock), but any way meanwhile troubleshooting I discovered several useful utilities.

Rule #1 See in dmesg

dmesg is a utility printing out kernel message buffers. It will show among other things drivers loading info. Sth like:

user@host:~# dmesg[68634.569288] ax88179_178a 1-1:1.0 eth0: register 'ax88179_178a' at usb-0000:00:01.2-1, D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter, 18:0f:76:00:f9:22
[68635.240698] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[68641.135756] ax88179_178a 1-1:1.0 eth0: ax88179 - Link status is: 1
[68641.263684] ax88179_178a 1-1:1.0 eth0: ax88179 - Link status is: 1
[68641.310328] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

ax88179_178a is a driver. You can list all modules loaded and see whether it’s used or not. And try to reload it with rmmod and insmod if there are any problems

user@host:~# lsmod | grep  ax88179_178a
ax88179_178a 24576 0
usbnet 28672 1 ax88179_178a

Rule #2 Try to rebind

These commands are also useful if you want to emulate USB insertion/removal remotely. But first of all you need to get bus and device id. Here is lsusb command is very useful:

user@host:~# lsusb
Bus 002 Device 005: ID 2001:4a00 D-Link Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

or you can use usb-devices command if you want extended information altogether with driver name:

user@host:~# usb-devicesT:  Bus=02 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  5 Spd=5000 MxCh= 0
D: Ver= 3.00 Cls=ff(vend.) Sub=ff Prot=00 MxPS= 9 #Cfgs= 1
P: Vendor=2001 ProdID=4a00 Rev=01.00
S: Manufacturer=D-Link Elec. Corp.
S: Product=D-Link DUB-1312
S: SerialNumber=00000000001291
C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=496mA
I: If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=00 Driver=ax88179_178a

In our case bus number is 2 and device number is 5, so information about our device is available under /sys/bus/usb/devices/2–5/

user@host# cat /sys/bus/usb/devices/2-5/product
D-Link DUB-1312

For rebind use the following from the root bash:

sudo sh -c 'echo 2-5 > /sys/bus/usb/drivers/usb/unbind'
sudo sh -c 'echo 2-5 > /sys/bus/usb/drivers/usb/bind'

and checkout dmesg:

[9695259.381150] ax88179_178a 2-5:1.0 enx180f7600f922: unregister 'ax88179_178a' usb-0000:00:14.0-5, D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter
[9695272.564409] ax88179_178a 2-5:1.0 eth0: register 'ax88179_178a' at usb-0000:00:14.0-5, D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter, 18:0f:76:00:f9:22

Hope this small troubleshooting will help to solve errors or to get info about USB driver for example :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Karina
Karina

Written by Karina

I’m not a programmer, I’m just pretending https://github.com/keyrnk

No responses yet

Write a response