Posted on

NesPi Retroflag Case Safe Shutdown Reset Power Button Mod

Check out ETAPrime’s new video: NesPi Case Safe Shutdown Reset Button Mod Power Button for the Retro Flag case using a modified version of the 8bitjunkie “easy button” script.

26 thoughts on “NesPi Retroflag Case Safe Shutdown Reset Power Button Mod

  1. hey! Great job on the retroflag script for shutting down the pi safely! I did notice that the script will ONLY work in the retroflag NESPI case. If i take the SD card out and put it in another pi, it starts to go through the startup sequence and shut itself down before it even reaches the intro video.

    When I reinsert it into the PI in the NESPI case, it works as you intended it to. Wondering if there is an easy way to disable the script if I wanted to use the SD card in another PI without the mod?

    Thanks so much!
    Matt

    1. Hm. I don’t think so. It seems like the sensible thing to do would be to use a second sd card. If you clone your existing card, you can put the clone in the retroflag, and then install the non-retroflag script. then you could use that card in a non-retroflag pi

    2. I did the same thing — the same mistake. I happen to have a Linux computer next to me when it happened, though. So I pulled the SD card, installed it into a card reader and then connected the reader to the Linux computer. From there, I was able to find and edit the files installed so they don’t work any longer. (# added comment to the line that calls the python script in the pi_shutdown within /etc/init.d)

      Fixed without re-doing the whole machine. I’ll bet a Linux LiveCD will suffice as well so having a whole Linux machine wouldn’t be needed.

    3. If you absolutely must swap your SD card seamlessly between different Pis, use pin 7 on the GPIO port instead of pin 5 for your reset switch.

      First, edit the shutdown script (/home/pi/scripts/shutdown.py) and change all references to pin 5 to pin 7. The following two lines are the ones that need to be changed.
      GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
      buttonState1 = GPIO.input(5)
      Just replace 5 with 7.
      Next, physically move the reset wire from GPIO pin 5 to pin 7.
      Now, your system should behave properly. It will safely shut down when you press reset in the modified retroflag case, but it won’t automatically shut down if it is running outside a retroflag case.

      The reason why pin 7 behaves better than pin 5 is because pin 5 is hard wired to a pull up resistor. Without the 150 ohm resistor from the nespi mod pulling it to a low state, pin 5 automatically remains in a high state, which triggers the shutdown script.

      Pin 7, on the other hand, is not hardwired to a pullup resistor. Because of this, the script can initialize it in a low state, and it won’t automatically be in a high state when it is used outside of a modified nespi case.

    4. Matt, that can happen if you leave the pin floating, as it will randomly be floating between 1 and 0. — If you want to use it with no button hooked up, then you should add a jumper (like an old harddrive one) from GPIO3 to ground (third row from the top should do it).

  2. Thank you Chuck for your cool solution. Did someone tried it out? Consider that Pin 7 GPCLK0 can also be used to to output a 1MHz+ clock signal. Is Pin 7 the only Pin that can be used? Thank you for your answer.

  3. I’m getting this error. (6) Could not resolve host: pie.8bit.junkie . Is this file not hosted by 8bit anymore?

    1. It’s pie.8bitjunkie.net

  4. I get “curl: (6) Could not resolve host: bash” at the end

    1. Also before that it says ” exit 0curl:(6) Could not resolve host: l

      1. it’s a pipe “|” not a lowercase letter “L”.

  5. How do you undo the shutdown script so I can put my pi in a different case. Any help would be greatly appreciated.

    1. You can try:

      sudo update-rc.d -f pi_shutdown remove

      Let me know how that works

      1. Did this work? I need to remove the script from mine as well.

  6. I installed following the instructions on a Stretch implementation on my rpi. I get exactly the same problems as reported earlier. The button works after the install, but after a reboot it does nothing. Restarting works of course.
    Should I be changing the installation someway, because I note that the problem claims to have been fixed?

    Thanks for the help

    1. OK, thanks for letting me know. I’ll have to try it and see what might be happening.

  7. Did the update to 4.4 break something? I’ve followed all the instructions more than once, and am not too shabby with (RedHat) Linux commands. The resistor mod will turn it on, but I cannot get the python script to run automatically as intended. If I add it to rc.local without the ‘$’, it runs and the button works as intended however it never completes the boot process. If I add the ‘$’, it does not seem to run at all. If I do a cronjob, it appears to be running…but it does not work. If I add it to /profile, it will run only if I drop to a shell prompt. I’m having a dickens of a time getting it to run in the background as intended. But on the plus side, my hardware is correct, and the script CAN work…

    Any thoughts?

    1. Also have the same problem… Can someone provide a workaround??

    2. Samesies for me. I have a Raspberry Pi 3 Model B V1.2, performed the hw mod and RetroPie 4.2 and 4.3 work fine. Problem is, I found that out AFTER trying 4.4. In v4.4, everything boots fine, but the RESET button does literally nothing. I first made a comment on the listed ETAPrime video before visiting this website to see if there was a solution. Wish I would have read this first before pulling my hair out regarding RetroPie v4.4…

  8. Holy crap I was going bonkers. Atleast its just not me. I am going to go back to 4.3 for now and probably just order the new NESPi+ case.

  9. Hey, very new to this but I haven’t seen anyone else with this issue yet.

    I did this mod on my case and ran the script for adding the safe shutdown. All seems to go well and it says it is installed, then auto shuts down? When I boot back up, the button does nothing. In the instructions he tells you to reboot, but it doesn’t automatically do it for him. Not sure if I’m doing something wrong or if the program has been updated since the video was made.
    In any case, neither shutdown or boot up works with my reset button. I just don’t know if it’s my modifications or the code since I couldn’t check line by line before it shut itself off.

    Any help appreciated

  10. I had the same symptoms, and believe I have a fix.

    My setup:
    Nespi Case
    Retropie v4.4
    ETAPrime hardware mods
    Successful installed the software:
    curl https://pie.8bitjunkie.net/shutdown/setup-retroflag-shutdown.sh | bash

    Result: The pi_shutdown process still would not launch

    To see if the process is running, in the shell, type:
    ps -leaf | grep shutdown

    You should see something like:
    pi@retropie:~ $ ps -leaf | grep shutdown
    4 S root 533 1 0 80 0 – 2165 – 22:24 ? 00:00:00 sudo python /home/pi/scripts/shutdown.py
    4 S root 542 533 0 80 0 – 2425 – 22:24 ? 00:00:00 python /home/pi/scripts/shutdown.py
    0 S pi 705 607 0 80 0 – 1194 pipe_w 22:29 pts/0 00:00:00 grep –color=auto shutdown

    The fix was to edit /etc/rc.local, and launch the script from there, appending the line with the ampersand character so that it runs in the background, and does not halt the boot process.
    This is my rc.local file:

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will “exit 0” on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # 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
    sudo python /home/pi/scripts/shutdown.py &
    exit 0

    I don’t know if the sudo part is necessary or not, but this worked for me.

    1. Also, I don’t know why I now seem to have two separate “shutdown.py” processes running…. so I’m investigating that quirk, but the reset button now safely shuts down my RetroPie box! Tap it again, and it boots up.

  11. My setup is a nespi case+ and retropi rev b pcb with the 4.4.4 software.

    I had a night mare of time installing the github software, so I looked for an alternative to get this case working and I came across this youtube video.

    The script installed perfectly.

    I noticed when I went to do the Resistor mod, I noticed I had a later rev pbc board. It has the markings below
    “180408”
    “POWER D6”
    It also has a on/off switch installed.

    I’m not sure where to jumper the resistors on this newer pcb

    Additionally when I try to power up this board, it turns on briefly then shuts down so I cant remove this script.

    please advise on how to proceed
    thanks

  12. Steve’s solution work..

    I did modify it a little so executing the script is silent and errors are loged.

    Ad this to RC.local above exit 0

    sudo bash -c ‘/usr/bin/python3 /home/pi/scripts/shutdown.py > /home/pi/scripts/shutdown.log 2>&1’ &

  13. Tried Chuck’s solution , to change Gpio 5 to Gpio 7 ..

    this does work for shutdown , but it will not restart the pi again by pressing the reset button again after shutdown.

Leave a Reply

Your email address will not be published. Required fields are marked *