19.07.0 not working control power usb (wdr 3600)

root@OpenWrt:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/18040000.gpio, 18040000.gpio:
 gpio-11  (                    |tp-link:green:usb1  ) out lo
 gpio-12  (                    |tp-link:green:usb2  ) out lo
 gpio-13  (                    |tp-link:green:wlan2g) out hi
 gpio-14  (                    |tp-link:green:system) out lo
 gpio-15  (                    |tp-link:green:qss   ) out hi
 gpio-16  (                    |gpio-keys           ) in  hi
 gpio-17  (                    |gpio-keys           ) in  lo
 gpio-18  (                    |tp-link:ext:lna0    ) out hi
 gpio-19  (                    |tp-link:ext:lna1    ) out hi
 gpio-21  (                    |tp-link:power:usb2  ) out hi
 gpio-22  (                    |tp-link:power:usb1  ) out hi

gpiochip1: GPIOs 496-511, parent: pci/0000:00:00.0, ath9k-phy1:
 gpio-496 (                    |tp-link:green:wlan5g) out lo
root@OpenWrt:~# echo 0 > /sys/class/gpio/gpio22/value
-ash: can't create /sys/class/gpio/gpio22/value: nonexistent directory
root@OpenWrt:~# echo 0 > /sys/class/gpio/gpio21/value
-ash: can't create /sys/class/gpio/gpio21/value: nonexistent directory
root@OpenWrt:~# cat /sys/kernel/debug/gpio

OpenWrt 19.07.0, r10860-a3ffeb413b

Please check master first, there have been some tiny changes to ar9344 USB in master over the last couple of days.

Try these commands:

To turn off USB1:
echo 0 > /sys/class/gpio/tp-link:power:usb1/value
To turn off USB2:
echo 0 > /sys/class/gpio/tp-link:power:usb2/value

To turn on USB1:
echo 1 > /sys/class/gpio/tp-link:power:usb1/value
To turn on USB2:
echo 1 > /sys/class/gpio/tp-link:power:usb2/value



For gracefully shutting down USB power, I recommend adding these lines before and after the actual power cycle - to unbind and to bind the usb device, which is in essence "ejecting the usb before powering off and inserting the usb before powering on":

echo 1-1 > /sys/bus/usb/drivers/usb/unbind
sleep 1
echo 0 > /sys/class/gpio/tp-link:power:usb1/value
sleep 10
echo 1 > /sys/class/gpio/tp-link:power:usb1/value
sleep 1
echo 1-1 > /sys/bus/usb/drivers/usb/bind
sleep 1

This will save the routers internal USB hub from errors and softbrick, as it happened to me today when I was testing my new script. Reboot fixed it, but the whole idea of this USB power command is to save time, and not to reboot (for example, a 4G dongle power cycle is faster than a full reboot). Besides, the softbrick of USB hub is not detected by any scripts, so essentially the process stops.

1 Like

thanks, it works!

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.