19

I am using Kensington Expert Mouse, a trackball, which usually works. However, sometimes, after system goes to sleep, it stops reacting to the movement of the ball.

Under Windows, i can go to the device manager and disable-enable the device, which results in it working again, but how can i do the same under Linux? Unplugging the device works but is is annoying.

My OS is Linux Mint 18.

Srv19
  • 461

3 Answers3

16

To find out the exact device run:

$ lsusb

To disable and enable the device(f.e. USB on port 2 and device ID 1):

1)Turn off device ID 2-1:

$ echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind

2)Turn device ID 2-1 back on:

 $ echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/bind

Alternatively, if you just want to reset a USB device, the bind/unbind can be tricky as the IDs can change overtime and you might accidently select another device. In this case you could use the vendor and product IDs given by lsusb with usb_modeswitch.

F.e.: to identify a wireless adapter:

$ lsusb
Bus 001 Device 042: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Bus 001 Device 035: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can reset the Wireless adapter from Edimax Technology by:

$ sudo usb_modeswitch -v 0x7392 -p 0x7811 --reset-usb
ul3m8
  • 176
7

Depending on your host, just run 'lsusb' is not enoguh. The unbind/bind thing needs Bus and Port number, but lsub retruns device number. This may not match.

For example on one of my system are two usb disk. Bus 2, Dev 2 and 3.

root@hp-leipzig:/sys/bus/usb/drivers/usb# lsusb
Bus 002 Device 003: ID 1058:2621 Western Digital Technologies, Inc. 
Elements 2621
Bus 002 Device 002: ID 1058:25ed Western Digital Technologies, Inc. My 
Book 25ED
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

If you ls inside sys/bus/usb/drivers/usb you see, there are no 2-2 or 2-3 but 2-7 and 2-8

root@hp-leipzig:/sys/bus/usb/drivers/usb# ls 
2-7  2-8  bind  uevent  unbind  usb1  usb

One way could be, to memorize the bus/dev part (lets say 2/2 for the My Book) and run lsusb -tand look there for bus, dev 2:

root@hp-leipzig:/sys/bus/usb/drivers/usb# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
    |__ Port 7: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    |__ Port 8: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M

There may be other ways, for example for a usb storage device (/dev/sdb):

udevadm info --name /dev/sdb -q path there the result is somethinh like /devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.0/host2/target2:0:0/2:0:0:0/block/sdb --> its 2-7

1

usbreset is shipped in usbutils since 2016 (it calls the USBDEVFS_RESET ioctl on the device).

usbreset VENDORID/DEVICEID
usbreset BUSNUM/DEVICENUM
usbreset "device name"

see manpage man usbreset (though the example for BUSNUM/DEVICENUM has a typo but fix pending upstream and on Debian)