HTPC

Installing RetroPie & EmulationStation in XBian

With my media centre and HTPC project coming together, I decided I wanted to add another dimension to the vision.  The system already supports streaming full HD video and high quality music throughout the house, all served from a central point.  The next step was to add a classic gaming system.

There’s more to follow on my media server and (temporary) HTPC set up but as a quick summary:

All media, including centrally controlled libraries for movies, music and games are served by my custom media server.

Due to budget limitations, my media centre project is on-hold but due to the amazing work of the people at Raspberry Pi, it’s possible to build a media centre device that is capable of playing all your music formats and full HD video.  I decided to use XBian, which is a lightweight Linux distribution desdeveloped to host XBMC.

The Hardware

The Raspberry Pi is a remarkably versatile device for it’s cost.  That being said, the hardware does have it’s limitations with a basic CPU and relatively small amount of memory.  However, the hardware accelerated graphics, which support OpenGL ES should be able to provide more than enough power to provide a stable and smooth classic gaming experience.

Or, at least that’s the theory.

The Emulation Platform

The various games consoles produced over the years have all used different hardware and operating systems which means that normally the games we used to play, can’t be played on current systems.

That’s where the emulator comes in.  Emulators interpret the instructions known by these old systems and convert them into the logic, graphics and sounds of the games we know and love.   The difficulty comes with the fact that each manufacturer requires a different emulator (eg – a Nintendo emulator won’t play Sega games) and even some platforms may require different emulators (NES, SNES and N64 games would each probably need their own emulator!)

RetroArch

RetroArch is a multi-system emulator that runs on pretty much anything (including Android, iOS and Raspberry Pi!)  The hard work done by the developers at RetroArch makes this whole process much easier.

EmulationStation

My final goal of a play all, seamless media centre would require an easy to use, graphical front end.  Again there are various projects available that simplify this approach.

EmulationStation is a themeable front end that can be used to browse your games collection and launch the required emulator provided by RetroArch (or it’s Raspberry Pi adaptation – RetroPie).  This will hopefully integrate into XBMC nicely but for now and the ease of testing, I’ll be manually running EmulationStation from a command prompt.

Installing RetroPie & EmulationStation in XBian

There’s lots of information available online to help when installing RetroPie but I found little information when it came to installing under XBian.  Since XBian is a watered down version of Raspbian and people have reported various success with Raspbian, I thought it was worth a try.

The installation and setup process was simplified and almost automated by RetroPie-Setup which will download, install and configure both RetroPie and EmulationStation.

So, installing the set up script couldn’t be easier.  First, you need to ensure that the software repositories are up to date.  From an SSH prompt or command prompt enter:

sudo apt-get update
sudo apt-get upgrade -y

Confirm git and dialog are installed and up to date:

sudo apt-get install -y git dialog

Download the latest version of the RetroPie-Setup script to the user’s home directory:

cd
git clone –depth=0 git://github.com/petrockblog/RetroPie-Setup.git

Note – the users home directory for XBian defaults to /home/xbian/.   This is also where the emulators will be installed.

To run the script, first make sure the script is executable and run it as a superuser:

cd RetroPie-Setup
chmod +x retropie_setup.sh
sudo ./retropie_setup.sh

The GUI will now take you through the rest of the process.

You now have the option of installing the emulators from pre-compiled binaries or from the source code.  Installing from binaries is considerably faster but not guaranteed to work as expected and may not provide the most recent versions of each emulator.

I opted for installing and compiling  from source code.  The script warns this may take several hours, some users reported about five hours.  In my case, the full process of downloading and compiling the source code took in excess of nine hours.   This may be due to the fact that I was installing from an SSH prompt and not a direct command prompt.

IMPORTANT NOTE: Leaving the option set to “Install latest Raspberry Pi firmware” may break your XBian installation.  I deselected this option and both EmulationStation and RetroPie run correctly.  For now, I recommend turning this option off.

After a reboot and all being well, you should now have a working installation.  All that remains is to copy your game roms to your memory card or create  a link to the location if they’re stored elsewhere.  I opted for the latter option and will post a separate tutorial on how to do this.

If you’re using XBian and the default installation options (as shown above), the location for your game roms should be /home/xbian/RetroPie/roms/ with a sub-folder for each gaming platform.

Running EmulationStation and Launching Games

To launch EmulationStation, navigate to the installation folder (again if installed with default options, this should be /home/xbian/RetroPie/supplementary/EmulationStation/ and enter:

 emulationstation

Note – this must be done from a direct command prompt.  This stumped me for a while initially when trying to launch EmulationStation for the first time.  Trying to launch from an SSH prompt will result in failure and an unhelpful error message.

Once in the interface, pressing the keys you have assigned to left/right will scroll through the different game platforms.  These are only visible when you have game roms in the corresponding folders.  The up/down keys  should scroll through the various games you have available for that platform.

General Note: All of the commands above are case sensitive and due to the ongoing development of all of the components used in the project, the steps listed are subject to change at any time.

What’s Next?

So, now we have a set up that can play almost any classic game on any console platform that we wish.

But… it’s not very user friendly.  The interface needs to be manually launched from the command prompt and requires the use of an attached keyboard.

So what’s next?

Seamless XBMC Integration

My final goal is to launch games from the XBMC interface, with games browsable similar to the Movies and Music sections.  An intermediate would be to launch EmulationStation from XBMC and depending on the amount of games you have, this may be the preferable option.

Wireless Joypad Control

Using a wireless joypad is certainly possible with XBMC and EmulationStation/RetroPie and is the final piece of the puzzle for my all-in-one, seamless media centre.

Super Mario Bros (NES)

Well, that’s it.  Feel free to leave any comments/questions below, or even share your experiences.

18 Comments

    1. I’ve exited XBMC to get to the terminal. Either via an option in the skin which shuts down XBMC and returns me to the prompt. Or, it can be done if you’re already in an SSH session, you can run the following command to cleanly shut XBMC down:

      /etc/init.d/xbmc stop

      I know this isn’t ideal as I’d rather keep XBMC running so I can return when finished with EmulationStation. I’m looking to integrate XBMC and EmulationStation asap but haven’t yet experimented with the different options to get the two running seamlessly… It may be as simple as running EmulationStation from something like Advanced Launcher – but this sounds too easy 😉

    1. Hi, unfortunately I’ve not had much time to work on this as another project has taken my attention.

      I have made some progress with other aspects of the media centre and hope to have more info up soon.

  1. I had the exact same idea of a HTPC as you had. I chose xbian because it has great performance even when i play HD videos at the same time as i play music on my stereo via MPD (silly idea because both are in the same room but at least i can do it ;o)). I also came across RetroPie and installed it via SSH and thats where i am stuck. I can not get into a terminal session, not with “/etc/init.d/xbmc stop” and not with the gui (Exit) nor can i start EmulatorStation from Advanced Launcher within XBMC. Any pointers?

  2. Any news on this project? I also tried to make Xbian an all-in-one solution like you described but i cant even get to a terminal session, neither with “/etc/init.d/xbmc stop” via ssh nor via the gui.

    1. What version of XBian are you using?

      Also, what output do you get when trying to exit XBMC using the “/etc/init.d/xbmc stop” method (either in the shell session or on screen)?

      1. From the ssh i get:

        xbian@xbian ~ $ /etc/init.d/xbmc stop
        -bash: /etc/init.d/xbmc: No such file or directory
        xbian@xbian ~ $ sudo /etc/init.d/xbmc stop
        [sudo] password for xbian:
        sudo: /etc/init.d/xbmc: command not found

        and when i try to shut down from gui (exit) or kill the task using top i get nothing but a black screen.

        I am using the most current xbian version (1.1) with all updates but the last firmware update (breaks shutdown).

        Sorry for double post.

        1. It looks like the init script is missing. (The XBian version you’re using is a more recent version than the one I was on… Wouldn’t expect the script to have been removed though!)

          I should be able to take more of a look tomorrow but in the meantime, try looking in the /etc/init.d directory to see if there’s any reference to XBMC.

          Edit: or try the following (needs to be done as a superuser so if ‘sudo’ doesn’t work try ‘sudo su’):
          sudo service xbmc stop

  3. Any updates? I’ve been battling a single-card XBMC+RetroPie build for days now. First tried to set up BerryBoot, but after hours and hours I never could get everything to work right. I’d be ecstatic to have everything running out of XBMC.

  4. Thank you very much for your input! Got it to work. As you already have mentioned the final step is to interate it with xbmc (a script maybe that starts emulatorstation on xbmc exit and/or vice versa). Just played tetris on my tv and it felt good and wrong at the same time.

    1. Glad you got it working. I’ve found playing Super Mario (NES version) is quite enjoyable on a big screen and reminds me of the NES console I used to play in the local toy store.

  5. I’m trying the same setup at the moment. Using the Rom Collection Browser would be my favourite setup. For now I still have to tinker with it a litte bit more to work with my different Emulators and Solo Mode.

    But if you want to use the emulationstation maybe you want to try Advanced Launcher: (http://forum.xbmc.org/showthread.php?tid=85724).

    Not quite sure if this performs well (emulationstation + xbmc startet at the same time) but you wouldn’t need to get into the shell manually.

    1. I have been experimenting with launching emulationstation from Xbian’s kodi via the advanced launcher add-on on a Raspberry Pi 2.

      It works, but not quite as hoped in that there is no keyboard input in ES, making it impossible to exit by pressing F4 (the process needs to be killed via SSH). I have tried running a shell script from advanced launcher that stops the Kodi service, runs ES and restarts the Kodi service when ES exits – all in a ‘detached’ process. No joy.

      It seems to me that the only way Kodi and ES can co-exist at present is to alternate between them when either is exited. At least this way both programs can enjoy exclusive use of available resources.

      Unfortunately, this would appear to mean either fudging with Kodi’s service script or not using the service mechanism at all and creating a custom init script instead. Pity.

      1. What did you end up doing to get the launch from Kodi in the advanced launcher? I’m new to LInux/Raspberry Pi and Kodi but I have the two setup and I use a gamepad controller to navigate around ES. So I don’t think I’ll have the same concern you did when trying to get the two to work together. How do I get the Advanced launcher setup like you spoke about… thanks

  6. If I start emulationstation while kodi is not running, the keyboard and both gamepads are reacting when I press buttons or keys.
    When I start emulationstation while kodi is running (Advanced launcher or extra menu item in Home.xml or from ssh shell) the keyboard and gamepads are not responding. The startup screen from emulationstation says “2 Gamepads detected” but nothing happend if I press gamepad buttons. If I press one of the Arrow keys on the keyboard I can hear kodi menu sounds while emulationstation is on the foreground. Is there a way to “move” the input devices to the launched program? Does someone can think of examples of addons or advanced launched programs that run outside kodi to compare with?

Leave a Reply