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

    Multi Switch Shutdown Script!

    Scheduled Pinned Locked Moved Ideas and Development
    shutdown scriptshutdown switchcyperghost
    272 Posts 40 Posters 109.5k 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 @Efriim
      last edited by cyperghost

      @Efriim You may add the shutdown script according to the github description

      1. Install fan_shutdown script: cd /lib/systemd/system-shutdown/ && sudo wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdown_fan
      2. Install raspi-gpio with sudo apt install raspi-gpio
      3. The shutdown_fan is setted to GPIO4 as standard
      4. Therefore you might edit with sudo nano /lib/systemd/system-shutdown/shutdown_fan

      The script will be executed miliseconds before shutdown and will cut off power and stops the fan from everlasting blowing.

      EfriimE 1 Reply Last reply Reply Quote 0
      • EfriimE
        Efriim
        last edited by Efriim

        I'm trying the different GPIO for the shutdown_fan as it isn't doing anything. I'll update if I am successful. The fan is not connected to the gpio however it is connected to the board that connects to the GPIO. I tried GPIO set 1,2,3,4,5,7,8,10 none did as I wanted it to do. Hitting the powerswitch turns off the fan as per normal.

        1 Reply Last reply Reply Quote 0
        • EfriimE
          Efriim @cyperghost
          last edited by Efriim

          @cyperghost Hi, along with the script and its shutdown function working for dreamcast. A new feature of the reicast emulator is to save the rtc setting to emu.cfg when invoking the exit by pressing the exit hotkey. Using the script reset button to exit the emulator does, so successfully however it doesn't save the rtc settings. Meaning I have the set time/date screen until I make a clean exit with the controller and this lasts for a month or so. Do you think we will be able to add this type of exit to the script for reicast?

          I meant here that the reset button to exit reicast works and I am happy and proud to use this script. If there was a way to passthrough a command to reicast to initialize the poweroff where it saves the rtc, I would too like to know this.

          mituM cyperghostC 2 Replies Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @Efriim
            last edited by

            @Efriim said in Multi Switch Shutdown Script!:

            A new feature of the reicast emulator is to save the rtc setting to emu.cfg when invoking the exit by pressing the exit hotkey

            Are you sure ? The RTC is saved in the NVRAM file (BIOS/dc/dc_nvmem.bin), not in the emu.cfg file.

            EfriimE 1 Reply Last reply Reply Quote 0
            • EfriimE
              Efriim @mitu
              last edited by Efriim

              @mitu
              The setting looks like this from emu.cfg
              Dreamcast.RTC = 1543281985

              The nvram needs to be within a number of seconds of this setting, that is why it asks for the time/date even if it has already been saved in the nvram.

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

                @Efriim This could happen if the kill command fails. After 2 seconds annother kill command with -9 parameter is send to process and this will terminate the emulator. The only way I see is to use the NET commands retroarch offers. There you can send key commands to proper exit the core. Let me think about it ..,

                1 Reply Last reply Reply Quote 0
                • EfriimE
                  Efriim
                  last edited by

                  Though it is only with the standalone reicast, indeed. There must be a passthrough to the sdl to initialize the emulator to its shutdown state.

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

                    @Efriim oh yes and even it's not a libRetro core UDP will also fail. You may find a way to send signal level 15 to this core then it will save the day time

                    1 Reply Last reply Reply Quote 0
                    • EfriimE
                      Efriim
                      last edited by Efriim

                      @cyperghost said in Multi Switch Shutdown Script!:

                      > /dev/null 2>&1

                      This broke some things, mostly only the rc.local stopped working. I shouldn't have added it to rc.local, but It worked with rc.local as long as I'm not fumbling around on other things so much.

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

                        @Efriim Sorry ... I should think more about next time.
                        The output of stdout to /dev/null can't work. Because this output is needed for the python scripts to get response from the script. Maybe just send stderr to /dev/null is better? I did not test so far but I think that makes more sense. Yes, set it for the python script because this causes the error.

                        2>/dev/null

                        Yes /etc/rc.local is used for the retroflag script for automatic startup. But you can also use autostart.sh from emulationstation. That's the way I prefer...
                        You can edit with nano /opt/retropie/configs/all/autostart.sh

                        Broken means your installation does not boot anymore? Oh dear, you may edit the file from a second mashine?
                        About the commands... please don't forget to add an & at last sign. This will send the process to background otherwise the boot progress stops here.

                        EfriimE 2 Replies Last reply Reply Quote 0
                        • EfriimE
                          Efriim @cyperghost
                          last edited by

                          @cyperghost
                          Thanks. I got the rc.local to work again, I left one of these ">" when I deleted /dev/null.

                          When I made reicast from source with /dev/null added to the rc.local I didn't notice any build errors, though when I ran reicast.sh it did give me an error about /dev/null and wouldn't work. I recompiled it and it is not working still. So I guess I was dumb and it had not to do with that.

                          I don't know what is up with reicast, the controller used to work without ever setting it up, and then it stopped and the joyconfig didn't work and now the emulator wont even start.

                          1 Reply Last reply Reply Quote 0
                          • EfriimE
                            Efriim @cyperghost
                            last edited by Efriim

                            @cyperghost
                            Sorry for blaming you. It looked to me that way but I didn't think. They were concatenated in my head as I went from that to this and I apologize.

                            The reicast binary installation still works, maybe building has trouble with my environment or maybe it is just broke. The PS3 controller needed to be removed from the bluetooth and resynced because of the alternative driver, it is working again. And now I just might try to add the > /dev/null 2>&1 for the third time.

                            On top of that my powersupply was halfway falling out of the surge protector, and I couldn't figure out why I was getting low voltage errors, and I got experimental settings going on with 667 sdram_freq. And I couldn't even think of all the things that can't go wrong with /dev/null.

                            Yes the Reicast source is broken and the binary is somewhat broken, there is the older binary in the "working dreamcast games" thread somewhere and I'm using that now. The updated binary works for a while and then crashes on the second round. The errors are a gl get error 0x500 on start and about 15 OMX buffer underruns, which existed with the old version and persist if using "oss"

                            I thought about creating a new thread, it will probably get fixed eventually. Or is it more sensible to add to the github?

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

                              @Efriim said in Multi Switch Shutdown Script!:

                              Sorry for blaming you. It looked to me that way but I didn't think. They were concatenated in my head as I went from that to this and I apologize.

                              There is no need for an apologize, I never felt offended. But nice you sorted this out.

                              Maybe you can give feedback how we can get rid off some error messages.

                              1 Reply Last reply Reply Quote 2
                              • RanmaR
                                Ranma
                                last edited by Ranma

                                Hi, hope I'm OK asking this here. My Google-fu has failed me, and searching has proved complicated.

                                I'm using the Mega-Pi case with your shutdown script and it works brilliantly. However I'd really like to hide the console text on shutdown for cosmetic reasons. I understand that sometimes things go wrong and output is needed when this happens, but I have a backup image and do not intend updating my system. I feel like I've finished my project now and would like to wrap it up with the addition.

                                I did find a comment somewhere that suggested to add >/dev/null 2>&1 to /etc/profile.d/10-retropie.sh. I did this and it removed the "terminated 671" line, but the console prompt remains. This is pretty much what displays before shutting down - alt text

                                I'd like it to simply go to a black screen if possible before shutting off. If you can help that would be very much appreciated. many thanks.!

                                lostlessL 1 Reply Last reply Reply Quote 2
                                • lostlessL
                                  lostless @Ranma
                                  last edited by lostless

                                  @Ranma you need to edit the cmdline.txt file in the /boot directory.
                                  I use this for all my pi projects and it hides all text during bootup and shutdown.

                                  dwc_otg.lpm_enable=0 console=serial0,115200 console=tty3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait usbhid.quirks=0x0079:0x1801:0x40 quiet loglevel=3 consoleblank=0 plymouth.enable=0 quiet logo.nologo
                                  

                                  put it in all as one line.

                                  RanmaR 1 Reply Last reply Reply Quote 1
                                  • RanmaR
                                    Ranma @lostless
                                    last edited by

                                    @lostless Hi thanks for replying. I've already got all that in my cmdline.txt file. I'd already followed a guide to silence the Pi during boot and shutdown, but it doesn't completely work. If I shutdown Retropie via the menu, it's completely quiet, but if I use the button on the Mega-Pi I get the console as above.

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

                                      @Ranma you can try to edit $HOME/.bashrc and play around with it a bit.
                                      The reason for showing the terminal is that the multi_switch script terminates ES and you will be set back to terminal. Maybe it helps to just add a clear command at the end of .bashrc

                                      RanmaR 1 Reply Last reply Reply Quote 1
                                      • RanmaR
                                        Ranma @cyperghost
                                        last edited by

                                        @cyperghost Thanks so much for replying. Could I ask, what would be the best way to do this? I can find a number of commands on the internet but I'm not sure of the best one to try. I've been using Linux for some time but never had to edit ./bashrc at any time in the past so my knowledge is non-existent I'm afraid.

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

                                          @Ranma To be true I have not a real clue about this topic, too. I never ran RetroPie as complete hidden software.
                                          Best way to accomplish this task is to use nano $HOME/.bashrc
                                          then add clear as last command. This will likely reduce your screen to just the prompt. Maybe @mitu can tell how to redirect the complete terminal tty1 to tty3 or so ;)

                                          The clear command gots the advantage that it does not break anything on your current setup. So I consider it as ("breakfail"-)save solution.

                                          RanmaR 1 Reply Last reply Reply Quote 2
                                          • RanmaR
                                            Ranma @cyperghost
                                            last edited by

                                            @cyperghost Excellent, thanks for replying. I added a simple clear at the end of the file and you're right - there's just the login prompt onscreen now. If there's a way to hide that too, that would be even better. Many thanks for your help. :-)

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