Multi Switch Shutdown Script!
-
Mine is working perfectly.
If I have an emulator running and I hit Reset, it only exits the emulator. If I have no emulator running and I hit Reset, it restarts Emulationstation.
If it is off and I press the Power button, it powers on. If it is on and I press the Power button, it safely saves metadata and shuts down.I have noticed though that if I press and release the Reset button too quickly, it does not work. Is there a configured amount of time it must be held?
-
Ok, I've commented line 183. It now shuts down properly again, but the fan still runs.
I turned it back on, exited ES, then typed the
raspi-gpio set 4 op dl
command. Nothing happened. The fan keeps running.I've re-checked the on-off switch. It's firmly all the way in the on position.
Here's a photo, if that helps. (For some reason the photo isn't showing up...) Here's the direct link instead: https://www.dropbox.com/s/vgt95faj8oe65ib/raspi3.jpg?dl=0
-
@gollumer The link you've posted is not working :( So it may be helpfull to upload your photo again ;)
I assume two things as @cloudlink is reporting a good shot and even a powered down fan.
- There are several cases around with different PCBs (maybe annother reversion)
- You have annother script running in background
You are talking about an endless reboot loop...
This isn't possible with my script. In the worst case it will powerdown the Raspberry, but won't reboot. Can you post output ofps -la
please? This will show all programms running. So you can be sure no other script is running.Sadly I don't have this case! Without this it's a bit difficult to give you best advices. So it's just a bit of try and error! But I've to thank your for your energy in testing.
Can you type
raspi-gpio set 4 op dl
if ES is running? And what is happening then?I have noticed though that if I press and release the Reset button too quickly, it does not work. Is there a configured amount of time it must be held?
Yes it's the sleep loop. The state of all switches is polled only every second. So it can take up to one second until the button press is detected. It's caused by the script itself you may use
sleep 0.5
instead ofsleep 1
-
Thank you very much for your help, you've been very patient.
I re-sized the image after I posted the link, so I think Dropbox thought it was a new image. Here's a new link: https://www.dropbox.com/s/cevy9c5zeijm434/raspi3.jpg?dl=0
Here's the output from
ps -la
:pi@retropie:~ $ ps -la F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 1000 914 631 0 80 0 - 1272 wait tty1 00:00:00 bash 0 S 1000 919 914 0 80 0 - 1152 wait tty1 00:00:00 bash 0 S 1000 920 919 0 80 0 - 1192 wait tty1 00:00:00 multi_switch.sh 0 S 1000 921 919 0 80 0 - 1154 wait tty1 00:00:00 emulationstatio 0 S 1000 931 921 0 80 0 - 477 wait tty1 00:00:00 emulationstatio 0 S 1000 934 931 43 80 0 - 49770 futex_ tty1 00:00:43 emulationstatio 0 S 1000 1833 920 0 80 0 - 849 hrtime tty1 00:00:00 sleep 0 R 1000 1835 1676 0 80 0 - 1070 - pts/0 00:00:00 ps pi@retropie:~ $
When I run this command (
raspi-gpio set 4 op dl
) with ES running, nothing happens. I get straight back to the command prompt (running in an SSH session from my laptop). Fan still runs.I hope this helps.
-
I'm not sure if this could cause the issue, but I had to correct the path in step 5 of the installation instructions at the top of this thread:
From
/home/pi/RetroPie/multi_switch.sh --nespi+ &
To
/home/pi/RetroPie/scripts/multi_switch.sh --nespi+ & -
@gollumer Thanks.... Yes it looks all clean.
Annother user posted an image of the case maybe you can compare revision numbers but I see really no error in the setup.... strange strange strange....Can you please post output of
cat /opt/retropie/configs/all/autostart.sh
@cloudlink Oh really? Yes that a wrong path! Indeed. I corrected this! Thank you so much. That may caused the issue at all! And your fan shuts off if you powerdown the system?
-
Sorry I didn't think to mention that earlier. I forgot I had corrected that, but I just remembered while retracing my steps.
See if that fixes the issue. -
Yes, my fan shuts off when the system shuts down after I uncommented line 184 in /home/pi/RetroPie/scripts/multi_switch.sh
-
@cyperghost said in Multi Switch Shutdown Script!:
Can you please post output of cat /opt/retropie/configs/all/autostart.sh
Here you go:
pi@retropie:~ $ cat /opt/retropie/configs/all/autostart.sh /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ & emulationstation #auto
-
@gollumer and now... output of
ls /home/pi/RetroPie/scripts
I still found no error ;)
-
@cyperghost said in Multi Switch Shutdown Script!:
@gollumer and now... output of
ls /home/pi/RetroPie/scripts
I still found no error ;)
pi@retropie:~ $ ls /home/pi/RetroPie/scripts multi_switch.sh pi@retropie:~ $
Definitely weird. It must be something with my specific board? At least it's shutting down and saving metadata.
-
@gollumer Hello my friend!
Today I got my NESPi+ case, too! And I was able to get the same behaviour as you descriped! So there is nothing wrong with your setup!The NESPi+ case is a real bummer! It can COMPLETLY shutdown power!!! Really!
You need the
shutdown_fan
script. Please install with this line
cd /lib/systemd/system-shutdown/ && sudo wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdown_fan
That might work but you may edit the
multi_switch.sh
You can edit line that is round about 160 and change or download newest version 0.51
I removed the line that sets GPIOPoweronctrl to low, this caused issues! You can alse let this line still commented and use old version!raspi-gpio set $GPIO_poweronctrl op dh to raspi-gpio set $GPIO_poweronctrl op pn dh
-
@cyperghost - YES! That did it! I installed the
shutdown_fan
script, then edited multi_switch.sh. Problem solved! Thank you! -
@gollumer Yes, it was a long way. Thanks for your reports and patience.
-
Thank you so much @cyperghost!
I updated the multi_switch.sh and installed the shutdown_fan script. Everything is working perfectly except that it is not saving metadata when powering off now.
It is when I reset though. -
@cloudlink Well I tested several times now. And I've achived always flawless shutdown and poweroff with no loss of metadata ... So safe shutdown works!
You can see if you restart ES ... as the file system is initiated you will see "retropie: clean" or "dirt bit set!"
If the dirt bit is set! Then there were issues with the shutdown.
In my setup it never accours. I would assume you've downloaded the newest version but did not remove the older one. So the new one is named
multi_switch.sh.1
Enter:
cd /home/pi/RetroPie/scripts
thenrm multi_switch.*
This will remove all copies of multi_switch.Then follow this guide here
I've written it for NESPi+. If you made all steps right then you just need Pt. 3 of the guide!Btw: My NESPi+ board version is USB2 V2, 18/01/18
-
@cyperghost So, does this mean that with the proper software configuration using your latest updates etc., the NESPi+ case can function with full shutdown without the need for a Mauseberry or similar hardware hack/addition?
-
@caver01 As far is a tested: Yes, it makes a full power cut.
There aren't any LED activites anymore (red LED for power on Raspberry for ex.) and 5V rail is also shut off. So this seems to work. It seems to work very similar to the Pimoroni ShimOnOff ... You need also a GPIO set to 0 that immediatly cuts power also via systemd, too ;)
-
@cyperghost Amazing. This little case just keeps getting better and better. The updated script and NESPi+ means you can save $20 by not needing a power button circuit, and you save all of the modification time/risk, and you save the space inside the case for all of the rewiring etc.
About the only thing worth doing to these now is moving the ethernet port to the back.
-
@caver01 If you want to save money definitly a good choice! A user from github told me, that in python script from retroflag it is possible to cut power, without the systemd-service. Because he said, my script works with reboot/save shutdown and so on... but the fan is still blowing.
Therefore I used the systemd-service to cut power and now the fan is shutdown by poweroff - same was reported by @gollumer. He made constant report that helped a lot. On my first tests I had exact the same issues as he reported - The Pie was shutdown but only in idle-mode (means 5V rail on, red LED on Pie also on). But with the introduction of the systemd-script the fan-off issue is also solved and we obtain a complete unpowered device (means 5V rail off, red LED on Pie also off)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.