11

I need to:

  • turn off -> sleep some seconds -> turn on the USB power of beaglebone black

to be able to hardware-reset a device that is connected to USB (Huawei E220 Modem)

Already tried soft-reset (with unbind/bind and with authorize 0/1), but software reset is not enough to make the device to work well again; the device has some weird bug, that is triggered by a long-time usage (after a few days connected).

Many answers were found using /sys/debug/omap_mux, but this device does not exist anymore in new kernels.

Since this question took a pair of days to get a workable answer, I decided to post it here, with the answer, so it may be useful for others.

pzn
  • 502
  • 3
  • 11

1 Answers1

14

Thanks to my friend Cleiton Bueno http://cleitonbueno.wordpress.com/ that found this solution for me:

prerequisites:

  • apt-get install devmem2

Code that solved the problem:

devmem2 0x47401c60 b 0x00
sleep 1
echo "usb1" > /sys/bus/usb/drivers/usb/unbind
sleep 20
echo "usb1" > /sys/bus/usb/drivers/usb/bind
sleep 1
devmem2 0x47401c60 b 0x01

The "devmem2" command is responsible to direct access GPIO3_13 of the beaglebone, that controls the IC that powers on/off the USB port.

The "unbind/bind" commands are responsible to tell the usb driver to "rescan" the port after the power.

pzn
  • 502
  • 3
  • 11
  • 3
    This is incredibly useful, thanks for figuring this out. The order of operations seems critical, and the sequence is not 100% reliable. I've had better luck with the sequence being 'unbind', 'bind', power-off, power-on. In my case it is specifically to reset a usb hub and all down-stream devices. Reliability may be related to the hub itself, not your sequence here. – giles Jul 17 '15 at 14:59
  • 3
    where that address (0x47401c60) comes from? I wanna understand. – Davide Berra Sep 08 '15 at 14:56
  • 1
    @DavideBerra Not a complete answer to your question, but I did dig up a bit of info on the magic value 0x47401c60. See what I wrote in the answer on this question: http://stackoverflow.com/questions/37086057/turn-off-power-to-a-usb-port – Stéphane May 17 '16 at 19:51
  • 3
    This is exactly what I needed! However, `devmem2` isn't in apt, so the install command fails. I found this blog post for getting a compiled binary: https://scivision.co/devmem2-on-the-beaglebone-black/ – BoomShadow Jul 13 '16 at 15:10