My Netgear WiFi stick (using the ath9k_htc driver) on my Raspberry Pi periodically gets into a bad state that results in USB read errors in dmesg. This state cannot be corrected by a system reset, but requires a full power cycle of the USB device, either by unplugging it and plugging the USB stick back in, or power cycling the whole computer.

I have read that it is possible to programmatically cycle power to a USB device using a USB hub. So I have tried this with my inland 4 Port USB 2.0 Hub based on the information in this posting:


But the lights on the USB WiFi stick stay glowing even after issuing the command below, although it does make the wlan0 device disappear. I tried it on a Belkin 4-Port Hub with the same results. Anybody have any ideas?

echo '1-1.2.3' | tee /sys/bus/usb/drivers/usb/unbind

Details of my usb connections:

pi@fpi-16 ~ $ sudo lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/3p, 480M
        |__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
        |__ Port 2: Dev 4, If 0, Class=hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 5, If 0, Class=vend., Driver=rt2800usb, 480M
            |__ Port 3: Dev 6, If 0, Class=vend., Driver=ath9k_htc, 480M

If your USB host driver is compiled as a kernel module you can try to unload it and reload it. This should usually also power off totally the USB (I did it on other devices with faulty USB hardware that need to be electrically reset, not specifically on the Rasperry Pi which I don't have sorry). So check if you see it as a module (lsmod) or compile it as a module and later on rmmod it (and all the dependencies eventually) and reload it again, it should do the trick.

| improve this answer | |

Here is an app that can do just what you need: https://github.com/codazoda/hub-ctrl.c

For installation and usage instructions see README.md.

It may take some trial and error to figure out which hub and port does correspond to each USB port, which seems to vary depending on the Raspberry Pi model.

Power cycling can be achieved in a single command by sending a p 0 command (power off) followed by a p 1 (power on).

| improve this answer | |

Prerequisite: Download and compile usbreset from https://gist.github.com/x2q/5124616 Compile with gcc -o usbreset usbreset.c . GCC should be already on your raspberry pi. Then chmod +x usbreset

If you have only one usb device, you can reset that device and will work. If you have many usb devices, you should reset the usb hub instead.

To find the ids of usb devices run lsusb. You should see something like: Bus 001 Device 009: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. Bus 001 Device 008: ID 1f75:0621 Innostor Technology Corporation Bus 001 Device 007: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The hub I am writing about is SMC9514 Hub.

Create a sh file:


USBNAME=0424:9514 #Put here the usb ID
LSUSB=$(lsusb | grep --ignore-case $USBNAME)
FOLD="/dev/bus/usb/"$(echo $LSUSB | cut --delimiter=' ' --fields='2')"/"$(echo $LSUSB | cut --delimiter=' ' --fields='4' | tr --delete ":")
echo $LSUSB
echo $FOLD

sudo ./usbreset $FOLD; #The path where you have the usbreset executable

And run it ar boot: bash usbreset.sh

You must bash usbreset.sh before mounting any usb device that already works. My Pi, for eaxample, has one permanent attached SSD and two HDD powered by a relay board. I must run the reset command before mounting the SSD, otherwise it will not work.

It should work for your device too.

Hope it helps.

| improve this answer | |

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.