-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pi 4: uhubctl doesn't power off downstream USB ports #3079
Comments
Just curious, can you please post output of I suspect that USB3 and dual USB2 hubs might have different PPPS properties. |
|
Per USB 3.0 spec, all USB3 hubs must advertise both USB3 hub and USB2 compatibility hub.
Basically, we have 4-port USB3 and USB2 hubs, which are obviously part of the same physical 4-port hub. However, they advertise different power switching characteristics: USB3 claims per-port power switching, USB2 claims ganged power switching (and is filtered out by uhubctl). In addition to that, USB3 device does not define ContainerID at all, even though by USB 3.0 spec it is required.
If not, we might be able to hack uhubctl to add an exception. However, lack of ContainerID advertisement by USB3 hub still stands, and has to be hacked as well. There are 2 more 1-port USB hubs, but I don't think they are important for this discussion, as one is OTG controller:
|
Thanks for responding. On the Pi 4, in common with previous board designs, the first externally-accessible power switching/vbus control pin is connected to the USB power switch that controls all downstream ports. On the SMSC devices, there was no way to specify ganged power switching without the use of an EEPROM so the hub reported per-port switching but port 2 switched off power to all of the downstream ports. I think the LAN7515 behaves in the same way. The broken hub descriptors should be fixed - we have a relationship with VIA labs as they are supplying chips directly to us, so we can feed back any non-compliant behaviours that we come across. The hub descriptor can probably be fixed with a firmware update, but for the sake of testing the hardware - what hacks do I need to do to uhubctl to stop it skipping over the USB2.0 hub? |
You can hack this condition https://github.com/mvp/uhubctl/blob/master/uhubctl.c#L417-L422 to allow However, since Ideally, we need 2 action items:
Minor note: one of 1-port hubs above reports ganged power switching (OTG controller). Since it is 1-port anyway, perhaps you could change it to per-port? At 1-port capacity, it shouldn't really matter anyway. |
If I nobble the readback of the BOS descriptor, and permit power switching on ganged hubs, then setting port power to off on both the 4-port USB2.0 hub device and the USB3.0 root hub removes downstream power. It looks like the broken descriptor is the only thing that needs fixing. For dwc_otg, the hub descriptors are just open-coded in dwc_otg_hcd.c so it's a trivial change. |
Thanks for the update! Please shout out when these descriptor changes are out, and if you need me to fix anything in uhubctl. |
Added a link to Raspberry 4B issue raspberrypi/linux#3079. Once this is fixed in firmware, uhubctl should start working on 4B.
Any update on fixing broken descriptors in 4B firmware? Can I help somehow? |
I do have a question - how do you do port power control of USB3.0 root hub ports? Linux provides the descriptor in this case but without a BOS/containerID. |
USB3 hubs advertise themselves as 2 virtual hubs: one is USB 3.0, and another is compatibility USB 2.1, but they both share the same physical port. (USB 2.1 to signify that hub is just a bit smarter than old USB 2.0.). To address this problem, uhubctl tries to guess correct USB2+USB3 hub pairs, and turn off power on both automatically. Until recently, If Linux does not provide containerID for root USB3 hubs, we have few options:
However, all of these methods still require all relevant USB descriptors to report per-port power switching. |
Some devices (notably Raspberry 4B) have USB3 hub that advertises its USB2 compatibility partner at different depth level. Raspberry 4B onboard hub doesn't yet support uhubctl directly (but it should once raspberrypi/linux#3079 is fixed), but this breaks level check restriction for any external USB3 hub attached to RPi4B - so this check has been removed.
any update on this? It would be really helpful to have working uhubctl on my 4B |
The issue is being investigated by VLI (and they have reproduced the issue). We don't have a timescale for a fix. |
I am also interested in this. As a temporary solution, hacking uhubctl as described above allows per-port power switching? Or does it only allow switching all ports at once? |
I don't know - I don't have Raspberry Pi 4B and don't have access to one. It really depends on what 4B hardware is actually supporting - per port or ganged power switching. Also, it is possible that updated USB firmware can change power switching behavior. |
Got a Pi 4B today and I could try it. I patched uhubctl as described above. With a basic device (mouse with led) it works as expected. I also have an external case for hard drive (with its own power supply) that has an option to go to sleep when unplugged from usb. My plan was to use usb per-port power switch to control it from command-line. The thing is, it only goes to sleep if I turn off all ports, both USB2 and 3. As soon as I turn on power on a port, USB2 or 3, it wakes up. I'm not sure if it specific to raspberry pi as I do not have another hardware with per-port power switching. |
Using Raspbian GNU/Linux 10 (buster) on Pi4 with 4.19.75-v7l+ and replacing We are using a Pi4 to write FW to several CM3. Using this method is a pretty simple way to turn off the IO board during replacement of the CM3. First I planed to use a GPIO with an external switch, but that way is perfectly cheep and simple. Many thanks to mvp. |
We've received updated firmware from VLI: https://www.raspberrypi.org/forums/viewtopic.php?t=258489 A patch to uhubctl is still required but in a slightly different form to the one posted by @mhgue. |
@P33M , please post output from |
lsusb:
Patched output:
|
Sorry, it took so long to respond - I was traveling. I don't see any difference in new firmware behavior.
All that was done here is to hack uhubctl to treat ganged hubs as per-port. |
The patches are the same, except for line breaks and comments. The difference of the new VL805 firmware release 0137ac is no more |
@P33M, @mhgue: |
Bump: I need someone to try rpi4 fix. I don't have Raspberry Pi 4 (unless you want to send me one 😄 ).
|
Unfortunately this does not seem to work. I get a
as result. Firmware version is |
@ntova, thanks for trying. Can you show output for |
|
@ntova, thanks! This is looking good to me. As a sanity check,
At this point, Can you also try turning power off by using 2 commands in a row:
(-e disables automatic USB 2/3 duality handling). Thanks! |
Thank you very much, works for me. Now we just need to hope for per-port switching... |
Thanks, @ntova. Per-port might work, but I don't think it's likely. Basically this is limited by what hardware actually supports. |
In the current state, powering off for example port 4 leaves the power on although uhubctl reports it as powered off. Only powering off everything (the command used above) actually works. |
Thanks. This behavior is consistent with ganged power switching - only turning all ports would cut off VBUS. |
@mvp yes it is, I can confirm that 1-1 and 2 works identically. Also I have USB lamp plugged in 4 port, so ./uhubctl -l 2 -p 4 -a on / off affects only this port. |
Sorry for misinformation. It was a coincidence. Yeah port4 turns off everything, and other ports do nothing |
Oh wait, port 4 controlling all other ports? @justinasjaronis |
I have merged this fix to uhubctl master branch mvp/uhubctl@4aae44c. However, it would be great to know actual requirements for VBUS off - is it really all ports, or just port 4 is enough. |
Yes exactly. I have testested both USB3 and USB2 ports, all ports get turned on/off by either 1-1 or 2 hub port 4. |
Other ports power state does not matter anything on any port VBUS |
Thanks, @justinasjaronis. I will update the readme. |
Anyway, for my business case this is more than enough. Thank you once again ! Will you need the device anymore, or can I turn it off? |
Much thanks for providing access to RPi4, @justinasjaronis! |
For the record, I expect this to work with old or new USB firmware exactly the same @P33M. You should still ask Via to fix USB descriptors |
I have updated the fw to the last version but it doesn't work. Do you have any suggestion? |
(please post output from running this command!)
|
It seems not to work for me. I have install the USB firmware form here: https://www.raspberrypi.org/forums/viewtopic.php?t=258489 I have the latest version of uhubctl installed and I use one of the compatible D-Link USB Hubs. My output for sudo ./uhubctl/uhubctl looks like:
hub1 seems to be the compatible USB hub. I try to power it down with:
But my device attached to hub still gets power and (all my devices seem to have stopped?) What is my mistake? (Sorry if not completely clear, I'm new to the RP stuff) |
You need to specify hub 1-1 or 2. Hub 1 is just intermediate 1 port hub, that won't work. |
Hi mvp, thank you for your response. If I use sudo ./uhubctl/uhubctl -l 1-1 -a 0, it powers down all USB devices. I thought, there was a way to power down an external USH hub only, while keeping all USB devices directly plugged into the raspi active. |
@rob2212 , you can connect any hub from uhubctl compatibility list to Raspberry Pi and control its ports separately, just be sure to target that hub with -l option, this is covered in uhubctl FAQ. For the future uhubctl questions, perhaps consider asking them in uhubctl repo. issues. |
It's working, my mistake. |
Hello, On my side i have a pi4b, with vl805 firmware to 000137ad.
This is not working, usb port is just powered off for ~ 1sec. Command :
Syslog :
Any clue about this ? rgds Nicolas |
@nmeaux , please read FAQ at https://github.com/mvp/uhubctl/blob/master/README.md. Basically, you should use
where N is a number 100 or higher. |
This is tested and working on Pi 4 - closing. |
I think there is a bit of confusion from
There is confusion regarding the PI4B with update 00137ac or later.
The latest README.md should be updated at the "Raspberry Pi 4B" section with the working commands. Thanks for this nice tool @mvp ! |
@kindoshi Its not entirely clear which document you are suggesting should be updated, and with what. Easiest would be to send in a PR with the changes you think need to do done. |
hey @mvp thanks quick question does your way turn off all the 4 usb ports in raspberry pi 4? If I want to turn on or off one of the usb ports what is the command? thanks. |
@bachoo786, please read uhubctl FAQ https://github.com/mvp/uhubctl#raspberry-pi-4b |
Vbus still remains powered even if uhubctl is called to turn off all USB ports.
The text was updated successfully, but these errors were encountered: