RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    METADATA not saving - Favorites will never remain tagged

    Scheduled Pinned Locked Moved Help and Support
    nespi casemetadata issuesfavoritesshutdown scriptgameslist.xml
    121 Posts 7 Posters 19.8k 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 @Yahmez
      last edited by cyperghost

      @yahmez Can you test the script on your build, too?
      @mitu Python is very cool - indeed. But I also checked the way GPIOs are called. It's BCM mode. So Python GPIO = Bash GPIO

      YahmezY 1 Reply Last reply Reply Quote 0
      • YahmezY
        Yahmez @cyperghost
        last edited by

        @cyperghost I will give it a try this weekend if I can but I have relatives coming to stay so I'm not 100% sure I'll be able to till next week.

        cyperghostC 1 Reply Last reply Reply Quote 1
        • YahmezY
          Yahmez
          last edited by

          @Semper-5
          Can you try gpio readall to verify that the on control pin is high?

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

            @yahmez No problem... I would be glad to hear your outfindings but take your time.

            YahmezY 1 Reply Last reply Reply Quote 0
            • YahmezY
              Yahmez @cyperghost
              last edited by

              @cyperghost I am no coding guy. Does your BASH script enable the internal pullup on 25?

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

                @yahmez No! I don't use wiringpi.... or raspi-gpio.

                But would be possible with bash, too

                raspi-gpio set $trigger_pin ip pu
                echo "monitoring BCM $trigger_pin"
                
                pin_state() {
                    raspi-gpio get $trigger_pin | grep -c "level=0 fsel=0 func=INPUT"
                }
                
                shutdown_trigger() {
                    if [ `pin_state` = 1 ]; then
                        echo "BCM $trigger_pin asserted low"
                ....
                
                YahmezY 1 Reply Last reply Reply Quote 0
                • YahmezY
                  Yahmez @cyperghost
                  last edited by

                  @cyperghost That is the problem then, at least part of it.

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

                    @yahmez afaik this should work without the pullup. As I said, I sadly have no POLOLU switch available. Is there no connection to ground from the POLOLU to the GPIO?

                    YahmezY 1 Reply Last reply Reply Quote 0
                    • S
                      Semper 5
                      last edited by Semper 5

                      sorry for the late reply. I'm trying to get out of work.
                      my GPIO config is exactly as configured in Yahmez's tutorial.
                      23 reset
                      24 power
                      25 power (ON)

                      my GPIO readall with cyperghost's script
                      but as we see here, its not looking very live.

                      just as a reminder, I can get Yahmez's to fire up with no problem - just to rule out the possibility of bad wiring and I did confirm that my wiring looked good to a few other people who are VERY familiar with this mod.

                      EDIT: SORRY I didn't run the gpio readall with the script running. GPIO 25 has a difference now

                      cyperghostC YahmezY 2 Replies Last reply Reply Quote 1
                      • YahmezY
                        Yahmez @cyperghost
                        last edited by Yahmez

                        @cyperghost No. It will absolutely not work without the pullup. There is a reason I put it in my script :p

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

                          @semper-5 Why is GPIO25 set low? Okay corrected now.
                          @Yahmez Okay, that's interesting.... but I think it's no problem to integrate the script into yours. So I would suggest to remove the GPIO init and just make a call to to PID detection/removal routine.

                          1 Reply Last reply Reply Quote 0
                          • YahmezY
                            Yahmez @Semper 5
                            last edited by

                            @semper-5 Looks like the script is not setting GPIO 25 high according to your GPIO readall

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

                              @Semper-5 Use sudo command for this

                              echo "$GPIOpin2" > /sys/class/gpio/export
                              echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
                              echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
                              

                              With GPIOpin2=25 it will be a self runner ;)

                              @Yahmez Ah so you tried out without using the pullups? That's interesting. So I should investigate this ;) As I said: No POLOLU switch, no testing area.

                              So I say thank you to both of you! You should integrate a small 3,3V regulator. Then it's no problem to generate this. So intead of

                              python os.system("sudo shutdown -h now")

                              hook to a stripped down script with sudo command

                              # Detect PID or EMULATOR NAMES
                              emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)"
                              espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")"
                              
                              # Handle calls and send TERM signal
                              if [[ -n "$emucall" ]]; then
                                  emupid="$(pgrep -f "$emucall" | tr '\n' ' ')"
                                  pkill -P "$(echo $emupid | tr ' ' ',')"
                                  kill -9 "$emupid"
                                  sleep 4
                              fi    
                              
                              if [[ -n "$espid" ]]; then
                                  touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown
                                  kill "$espid"
                                  exit
                              fi
                              
                              poweroff
                              
                              YahmezY 2 Replies Last reply Reply Quote 0
                              • YahmezY
                                Yahmez @cyperghost
                                last edited by

                                @cyperghost it's not just the Pololu, but the way everything is wired in the case, the existing switches plus the added parts to convert it for safe shutdown. The Pololu on it's own is straight forward. Pin 25 has a diode between it's self and the switch to protect it from the 5v. It's internal pullup pulls it high. When you hit the switch it connects to ground and pulls gpio 25 down, which the script detects and initiates the shutdown.

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

                                  @Yahmez But what is the difference to connect a GPIO directly to ground (maybe over an external resistor) or to activate the internal ones? I see there no difference. Maybe you can explain, me?

                                  The internal pullup prevents from floating... yes.. but where is the difference?

                                  1 Reply Last reply Reply Quote 0
                                  • YahmezY
                                    Yahmez @cyperghost
                                    last edited by Yahmez

                                    @cyperghost Not sure what you mean about the 3.3v regulator but the pin needs a pull-up resistor to work. It can be a physical resistor added to the circuit from the pi's 3.3v rail or it can be the internal pullup. I used the internal pullup in my tutorial because it was cheaper and easier.

                                    You want the pin to be high by default, detect a low, then shutdown.

                                    If you can get the internal pullups working thru bash, it should all work. If you can not, than how about stripping out the shutdown part from my script and calling the bash to exit es and shutdown? Basically have the python handle the pins and the bash handle the exit and shutdown...

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

                                      @yahmez Well a regulator would convert the 5.0V to 3.3V (just a few cents) are use the internal 3.3V rail... or strip down the script ... Already done here

                                      Thank you for your patience and helpfull explaination. So it would be nice that you would implent this in your scripts.
                                      It has to be excuted with sudo command

                                      YahmezY 1 Reply Last reply Reply Quote 0
                                      • YahmezY
                                        Yahmez @cyperghost
                                        last edited by

                                        @cyperghost no problem. Unfortunately, I do not have the knowledge to properly incorporate your script into mine. At best, it would be trial and error on my part. Perhaps @Semper-5 can tinker with it though.

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

                                          @yahmez Well.... I can also try to deal with raspi-gpio
                                          Let us work together on this if you want.
                                          sudo apt install raspi-gpio will install a 66kB binary

                                          help page ;)

                                            raspi-gpio get [GPIO]
                                          OR
                                            raspi-gpio set <GPIO> [options]
                                          OR
                                            raspi-gpio funcs [GPIO]
                                          OR
                                            raspi-gpio raw
                                          
                                          Valid [options] for raspi-gpio set are:
                                            ip      set GPIO as input
                                            op      set GPIO as output
                                            a0-a5   set GPIO to alternate function alt0-alt5
                                            pu      set GPIO in-pad pull up
                                            pd      set GPIO pin-pad pull down
                                            pn      set GPIO pull none (no pull)
                                            dh      set GPIO to drive to high (1) level (only valid if set to be an outpu$
                                            dl      set GPIO to drive low (0) level (only valid if set to be an output)
                                          Examples:
                                            raspi-gpio get              Prints state of all GPIOs one per line
                                            raspi-gpio get 20           Prints state of GPIO20
                                            raspi-gpio set 20 a5        Set GPIO20 to ALT5 function (GPCLK0)
                                            raspi-gpio set 20 pu        Enable GPIO20 ~50k in-pad pull up
                                            raspi-gpio set 20 pd        Enable GPIO20 ~50k in-pad pull down
                                            raspi-gpio set 20 op        Set GPIO20 to be an output
                                            raspi-gpio set 20 dl        Set GPIO20 to output low/zero (must already be se$
                                            raspi-gpio set 20 ip pd     Set GPIO20 to input with pull down
                                          

                                          @Semper-5 Ready for some tests?

                                          S 1 Reply Last reply Reply Quote 0
                                          • S
                                            Semper 5 @cyperghost
                                            last edited by

                                            @cyperghost oh I'm excited to do some testing :)

                                            Forgive me in advance if my replies are a bit far and few between this weekend. I packed up my system to take home but I'll be doing a lot of errands and driving. I'll check in as frequent as I can. Thank you once again team for your efforts!

                                            Let's kick this can of worms!

                                            cyperghostC 1 Reply Last reply Reply Quote 1
                                            • 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.