DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Switching off USB power at shutdown with retropie

Thu Jan 31, 2019 10:49 pm

Hi Guys,

I've got a Joystick and a set of illuminated buttons connected on a pi 3 B with RetroPie and everytime I shut it down with

Code: Select all

sudo shutdown now
the usb ports have power even if the pi has is halted.
Is there anyway to circumvent this and kill the USB power upon shutdown so that the LEDs of the buttons switch off ?

User avatar
Imperf3kt
Posts: 2389
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Switching off USB power at shutdown

Thu Jan 31, 2019 10:55 pm

By default, they should lose all power at shutdown...
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 12:16 am

Well the button lights are still on so apparently not.

User avatar
Imperf3kt
Posts: 2389
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 3:37 am

I just tested my own Pi's and can guarantee the USB power shuts off when the Pi halts.
And the documentation also supports this as the USB hub is controlled by software - when the Pi shuts down, no software can be run as it is off.

Perhaps there is a large capacitor inside your joystick holding power? Do the lights still glow if you walk away for five minutes?

Or are you using a powered USB hub?
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 7:46 am

No powered USB hub on the system.
Also, the buttons stay on forever. A few seconds after the system shutsdown they momentarily switch off for a few miliseconds but afterwards they switch on again.

Could this be related? I've used https://howchoo.com/g/mwnlytk3zmm/how-t ... spberry-pi this guide to connect a shutdown button onto GPIO 5 and 6 and the script calls

Code: Select all

shutdown -h now
instead of

Code: Select all

shutdown now
. However, this shouldn't make any difference since whatever command I use the buttons never switch off.

User avatar
Imperf3kt
Posts: 2389
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 8:10 am

That guide should not affect anything usb related. In fact, it's in raspbian by default if you enable the device tree overlay for shutdown.

Im genuinely stumped on this one, sorry.
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 8:15 am

Imperf3kt wrote: That guide should not affect anything usb related. In fact, it's in raspbian by default if you enable the device tree overlay for shutdown.

Im genuinely stumped on this one, sorry.
No worries mate. I'll give google fu more effort..

tinkerBOY
Posts: 7
Joined: Thu Mar 01, 2018 9:35 am
Location: Baguio City, PH
Contact: Website Facebook

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 10:26 am

Try updating your version of Raspian or try a fresh installation.
“Everything should be made as simple as possible, but not simpler.” Albert Einstein

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 11:46 am

Actually its a retropie installation so i am not really sure if it's the OS version that causes the problem

fruitoftheloom
Posts: 19782
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 5:53 pm

DjGeNeSiS wrote:
Fri Feb 01, 2019 11:46 am
Actually its a retropie installation so i am not really sure if it's the OS version that causes the problem

Retropie is a collection of software which from version 4.4 uses Raspbian Stretch Lite as the base Operating System.


What occurs when you remove the On/Off Button ??
adieu

My other Computer is an Asus CS10 ChromeBit running Chrome Operating System.
HP Envy 4500 Wireless Printer supported by HPLIP software in Raspbian Buster.
Raspberry Pi Model 2B v1.1

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 5:57 pm

fruitoftheloom wrote:
Fri Feb 01, 2019 5:53 pm
What occurs when you remove the On/Off Button ??
Good suggestion, I'll try it out and let you know

User avatar
HawaiianPi
Posts: 4202
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 6:35 pm

Imperf3kt wrote:
Thu Jan 31, 2019 10:55 pm
By default, they should lose all power at shutdown...
True if the Pi is booted from SD card, but not if it's booted from USB...

In my experience the USB ports remain powered after shutdown when the Pi is booted from a USB drive.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

DjGeNeSiS
Posts: 22
Joined: Thu Apr 07, 2016 8:54 pm
Contact: ICQ

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 8:50 pm

HawaiianPi wrote:
Fri Feb 01, 2019 6:35 pm
True if the Pi is booted from SD card, but not if it's booted from USB...
Bingo! I'm booting from USB so the USBs remain on at shutdown.

I've tried to disable the USB power with

Code: Select all

echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind
which switches the USBs off indeed, but since the O/S is running on the USB stick and I disconnect it from the system, I can't issue another command to switch the system off. For every other command I use I get

Code: Select all

Input/output error
So, I created an executable script that runs at shutdown:

Code: Select all

sudo nano /lib/systemd/system-shutdown/turnoffUSB.sh
and run the command at shutdown.

Code: Select all

#!/bin/bash
mount -oremount,rw /
echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind
mount -oremount,ro / 
The USB lights switch off when the system shuts down, but after a few seconds the come back on ! Ghosts maybe? :o

How can I make the lights stay off?

User avatar
HawaiianPi
Posts: 4202
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Switching off USB power at shutdown

Fri Feb 01, 2019 11:57 pm

DjGeNeSiS wrote:
Fri Feb 01, 2019 8:50 pm
How can I make the lights stay off?
Well, the obvious answer is to boot from SD card.

You could try reporting this as a bug, but it's always behaved that way as far as I recall, so if it was a bug I suspect it would have been squashed by now. Perhaps one of our resident RPF/RPT people can chime in on this and let us know if it's by design?
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
Imperf3kt
Posts: 2389
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Switching off USB power at shutdown with retropie

Sat Feb 02, 2019 2:02 am

In the meantime, you could make an external transistor controlled USB port that turns on via a couple of lines of code run at cron, but it would probably be a bit of work involving both hardware and software.
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

PhatFil
Posts: 1223
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Switching off USB power at shutdown with retropie

Sat Feb 02, 2019 2:54 am

you could employ the usb power thats causing you a headache to power a 2ndary device like an arduino,attiny, or esp8266 which checks the status of a gpio pin known to revert to Ground after shutdown which you have set to High at system start up, and cut the dc power to the pi and by default itself after a shutdown.

again more work and h/w..

Return to “Gaming”