Wednesday, December 26, 2012

Restarting USB ehci_hcd

Lately I have been having issues with my Logitech Unifying wireless USB dongle for my mouse and keyboard.  I know this is not the Logitech device itself since it has worked reliably for over a year now.  This hasn't been an issue before so I suspect a recent update caused it to become unreliable.  I haven't tested other USB devices yet.  This is what I get when attempting to connect my Unifying USB dongle from dmesg:


    usb 2-1.3: new full-speed USB device number 39 using ehci_hcd
    usb 2-1.3: device not accepting address 39, error -32
    hub 2-1:1.0: unable to enumerate USB device on port 3

I found that simply reseting ehci_hcd resolves the issue so I wrote the following script:


    #!/bin/bash
    
    USB1="0000:00:1a.0"
    USB2="0000:00:1d.0"
    
    function reset_usb() {
        echo -n "$1" > /sys/bus/pci/drivers/ehci_hcd/unbind
        echo -n "$1" > /sys/bus/pci/drivers/ehci_hcd/bind
    }
    
    reset_usb $USB1
    reset_usb $USB2

You will need to fill in the "0000:00:xx:x" to fit your need.  You can find them by

    ls /sys/bus/pci/drivers/ehci_hcd


You will find a directory usb* in the "0000:00:xx:x" folder:

    ls -d /sys/bus/pci/drivers/ehci_hcd/0000\:00\:xx.x/usb*

No comments:

Post a Comment