6

We've bought a commercial application who just work only if their dongle usb is connected to the server. However sometimes the application can not recognize the dongle, so it doesn't work, but if someone eject the dongle physically from USB port and attach it again it will recognize and work fine.

There are 43 modules loaded on the server and attach/eject the dongle does not increase/decrease number of modules.

Also I have usbmon0, usbmon1 and usbmon2 files in /dev before/after eject/attach the dongle and number of files in /dev will not change before/after eject/attach the dongle.

journalctl -f command after ejecting the dongle:

Jan 19 18:10:28 iwr kernel: usb 2-2.1: USB disconnect, device number 5

journalctl -f command after attaching the dongle:

Jan 19 18:11:11 iwr kernel: usb 2-2.1: new full-speed USB device number 6 using uhci_hcd
Jan 19 18:11:11 iwr kernel: usb 2-2.1: New USB device found, idVendor=0403, idProduct=c580
Jan 19 18:11:11 iwr kernel: usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jan 19 18:11:11 iwr kernel: usb 2-2.1: Product: HID UNIKEY
Jan 19 18:11:11 iwr kernel: usb 2-2.1: Manufacturer: OEM
Jan 19 18:11:11 iwr kernel: usbhid 2-2.1:1.0: couldn't find an input interrupt endpoint

Can I eject and then attach it logically? (issue a command, remove a module, etc.)

  • 1
    Please check if any of those solutions work. – TNW Jan 19 '16 at 15:35
  • 1
    Thanks TNW for replying, I tried them but none of them worked for me. echo 2-2.1 > /sys/bus/usb/devices/2-2.1/driver/unbind worked for eject and echo 2-2.1 > /sys/bus/usb/drivers/usb/bind – Ali Yousefi Sabzevar Jan 19 '16 at 18:43
7

Many answers found on the Internet (including those in TNW's comment) rely on /sys/bus/usb/devices/2-2/power/level or /sys/bus/usb/devices/2-2/power/control which are both deprecated since 2.6.something kernel. For newer kernels, the suggested procedure is to unbind and rebind its driver, which usually results in a power cycle:

# Find out which driver to unbind
tree /sys/bus/usb/devices/2-2.1 | grep driver
|-- driver -> ../../../../../../bus/usb/drivers/whatever

# Unbind the driver
echo 2-2.1 > /sys/bus/usb/drivers/whatever/unbind

# Rebind the driver
echo 2-2.1 > /sys/bus/usb/drivers/whatever/bind
| improve this answer | |
  • 1
    Thanks dear Dmitry. As Dmitry said, /sys/bus/usb/devices/2-2/power/level and /sys/bus/usb/devices/2-2/power/control does not work (level and control files do not exist) because the kernel version is 3.10.0 . but echo 2-2.1 > /sys/bus/usb/devices/2-2.1/driver/unbind worked for eject and echo 2-2.1 > /sys/bus/usb/drivers/usb/bind worked for attach. – Ali Yousefi Sabzevar Jan 19 '16 at 18:38
  • I'm glad that helped, and thanks for reporting back! – Dmitry Grigoryev Jan 19 '16 at 20:31
  • 1
    How do you identify the device number when you have many devices? – djsmiley2kStaysInside Aug 23 '18 at 16:57
  • @djsmiley2k usually by looking at vendor ID and device ID of each USB device – Dmitry Grigoryev Aug 23 '18 at 19:21
  • 1
    I found it in dmesg, at the start of the logged message ;D - I'm so blind! :) – djsmiley2kStaysInside Aug 23 '18 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.