bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

[Solved] Autostart Emulationstation

Sun Apr 13, 2014 7:21 pm

ok so let me start by saying that I do not have a normal retropie setup.

I have installed rasbian weezey and then compiled retropie on top of that and also compiled xbmc on same iso.

basically all in one (I know its been done before but I want to do it myself from scratch)

I have everything working great and able to startx and xmbc through emulationstation

now my only problem is getting emulatinstation to start automatically.

I have managed to get it to start automatically but when it does it just hangs at the black screen with the white dot (same as if I run sudo emulationstation)

the script I have set up to run at startup is as follows

#! /bin/sh
emulationstation

any suggestions? any idea how I could make this run as the user pi (since thats when it works)?
Last edited by bakan723 on Thu Apr 17, 2014 6:43 pm, edited 1 time in total.

jayminer
Posts: 44
Joined: Sun Jul 07, 2013 3:33 pm

Re: Autostart Emulationstation

Sun Apr 13, 2014 8:17 pm

Where have you put the script now, it sounds like it's being ran as root, if this is a problem you're usually getting while starting it via sudo. You could try to start it as a cronjob instead, and run it as your normal user. From a terminal type "crontab -e" which will launch a texteditor to edit the crontab file. At the end of it add:

"@reboot emulationstation" (without the ") and be sure to save the file. Hopefully this will work but haven't tried it myself.

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Sun Apr 13, 2014 8:57 pm

i have made the emulationstaion.sh in /etc/init.d/emulationstation.sh and with your suggestion it still hangs at boot (black screen white dot)

jayminer
Posts: 44
Joined: Sun Jul 07, 2013 3:33 pm

Re: Autostart Emulationstation

Sun Apr 13, 2014 9:08 pm

You should remove that script from init.d, otherwise they will'clash'

Or you could try and change the script to run 'su - pi emulationstation' (this is from memory, might be a different syntax, and pi should be replaced by the name of your user if you have changed it)

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Sun Apr 13, 2014 9:15 pm

sorry i am new to this, I think that I am doing some things wrong.

If I delete the emulationstation.sh via sudo rm /etc/init.d/emulationstation.sh I get an error during boot that says startpar: service returned failure : emulationstation.sh

I can still log in and run it just fine

and as far as your previous instructions was there something else I was supposed to do other than add that one line of code?

jayminer
Posts: 44
Joined: Sun Jul 07, 2013 3:33 pm

Re: Autostart Emulationstation

Sun Apr 13, 2014 9:49 pm

I don't have any experience of adding things to init.d so I'm not sure where that error is coming from, but it sounds like it's referenced from somewhere else, did you edit any other file when you put the script there?

And no, you should not have to do anything else after running crontab -e than to add that line, I remember crontab can be picky about needing a linebreak at the end of the line (just enter), it should say something like installing new crontab, the command should be run as your normal user, no sudo or anything like that.

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Sun Apr 13, 2014 10:21 pm

I also get it to start using /etc/rc.local but again same problem hangs at the white dot

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Sun Apr 13, 2014 11:40 pm

ok so it is definetly a issue with emulationstation being run as root and not as pi.

I need it to be run as user pi in order for it to work for some reason.

does anyone know a way I can automatically run emulationstation as pi after login either via rc.local or crontab or init.d I am just lost.

I get all three to run as root but can not figure out how to run them as pi

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Mon Apr 14, 2014 4:28 am

I got emulationstation to autostart by following what retropie did in the setup script...

Auto login and boot of emulation station:

In /etc/inittab:

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
# change for auto login
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

In /etc/profile:

# if SSH connection do nothing, else launch emulationstation
# (first construct checks that SSH_CONNECTION is set to something)
[ -n "${SSH_CONNECTION}" ] || /home/pi/EmulationStation/emulationstation

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 8:14 pm

I will try this now, but it seems you have a different folder structure than I do as my emulation station is located in /usr/bin/emulationstation. I have no folder in my pi folder called EmulationStation.

also I have tried using the retropie install to autostart emulationstation and I get the same result, black screen white dot

the only way I can get this to work is to wait for the pi user to be auto logged in and then to manually type emulationstation

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 8:54 pm

ok I have tried your method via the profile file and can not get it to function propperly. I have used the line just like you gave it, I have also tried other setups like [ -n "${SSH_CONNECTION}" ] || /usr/bin/emulationstation , and /home/pi/emulationstation and none of the three have worked.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Mon Apr 14, 2014 9:23 pm

This part does an autologin, but assumes your user is "pi". If it's not "pi" you need to update it accordingly. Also note the first line is me commenting out the old behavior, which you need to do as well:
In /etc/inittab:

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
# change for auto login
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
This is what starts emulationstation, but it assumes emulationstation is located in /home/pi/EmulationStation/ (so again, you would need to update it if your location is different)

Code: Select all

In /etc/profile:

# if SSH connection do nothing, else launch emulationstation
# (first construct checks that SSH_CONNECTION is set to something)
[ -n "${SSH_CONNECTION}" ] || /home/pi/EmulationStation/emulationstation

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 9:29 pm

yes I know about the autologin I have that done already and working. Yes I use the user pi.

I have changed the location in the profile file to my location /usr/bin/emulationstation and it is still not working.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Mon Apr 14, 2014 10:15 pm

How exactly do you launch emulationstation from the command line? If you do it the same way in /etc/profile then it should work (as this file is executed at login). The only thing the "[ -n "${SSH_CONNECTION}" ] || " part does is prevent it from running when you login via ssh.

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 10:33 pm

to run it from commandline i just type "emulationstation" minus the ""

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 10:48 pm

by the way thank you for all the help, I have made a few posts on these forums about other things and have not got so much as a single answer. So thank you again it is much appreciated.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Mon Apr 14, 2014 11:04 pm

No problem, happy to help. What path does it show if you type "which emulationstation" ?

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Mon Apr 14, 2014 11:14 pm

/usr/bin/emulationstation

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Tue Apr 15, 2014 12:27 am

Hmmm... not sure what to suggest.

If you've added this to your /etc/profile:

Code: Select all

[ -n "${SSH_CONNECTION}" ] || /usr/bin/emulationstation
Made sure to save the change, and then rebooted your pi, it should be starting emulationstation.

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Tue Apr 15, 2014 2:04 am

ok now I have tried again and it is now showing an error
lv10: Error initializing SDL!
unable to open mouse
lv10: renderer failed to initialize!
lv10: Window failed to initialize!

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Thu Apr 17, 2014 6:11 am

ok here is something weird.

if I remotely connect to the pi from my pc emulationstation autostarts on my pi

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Autostart Emulationstation

Thu Apr 17, 2014 4:35 pm

Sounds like maybe this command was mistyped (as it's doing the opposite of what's intended in your case):
[ -n "${SSH_CONNECTION}" ] || /usr/bin/emulationstation

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: Autostart Emulationstation

Thu Apr 17, 2014 6:43 pm

ok I was able to get it working by editing the file /home/pi/.bashrc

I added the line

/usr/bin/emulationstation

to the end of the file and it works.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: [Solved] Autostart Emulationstation

Thu Apr 17, 2014 7:00 pm

Yeah, what you did is bypass the SSH connection test that's meant to prevent emulationstation from starting when you telnet to the box. The way you have it now it will always try to start regardless of whether of the box just booted or you've entered a new telnet session.

bakan723
Posts: 28
Joined: Wed Mar 26, 2014 12:46 am

Re: [Solved] Autostart Emulationstation

Thu Apr 17, 2014 7:14 pm

That is ok for my setup since using puty to ssh in still works fine and I rarely use remote connect. Mostly it is used with mouse and keyboard or controller.

Return to “Gaming”