An A to Z Beginners Guide to Installing RetroPie on a Raspberry Pi

To find out what you need for this project, please visit the “Materials” page.

__________________________________________________________

MAJOR TIME SAVING UPDATE:

To save a lot of time on the installation of RetroPie, you can actually just head over to the RetroPie Download Site, and grab the “RetroPie Project SD Card Image” – Then unzip that file to a location on your primary computer.  Also, don’t forget there is a donate button there if you feel like sparing some change for the creators of this awesome package.

Once you have that image downloaded, you can use Win32 Disk Imager (as detailed in the next section) to mount the image to the card, and then slap it right into your Raspberry Pi.

By doing this, you bypass the (very) long wait to download and compile the emulators, however, the image may not contain the most up-to-date version of the emulators.

Now you want to plug your Raspberry Pi into a screen via HDMI, plug in the ethernet cable, and plug in your USB Keyboard.  Now power on your Raspberry Pi by plugging it into your Micro USB Power Supply.

Once the Raspberry Pi boots up, it should jump right into EmulationStation and have you map out the controls (keep in mind this does not map controls for the emulators, only the EmulationStation menu) – Just follow through the prompts here.  We will come back later and configure it with the controller, but for now, that is not important.

Once your are done with that, you will be presented with the EmulationStation menu.  We have some other things to take care of, so press F4 to exit EmulationStation.

This will bring you to the terminal.  Type in:

ifconfig

Press enter.

Take note of your IP address, it is the string of numbers following the line “inet addr“.  It will probably look something like “192.168.1.5″ - Write this string of numbers down somewhere.

Back at the terminal type:

sudo raspi-config

And press enter.

Please skip to the section “Software Configuration of the Raspberry Pi”

Initial Setup Of The Raspberry Pi: 
For those who didn’t use the RetroPie Image

  1. Download the latest Raspian Wheezy from www.raspberrypi.org/downloads
  2. Download the latest Win32 Disk Imager from http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml
  3. Plug your SD card into your computer via an SD card reader.
  4. Unzip the contents of the two downloaded files into a folder, and run “Win32DiskImager.exe
  5. Click on the blue folder to the right of the empty box for “Image File
  6. Select the .IMG file of the Wheezy Raspian version that you downloaded (Or the RetroPi Image if you downloaded that).
  7. Open up “My Computer”/”Computer” to check the letter assigned to the SD card you have inserted.  Make note of this letter, if the incorrect drive is selected in the next step, it can re-write all of the data stored on that drive.
  8. Back in Win32 Disk Imager under “Device” select the letter that corresponds with your SD card, the one we made a note of before, and then click “Write(This will take several minutes.)

When this is done, remove the SD card from your computer, and insert it into the SD slot on your Raspberry Pi.

  1. Plug your Raspberry Pi into your video source
  2. Plug your Raspberry Pi into the same router as your primary computer
  3. Plug your USB keyboard into your Raspberry Pi
  4. Now turn on your Raspberry Pi by plugging it into your USB power supply

__________________________________________________________

Software Configuration of the Raspberry Pi:

When your Raspberry Pi has finished its first boot (or you got here from the RetroPie Image section), it should present you with the Raspi-config window.

Select the second option, “expand_rootfs” and press enter. (This will take a few seconds.)

You will be presented with a message saying that the partition will be resized on your next reboot. Press enter.

Configuring the Keyboard

  1. Back at the Raspi-config screen, select the 4th option “Configure_keyboard” and press enter. (This will take a few seconds to load.)
  2. You will be presented with a list. Select the option that best suites your keyboard.  I selected “Generic 105-Key (Intl) PC”.  Press enter.
  3. Select your preferred keyboard layout. I scrolled down to the bottom of the list and selected “Other” and pressed enter. In the expanded list, I chose English(US) and pressed enter. This brought me to keyboard layouts for English(US). I scrolled up to the top and selected English (US). Press Enter.
  4. In the next screen, you can select special options for your keyboard layout. I selected “Default for this keyboard layout”. Press Enter.
  5. In the next menu, you can setup a “Compose Key”, if you would like one of these, you can configure it here. I selected “no compose key.” Press Enter.
  6. The next popup gives you the option to end the X Session with the Ctrl+alt+delete key combo. I selected yes for this and pressed enter.(This is not necessary, but useful to have if you need it, which you probably won’t).

This will bring you back to the Raspi-config.

A note on Passwords:

In this tutorial, I am going to skip over making a password.  By default, the password is “raspberry”. If you would like a personal password setup in your own configuration, select the 5th item on the menu, “change_pass” and press enter. Follow the prompts after that to set up a new password. This password will be used for the user ID “pi”.

Configuring your Raspi-config Settings

  1. Back at the Raspi-config, select the 6th option, “change_locale” and press enter
  2. Scroll down this list, and press “space” on the locales that you want to add. (I used the spacebar to de-select “en_GB.UTF-8 UTF-8″ as I am in the US, so I do not want the english United Kingdom locale, but the English United States locale)  and then scrolled down to “en_US.UTF-8 UTF-8” and pressed space to select it, and then press enter.
  3. In the next screen, once again, select your locale, (I selected “en_US.UTF-8 UTF-8″) and press enter. (Setting the locale will take several seconds.)
  4. Back at the Raspi-config, select the 7th item on the list, “change_timezone” and press enter.
  5. This will ask you to select your region, (I selected “US” at the bottom of the list) and press enter.
  6. Then select your time zone within your region, (I am on the East Coast of the US, so I selected “Eastern”) and press enter.
  7. Back to the Raspi-config menu again, this time select the 8th item, “memory_split”, and press enter.
  8. Depending on what version of the Raspberry Pi you have, you can do different things here. I have a 512mb Model B Raspberry Pi. I have previously tried this setup on the 256 model, and in both cases, I found a 50/50 split to work well.  If you have a 256MB Model B, enter “128″ into the field, if you have a 512MB Model B, enter “256” into the field. Press enter.
  9. You will have the option to overclock here, but we are going to skip that for now.  If you do any overclocking before the updates and installations, it can cause issues.
  10. Back at the Raspi-config menu, press the right arrow key twice to select “finish” and then press enter.
  11. It will ask you if you want to reboot now, select “yes” and press enter.

It will take some time to reboot, as it is applying all the settings on the next startup.

__________________________________________________________

Installing RetroPie and EmulationStation

If you downloaded and mounted the RetroPie Image, you can go ahead and skip to the section “Moving ROMS Over To Your Raspberry Pi”

When your Raspberry Pi finishes booting up, it will prompt you to enter a “raspberrypi login” – this is your “user ID” on the system.  Enter “pi” and press enter. It will then prompt you for a password.  (If you setup a different password earlier in the Raspi-config, enter that password.) Otherwise, enter “raspberry” (the default password) and press enter. Keep these credentials in mind, you are going to need to use them quite a few times throughout this guide.

It will display a few lines, and then end at one that says “pi@raspberrypi ~ $” – This is the Terminal prompt. This is your command prompt, your home base, your Linux command-giving console. From here we are going to install RetroPie with the petRockBlog initialization script.

Any line that is tabbed in, and surrounded by a light gray box
(like this paragraph) is a line that needs to be entered in the
terminal.  This means type that line out and press enter. 
Please note that everything is case sensitive

First, we need to make sure you have the latest updates.

sudo apt-get update

This will take a few minutes, when it’s done, you will be back at the terminal

sudo apt-get upgrade -y git

This will take a few minutes, when it’s done, you will be back at the terminal

 sudo apt-get install -y git dialog

This will take another few seconds/minutes.  You will be brought back to the terminal prompt input.

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

This will download the files needed to install the emulators.  When it is done, you will be back at the terminal.

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

 

  1. You will be presented with a screen where you have a few different options. Select Option 2 (Source Based Installation) and press enter.
  2. This will bring you to a screen where you can select/deselect systems and features that you may or may not want (spacebar to toggle). For simplicity’s sake, we’re going to leave it as the defaults, so just press enter.

RetroPi should now be installing. This is going to take a very long time. No, seriously. You should probably go find something else to do for a while. I think mine took around 9 hours to finish the installation.  Take note that your Raspberry Pi will turn off the display if idle for a ling time.  The installation will still be going, just press a keyboard button or move your mouse to wake up the display.

When that is complete:

  1. You will be brought back to a blue screen letting you know how to run the emulators. Because of the way EmulationStation works, you won’t have to pay attention to any of this. Press enter.
  2. It will then let you know that the tasks are completed, and give you the command to start EmulationStation. Press enter.
  3. You will now be back at the RetroPie-Setup homescreen. This time, select the 3rd option, “Setup (only if you have run one of the installations above)” and press enter.

Make EmulationStation Workable without a Keyboard

  1. For this walkthrough, we are going to make this an EmulationStation that is workable without a keyboard, so go down to the 5th option – “Start EmulationStation on boot?” and press enter.
  2. Then select the 2nd option on the next screen “Start EmulationStation on boot” and press enter. (You can always come back later and change this by running the RetroPie-Setup again)

Back at the RetroPie-Setup, press tab to select “cancel” and press enter.  This will bring you back to the main install screen.  Press tab again to select “cancel” and press enter to get back to your terminal.

While we are here, we want to collect some information for the next steps.

ifconfig

Take note of your IP address, it is the string of numbers following the line “inet addr“.  It will probably look something like “192.168.1.5″ - Write this string of numbers down somewhere.

exit

Leave your Raspberry Pi powered on and at the login screen.

__________________________________________________________

Moving ROMS Over To Your Raspberry Pi

Keep your Raspberry Pi powered on!

First, you need to go get some 100% legitimate homebrew non-pirate ROMs, because that’s the only kind you would ever download, right?

On your primary computer, go download, install, and run the program WinSCP – www.winscp.net

When WinSCP opens, it will be asking for details about a session.

  • File protocol: select SCP.
  • Host name: enter the IP address of your Raspberry Pi (You wrote this down before, remember? my example was 192.168.1.5).
  • User name: pi

Press “Login”.

It will prompt you for a password.  Enter the password that you have setup for the user “pi” (raspberry by default).

Once it connects, it should show a file browser of your primary computer on the left, and your Raspberry Pi on the right.

On the right (your Raspberry Pi) open the folder “RetroPie”, and then open the folder “roms”.

On the left, open the folder where you keep your ROMs on your primary computer.

Drag and drop the ROMs from your primary computer into the corresponding system’s folders on the Raspberry Pi (SNES ROMs go in the “snes” folder, NES ROMs go in the “nes” folder etc…)

When you drag them over, you will get a prompt to copy the files over, click on copy.  Depending on how many files you’re moving, this may take a while.  When you are done copying your ROMS over, exit out of WinSCP.

Your Raspberry Pi is more or less ready to play some games.

Go back to your Pi, and put in your user ID and password.

EmulationStation should boot up.

First EmulationStation Run

On first boot, EmulationStation is going to have you run through the button configuration for navigating the menu in EmulationStation (Please take note: Configuring EmulationStation controls will not configure your controls for the emulator.  We will get to that later)

Use left and right on your keyboard to select an emulator, then up and down to select a ROM, and then press enter to run it.

Default controls use the A,S,Z,X keys for the button pad, Enter and Shift for start and select, and arrow keys for D-pad.  Esc will exit the game, and F4 will exit the EmulationStation frontend and bring you back to terminal.

Take note that pressing Esc from the game will dump the save data to the Pi keeping your save games.  However the only time it does save your game to the memory is when you press Esc – not when you press save in the game.  If the system is powered off before Esc is pressed, your save file will not be written to memory.

When you’re done messing around, shut down your Raspberry Pi by going back to the terminal (from a game press esc then F4)

sudo shutdown -h now

__________________________________________________________

Configuring Controllers and Other Settings

While the Raspberry Pi is powered off, plug in one of your USB controllers (if you are using a controller other than the one specified in this guide, you may have to install drivers first, it depends on the controller) – You should also still have your keyboard plugged in.

Power on your Raspberry Pi by unplugging it, and then plugging it back in again.

Your Pi should go through its regular startup, and launch EmulationStation.

Before we can configure your controller for working with EmulationStation, we need to get rid of the .cfg file which currently should be telling ES to work with your keyboard.  So from the EmulationStation main menu, press F4 to get back to your terminal.

cd .emulationstation
sudo rm es_input.cfg

Note: If you want the ability to navigate the EmulationStation menu with more than one controller (2 Player), you should shut down your Raspberry Pi now, plug in your second controller, and then power it back on, and skip the next 2 lines.


cd
emulationstation

This should boot right into EmulationStation

It should recognize that a controller has been plugged in.  If it does not, your controller may need a driver.  Follow the on-screen instructions to setup your controller with EmulationStation. When it says press up, press up on your controller, when it says press down, press down etc…

It will also prompt you to input the 2nd player menu controls, so if you have a second controller plugged in, you can follow the prompt.  Otherwise hold down any button on the P1 controller for a bit, and it will skip it.

Once you are done with this, it should boot up EmulationStation.  You should now be able to use your controller to navigate the EmulationStation menu. Keep in mind that this is only the controls for the frontend, not for the emulators.  We’ll get to that now.

Press F4 to exit EmulationStation and go back to terminal.

cd RetroPie/emulators/RetroArch/installdir/bin
./retroarch-joyconfig >> ~/RetroPie/configs/all/retroarch.cfg

Next you are going to use your controller and follow the prompts.  If your controller has less buttons than the config tries to setup (My SNES controllers lack the R2/L2, R3/L3, and Joysticks), then you need to select a dummy button (I used left trigger) for the buttons you don’t have. We will edit those out later.  Once this is done, it will bring you back to the terminal.

At this point, you should be ready to game with one controller.  If you type sudo reboot in your terminal, it should restart, and bring you into EmulationStation on the restart. You can then use the controller to select a game and play it. To setup a second controller, go back to your terminal (Esc to exit game, F4 to exit EmulationStation) and follow the next steps:

sudo shutdown -h now

When your Pi is done shutting down, unplug your controller, and plug in your mouse.  Once you have done this, unplug the power from your Pi, and plug it back in. When EmulationStation boots up, press F4 to exit it and go to the terminal.

startx

This will boot you up into the Raspian LXDE GUI, it should look pretty similar to a Windows desktop.

First, click on the LXDE menu in the bottom left (What would be your “start” menu if this was windows), and then select “Accessories” and then “File Manager” – This is your file explorer.  Open the folder “Retro Pie” and then open “configs” and then open “all”

In here, you can find the retroarch.cfg file.  This is a configuration file that applies its properties to all of the emulators. Open this text file.

Alternatively, you could have opened the folder/config for a specific Emulator.  This could be useful for making configuration settings specific for each console.  Let’s say you want the controller mappings for NES to be different than what you have setup for SNES. You could go into the NES folder under “configs” and edit the retroarch.cgfto your likings, and do the same for the retroarch.cfg file inside of the SNES folder.  The code written in the folders for the specific emulator will override the code written in the “all” folder/config.

Scroll down to the bottom of the retroarch.cfg file, and you should see the lines for all of the button mappings that you did just a minute ago.

If you used a “dummy” button like I did, you are going to see that a lot of the buttons will have the same value.  Because I am using a SNES USB controller, I’m going to delete the lines that I won’t be using.  I am going to delete the lines:

input_player1_l2_btn = "4"

input_player1_r2_btn = "4"

input_player1_l3_btn = "4"

input_player1_r3_btn = "4"

I am deleting these because I have no L2 or R2 buttons on the controller, and I also have no L3 or R3 buttons.

Further down in the .cfg file, I am also going to delete the Joystick configurations, because the controllers I have, use only a D-Pad.  So delete all the line “input_player1_l_x_plus_btn = “x”” and all of the lines under it.

Now the only things you should have left, are the buttons that exist on an SNES controller (A, B, Y, X, L, R, Start, Select, Up, Down, Left, Right), and one line at the top defining the first controller plugged in as “Player 1″

Now highlight the line:

input_player1_joypad_index = “0″

and also highlight all of the lines under that.

Copy that block of text, and then under it, press enter to add a space, and paste a second copy of it. You should now have 2 blocks of identical text.  In the second block, we are going to make some changes to let the system know there will be a Player 2 controller, and map the buttons for it.

Change the top line of your second block of text to:

input_player2_joypad_index = “1″

Now go down the lines of code, and wherever it says “player1″ change it to “player2″

For example, in the second block of text, change

"input_player1_a_btn = "1"

to:

input_player2_a_btn = "1"

Keep in mind that this specific setup will only work if you are using 2 identical controllers.  In my setup, I have 2 of the same SNES USB controllers, so the button mappings are exactly the same.  If you have 2 different controllers, you will have to run the retroarch-joyconfig again for the second controller, and make the appropriate changes to the retroarch.cfg for the mappings of Player2_joypad to reflect the correct controls.

OPTIONAL BUT PREFERRED:

You can setup an “exit emulator” button combination that will bring you back to the emulator/game selection screen.  When you do this, it will dump the ROM and keep any save files that you have.  There are other ways this can be accomplished; we will go over those later.

So at the bottom of the retroarch.cfg, enter these two lines

input_enable_hotkey_btn = "X"
input_exit_emulator_btn = "Y"

Replace X with one of the numbers that corresponds to a button on your controller, and replace Y with a different number.  In my setup, I wanted it to exit the emulator by pressing Select + Start.  So I replaced X with the number corresponding to my select button (I think it was 8), and I replaced Y with the number corresponding to my start button (I think it was 9)

Once you have made all the changes you need, press ctrl+s to save the configuration file.  You can now close the configuration file. Back at the desktop, click on the LXDE Start menu, and select “logout”. It will prompt you again, so click “logout”.

Back at the terminal.

sudo shutdown -h now

Once the Pi is done shutting down, unplug your mouse, keyboard and power supply. With the Pi powered off, plug in your two USB controllers. Plug the power supply back into the Pi.

You should now be ready to rock some oldschool emulation with 2 controllers plugged into your Pi, and no mouse or keyboard necessary.  Your system will boot into EmulationStation.  Use the P1 controller to select and play a game, and P2 will act as P2 in the games (usually… Some ROMs seem to have difficulties).  The only thing left is making RetroPie look nice.

Note: If you did not setup an “exit emulator” button combo, there will be no way for you to keep your save files.  Here are some other options for setting up a way to dump your save files.

Solution 1: Wire a button to your GPIO pins to act as a keyboard that presses “esc” – you can then use this button to dump the save files and go back to the EmulationStation.  Any time the Pi is powered off after that, your save files will still be in tact

Solution 2: Use a Powered USB hub/splitter and also have a keyboard plugged in.  You can then use the keyboard to exit the game.  You can also use the keyboard for other features like save and load state. (In my personal setup, I programmed a Teensy to act as a keyboard.  I then wired it to my reset switch.  When the reset switch is pressed, the Teensy presses “esc” and exits the emulator – this will not be covered in this tutorial, as it is likely unnecessary)

Solution 3: If you have a controller that is not a SNES replica, you can add the line “input_exit_emulator_btn = “x”” where “x” is the extra button on your controller that you have set aside to save and exit the game.  You can find out what the definition of “x” is by using the retroarch-joyconfig tool and pressing that button (it should display the number associated with the button you are pressing as you go through the script)

Solution 4: (advanced and requires soldering): This is actually the preferred method for advanced users/hobbyists.  For your entire controller setup, use a RetroPie GPIO Adapter (http://petrockblog.wordpress.com/2012/10/21/the-retropie-gpio-adapter/) or make your own GPIO setup .  This way, you can use authentic SNES controllers, and the Adapter has a button on it that can be programmed as the exit emulator button (or you can make your own button hooked up to the GPIO).  You will also have to install the gamecon GPIO driver which is available in the RetroPie-Setup.

__________________________________________________________

Making EmulationStation Look Pretty

Now that you have a sweet micro retro gaming rig, it’s time to make it look nice.  Plug in a keyboard into your Raspberry Pi and turn it on.  When it boots into EmulationStation, press F4 to quit.  This will bring you back to the terminal.

cd RetroPie/supplementary
git clone http://github.com/elpendor/ES-scraper
cd
cd RetroPie-Setup
sudo ./retropie_setup.sh

When the RetroPie setup starts, select the 3rd option, “Setup” (only if you have run one of the installations above) and press enter.

We need to turn off the EmulationStation on boot for this next part, so go down to the 5th option – “Start Emulationstation on boot?” and press enter.

Select option 11 - “Run ‘ES-scraper” and press enter.

At the next menu, select the first option “(Re-)scape of the ROMs directory”, and press enter.  If you add more games to your directories in the future, just run this again, and it will download art for all of the missing games.

Keep in mind that you need to be connected to the internet for this to work

It’s now going to search for, download, and install box art and game descriptions for all of the ROMs that you have.  Depending on how many roms you have, this will take a different amount of time.  When that is done, it will bring you back to the RetroPie setup screen.  Press tab to select cancel, and then press enter.

sudo shutdown -h now

After your Pi is powered down, unplug the power supply.  Then plug in your 2 controllers, and plug the powersupply back in.

You are now done with your Setup.

Troubleshooting

If you are having trouble with something in the setup, please check the comments for some of the issues people have had, and the solutions they have come up with.  Aside from that, check out the RetroPie Wiki, and there are plenty of extra troubleshooting steps there