# Resetting an usb device

## mv

I have a machine with an usb dvb-stick permanently attached. After a few days (not very reproducible) this stick fails to work, that is, it produces no output anymore (it still shows up with "lsusb" and reacts to commands, but does not output DV data).

With physical access to the machine, the fix is easy: Pull the stick for a few seconds, put it back, and everything works again.

But what to do without physical access? Rebooting the machine does not help (apparently, this does not cut power of USB devices, or at least not long enough).

Is there perhaps a command I could attempt to send a "reset" to that USB stick? I read that some machines have an /usr/sbin/usbreset binary, but I don't have such a binary, and it is not listed in www.portagefilelist.de either.Last edited by mv on Tue Sep 22, 2015 6:48 am; edited 2 times in total

----------

## Buffoon

Maybe this helps.

----------

## mv

Thanks. That's really a lot of hints. I will report back after a while when the problem reoccurs.

----------

## mv

The binary obtained from usbreset.c (from the above link) works like a charm.   :Very Happy: 

----------

## mv

Now when it happened again, the usbreset binary did not help. Also the other hints from the above link did not help (after trying the "remove" hint, I had to restart the machine, but it didn't help, either).

However, manually unplugging the device for 1 second was enough...  I am beginning to suspect that this cannot be solved by software.   :Sad: 

(There was an upgrade from hardened-sources-4.1.6 to hardened-sources-4.1.7-r1 meanwhile, but I would be very surprised if this upgrade had just broken the usbreset functionality...)

----------

## Akkara

Try unloading its driver module, then reloading it.  (Obviously it needs to be compiled as 'module' in the kernel config for this to have any hope of working.)  You probably will need to quit whatever application(s) are using it before the kernel will let you unload the module.  If that doesn't work, try mixing it in with the reset thing above.

Hmmm...  on 2nd thought, if even a reboot didn't do it, it sounds like there's probably a bug in the USB device's firmware.

----------

## mv

 *Akkara wrote:*   

> if even a reboot didn't do it, it sounds like there's probably a bug in the USB device's firmware.

 

Yes, a reboot doesn't help at all. However, maybe there is still the possibility to send some "reset" signal which might restart that firmware and which is usually not sent on reboot...

The stick had worked for several months without such problems, so I would exclude a firmware problem. It is probably some hardware problem, but it does not put the stick into a completely crashed state: The stick still shows up correctly with e.g. lsusb and can be connected to with tzap - it reports back after a while that it found a signal, but just doesn't output anything (when it is in this "bad" state).

Also the above usbreset program reports that the reset signal was succesfully sent...

----------

## mirekm

You can put the reset program in the cron, and reset your USB device when it still works (for example every day at midnight), instead of waiting until it get hardlocked.

----------

## Fitzcarraldo

I wonder if unbinding the driver from the USB dvb stick then rebinding the driver to the stick would make the stick work again (see Manual driver binding and unbinding)?

For example, when I wanted to unbind  the usb_storage kernel module from a USB storage device, I found out which bus ID the USB device was plugged into (1-1.2.2:1.2 in my case) and then used the following command:

```
echo -n "1-1.2.2:1.2" > /sys/bus/usb/drivers/usb-storage/unbind
```

To rebind the driver to the USB device I then used the following command:

```
echo -n "1-1.2.2:1.2" > /sys/bus/usb/drivers/usb-storage/bind
```

In your case the driver will not be usb_storage but the principle would still apply. Worth a shot, anyway, just to see if it has an effect after the stick stops working.

----------

## mv

 *Fitzcarraldo wrote:*   

> I wonder if unbinding the driver from the USB dvb stick then rebinding the driver to the stick would make the stick work again

 

This is one of the hints in the above mentioned post which I already tried.

----------

## mv

 *mirekm wrote:*   

> You can put the reset program in the cron, and reset your USB device when it still works

 

It is hard to decide about a timing, and it is unclear how it might help: Last time, the lock appeared already 1-2 hours after the last succesful test.

In the moment, it works since days...

----------

