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.9k 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 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
        • cyperghostC
          cyperghost @Semper 5
          last edited by cyperghost

          @semper-5

          Please install raspi-gpio, this tool gives BASH control over internal pullup resistors ;)
          install with sudo apt install raspi-gpio
          That are just 66kB ;)

          Then copy script as done times before, make it executable and execute it in SSH ;)
          I'm not sure if it needs sudo privileges.

          1. If it is not working, then you may alter until [[ $power == 0 ]] from 0 to 1
          2. If this is sill not working then alter raspi-gpio set $GPIO_powerswitch ip pu from pu to pd
            So all in all you have 4 possibilites ;)

          then the new switch.sh

          #!/bin/bash
          # End Emulationstation if condition of running binary is true (v1.7)
          # v1.00 07/21/17 by cyperghost - Inital run 
          # v1.50 07/27/17 - Great step to exit ES even if emulators is running by runcommand.sh are started // meleu
          # v1.56 07/30/17 - All emulators will be detected. // meleu
          # v1.58 08/02/17 - generel method: Use PPID to detect child PIDs now (ScummVM fix) // cyperghost
          # v1.59 11/14/17 - Inserted newest emucall detection // meleu
          # v1.60 04/20/18 - added kill -9 to terminate emulators // julenvitoria
          # v1.70 version for NESPi case // Yahmez, Semper-5
          
          # Please install raspi-gpio via sudo apt install raspi-gpio before!
          
          #this is the GPIO pin connected to POWER SWITCH
          GPIO_powerswitch=24
          
          #this is the GPIO pin connected to POWER ON CONTROL
          GPIO_powerctrl=25
          
          # Init ...
          raspi-gpio set $GPIO_powerswitch ip pu
          raspi-gpio set $GPIO_powerctrl op dh
          
          until [[ $power == 0 ]]; do
              power=$(raspi-gpio get $GPIO_powerswitch | grep -c "level=1 fsel=0 func=INPUT")
              sleep 1
          done
          
          # 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([^.]|$)")"
          
          echo "Button Pressed pullup going from 1 to 0: $power"
          echo "ES-PID: $espid"
          sleep 5
          
          # 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
          
          echo "Script terminated not by ES!"
          

          Thanks for your patience!


          @Yahmez I tested the script on my old Pi1B+. Just connected a momentary push button to GPIO24 and to ground. Works flawless if I press the button. On default (no button action) the GPIO24 status is 1, if the button is pressed the pullup is dropped to 0 and the loop is breaked! Got an excellent knowledge base from you - Thx.

          @Semper-5
          If you need guidance then don't hestiate to ask. But I think the script should work out of the box after installing the raspi-gpio binary

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

            EUREKA! IT WORKS!

            Just some minor bumps in the road...some emulators/ports I can add games/entries and they'll save to favorites but can't be removed (they can be removed but on a power down, power up, they remain added). I'm going to be doing some updating from sources to see if this will fix it, but this is a huge leap in the right way team :D

            Also to add, this has been tested on the 4.4 Retropie image

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

              @semper-5 Thx ;)

              Now I have ready setted script for you!
              This got working power button
              If you press reset and a emulator is running it will fire you back to ES
              If you are in ES and press reset again ES will reload!

              It's uses the same script base as here but is much much extended!

              Use the same procedure to install script as always....

              But now it supports parameters:
              in your case: scriptname.sh --nespicase &

              Get this thread here

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

                @cyperghost I had a chance to update the script to its entirety from your thread and using your parameters, but unfortunately I'm set back a bit.

                I ran the script with its parameter in SSH and it was complaining about not finding commands, but with executing it, it immediately starts a shutdown command and does not keep any favorites tagged. It's a good thing I didn't put it into the autostart.sh or else it'd probably start up and shutdown as soon as ES was loaded.

                SSH output screenshot

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

                  Well I don't know why this is don't running.
                  Did you have raspi-gpio installed?

                  Please do so with sudo apt install raspi-gpio

                  Then cd /home/pi/RetroPie/scripts

                  Then wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh

                  Then run the scripts via SSH
                  ./multi_switch.sh --nespicase &

                  You don't need sudo, you don't need the bash interpreter to call, all automatic done ;)

                  caver01C 1 Reply Last reply Reply Quote 0
                  • caver01C
                    caver01 @cyperghost
                    last edited by

                    @cyperghost I think there is an unmatched single quote' in the script text above, or maybe a " that should be a ' in the emucall. See how the comment # Handle calls and send TERM signal is the wrong color? Something is not right in one of the commands above that.

                    My 4-player cocktail style cabinet built as a custom "roadcase"

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

                      @caver01 No the script is working ;)
                      But raspi-gpio is not installed ;) As command is not found
                      The ticks are taken from the original script.

                      caver01C 1 Reply Last reply Reply Quote 0
                      • caver01C
                        caver01 @cyperghost
                        last edited by

                        @cyperghost Ok, fair enough, but you see how the colors are messed up before that comment, right?

                        My 4-player cocktail style cabinet built as a custom "roadcase"

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

                          Oh... No I get you ;)

                          We are talking about this one here

                          The other script was just for testing purposes if I understand the logic of the NESPICase mod done by @Yahmez

                          By the way..... BASH is also capable of handling the pullup resistors.
                          That's very nice, becasue now you just connect the switch with an GPIO to GROUND!

                          raspi-gpio set YOURGPIONr ip pu sets up internal pull up resistor
                          Now the PULLUP is setted 1 if it's not connected to ground
                          Press the button and connect to ground and the pull is set to 0

                          the logic

                          until [[ $power == 0 ]]; do
                          power=$(raspi-gpio get $GPIO_powerswitch | grep -c "level=1 fsel=0 func=INPUT")
                          done
                          
                          caver01C 1 Reply Last reply Reply Quote 0
                          • caver01C
                            caver01 @cyperghost
                            last edited by

                            @cyperghost Oh. Ok. Wow. That thing is getting pretty huge. I need to dig into this a bit. I like where things are going.

                            My 4-player cocktail style cabinet built as a custom "roadcase"

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

                              @caver01 Yes I posted a comment above

                              but I like also to use the command line parameters

                              --es-pid shows PID of ES binary, if ES isn't running then it's 0
                              --rc-pid shows PID of runcoomand, if no runcommand (=emulator) is running then it's 0

                              kind of swiss knife

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

                                @cyperghost ok we're back to having power button functionality but no metadata saving. I was able to quickly catch it complaining about the gameslist.xml:

                                here's my ES log

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

                                  @semper-5 Set "Save Gamelist on exit" in ES
                                  It's found in MainMenu > Other Settings > Save Metadata on exit (ON)

                                  That's a bit curious, because the scripts save metadata for me. In every usecase now (okay didn't scraped tons of emualtors but I see last played games and last accessed game)

                                  Furthermore, does the reset button works?

                                  If you are in ES main screen and press reset ... it will reload ES (NOT REBOOT!)
                                  if you have an emulator running it will bring you back to ES main screen

                                  EDIT:
                                  I release the next version in a short time
                                  I added ... check user priviliges (if you need root and aren't using sudo, It will stop the script)
                                  I added ... check raspi-gpio package (If not installed, then print error message, and stop the script)

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

                                    @cyperghost yup I checked the Save Metadata on Exit. And the buttons all work great and exactly as you described.

                                    I'm just stumped why I'm getting these lines of errors AGAIN :(
                                    I seriously starting to think I'm cursed or something.

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

                                      @semper-5 I upgraded script with packages check and user priviliges.
                                      If you want to upgrade remove old script with rm multi_switch.sh before using wget!
                                      But this won't help you in your issue now.
                                      Is the metadata is saved on regular exit via main menu?

                                      I'm starting to integrate the NESPi+ for this script!

                                      EDIT:
                                      Even with scraping games, setted to favourites and run the game
                                      Then called script via ./multi-switch.sh --es-poweroff
                                      My scraped data was not removed, game was found in favorites and it was marked as last accesed ;)

                                      So everything is fine!

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

                                        @cyperghost ok I had to wipe everything and start from a fresh image again. that fixed those weird errors with the XMLs.

                                        Power button: works
                                        Reset button: works
                                        Tag favorite games: works
                                        Remove tags: doesn't work

                                        so the only little snag is that you can add favorites but you can never remove them. for some reason ES doesn't unmark/delete the favorites attribute in the gamelist.XML

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

                                          @semper-5 That seems to be a bug in ES itself! I'm using an older version and I can remove the Favourite-tag and it will still be removed after reboot/poweroff done with script

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

                                            @cyperghost ok I figured it out :)
                                            it's a little bit of a bug but totally fixable.

                                            ES uses both gamelist.xml found at /opt/retropie/configs/all/emulationstation/gamelists/"console"/ and /home/pi/RetroPie/roms/"console"/

                                            so if there's no gamelist.xml in the console folder under roms, it will use the one found in configs. for some reason it doesn't remove entries, only adds them.

                                            it will also not untag favorites if you DO have a gamelist.xml in your roms but DON'T have an entry in your gamelist.xml for the tagged favorite game.

                                            Best word of advice: scrape like you've never scraped before lol

                                            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.