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

    Powerblock proper ES shutdown

    Scheduled Pinned Locked Moved ControlBlock, PowerBlock & Co.
    powerblockmausberrshutdownswitch
    24 Posts 6 Posters 12.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.
    • CapemanC
      Capeman
      last edited by

      Thanks! I'll try this tonight after my day's worth of responsibilities are done with, haha.

      Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

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

        @capeman I've got the script!

        #!/bin/bash
        shutdown -h now
        

        So I've updated to previous posting. It should work!

        1 Reply Last reply Reply Quote 1
        • CapemanC
          Capeman
          last edited by

          Great! I will test it out tonight and report back.

          Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

          1 Reply Last reply Reply Quote 0
          • CapemanC
            Capeman
            last edited by Capeman

            Interesting, I must be using really old powerblock drivers (i've had the thing for a year and a half now) - and the .sh file isnt located in /etc/... so I'm going through the retropie update and installing the built in driver from source. I hope i don't cause a conflict haha.

            Edit a that did it! the .sh file is there now! Let's do some editing.

            Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

            1 Reply Last reply Reply Quote 0
            • CapemanC
              Capeman @cyperghost
              last edited by Capeman

              @cyperghost Dang you guys are smart! Works with powerblock without a hitch! Beautiful piece of coding!

              One question. I read and noticed that when the power button is switched, retroarch exits out to ES first before shutting down. Is Retroarch exiting cleanly to the point where it will save sram on exit or is it being crashed out and sram will be lost?

              I have my autosave interval set to 10 seconds, but i read somewhere it doesnt write unless theres a change so i might drop it to 3 seconds, but if the switch exits cleanly, then i probably dont have to worry about it.

              Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

              lostlessL 1 Reply Last reply Reply Quote 0
              • CapemanC
                Capeman
                last edited by

                Hmmm i may as well test it, I'll remove autosave interval in my retroarch cfg, start a new game in kirby's adventure on NES (which i am certain autosaves), then use the power switch process to shut down. If Kirby has a save file, then i would assume that retroarch is exiting cleanly and saving sram... right?

                If not i might try switching out KILL with SIGTERM in the code above to see if simulates a clean exit, it's worth seeing what happens. (as detailed in the retroarch.cfg notes).

                # Killing it in any hard way (SIGKILL, etc) will terminate RetroArch without saving RAM, etc.
                # On Unix-likes, SIGINT/SIGTERM allows a clean deinitialization.
                input_exit_emulator = "esc"
                

                I'll let you know what i find and if i need to adjust anything. If this was covered in the mausberry thread and i didn't read it, my bad, that was alot to go back and read and I'm impatient and mostly skimmed.

                Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

                lostlessL 1 Reply Last reply Reply Quote 0
                • lostlessL
                  lostless @Capeman
                  last edited by

                  @capeman Do a test for us all. Turn off auto save. Make a save in game. Then hit the a switch and see if it saves.

                  1 Reply Last reply Reply Quote 0
                  • lostlessL
                    lostless @Capeman
                    last edited by

                    @capeman find a game that makes it obvious. Like one of the gba castlevania games. Save, kill one enemy. Check the xp before and after. Save and see what the xp is after the shutdown.

                    CapemanC 1 Reply Last reply Reply Quote 0
                    • CapemanC
                      Capeman @lostless
                      last edited by

                      @lostless Right, that was my plan. I'll test it after my wife watches her netflix, and report back.

                      Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

                      lostlessL 1 Reply Last reply Reply Quote 0
                      • lostlessL
                        lostless @Capeman
                        last edited by

                        @capeman i beat you to it. It does save! I will still keep auto on just in case of power outage. But it does solve then default delema of losing my save using a switch because I didn't to exit out of the emulator.

                        1 Reply Last reply Reply Quote 2
                        • CapemanC
                          Capeman
                          last edited by Capeman

                          You indeed beat me to it, but i just got done finishing testing. Appears to be working for me too. I read a bit more into it, apparently KILL when used with a properly running non-frozen application can be ignored by the application and treated as a termination call. Most applications will clean exit on a KILL command and not hard exit when not frozen. So yeah, this seem to work just fine.

                          Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

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

                            @capeman It wasn't possible withouth the great work @meleu and his RegEx hacks.

                            1 Reply Last reply Reply Quote 1
                            • P
                              petrockblog Global Moderator
                              last edited by

                              You are doing awesome work here!
                              Do you think that the PowerBlock driver in the repository should be modified or extended in any way?

                              CapemanC cyperghostC 2 Replies Last reply Reply Quote 1
                              • CapemanC
                                Capeman @petrockblog
                                last edited by Capeman

                                @petrockblog I would vote yes on this! It works flawlessly with ES and retroarch. It is such a simple update to the .sh file and even if doesn't clean exit a non retroarch emulator, it will still exit the old fashioned way and clean exit ES for meta save. So either way it seems pretty harmless.

                                Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

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

                                  @petrockblog said in Powerblock proper ES shutdown:

                                  You are doing awesome work here!

                                  This one has several fathers.

                                  Do you think that the PowerBlock driver in the repository should be modified or extended in any way?

                                  Well ... I think the usecase must be cleared. I'm not sure if everybody will take case in the use of emulators. So I would rather prefer you take this sniplet and push it to your github and let the user get the choice to download/use it during driver installation.

                                  @meleu What is your opinion?

                                  meleuM 1 Reply Last reply Reply Quote 0
                                  • meleuM
                                    meleu @cyperghost
                                    last edited by

                                    @cyperghost

                                    @meleu What is your opinion?

                                    Well. I got my ego massage receiving a compliment from the RetroPie's creator. :-)

                                    Oh... You're talking about modifying/extending the PowerBlock's driver in the repo... Well, what we made here is very specific for a RetroPie-EmulationStation setup. Some people use Attract Mode and at some point others will use Pegasus, and maybe there are PowerBlock owners that don't even run RetroPie.

                                    Maybe you can put this code in the repo as an option, not as default.

                                    That is my opinion.

                                    • Useful topics
                                    • joystick-selection tool
                                    • rpie-art tool
                                    • achievements I made
                                    P 1 Reply Last reply Reply Quote 0
                                    • P
                                      petrockblog Global Moderator @meleu
                                      last edited by

                                      @meleu I agree. I will put that script into the repository as alternative shutdown script. Thanks!

                                      cyperghostC 1 Reply Last reply Reply Quote 2
                                      • cyperghostC
                                        cyperghost @petrockblog
                                        last edited by cyperghost

                                        @petrockblog
                                        There's a update to the code!

                                        Version 1.59 --- I update forst posting!

                                        Version 1.58 Introduced a method to kill child processes via PPID @cyperghost
                                        Version 1.59 is a code polishing done by @meleu

                                        SaturnXS 1 Reply Last reply Reply Quote 0
                                        • SaturnXS
                                          SaturnX @cyperghost
                                          last edited by

                                          @cyperghost @petrockblog

                                          I know this topic a bit old - but I wanted to ask if this is still the best approach for a proper shutdown of a RetroPie/EmulationStation/PowerBlock combo?

                                          @petrockblog you mentioned above that you were going to add this into your repo, but it looks like it's not there?

                                          I just installed the PowerBlock on my Pi4 last night and it's working well, but I just wanted to add the proper shutdown of ES.

                                          Thanks! Apologies for reviving an old thread.

                                          lostlessL 1 Reply Last reply Reply Quote 0
                                          • lostlessL
                                            lostless @SaturnX
                                            last edited by

                                            @saturnx
                                            @cyperghost has released a full power, exit script that works for many power options a while ago. It’s generic and just have to run certain tags from it to get the result you want.
                                            https://github.com/crcerror/ES-generic-shutdown

                                            SaturnXS 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.