Turn USB power off/on with BeagleBone Black kernel >= 3.8
Asked Answered
G

1

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.

Gosselin answered 4/6, 2014 at 13:56 Comment(0)
G
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.

Gosselin answered 4/6, 2014 at 13:56 Comment(4)
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.Berneta
where that address (0x47401c60) comes from? I wanna understand.Stonework
@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: #37086557Gablet
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: scivision.co/devmem2-on-the-beaglebone-blackCopestone

© 2022 - 2024 — McMap. All rights reserved.