Multi Switch Shutdown Script!
-
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)
-
@caver01 I'm currently working on a version that supports command line options.
Up to now 4 parameters are supported
powerbtn=
with this command you set desired GPIO the powerbutton is attached to. If you left unsigned or you enter wrong setting, then default values are used. All devices support that commandresetbtn=
with this command you set desired GPIO the resetbutton is attached to. If you left unsigned or you enter wrong setting, then default values are used. Only the both NESPi cases supports that type. So if you use this command on a generic button it will be ignored!powerctrl=
with this command you set desired GPIO the power ON control is attached to. All devices needs this, except the generic button only! If you enter wrong values or leave it blank the default values for expected device are used. This command indicates the power device in which state the Raspberry is, so a complete power cut can be performed!ledctrl=
with this command you set desired GPIO a LED can be shut ON or OFF. Up to now only the NESPi cases supports that feature. I think I can integrate it to other devices, too.
So you set for example your Mausberry-switch via commandline:
- default values:
multi_switch.sh --mausberry
this will use GPIO23 for power button and GPIO24 for power ON control. multi_switch.sh --mausberry powerbtn=17
this will use GPIO17 for power button and GPIO24 for power ON control still as defaultmulti_switch.sh --mausberry powerctrl=4 powerbtn=3
this will use GPIO3 for power button and GPIO4 for power ON controlmulti_switch.sh --mausberry powerbutton=3 powerctrl=3a
will use default values GPIO23 for power button and GPIO24 for power ON control as parameters were all setted wrong.
Also better support pages will be contained. So you get support for each command or device if you just enter
./multi_switch.sh --nespi+ help
for example. I will integrate this into a later version so we can rush to v1.00.Annother thing I may add:
--systemd
value to create compatibility with Shutdown Service by @meleu. So you entermulti_switch.sh --systemd
into the service file:
instead :ExecStop=/etc/killes.sh
you enter:ExecStop=/path/to/multi_switch.sh --systemd
Then you are completly independent of the power switch settings from here and can use python or any other coding language to to get ES gracefully shutdown just by usingsudo poweroff
orsudo shutdown -h now
. The script is in no way abolished by revitalising the shutdown service because you can still reset/reboot ES with commands this script provides ;)And then maybe some installer scripts ;)
Much better documentatation ;)
So feedback is appreaciated ;) -
Version 0.85 is now available.....
This is a huge step!
v0.70 Parameter control, added extended help pages
v0.75 Parameter --CLOSEEMU is called --ES-CLOSEEMU (both can be used for backward compatibility!)
v0.80 Introduced --ES-SYSTEMD parameter, now the ES gracefully shutdown service by @meleu can be used
v0.85 Code cleanup, added watchdog to kill only persistent emulators with sig -9, added more helppages -
Awesome!
With Version 0.85, are the installation instructions still the same? -
@cloudlink Yes! Remove old version before and just download the newest. So first use point 3.1 and then do point 3.0 from instructions ;) But there are just a small things improved. It's just better documented now and some calls are much much cleaner. The biggest point is the possibility to setup GPIOs via commandline now and I differ between kill -15 and kill -9 signal now. I try to use kill -15 in first instance. If after 2 seconds the process is still active... kill level 9 is used. kill -9 can make some problems and it should only be used as last resort.
So I use this only for emulators.... you can test for example withpifba
. This isn't closed with kill -15 so after 2 seconds the emulator will close caused by kill -9 signal.@caver01 I tried to use a kind of systemd-like call. But I wasn't able to integrate this into the shutdown service. The call to should be
ExecStop=path/to/multi_switch.sh --es-systemd
but It didn't work. Even a call to killes.sh that calls the multi_switch.sh and waits several seconds.... Did not work! I hope the service can be done to rework again! -
@cyperghost said in Multi Switch Shutdown Script!:
@caver01 I tried to use a kind of systemd-like call. But I wasn't able to integrate this into the shutdown service. The call to should be ExecStop=path/to/multi_switch.sh --es-systemd but It didn't work. Even a call to killes.sh that calls the multi_switch.sh and waits several seconds.... Did not work!
Bummer. This was exactly what I wanted to do. I wonder if needed subsystems are closing before the call.
-
-
@cyperghost I see what you were doing. . . you were actually trying to define the service using
multi_switch.sh --es-systemd
. I guess I was simply going to call themulti_switch.sh
from meleu's service instead. I need to look at it and see how it is setup now. I wonder if the problem is what others are seeing--that even meleu's service is not working correctly now.
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.