Hard Reset USB in Ubuntu 10.04

7

1

I have a USB device (a modem) that is really finicky. Sometimes it works fine, but other times it refuses to connect. The only solution I have found to fix it once it gets into a bad state is to physically unplug the device and plug it back in. However, I don't always have physical access to the machine it is plugged in on, so I'm looking for a way to do this through the command line.

This post suggests running:

$ sudo modprobe -w -r usb_storage; sudo modprobe usb_storage

However I get an "unknown option -w" output. This slightly modified command:

$ sudo modprobe -r usb_storage

Fails with the message FATAL: Module usb_storage is in use. If I try to kill -9 the processes marked [usb-storage] before running they refuse to die (I think because they are deeply tied to the kernel).

Anyone know of a way to do this?

NOTE: I cross-posted this on serverfault as I didn't know which was more appropriate. I will delete and/or link whichever one is answered first.

Cory

Posted 2010-08-16T09:39:27.657

Reputation: 483

i guess, if you don't have physical access to a machine i'll classify it as a server of some sort. there is little point keeping failing hardware on a server. – bubu – 2010-12-23T09:35:30.110

bubu, it depends on what you mean by "failing". It sounds to me like the device is working fine, but has poor Linux support. – nitro2k01 – 2013-11-25T13:08:56.507

@nitro2k01 This question is 3 years old... Anyways the device is failing as it can connect sometimes but not always... The asker is trying to reset the wrong device so it can't work and has nothing to do with linux support... – laurent – 2013-11-25T13:55:46.777

Answers

5

I have Ubuntu 14.04.4. I have no idea if this works in 10.04. I tested it on Cyborg Rumble Pad (and a generic USB flash drive).

Just after I connect the device:

dmesg | grep usb | tail -n 20

I get (maybe among other things):

[ 2875.790610] usb 2-1.2: new full-speed USB device number 7 using ehci-pci
[ 2875.887485] usb 2-1.2: New USB device found, idVendor=0738, idProduct=cb02
[ 2875.887489] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2875.887490] usb 2-1.2: Product: Cyborg Rumble Pad - PC/Xbox 360
[ 2875.887492] usb 2-1.2: Manufacturer: Saitek
[ 2875.887493] usb 2-1.2: SerialNumber: 0CFE6B97

The crucial part is 2-1.2 string. It identifies the USB port. Good news is it should not change unless I plug the device into another port, so I need to obtain the string just once.

Next I go to the right place:

cd /sys/bus/usb/drivers/usb

and invoke as root (e.g. sudo bash first):

echo 2-1.2 > unbind ; sleep 3 ; echo 2-1.2 > bind

The result is my Rumble Pad reinitializes itself as if it was plugged out and in again. I tested my USB flash drive as well. It (its LED) behaves as if nothing happened, still my KDE reacts and asks if I want to mount.

All the time the device is powered. This method will not work if your modem resets itself because of the lack of power.

Kamil Maciorowski

Posted 2010-08-16T09:39:27.657

Reputation: 38 429

1

You can try to reset the usb device by using usbreset. Here's a link to the source -- http://marc.info/?l=linux-usb&m=121459435621262&w=2

You just look for a device you want to reset (lsusb):

# lsusb
Bus 005 Device 004: ID 0951:1642 Kingston Technology DT101 G2

and then:

# usbreset /dev/bus/usb/005/004

Mikhail Morfikov

Posted 2010-08-16T09:39:27.657

Reputation: 781

0

Why are you trying to unload the usb_storage module, when your device is a usb modem?

run sudo lshw and find the entry for your usb modem. There should be a configuration: line like this (your driver will be different, obviously):

configuration: ... driver=iwlagn ...

confirm that the module is loaded (substituting in the correct driver name):

lsmod | grep iwlagn

then just do:

sudo modprobe -r iwlagn && sleep 2 && sudo modprobe iwlagn

I like to put the sleep in there just in case the device takes some time to power down.

sml

Posted 2010-08-16T09:39:27.657

Reputation: 1 582

lshw seems to indicate that the driver is using usb_storage (the modem also mounts itself as a disk). I can't find a separate entry for the modem part of it. How could I kill the process so that I can reload the driver? – Cory – 2010-08-16T12:27:42.980

0

easiest way to power off arbitrary USB devices from the command line (i.e. with real power cycle to USB):

  1. buy a 4-port DELOCK 87445 USB hub (google for < DELOCK 87445 >)
  2. this piece of hardware is compatible with hub-ctrl.c (google for < hub-ctrl.c>). So arbitrary ports can be switched on/off. For further reference also see: http://code.google.com/p/wl500g/source/browse/branches/rt-n/utils/hub-ctrl.c?r=2235

sparkie

Posted 2010-08-16T09:39:27.657

Reputation: 2 110

-1

This is a "way out there" solution, but it might work.

  • Get a second, old, not-very-powerful PC. Install Debian on it. Install usbip on it.
  • Then, install usbip on your server.
  • Connect the modem to the second PC. Configure usbip on both machines so that the modem, plugged into the second PC, is reachable via VHCI from the server.
  • Configure ssh on the second PC or other means that you can remote into it and issue commands.
  • When the device fails, log in and reboot the second PC via the reboot command, then once it comes back up, reconnect using whatever facilities usbip provides (I've never actually used usbip). That should reset the device. You probably could script this.

LawrenceC

Posted 2010-08-16T09:39:27.657

Reputation: 63 487