Last active Sep 6, 2019

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.

--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 0before 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:

This comment has been minimized.

edited

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 besudo 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

This comment has been minimized.

edited

thanks for this guide - i've installed on a pi4 with buster lite. all goes well, but when I try to launch retrorarch i just get a flashing cursor... any ideas why?
fwiw i had to disable experimental GL driver, i was getting the 'failed to add service' error before that.

This comment has been minimized.

Oh, did it work for you, danpowpow? I just followed the guide on Raspberry pi4 with Buster Lite and got some opengl errors that stopped the build. Is that what you fixed by disabling the experimental GL drivers?

This comment has been minimized.

I have just found out the problem I reported was due to fact that GL driver is not enabled. I tried to build with GL core disabled, ended successfully, am just not sure how will emulation run in this mode.

This comment has been minimized.

Ok, I thought I could start from scratch just in case I messed something up with other projects I was building. I re-flashed Raspbian Buster and directly followed this guide. I was able to build retroarch, but when I launch it I get this error:

This comment has been minimized.

Oh thanks!
I guess there's something yet to be done in the new Raspbian Buster, as I
was able to build another thing yesterday (LÖVE framework) and I heard
sound but had no image. I might wait a few weeks and check again :)
Thanks for your quick replies!
El vie., 28 jun. 2019 12:53, stgoh <notifications@github.com> escribió:

This comment has been minimized.

@molul try rebooting and running the verbose command - i found that on a clean boot i got further, alhough never to a gui.
i noticed a line referring to the VideoCore IV in my logs, and the pi 4 features VC VI, which makes me think all this is down to the upgraded GPU on the pi4 not fully being supported yet.

This comment has been minimized.

Thanks man! Will try that later :)
I wonder, is this something that should be fixed by Libretro or by the
Raspberry pi team on some update?
El lun., 1 jul. 2019 12:42, danpowpow <notifications@github.com> escribió:

This comment has been minimized.

edited

Thanks c0d3h4x0r! Did you try this yourself? Added --disable-x11, but unfortunately no image is displayed when running Retroarch :(

Yes. I had to add a bunch more CFLAGS and configuration options to finally produce a reasonable build of 1.7.7 for use on my Raspberry Pi 3B+ w/ RetroPie. The additional CFLAGS provide noticeably better perf optimization for this hardware (on par with the original retroarch binary supplied w/ RetroPie... actually, slightly better performance in my initial testing of NeoGeo games w/ lr-mame2010). Here's what I used:

This comment has been minimized.

Hmm, I noticed going back through the instruction that it was in there to install, must have missed it on the first run.
Got the sound working, switched it to 'tinyalsa' and sound under Gensis Emulator.

Might be worth making a note that if you botch your install (change a setting that messes it up) simply rename the config to go back to defaults.

This comment has been minimized.

The main issue I'm having is that even when I get retroarch to compile and install without errors, the Core Updater doesn't work. When I click on it, the screen goes black for a split second but nothing else happens.

If I run '$ retroarch --verbose', when I click Core Updater the log says

[INFO] [GL]: VSync => on
[INFO] [EGL]: eglSwapInterval(1)

I tried downloading cores manually and extracting them to the cores folders, but they don't register within retroarch.

I'm using a Raspberry Pi 4 4gb. I've reformatted and recompiled several times, and it's always the same result.

It might be worth nothing that with the first two builds, dispmanx doesn't show up as an option for the video driver.

After these 2 tries, I reformatted again and repeated both methods, just to make sure I hadn't made an error somewhere. This time I got compiler errors related to dispmanx, so I tried leaving --enable-dispmanx out and got no compiler errors, but still Core Updater wasn't working, nor was manually copying cores over.

I've been playing with the rpi for years, and my habit on getting a new one is to install retropie (with berryboot) or retroarch without, then kodi, then the rest of my projects. It's driving me nuts that I've had the rpi4 for a few days and still can't figure out how to play my old ps1 games on it.

How do I format my post so that I can present the commands I've tried the same way everyone else seems to?

What is fkms-v3d? What is x11? These relate to how Raspbian displays windows?

If I want to change the CLFAGS portion of my install, how should I go about recompiling? Should I just delete the RetroArch-1.7.7 folder and start over at $ tar -zxvf v1.7.7.tar.gz, or is there a better way to remove the previous installation and start over?

Has anyone figured out a berryboot type method of dual booting the rpi4? If so, I'd like to try RetroPie and see if I have the same issue.

Save me, you guys. I'm getting frustrated. Also I apologize if this isn't the correct place to post this.

This comment has been minimized.

edited

Firstly are you using Buster or BusterLite? Command prompt or GUI (Desktop).

I have built this and have it installed using Raspbian Buster (Desktop) not CLI on a Pi4b.

Tried BerryBoot ages ago, but never really got on with it. I now run Buster Desktop as a Desktop, but still have Retroarch and Kodi as Apps I can run. This is not my main Media PC, just watch bits on it.

Some answers (I think to your questions).

Fkms-v3d is to with the experimental 3D drivers that came out a while ago. I did not use this setting so I think is disabled, X11 is just a posh way of saying the Desktop (rather than CLI) as the Pi by default in Raspbian uses X, there are other desktops you can run if you desire! See above posts for some suggestions.

Every time you alter the CFLAGS you will need to make and make install again as the CFLAGS is basically setting up the configuration you want to build (using the make command), this will overwrite what it did before.

If you’re not sure go to where you built the software, but run sudo make uninstall. Then set CFLAGS and make (to build your new version) the make install.

I understamd having 3 different boots / systems? But it is possible to run them all through Buster Desktop, X11)

This comment has been minimized.

edited

Hi there, ok guys I gleaned all the information to get RetroArch compiled, installed and running on the full buster installation on a PI4Steps taken....
Installed the Raspbian Buster with desktop and recommended software : “2019-06-20-raspbian-buster-full.img”https://www.raspberrypi.org/downloads/raspbian/

Once your all logged in and working,

Get the updates
open the Terminal and type:

sudo apt-get update --allow-releaseinfo-change
sudo apt upgrade

Now install everything we need for RetroArch
open the Terminal and type:

This comment has been minimized.

What you're describing is the exact steps I've taken, except I've just been using the Raspbian Buster image available through the NOOBS, while it appears you grabbed the img file and mounted and installed yourself.

I can't think of any reason that would make a difference, but in my experience the pi and raspbian are finicky bastards, so I will try your exact steps when I get home.

A few questions: You've verified that the Core Updater works with this setup?

I keep running up against this issue. I've had no problems setting up samba shares to copy over my ROMs, but without a core that step is pointless because a scan will not recognize ROMs. My point being, I havent had any success focusing on other aspects of the installed because it always comes back to needing the core updater to function.

If I follow your steps and still have the same issue, would you be willing to give me a copy of your img after you've gotten it working? Sometimes I have better luck going over someone's work, than trying to extrapolate a solution based on a description.

Anyway, thanks for your answer, I'll try your exact steps and let you know if it works for me.

This comment has been minimized.

I can verify this works on mine. Scanned a folder and sorted the games into systems. Also with the change made above it grabs and updates the cores. I need some tweaking to get PS1 games working, but they load at least. Genesis / Megaddive games work a treat.

This comment has been minimized.

What you're describing is the exact steps I've taken, except I've just been using the Raspbian Buster image available through the NOOBS, while it appears you grabbed the img file and mounted and installed yourself.

I can't think of any reason that would make a difference, but in my experience the pi and raspbian are finicky bastards, so I will try your exact steps when I get home.

A few questions: You've verified that the Core Updater works with this setup?

I keep running up against this issue. I've had no problems setting up samba shares to copy over my ROMs, but without a core that step is pointless because a scan will not recognize ROMs. My point being, I havent had any success focusing on other aspects of the installed because it always comes back to needing the core updater to function.

If I follow your steps and still have the same issue, would you be willing to give me a copy of your img after you've gotten it working? Sometimes I have better luck going over someone's work, than trying to extrapolate a solution based on a description.

Anyway, thanks for your answer, I'll try your exact steps and let you know if it works for me.

Yup it works

This comment has been minimized.

edited

Also have compiled a working version of retroarch 1.7.7 for Buster Desktop... The only thing that's not working for me is the Core Updater, and what I've been doing instead is compiling the Cores myself using libretro-super git. Are you guys saying the Core Updater is working for you? I thought as the Pi4 is still fresh out of the oven they may have not got round to having the cores for the updater out there as yet.

The only cores I'm having problems compiling are PCSX (run into floating point problems) and N64 cores. Was hoping to have reicast_lr compiled but do not see an entry for it. Mighty impressed with reicast on Lakka and like to see how well it runs on the V3d Desktop and the pi overclocled to 2.0ghz.

any suggestions welcome

UPDATE :: All sorted... saw the above post for the nightly core buildbot for armhf.. cheers to seven-lynx
As is I pretty much compiled everything they've got on the buildbot except the PCSX core.. sad to see no sign of N64/Reicast

This comment has been minimized.

Even following your steps EXACTLY, I still get a retroarch with no cores installed, and core updater not working.

Makes no sense. No matter what I do, I always end up with a non-functioning retroarch. No version of Lakka will even boot on my rpi4. I always get a black screen.

I can get retroarch to run on the pi4, but no cores, no updater, so it's pointless.

I even tried a 32gb img file for lakka that is confirmed to work on rpi4. Black screen, no boot.

All I can think to do at this point is buy another rpi4 and try again. Maybe this is some bizarre hardware fault? I seem to be the only person with this issue. Even following guides and videos that appear to work, always yields the same result for me.

Considering that 90% of what I do with a pi is retro gaming, I'm tempted to just throw this thing in the trash and go back to using my pi3s. This has been the single most frustrating issue I've ever tried to troubleshoot. This is something so damned simple, and I seem to be the only person alive who can't crack it.

This comment has been minimized.

edited

That's what has me puzzled. I've tried every lakka build from 7-27 onwards at least once, and it never boots. Yet it takes me less than 10 minutes to get lakka up and running on the rpi3, but on the pi4 I haven't gotten lakka to boot once, even using images that I know work for everyone else.

I've been using win32 disk imager to burn to sd card, while most people seem to use Etcher. Could that be the issue?

Even using the NOOBS version of lakka, I only ever get a black screen and no boot.

Couple questions. You said the core updater doesn't work for you, but I infer you've had no problem copying cores over manually?

Assume I'm an idiot and walk me through your exact process for manually adding cores, please? When I try it, They never show up in retroarch.

This comment has been minimized.

Yes all the ARM cores are there when I install it. Try etcher maybe that will help. Also try a different sd card. I assume you are not trying to use a USB dinner because the Pi4 can't boot from them yet.

This comment has been minimized.

Also, that was a mistype earlier. I meant to ask if your version of RetroArch has cores already installed, not lakka. I haven't gotten Lakka to boot even once on rpi4, but I have no problems getting retroarch to run, with gui in raspbian, on the rpi4. Just no cores, and it doesn't recognize cores I manually copy over.

This comment has been minimized.

Hi all,
I tried Lakka, got that working too, but you have to use the nightly build, it has the cores.find it here:http://nightly.builds.lakka.tv/
I used the image with the date stamp 2019-08-03 02:03, but will try the latest soon currently 2019-08-15 02:05 or later and report.
Extract the image file then write the image to your SD card (I know Etcher lets you skip this step but had better results with a different SD write program.)

This comment has been minimized.

I've also tried following @karbinunit's exact instructions from this post and RetroArch fails to run. I get video errors including "Failed to export dumb buffer: permission denied". I've been able to get the Lakka nightlies running but I'm having some Bluetooth controller issues.