Toggling USB subsystem via ssh

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
Snotboble
DD-WRT Novice


Joined: 15 Jul 2010
Posts: 3

PostPosted: Mon Oct 24, 2016 13:57    Post subject: Toggling USB subsystem via ssh Reply with quote
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!

Best regards,
-Allan
Sponsor
nullnothere
DD-WRT Novice


Joined: 27 Jul 2016
Posts: 15

PostPosted: Mon Oct 24, 2016 17:04    Post subject: Reply with quote
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).
LOM
DD-WRT Guru


Joined: 28 Dec 2008
Posts: 7647

PostPosted: Tue Oct 25, 2016 4:29    Post subject: Reply with quote
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!
Snotboble
DD-WRT Novice


Joined: 15 Jul 2010
Posts: 3

PostPosted: Tue Oct 25, 2016 11:02    Post subject: Reply with quote
LOM wrote:

gpio enable 22
gpio disable 22

and for the other USB port

gpio enable 21
gpio disable 21


This worked like a charm - thank you very much Very Happy

Best regards,
-Allan Jensen
msantos2007
DD-WRT User


Joined: 13 Oct 2009
Posts: 246

PostPosted: Fri Jun 19, 2020 3:30    Post subject: Reply with quote
Indeed. Those commands work and, also, they are pretty confusing! Laughing

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.

Best regards,

Marcelo Santos
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum