USB Power control

We are using the Jetson Nano dev board and we need to be able to power-cycle the USB ports from user-space.

I have seen posts like this, which looks good:
[url]USB Load Switches - Jetson TX1 - NVIDIA Developer Forums

Is this possible with the Nano on the dev-kit?


Please check if your board version is A02. On A02 board, the control pin is GPIO_PA6.External Media

Thank you very much for the response.

Our device is a ‘A02’ version, however I’m not able to export the pin.

ubuntu@jetson-1:~$ sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-255, parent: platform/6000d000.gpio, tegra-gpio:
 gpio-2   (                    |pcie_wake           ) in  hi
 gpio-6   (                    |vdd-usb-hub-en      ) out hi
 gpio-151 (                    |cam_reset_gpio      ) out lo
 gpio-187 (                    |?                   ) out hi
 gpio-189 (                    |Power               ) in  hi IRQ
 gpio-190 (                    |Forcerecovery       ) in  hi IRQ
 gpio-201 (                    |cd                  ) in  lo IRQ
 gpio-202 (                    |pwm-fan-tach        ) in  hi IRQ
 gpio-203 (                    |vdd-3v3-sd          ) out hi
 gpio-225 (                    |hdmi2.0_hpd         ) in  hi IRQ
 gpio-228 (                    |extcon:extcon@1     ) in  hi IRQ

gpiochip1: GPIOs 504-511, parent: platform/max77620-gpio, max77620-gpio, can sleep:
 gpio-505 (                    |spmic-default-output) out hi
 gpio-507 (                    |vdd-3v3-sys         ) out hi
 gpio-510 (                    |enable              ) out lo
 gpio-511 (                    |avdd-io-edp-1v05    ) out lo

ubuntu@jetson-1:~$ sudo echo 6 > /sys/class/gpio/export
echo: write error: Device or resource busy

I get the same response using python gpio library. Can you tell me how to use access this pin?


Please refer to
[url]Lack of USB3.0 - Jetson TX2 - NVIDIA Developer Forums
The pin might be used as another function.

The problem is this:

sudo echo 6 > /sys/class/gpio/export

This tells the shell to run “echo 6” in the context of super-user, after redirecting standard out to /sys/class/gpio/export…
But the shell is not root, so it can’t redirect to that file.
You need to either first “sudo -i” and then run the commands without sudo (so you have a root shell,) or run the entire shell expression as root.

sudo sh -c 'echo 6 > /sys/class/gpio/export

Or you can just bang the registers directly, using C/C++ code. There’s some code here to do that:

Note that this code is written as an example of how to talk to the GPIO hardware from user space; I haven’t tested it for this particular use case. But … it ought to work, perhaps with minimal changes?
Also, because it uses /dev/mem, it needs root.

Thanks very much DaneLLL and snarky.

The echo 6 suggestion yields the same result as before, even with the extra sudo flag.

DaneLLL: your link points to pretty much exactly what we’re trying to do: power-cycle the usb hub.
However, the corresponding regulator device on the Nano doesn’t seem to respond to writing to the ‘state’ file as shown here:

root@MA10014:/home/ubuntu# cat /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# echo disabled > /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# cat /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# echo disablebad > /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# cat /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# echo enabled > /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state
root@MA10014:/home/ubuntu# cat /sys/kernel/debug/regulator/vdd-usb-hub-en/regulator/state

Is there anything else I need to do for that setting to take effect?


On Nano, please download/extract the attachment and follow the steps:

Copy realtek_hub_power_cycle.c to Jetson Nano
$ sudo apt-get install libusb-1.0-0-dev
$ gcc -o power_cycle realtek_hub_power_cycle.c -lusb-1.0
$ sudo ./power_cycle (653 Bytes)

1 Like

Thank you very much DaneLLL, that worked perfectly. Very much appreciated.

Can you point me to any documentation for the commands that libusb_control_transfer is using?



It is suggested by vendor and there is no public document. FYI.

As I am having an unstable WLAN Access I supected that this solution could help.
Using this command (June 2020; more recent software):
sudo apt-get install libusb-1.0-0-dev
Its said, already installed.
When using:
gcc -o power_cycle realtek_hub_power_cycle.c -lusb-1.0
there is an error message:
gcc: error: realtek_hub_power_cycle.c: No such file or directory.
Nevertheless, the message: WARNING: system is no being throttled is still coming.
Was there a change?

power_cycle realtek_hub_power_cycle.c is in the attachment

Hi, just want to confirm, if this script works for Jetson Nano to power cycle individual USB port? or is there anyway to control individual port? Thanks!


It is to reset vendor’s hub. If you would need further detail, please contact vendor. Thanks.