RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    About the RetroFlag cases! Surprise surprise.... They can cut off power!

    Scheduled Pinned Locked Moved General Discussion and Gaming
    nespi case +safe shutdown
    52 Posts 15 Posters 17.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cyperghostC
      cyperghost @cloudlink
      last edited by cyperghost

      @cloudlink yes multi_switch.sh --es-restart
      Therefore I wrote the script...
      For more help type multi_switch.sh --help

      @diablo You are welcome

      C 1 Reply Last reply Reply Quote 1
      • D
        diablo
        last edited by

        cyperghost, you are a legend. When I first asked the question I had a few doubts about how I had done things. Something had happened with mine that kicked it off track though. I should have added that I am using a pi 3b. Anyway, following your instructions (to the letter), showed that the file structure was correct, though no multiswitch file (sorry for spelling it wrong, but i need to write this fast as i am needed elsewhere in twenty mins). Running the wget https bit gave me a newly created multiswitch.1 file. So it was definitely saving it.

        Ls of the scripts folder still showed nothing there.

        Backtracking through the hierarchy though I discovered both multiswitch and its newly created ms.1 version were both in the 'home' folder. Not where they should have been obviously.

        A quick google on how to move a file within putty (told you i was new to all this) and i moved ms to the scripts folder.

        Ls confirmed the move was good.

        Rechecked the ES autostart details, all looked good.

        Restarted the pi, finally seeing a flicker from the led then eventually lit solid.with ES fully loaded. Tried a game, pressed reset and it jumped back to game selection. Hit the power button and a second or three later it shut down. A number of test shutdowns and resets later and Basically, its working perfectly now (albeit without a fan as the one I had fitted sounds like a 747 taking off, so no idea about fan script working or not, though I have no reason to think it wont now the rest is ok.

        So again, cyperghost, thank you. Your 'fault finding' was used, albeit in a different manner, but its now working as intended thanks to your input. Greatly appreciated.

        I know a lot of people think the nespi has been done to death, but with the + sat next to my c64 and snes minis, and knowing its abilities, the pi is awesome to me now. It just looks'right'.

        1 Reply Last reply Reply Quote 0
        • C
          cloudlink @cyperghost
          last edited by cloudlink

          @cyperghost said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

          multi_switch.sh --es-restart

          It worked!
          Thank you so much!

          1 Reply Last reply Reply Quote 0
          • O
            OhOhOne @cyperghost
            last edited by OhOhOne

            @cyperghost said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

            @ilackiq Yes safe shutdown is possible.
            With the bash script posted here ... you have all the features you mentioned. Power on power off, reset ends running emulators, reset inside emulationstation restarts emulationstation only (NO REBOOT!). All with safe shutdown!
            But then you have to disable uninstall your python script!

            But you can also use the modified python script that I already posted to you, there you need just to follow instructions and do not need to disable the python script, you exchange it with the one I gave you link. This provides also safe shutdown of course. With this script you just restart emulationstation with reset button... feel free to extend this, if you want - that's also easily possible.

            cyperhost, I tried following your directions for replacing the stock RetroFlag script with your python script (as I had already installed the stock one), but it's not working for me, the red light just blinks indefinitely and never turns off. What did I do wrong? How can I disable or uninstall the python script so I can switch you your bash script and use that instead, since the reset button seems so much more useful on your bash script?

            Thanks.

            cyperghostC 1 Reply Last reply Reply Quote 0
            • cyperghostC
              cyperghost @OhOhOne
              last edited by cyperghost

              @OhOhOne
              Did you installed the original script by retroflag?
              Can you check if multi_switch.sh is executable and is located into cd /opt/RetroFlag folder?
              Is the python script exchanged by the one given in the thread?

              If you decide to install the bash script then you have to remove the installed python script first. Type sudo nano /etc/rc.local and remove or comment with # the line with the python code.

              Btw: You can easily extend the python with an el-if branch to just restart emulators if they are running.... I just give an example how script can be invoked into other languages. So the bash and the python script function equally.

              O 1 Reply Last reply Reply Quote 0
              • O
                OhOhOne @cyperghost
                last edited by OhOhOne

                @cyperghost
                I double checked everything and its still not working.
                I installed the original script by retroflag. It was working fine, but I wanted something that would save metadata, so I followed your directions posted in the other thread for replacing the original script with your own python scripts. But ever since then the power button just blinks red when I push it to off, and the reset switch doesn't do anything at all. I double checked and multi_switch.sh is there in /opt/RetroFlag and is executable, and I deleted the original python script and replaced it with yours (again, just to be sure). But its still not working.

                Am I missing something? Did I skip a step?

                EDIT: this is what I get when I type sudo nano rc.local:
                GNU nano 2.2.6 File: rc.local

                By default this script does nothing.

                Print the IP address

                _IP=$(hostname -I) || true
                if [ "$_IP" ]; then
                printf "My IP address is %s\n" "$_IP"
                fi

                /etc/switch.sh &
                /etc/switch.sh &
                sudo python3 /opt/RetroFlag/SafeShutdown.py &
                exit 0

                cyperghostC 1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost @OhOhOne
                  last edited by

                  @ohohone Why double /etc/switch.sh? Try to remove this first.
                  You can also remove the sudo from the python3 call. etc.local is already root

                  O 1 Reply Last reply Reply Quote 0
                  • O
                    OhOhOne @cyperghost
                    last edited by OhOhOne

                    @cyperghost
                    Okay, I made those changes to rc.local but there's no change, it still doesn't work. :(

                    cyperghostC 1 Reply Last reply Reply Quote 0
                    • cyperghostC
                      cyperghost @OhOhOne
                      last edited by cyperghost

                      @ohohone Sorry. I made just a quick try with the python code and it worked fine in my case. Maybe you can add a "print output" line to see if there is any value returned. But you can still use the bash script itself.Use the newest version. You can add it to rc.local or to autostart.sh with path/to/script/multi_switch --nespi+ &

                      Install raspi-gpio with sudo apt install raspi-gpio before. That should do the job.

                      1 Reply Last reply Reply Quote 0
                      • P
                        PWN3D_
                        last edited by

                        Hi,
                        I think I got it all right, the reset button work just as it should and reset to the ES loading screen, but the power button doesn't work at all and the red led is still on when I press it.
                        Well i'm a begginer so there is probably something I'm doing wrong.

                        I also notice that with the safeshutdown from Retroflag ( wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/install.sh" | sudo bash ), if I want to turn off the pi, i have to switch the power button to off and then press reset. Switching th power button to off doesn't do anything on his own.

                        So yep, i'm lost ... :/

                        cyperghostC 1 Reply Last reply Reply Quote 0
                        • cyperghostC
                          cyperghost @PWN3D_
                          last edited by cyperghost

                          @pwn3d_ said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                          Hi,
                          I think I got it all right, the reset button work just as it should and reset to the ES loading screen, but the power button doesn't work at all and the red led is still on when I press it.
                          Well i'm a begginer so there is probably something I'm doing wrong.

                          I also notice that with the safeshutdown from Retroflag ( wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/install.sh" | sudo bash ), if I want to turn off the pi, i have to switch the power button to off and then press reset. Switching th power button to off doesn't do anything on his own.

                          So yep, i'm lost ... :/

                          Please install the "shutdown_fan" script... type:
                          cd /lib/systemd/system-shutdown/ && sudo wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdown_fan

                          This will cut power if you press power button.

                          The method the retroflag script provides works in most cases but it's a simple "killall" and it will fail if there is a emulator running in background.
                          But I'm a bit confused.... Reset works... Power on/off not? Did you set the NESPi-case switch to "ON"?

                          Please remove the retroflag script by editing sudo nano /etc/rc.local and remove the python entry.

                          edmaul69E P 2 Replies Last reply Reply Quote 0
                          • edmaul69E
                            edmaul69 @cyperghost
                            last edited by

                            @cyperghost im really confused. Retroflag says that their script does safe shutdown and safe reset. And to me it appears to be doing just that. How is this better?

                            cyperghostC 1 Reply Last reply Reply Quote 0
                            • cyperghostC
                              cyperghost @edmaul69
                              last edited by cyperghost

                              @edmaul69 They do a safe shutdown by killing every instance of emulationstation binary but this method may fail if there is a emulator running in background. These may be a edge example but it's an improper way to terminate emulation station and is not clean way to save metadata.

                              Furthermore.... the reset button. It's just a waste of option with the original script as it just acts as a system reboot. The multi_switch script just resets the emulator (if there is one is running) and you turn back to ES main menu, or you restart just ES without performing a reboot (usefull if you changed metadata and want to save it, too).

                              All in all it doesn't matter which way you choose. Imho I would NOT use the original script but would stick to python and modify the original script like I've done here: Get text output from bash into you python script

                              In the end you decide ... I created the script to cover a lot of usecases and to make work to install switch to a Pie a bit more easier. Furthermore I learned a lot about handling command line parameters (used a uncommon method without shifting every single parameter).

                              In short why I don't rely on the retroflag script:

                              • Fixed shutdown timer (5 seconds in every case)
                              • The metadata may break in edge cases
                              • Reset button is useless (imho)
                              • (not related to the script itself) They change /boot/command to set UART for LED output
                              • The python libary (GPIOzero) is a real heavyweight (but very comfortable I must agree)
                              • I wanted to do something in bash ... as long as @meleu don't fixed the ES shutdown service (therefore I installed the --es-systemd parameter)

                              So I hope you are not confused anymore ;)

                              1 Reply Last reply Reply Quote 1
                              • P
                                PWN3D_ @cyperghost
                                last edited by PWN3D_

                                @cyperghost

                                Ok, I've instaled the shutdown_fan script, but it appears as shutdown_fan.sh1 , so I guess it was already there.

                                Sorry for the confusion about the Power switch , I'll try to be clear :
                                (The Nespi case switch is turned to ON)

                                -With the retroflag script, the Power on/off only works to turn on the pi. When I press the Power button to "off", it doesn't do anything. If I want to trun off the pi, i also have to press the reset button, see the retroflag script rolling to the end until it finally turn off the pi.

                                -With your script, it is the story, the Power off doesn't do anything but as the reset button only restart ES, I can't turn off the pi.

                                So yes, the Reset button work perfectly, the Power button works only in one way, when I have to turn On the pi.

                                PS: Today I have tested with a fresh sd card without the retroflag script, but this ended with the same result unfortunatly

                                PSS: Also I should mention my what I am working with :
                                -Nespi Case+
                                -Raspberry Pi 3 B+
                                -Kitty for SHH
                                -San Disk Ultra 16GB

                                cyperghostC 1 Reply Last reply Reply Quote 0
                                • cyperghostC
                                  cyperghost @PWN3D_
                                  last edited by cyperghost

                                  @pwn3d_
                                  Then I guess there is something wrong with the case.

                                  -With the retroflag script, the Power on/off only works to turn on the pi. When I press the Power button to "off", it doesn't do anything. If I want to trun off the pi, i also have to press the reset button, see the retroflag script rolling to the end until it finally turn off the pi.

                                  That's very curious. Usually the power button initiates a full power cut off if the GPIO is detected.

                                  -With your script, it is the story, the Power off doesn't do anything but as the reset button only restart ES, I can't turn off the pi.

                                  The reset and and power button are initiated all the same way. As reset works as it should and power does not work. I think I now I understand what may happening. It seems GPIO3 is not proper connected to your PIN header. You may check if it is attached right to the GPIO header. You can also reattach it to a new GPIO if you use ./multi_switch.sh --nespi+ powerbtn=xy & argument.
                                  XY is the GPIO header.....

                                  Because no script works in your setup, the error lies in your case.

                                  P 1 Reply Last reply Reply Quote 0
                                  • P
                                    PWN3D_ @cyperghost
                                    last edited by PWN3D_

                                    @cyperghost I will check all the wires and connectors right now

                                    Also, if the switch in the nespi case is set to "off" the power button work just fine when I turn off the pi, but as you know it just kill the power.

                                    P 1 Reply Last reply Reply Quote 0
                                    • P
                                      PWN3D_ @PWN3D_
                                      last edited by PWN3D_

                                      @pwn3d_ Oh, I'm getting somewhere : I tried to reattach the wire connected to the GPIO3 , to the GPIO11.

                                      Then I typed : ./multi_switch.sh --nespi+ pwerbtn=11 &
                                      the answer was : -bash: ./multi_switch.sh: No such file or directory

                                      Ps: I have also checked in the /home/pi/RetroPie/scripts directory. I can see the multi_switch script as : *multi_switch.sh
                                      I don't know if the * means anything

                                      mituM 1 Reply Last reply Reply Quote 0
                                      • mituM
                                        mitu Global Moderator @PWN3D_
                                        last edited by

                                        @pwn3d_ said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                                        I don't know if the * means anything

                                        It means is an executable file/script. Try typing the full pathname

                                        /home/pi/RetroPie/script/multi_switch.sh --nespi+ pwerbtn=11 &
                                        
                                        P 1 Reply Last reply Reply Quote 1
                                        • P
                                          PWN3D_ @mitu
                                          last edited by PWN3D_

                                          @mitu Nope, I'm getting the same message :

                                          -bash /home/pi/RetroPie/script/multi_switch.sh: No such file or dirctory

                                          PS: Scripts ... with an s at the end ... yep that was it

                                          cyperghostC 1 Reply Last reply Reply Quote 0
                                          • cyperghostC
                                            cyperghost @PWN3D_
                                            last edited by cyperghost

                                            @pwn3d_ said in About the NESPi+ case! Surprise surprise.... It can cut off power!:

                                            yep that was it

                                            = it does work now?

                                            Annother question - just curious about the not working GPIO3.... Do you have activated I2C connection somewhere? Maybe that's the reason the GPIO wasn't initiated right.

                                            The case uses the whole standard connection boards (I2C and UART) so I decided to develop command line parameters.

                                            P 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            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.