Emulation Station Battery optimization for RapberryPi Zero

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
User avatar
Hex
Posts: 113
Joined: Tue Aug 16, 2016 12:10 am
Has thanked: 12 times
Been thanked: 47 times

Emulation Station Battery optimization for RapberryPi Zero

Post by Hex » Fri Apr 28, 2017 2:48 pm

NOTE: This has been already implemented into the Retropie ES. Option is present in Settings>OtherSettings>PowerSaverModes


Binary Updated for Pi Zero and 1

While working on my GBZ build I noticed that my PiZero was heating quite a bit when emulation station was idle. So I sshed in and found that the ES was using 65% CPU on average doing nothing. I dug into the code and found the problem. The github fork link is below. It does not work well with video previews but my goal is to save power for the PiZero build. It helps a lot if you are running your build standalone, ie. not connected to wall socket.

My build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

Github ES repo : https://github.com/hex007/EmulationStation

Install from binary
I have attached the binary below. You can download and install on the Pi using:

Code: Select all

// Get Zip of binary
$ wget http://www.sudomod.com/forum/download/file.php?id=5772 -O es.zip

// Extract Zip
unzip es.zip

// Bkp original ES binary and replace with one downloaded
$ sudo mv "/opt/retropie/supplementary/emulationstation/emulationstation" "/opt/retropie/supplementary/emulationstation/emulationstation_bkp"
$ sudo cp "emulationstation" "/opt/retropie/supplementary/emulationstation/emulationstation"

// Reboot 
$ sudo reboot
Or if you prefer to build it
SSH into the pi or hook up a keyboard then to build on Pi :

Code: Select all

// note the pid of emulationstation
$ top
// press q to exit

//Kill emulation station using pid noted above
$ kill PID

// To build on pi zero we need more ram. Get root previleges to turn swap on
$ sudo su
// We define a way to increase the Swap space. Copy after "#" till the last "}" and paste into terminal
# function rpSwap() {
    local command=$1
    local swapfile="$__swapdir/swap"
    case $command in
        on)
            rpSwap off
            local memory=$(free -t -m | awk '/^Total:/{print $2}')
            local needed=$2
            local size=$((needed - memory))
            mkdir -p "$__swapdir/"
            if [[ $size -ge 0 ]]; then
                echo "Adding $size MB of additional swap"
                fallocate -l ${size}M "$swapfile"
                chmod 600 "$swapfile"
                mkswap "$swapfile"
                swapon "$swapfile"
            fi
            ;;
	off)
            echo "Removing additional swap"
            swapoff "$swapfile" 2>/dev/null
            rm -f "$swapfile"
            ;;
    esac
}
// Increase Swap space
# rpSwap on 512
// Exit from superuser shell
# exit

// Clone Repository
$ git clone --depth 1 --recurse-submodules https://github.com/hex007/EmulationStation

// Build EmulationStation
$ cd EmulationStation
$ cmake ./
$ make
// This will take a long time ~ 1.5-2 Hrs

// Once build is successful, bkp original ES binary and replace with one just built
$ sudo mv "/opt/retropie/supplementary/emulationstation/emulationstation" "/opt/retropie/supplimentary/emulationstation/emulationstation_bkp"
$ sudo cp "emulationstation" "/opt/retropie/supplementary/emulationstation/emulationstation"

// Reboot 
$ sudo reboot
Attachments
emulationstation.zip
(1.33 MiB) Downloaded 288 times
Last edited by Hex on Tue Apr 10, 2018 2:58 pm, edited 5 times in total.
Sent from 20,000 leagues under the sea

My Cardboard GBZ build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

EmulationStation optimization for Pi Zero : http://www.sudomod.com/forum/viewtopic.php?f=8&t=2922

McGyver
Posts: 226
Joined: Tue Jan 31, 2017 11:06 am
Location: Tianjin / China
Has thanked: 25 times
Been thanked: 53 times

Re: Emulation Station speedups for RapberryPi Zero

Post by McGyver » Mon May 01, 2017 10:03 am

I tried your updated version of emulationstation via zip file. My problem: after reboot emulationstation does not start up again! The retropie just boots into the command prompt. Any idea?

User avatar
Hex
Posts: 113
Joined: Tue Aug 16, 2016 12:10 am
Has thanked: 12 times
Been thanked: 47 times

Re: Emulation Station speedups for RapberryPi Zero

Post by Hex » Mon May 01, 2017 1:36 pm

McGyver wrote:
Mon May 01, 2017 10:03 am
I tried your updated version of emulationstation via zip file. My problem: after reboot emulationstation does not start up again! The retropie just boots into the command prompt. Any idea?
Did you replace the binary properly?

You have to extract the binary from Zip file and substitute the original with the modded. If you can attach a keyboard then you can do this directly from the Pi.

Can you tell me what steps you took so I can help you out.
Sent from 20,000 leagues under the sea

My Cardboard GBZ build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

EmulationStation optimization for Pi Zero : http://www.sudomod.com/forum/viewtopic.php?f=8&t=2922

McGyver
Posts: 226
Joined: Tue Jan 31, 2017 11:06 am
Location: Tianjin / China
Has thanked: 25 times
Been thanked: 53 times

Re: Emulation Station speedups for RapberryPi Zero

Post by McGyver » Mon May 01, 2017 2:16 pm

Via Terminal connected on SSH I did:
1: wget http://www.sudomod.com/forum/download/file.php?id=5057 -O es.zip (download your zip)
2: unzip es.zip (unzip...)
3: sudo cp "emulationstation" "/opt/retropie/supplementary/emulationstation/emulationstation" (move your version over the original one)
4: sudo reboot (reboot)

After reboot, emulationstation didn`t start, just the command promt...

User avatar
Hex
Posts: 113
Joined: Tue Aug 16, 2016 12:10 am
Has thanked: 12 times
Been thanked: 47 times

Re: Emulation Station speedups for RapberryPi Zero

Post by Hex » Mon May 01, 2017 6:09 pm

You have to kill the process for Emulationstation first and then copy the binary

Code: Select all

// Find EmulationStation PID using:
top
// note the PID and Press q to exit from top
kill PID
sudo cp ........................
Screenshot from 2017-05-01 17-07-56.png
Screenshot from 2017-05-01 17-07-56.png (98.48 KiB) Viewed 12004 times
Sent from 20,000 leagues under the sea

My Cardboard GBZ build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

EmulationStation optimization for Pi Zero : http://www.sudomod.com/forum/viewtopic.php?f=8&t=2922

McGyver
Posts: 226
Joined: Tue Jan 31, 2017 11:06 am
Location: Tianjin / China
Has thanked: 25 times
Been thanked: 53 times

Re: Emulation Station speedups for RapberryPi Zero

Post by McGyver » Wed May 03, 2017 1:26 pm

I stopped emulationstation by kill + PID. Same bad news: after replacing the original emulationstation to your one the Pi just boots into the console pi@retropie:~ $

User avatar
Hex
Posts: 113
Joined: Tue Aug 16, 2016 12:10 am
Has thanked: 12 times
Been thanked: 47 times

Re: Emulation Station speedups for RapberryPi Zero

Post by Hex » Wed May 03, 2017 4:02 pm

Well at least you can restore it cleanly by reinstalling from binary.

Are you using Pi Zero/1 or 2/3??? The binary is only for PiZero or 1.

Also verify the md5
md5sum : 59d9aec4d5d524d525714d4f70c83cd5
Sent from 20,000 leagues under the sea

My Cardboard GBZ build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

EmulationStation optimization for Pi Zero : http://www.sudomod.com/forum/viewtopic.php?f=8&t=2922

kendon
Posts: 13
Joined: Thu Mar 02, 2017 5:22 am
Location: Germany
Has thanked: 2 times
Been thanked: 2 times

Re: Emulation Station speedups for RapberryPi Zero

Post by kendon » Thu May 04, 2017 2:05 am

Make sure the file is executable:

Code: Select all

$ ls -l /opt/retropie/supplementary/emulationstation/emulationstation
-rwxr-xr-x 1 root root 4746728 Mar 16 20:41 /opt/retropie/supplementary/emulationstation/emulationstation
If the permissions (-rwxr-xr-x) look any different do:

Code: Select all

sudo chmod 755 /opt/retropie/supplementary/emulationstation/emulationstation

User avatar
Hex
Posts: 113
Joined: Tue Aug 16, 2016 12:10 am
Has thanked: 12 times
Been thanked: 47 times

Re: Emulation Station speedups for RapberryPi Zero

Post by Hex » Thu May 04, 2017 11:06 am

kendon wrote:
Thu May 04, 2017 2:05 am
Make sure the file is executable:

Code: Select all

$ ls -l /opt/retropie/supplementary/emulationstation/emulationstation
-rwxr-xr-x 1 root root 4746728 Mar 16 20:41 /opt/retropie/supplementary/emulationstation/emulationstation
If the permissions (-rwxr-xr-x) look any different do:

Code: Select all

sudo chmod 755 /opt/retropie/supplementary/emulationstation/emulationstation
The file is executable by default. I tested it on stock RetroPie 4.2, so it should work.
Sent from 20,000 leagues under the sea

My Cardboard GBZ build : http://www.sudomod.com/forum/viewtopic.php?f=9&t=2851

EmulationStation optimization for Pi Zero : http://www.sudomod.com/forum/viewtopic.php?f=8&t=2922

McGyver
Posts: 226
Joined: Tue Jan 31, 2017 11:06 am
Location: Tianjin / China
Has thanked: 25 times
Been thanked: 53 times

Re: Emulation Station speedups for RapberryPi Zero

Post by McGyver » Thu May 04, 2017 11:38 am

Yes: the checksum from the downloaded file is different!
I struggled to install from source: honestly: your code formatting in the post is really hard to read. Hard so see the differences between your comments and necessary terminal commands...

Can you maybe upload the programm again with the good checksum? In github would be just fine...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest