Posted: Mon Oct 24, 2016 13:57 Post subject: Toggling USB subsystem via ssh
Hi,
I have a device on the USB port of a TL-WDR4300v1 I'd like to be able to switch off and on at will.
In the GUI I can dis/enable USB subsystem, which does indeed power on or off as desired, but how do I do that via a command line?
nvram changes are only saved, not applied. Rebooting for this is really not an option, unfortunately.
(Un)loading the kernel modules doesn't seem to do the trick either.
Thanks for any help you can offer!
Usually the gui is running some commands behind the scenes - so it *should* be possible to mimic that from the command line (of course easier said than done).
A quick attempt would be to unload some of the "higher" (usb) modules that provide the functionality (like usb-storage etc.) which will in effect disable the device. It is not always possible to unload *all* the USB modules once loaded (but YMMV).
Have you tried to unload some of the usb modules in reverse order (i.e from those that have no dependencies "downwards") and has that helped?
The other option of course is to try and see what commands the gui is probably invoking and to try to run those (it may help to just browse SVN to see the various services and figure out what provides the USB stuff).
If no one comes up with an easier approach, I'll try to take a look at the source and see what I can come up with.
In the meanwhile do report if you have any luck with the unload module approach (which should be easily scriptable).
The WDR4300 has the USB ports power controlled from a gpio pin on the CPU so you can easily turn on and off power in software.
On a telnet cmd line or within a script:
gpio enable 22
gpio disable 22
and for the other USB port
gpio enable 21
gpio disable 21
You'll have to find out by yourself if enable is USB Power On or if it is USB Power Off, disable will then be the opposite.
You can toggle the USB LED's at the same time if you want, they are on gpio 11 and gpio 12. _________________ Kernel panic: Aiee, killing interrupt handler!
Indeed. Those commands work and, also, they are pretty confusing!
If you want to turn off USB 1 Port you can issue "gpio disable 22". And also you have to issue "gpio enable 11" in order to get the "Top" (supposedly) LED turned off, because the LED state is kept unchanged regardless USB Port state.
Turn ON both USB+LED:
USB 1 + Top LED. : gpio enable 22 • gpio disable 11
USB 2 + Bottom LED: gpio enable 21 • gpio disable 12
*"USB 1" is the closest to Power Button.
I love those routers because they're very versatile. Ironically they're good at anything but Wi-Fi strength.