I’m looking for a way to power down the USB-Ports through software.
I’ve already looked at some posts (see list at the bottom) which describe the use of a GPIO port to cut USB_VDD_0. However non-refer to the Jetson Nano. Looking at the NVIDIA Jetson Nano Pin and Function Names Guide which refers to Pin 87 as USB_VBUS_EN0. However running sudo cat /sys/kernel/debug/gpio does not tell anything about the function of GPIO 87.
Can someone confirm the function of GPIO 87 and if the following code will also work on a Jetson Nano Development Kit?
sudo su
cd /sys/class/gpio
echo 87 > export
cd gpio87
echo out > direction && echo 0 > value # Will turn off the port
echo out > direction && echo 1 > value # Will turn on the port
Thanks a bunch!
Some information on my setup
Jetson Nano Development Kit 4GB
JetPack 4.3 (R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t210ref, EABI: aarch64, DATE: Tue Dec 10 06:58:34 UTC 2019)
I am personally use this tool to power down and then turn on USB ports:
It has very short source code, the most important part is in function power_cycle(). It has the code split in two parts, one marked as “vendor command enable” (I think it powers down ports) and “vendor command disable” (I think it turns them back on). You can try to split it into two functions to turn USB ports on and off.
Thank you @Lissanro. Thank you for that link. I can power cycle USB with the script as expected. But no matter how I split the commands, the devices keep powering up again.
Pulling in @DaneLLL into the conversation, maybe he can help finding the right commands to keep USB turned off.
Hi @vsaw
Thanks for sharing the tips. Could you share which Jetson Nano module you use? realtek_hub_power_cycle.zip is valid for Nano SD card A02. You probably use Nano SD card B01 or Nano emmc.
realtek_hub_power_cycle.zip works for B01 too but I confirm that it only able to recycle the power, not to turn it off permanently. It seems that libusb_control_transfer(hub_devh, 0x40, 0x02, 0x01, ((0x0B<<8)|(0xDA)), 0, 0, 100000); in power_cycle() is enough to temporarily turn it off, and then it automatically turns on again. Not sure what other three libusb_control_transfer() after /*ep0 vendor command disable*/ are supposed to be doing (I originally thought they are turning it back on, but the USB hub does this automatically without them too).
I think uhubctl is a great solution. Even if I just want to recycle the power, it looks more readable in the script and it is well documented tool which can work on many different platforms, so a script using uhubctl is more portable.
It also supposed to be capable of turning off and on each USB port separately, but sudo uhubctl -aoff -p1 turns off all 4 ports in Jetson Nano. Turning off power on ports 2, 3 and 4 works programatically, but has no hardware effect. According to the documentation of uhubctl, Raspberry Pi has similar limitation in the hardware design, so only way to control power on selected USB ports instead of all 4, is to use external USB hub with such capability. Because of that limitation, I have to unmount USB disk and turn off swap even if I want to power cycle or turn off different USB device. Not complaining, just sharing my experience in case somebody wonders if it is possible to control power of each USB port separately in Jetson Nano.
@Lissanro Before uhubctl, I tried hub-ctrl. This did not work at all, but it told me that the Hub is “Ganged Switching” (aka turn on/off all ports at once). However, lsusb -v says about the Hub (USB 2.0 and 3.0 Both)
wHubCharacteristic 0x00a9
Per-port power switching
Per-port overcurrent protection
TT think time 16 FS bits
Port indicators
So I don’t quite know who to trust now 🤷♂️. I’ve tried reviewing vendor documentation, but could not find anything useful.
In any case I also did not manage to control individual ports, but to be fair I don’t need to, I want to turn off all USB devices to conserve power during RTC sleep.