Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn USB port power on and off in Raspberry PI 4

On a Raspberry PI 3B+, it's simple to turn power on its four USB ports off and on. Simply write a "0" to /sys/devices/platform/soc/3f980000.usb/buspower to turn power off and a "1" to turn power on.

The same method doesn't work on Raspberry PI 4B, 4GB (the hex number before ".usb" is different, that's NOT the problem). I have tried uhubctl and hub-ctl as well without any success. I have used a USB power meter to measure the voltage on the ports. It doesn't change. Un a PI 3B+ it changes as expected.

Does the PI 4 support turning USB power off and on in software at all? If it does, how to do it? Or is there a bug somewhere that has to be fixed to make it work? I use the newest Rapbian on both the Pi 3B+ and the Pi 4.

like image 466
Jørgen Frøjk Kjærsgaard Avatar asked Jan 16 '20 15:01

Jørgen Frøjk Kjærsgaard


People also ask

Are Raspberry Pi 4 USB ports powered?

The Pi-4 has a USB-C port while the other units use micro-USB. In most cases having a 5-volt power supply with a the appropriate USB interface is sufficient. Using the USB interface, the Pi can be powered through a phone charger.

How do you power cycle a USB?

Since few USB devices have power switches, the only method to power cycle the device is by unplugging and reconnecting it.

How do you turn Raspberry Pi on and off?

Your Raspberry Pi doesn't have a power switch. As soon as you connect it to a power outlet, it will turn on. Plug the power supply into a socket and connect it to your Raspberry Pi's power port.


2 Answers

Yes, uhubctl supports RPi4B, I have recently added support for it - you need to use uhubctl version 2.4.0 or later (or build it from master branch). It is also necessary to update USB firmware using sudo rpi-eeprom-update to make power switching actually work.

Note that you are missing out by using sysfs method to turn USB off on RPi3B+ - using uhubctl you can control either all 4 ports, or 2 of them independently. RPi4B only supports turning off all ports at once.

like image 58
mvp Avatar answered Oct 19 '22 12:10

mvp


As far as I read Raspberry Pi and Linux issues on GitHub, it seems that there was a bugfix released for uhubctl on 2019 July. Patch I'm refering to: mvp/uhubctl@4aae44c. It should be merged to master. So...

Another thing to have in mind, it seems that RRi 4B hardware only supports "ganged power switching", which means... that You can only turn on and off ALL the USB ports. Not every single one in particular.

like image 3
Kamiccolo Avatar answered Oct 19 '22 11:10

Kamiccolo