Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting up RetroArch on a Raspberry Pi

Setting up RetroArch on a Raspberry Pi

I just put the finishing touches on my Raspberry Pi 3 emulation machine running RetroArch. I was not a huge fan of RetroPie due to the reliance on Emulation Station - more moving parts meant that there were more things that could potentially break. I just wanted something that would run raw RetroArch, no frills.

This tutorial is mostly recreated from memory and was most recently tested with a Raspberry Pi 3 running Raspbian Stretch and RetroArch 1.7.7. If there is a mistake or a broken link, PLEASE message me and I will fix it.

Step 1: Install Raspbian

I used Raspbian Stretch Lite from this page. Write the image to your SD card using something like Win32 Disk Imager, or if you're using OSX/Linux follow a tutorial on how to write the image using dd.

Step 2: Get Comfortable

First things first, you're going to need to get Wi-Fi set up. Follow this tutorial. You will also need to give the GPU at least 128 megabytes of memory in order to properly run the more advanced interfaces, see this tutorial for instructions on how to do that.

After that, make sure your system is totally up to date:

sudo apt update
sudo apt upgrade

Unless you live in Great Britain, you will probably not be happy with some of the defaults. Use this to fix your keyboard:

sudo dpkg-reconfigure keyboard-configuration

Use this to fix your locale (choose en_US.UTF-8 if you live in the US):

sudo dpkg-reconfigure locales

Use this to fix your timezone:

sudo dpkg-reconfigure tzdata

It's probably a good idea to reboot at this point.

3. Compile RetroArch

Unlike some other tutorials, I believe in keeping things simple, explaining what flags I'm enabling and why, and not going overboard on bells and whistles or disabling things. So let's get started:

sudo apt install build-essential libasound2-dev libudev-dev

Okay, time out - what are we installing and why?

  • build-essential is a meta-package that depends on GCC, libc development libraries, and GNU Make. Essentially it contains the bare minimum needed to compile software on Debian.
  • libasound2-dev is ALSA. This library ensures that RetroArch will have sound - kind of important.
  • libudev-dev is udev. This library is necessary to ensure compatibility with a wider range of input devices. Without this, my DualShock 3 could be detected, but didn't actually work.

Now that we have libraries, grab the source for the latest stable version of RetroArch. You can find the latest source of RetroArch on the Releases page of the official RetroArch github - you want to copy the link labeled "Source code (tar.gz)". From now on, we are going to assume use of 1.7.7, but this is more than likely not the latest release, so please do check the releases page for the latest version.

curl -LO 'https://github.com/libretro/RetroArch/archive/v1.7.7.tar.gz'
tar -zxvf v1.7.7.tar.gz
cd RetroArch-1.7.7

Now to configure it:

CFLAGS='-mfpu=neon' ./configure --enable-alsa --enable-udev --enable-floathard --enable-neon --enable-dispmanx --disable-opengl1

Okay, time out again - why are we passing these parameters to configure?

  • CFLAGS='-mfpu=neon' ensures that the --enable-neon option works, specified later.
  • --enable-alsa ensures that we're compiling with ALSA support. If the library isn't installed, the configure script will die screaming instead of disabling the feature.
  • --enable-udev ensures that we're compiling with udev support.
  • --enable-floathard ensures that RetroArch uses the Pi's built-in hardware Floating Point Unit. Without this, there is the possibility that floating point calculations might be emulated in software, which is much slower.
  • --enable-neon ensures that RetroArch can use the Pi's SIMD CPU instructions (called NEON) for extra speed. Some cores take advantage of this.
  • --enable-dispmanx ensures RetroArch can use the Pi's Dispmanx support for rendering graphics. Dispmanx is a low-level 2D graphics API unique to the Raspberry Pi's video core which you can use as an efficient alternative to OpenGL. Some emulators run faster with Dispmanx, but the downside is that it is not as featureful as OpenGL (for one, the OSD text at the bottom of the screen won't render), and comes with ugly bilnear filtering enabled by default, though this can be turned off. So we compile with support for both GL and Dispmanx, and you can decide for yourself which one you prefer.
  • --disable-opengl1 ensures RetroArch does not attempt to compile support for the legacy OpenGL 1.x standard, which the Pi does not support.

And that's it. Disabling 20 different options is pointless - all you're really saving is binary size. If the configure script completes without errors, you can then:

make
sudo make install

4. Configure RetroArch

Now that RetroArch is installed, run it:

retroarch

You will be presented with the GUI front-end. You can use the arrow keys to navigate the UI, x to select an option, z to back out, and esc to quit RetroArch completely. We still have a little ways to go, however, until we're completely up and running.

Quit out of RetroArch and edit the ~/.config/retroarch/retroarch.cfg file with your editor of choice - nano is good if you don't have a preference. Look for the line that mentions core_updater_buildbot_url and set it to http://buildbot.libretro.com/nightly/linux/armhf/latest/.

Next, unless you are incredibly lucky your controller probably is not working. Navigate to Online Updater, then Update Autoconfig Profiles and wait for the OSD text to stop flashing. Quit and restart RetroArch to see if your controller was found. If your controller still isn't configured, you might need to go to Settings, then Input, then Input User 1 Binds. It should be self-explanatory from here.

Now, let's test our updated settings. From the main menu, navigate to Online Updater, then Core Updater, and select 2048. Once it's installed, from the main menu, select Load Core then 2048. Finally, select Start Core. If everything went smoothly, you should be able to play a simple game of 2048 to prove that everything is set up correctly. To exit the game, press escape or use the button on your controller that you bound to said functionality.

At this point, you are now ready to follow other RetroArch tutorials that concern importing and playing your games.

5. Other Stuff

Does it bug you that sometimes your Pi will show a blank screen after a period of inactivity, which can only be undone by touching the keyboard? Use your editor of choice to modify /etc/rc.local and put the line setterm -blank 0 before the last line that says exit 0.

If you remember from earlier, we compiled RetroArch with Dispmanx support. To give it a spin and see if you prefer it to the default GL implementation, first ensure that you are using the default rgui menu driver - if you haven't changed your menu driver, you're fine. Next, at the Main Menu select Settings, Driver, then Video Driver and select dispmanx. You must then quit and relaunch RetroArch. If you ever want to go back, go to the same place and select gl instead.

RetroArch gives you many different choices for cores. Sometimes it's a little confusing trying to figure out which core is the best. Here is my suggestions based both on personal experience and other people giving me advice:

  • NES: FCEUmm.
  • Genesis: Genesis Plus GX. If you get slowdown, try PicoDrive.
  • 32X: PicoDrive.
  • SNES: Snes9x Next. If you get slowdown, try CATSFC.
@y4my4my4m

This comment has been minimized.

Copy link

commented May 29, 2018

Thank you, this worked for me.

@agentgerbil

This comment has been minimized.

Copy link

commented Nov 25, 2018

I'm getting error message - * failed to add service - already in use?
when i try to run retroarch

@thegreatestminer

This comment has been minimized.

Copy link

commented Apr 1, 2019

I'm getting error message - * failed to add service - already in use?
when i try to run retroarch

Ancient reply, but did you check if the GL Desktop is disabled? That should fix it.

@tonytech17

This comment has been minimized.

Copy link

commented Apr 5, 2019

Help! after running the make command I get this error.

CC menu/menu_setting.c
menu/menu_setting.c: In function ‘setting_append_list’:
menu/menu_setting.c:6928:19: error: ‘menu_shader_pipeline’ undeclared (first use in this function)
menu_shader_pipeline,
^~~~~~~~~~~~~~~~~~~~
menu/menu_setting.c:6928:19: note: each undeclared identifier is reported only once for each function it appears in
Makefile:137: recipe for target 'obj-unix/menu/menu_setting.o' failed
make: *** [obj-unix/menu/menu_setting.o] Error 1
pi@raspberrypi:~/RetroArch-1.3.6 $

@AlexMax

This comment has been minimized.

Copy link
Owner Author

commented May 17, 2019

@tonytech17 Hi there, my apologies, but the installation instructions were old and out of date. I just updated them for a more modern version of RetroArch and Raspbian, please try again.

@xlar54

This comment has been minimized.

Copy link

commented May 22, 2019

worked great!

@helyton

This comment has been minimized.

Copy link

commented May 26, 2019

Yesterday, I had the following problem when I tryed configure CFLAGS:
"dynamic loading of libretro is enabled, but your platform does not appear to have dlopen()"
What could i do?

@molul

This comment has been minimized.

Copy link

commented May 30, 2019

UPDATE: I was able to fix it by getting into the configure scripts and putting some debug messages. The problem was exactly here:

In file included from /usr/include/stdio.h:27:0, from .tmp.c:1: /usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory include <sys/cdefs.h> ^ compilation terminated.
Googling a bit I found the solution would be
sudo apt-get --reinstall install libc6 libc6-dev

It finished configuring without a problem after that :)

ORIGINAL REPLY:

@tonytech17 Hi there, my apologies, but the installation instructions were old and out of date. I just updated them for a more modern version of RetroArch and Raspbian, please try again.

Hi there! I tried your command but I get this output:

Checking operating system ... Linux Checking for suitable working C compiler ... not found Error: Cannot proceed without a working C compiler.

I have these in /usr/bin:
gcc gcc-6 gcc-ar gcc-ar-6 gcc-nm gcc-nm-6 gcc-ranlib gcc-ranlib-6

Any ideas? Thanks in advance :)

@AlexMax

This comment has been minimized.

Copy link
Owner Author

commented Jun 6, 2019

@molul Thank you for putting in the legwork here. I've updated my instructions to make sure a baseline compilation environment is included (build-essential). @helyton could you give that a shot?

@molul

This comment has been minimized.

Copy link

commented Jun 6, 2019

My pleasure.

If you want to take a look, your tutorial has been key to make Blast16, a new Mega Drive inspired emulator frontend that people seem to enjoy since it was released last week:

http://www.blast16project.com/

Thanks a lot for your work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.