Old Schoold by Harri Kauhanen

Installing RetroPie and Emulation Station [RetroPie series]

EmulationStation is loading

The basic setup of my RetroPie project, Linux and Emulation Station is covered here. We also have a section for Retro-Bit USB adapters as this required much more work than more standard compliant USB solutions.

Software

  • RetroPie
    • I currently have RetroPie 2.X for Raspberry Pi 2 (will update 3.X or any of the later releases later)

Hardware

  • Raspberry Pi 2 - Model B
  • 32 GB or 64 GB SSD card (big storage is needed, if you want to store PlayStation and N64 games)
  • a nice case
  • HDMI and micro-USB cables with 90 degrees angle (due to tiny space in the shelf of mine)
  • Controllers
    • Retro-Bit adapters for Sega Megadrive controllers and Atari-style joysticks
    • PS3 controllers + 3 metres long USB cables
    • Competition Pro joysticks
    • Sega Megadrive controllers

Bare system installation

  • SSD burning:
    • ApplePi Baker
      • ApplePi Baker sometimes has issues to start up. Perhaps the safest procedure is to insert SSD card, let it mount for some seconds, and only then launch the ApplePi Baker. Sometimes you need to restart OSX.
  • Backups
    • ApplePI Baker can be used to take an occassional backup, and restore if needed.
  • If you prefer, you can also install RetroPie on top of existing Rasbian

Linux configuration

  • Console
    • Locally or over SSH
      • Username / password : pi /raspberry
  • sudo raspi-setup
  • Hostname
    • sudo nano /etc/hostname
    • sudo nano /etc/hosts
  • Finnish keyboard (from here)
    • sudo dpkg-reconfigure keyboard-configuration
      • Generic 102-key (Int)
      • Finnish
      • AltGr → Default
      • Compose Key → Default
    • sudo reboot
  • Timezone
    • sudo dpkg-reconfigure tzdata
  • Updates
    • sudo apt-get update
    • sudo apt-get upgrade

Controllers

PS3 controllers work more or less out of the box – at least when they are connected via USB cable. Bluetooth is also possible, but as I am also using PlayStation 3, it’s much less of a hassle to use USB cables with RetroPie.

Retro-Bit USB adapters

To connect 8-bit “Atari” joysticks, Sega Megadrive controllers or almost any other controller, you might want to utilize the GPIO interface of PI and follow these instructions. I already had Retro-Bit USB adapters for Atari connector and MegaDrive, and the problem with these adapters are:

  • Direction left and up are not recognized at all
  • Linux sees the two controllers connected via adapter as a single input device
  • Buttons 0-7 are for the controller 1, and 8-15 for controller 2, but Axes-control is shared (both controllers mapped to Axes 0 & 1)

After a great struggle managed to get these USB adapters working decently. Not only I needed to recompile Linux kernel, but the configuration of the controllers was a lot of work. There’s also a little advantage using Retro-Bit USB adapters (over GPIO solution) – I can share my controllers with my Windows XP by routing through this USB switch.

Commands:

  • sudo apt-get install bc
  • git clone --depth=1 [https://github.com/raspberrypi/linux](https://github.com/raspberrypi/linux)
  • cd linux
  • make bcm2709_defconfig
  • nano drivers/hid/hid-input.c
/* REMOVE these lines */
// dbg_hid("Ignoring out-of-range value %xn", value);
// return;

/* ADD these lines */
if(value < field->logical_minimum)
  value = field->logical_minimum;
else
  value = field->logical_maximum;

/* ALSO REMOVE these lines */

// case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
// if (field->flags & HID_MAIN_ITEM_RELATIVE)
//   map_rel(usage->hid & 0xf);
// else
//   map_abs_clear(usage->hid & 0xf);
// break;
  • make -j4 zImage modules dtbs
    • This may take a lot of time, but ‘j4’ splits the work to all cores to make it as fast as possible
  • make modules
  • sudo make modules_install
  • sudo cp arch/arm/boot/dts/*.dtb /boot/
  • sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
  • sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
  • sudo scripts/mkknlimg arch/arm/boot/zImage /boot/kernel_retrobit_usb_support.img
  • sudo nano /boot/config.txt
# Append to the end of the file
kernel=kernel_retrobit_usb_support.img
  • sudo reboot

If Pi fails to boot, restore from a backup, or mount SD-card to a computer with ext3 filesystem support, and edit config.txt. For Mac, you can use FUSE for OS X.

Testing controllers

As you can see, Retro-Bit adapter controllers are seen as a single device by Linux. This may cause issues on some emulators.

  • jstest
    • Sega
      • jstest /dev/input/js0
    • Atari
      • jstest /dev/input/js1
    • PlayStation
      • jstest /dev/input/js2
      • jstest /dev/input/js3
  • lsub
    • sudo lsusb
    • sudo lsusb -D /dev/bus/usb/001/024

Emulation Station

  • List of emulators at /etc/emulationstation/es_systems.cfg
    • Modify, if you need to pass some custom variables to emulator executables
    • What emulators to show on Emulation Stations
      • Do not remove systems from this file if you don’t want them listed on EmulationStation.
      • Instead, make sure there are no game roms available for systems you don’t want to get listed.
      • If you want to keep roms of an unlisted system, you could e.g. create ~/RetroPie/roms/.RemovedSystems/scummvm and copy files from ~/RetroPie/roms/scummvm, but not remove the (empty) folder.
  • Controllers (for EmulationStation, not the emulators themselves)
    • Emulation Station asks to configure a controller on first lauch
    • Settings —> Configure input
      • Repeat for each controller all controllers
      • With Retro-Bit adapter controllers you can only use one of the controllers (use the one at “port 1” of the adapter)
    • Better animations
    • Settings → UI Settings → Transition Style → Slide

Game ROMs and images

Assuming you have a “game ROM” or “floppy image” (depends on the emulated system), you commonly make them available to the EmulationStation by this process:

  • Extract the game ROM from a downloaded file, and possibly rename it well
  • Copy the ROM to /home/retropie/roms/<system>
  • Games with multiple disks are not supported well. One approach:
    • Copy only the first disk under /home/retropie/roms/<system>
    • Copy the rest of the disks under /home/retropie/roms/<system>/.MoreDisks
  • Scrape game details
    • EmulationStation –> Scrape
      • Use gamesdb
      • Skip reviews
    • Add missing info using EmulationStation UI (or by editing game list file)
    • Usually the details for console games are found well
    • Computer games usually need more manual work (or a new scraper to be written)
    • Manual editing:
      • /home/retropie/.emulationstation/gamelists/nes/gamelist.xml
    • Cover images should not be too big (400px could be big enough)
      • /home/retropie/.emulationstation/downloaded_images/

Next steps

Now we have RetroPie running, it launches customized Emulation Station on start, and it has the support the controllers I use. We still need a bit more work to get games working and customize each emulated system for our tricky controller setup and my visual preferences. I have marked down my notes to the separate posts listed in the intro post of this series.