Page 1 of 1

[Solved] Autostart Emulationstation

Posted: Sun Apr 13, 2014 7:21 pm
by bakan723
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)?

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 8:17 pm
by jayminer
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.

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 8:57 pm
by bakan723
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)

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 9:08 pm
by jayminer
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)

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 9:15 pm
by bakan723
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?

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 9:49 pm
by jayminer
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.

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 10:21 pm
by bakan723
I also get it to start using /etc/rc.local but again same problem hangs at the white dot

Re: Autostart Emulationstation

Posted: Sun Apr 13, 2014 11:40 pm
by bakan723
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

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 4:28 am
by cacophony555
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

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 8:14 pm
by bakan723
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

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 8:54 pm
by bakan723
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.

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 9:23 pm
by cacophony555
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

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 9:29 pm
by bakan723
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.

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 10:15 pm
by cacophony555
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.

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 10:33 pm
by bakan723
to run it from commandline i just type "emulationstation" minus the ""

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 10:48 pm
by bakan723
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.

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 11:04 pm
by cacophony555
No problem, happy to help. What path does it show if you type "which emulationstation" ?

Re: Autostart Emulationstation

Posted: Mon Apr 14, 2014 11:14 pm
by bakan723
/usr/bin/emulationstation

Re: Autostart Emulationstation

Posted: Tue Apr 15, 2014 12:27 am
by cacophony555
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.

Re: Autostart Emulationstation

Posted: Tue Apr 15, 2014 2:04 am
by bakan723
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!

Re: Autostart Emulationstation

Posted: Thu Apr 17, 2014 6:11 am
by bakan723
ok here is something weird.

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

Re: Autostart Emulationstation

Posted: Thu Apr 17, 2014 4:35 pm
by cacophony555
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

Re: Autostart Emulationstation

Posted: Thu Apr 17, 2014 6:43 pm
by bakan723
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.

Re: [Solved] Autostart Emulationstation

Posted: Thu Apr 17, 2014 7:00 pm
by cacophony555
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.

Re: [Solved] Autostart Emulationstation

Posted: Thu Apr 17, 2014 7:14 pm
by bakan723
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.