Skip to content

Instantly share code, notes, and snippets.

@ematysek
Last active December 25, 2022 12:43
Show Gist options
  • Save ematysek/fc01a47c7d34f0ca4dad41226c53ff6e to your computer and use it in GitHub Desktop.
Save ematysek/fc01a47c7d34f0ca4dad41226c53ff6e to your computer and use it in GitHub Desktop.

Setting up RetroArch on Raspberry Pi 4 and building emulator cores

Guide for myself and others to get RetroArch running on the new Raspberry Pi 4 while projects like RetroPie get an image out for the rpi4.
Disclaimer: I am not an expert and this may not be the most optimal build possible, but it works.

Inspiration taken from:

1. Environment Setup

sudo raspi-config
Advanced Options -> GL Driver ->  G2 OpenGL desktop driver...
  • Update everything and restart - skip if you know this is done already
sudo apt update
sudo apt upgrade
shutdown -r now

2. Compile RetroArch

Install some needed packages - check the gist I linked for an explanation

sudo apt install build-essential libasound2-dev libudev-dev libgles2-mesa-dev libx11-xcb-dev libxxf86vm-dev

Download RetroArch source code - This guide will use the .tar.gz
https://github.com/libretro/RetroArch/releases

wget https://github.com/libretro/RetroArch/archive/v1.9.0.tar.gz
tar -xf v1.9.0.tar.gz
cd RetroArch-1.9.0

To fix undefined reference to XF86VidMode... errors change this line in Makefile:

#OLD line 24
LIBS :=
#New
LIBS := -lXxf86vm -lpthread

Configure with additional options to work with rpi4

CFLAGS='-mfpu=neon -mtune=cortex-a72 -march=armv8-a' ./configure --disable-opengl1 --enable-neon --enable-opengles3 --enable-opengles --disable-videocore

If no errors, build

make
sudo make install

3. Run/configure RetroArch

Launch RetroArch fullscreen

retroarch -f

Go ahead and update assets within RetroArch

Online Updater -> Update Assets

The gist for rpi 3b+ will tell you to update the retroarch.cfg file with a url, but those cores did not work for me so this guide will walk through building them.

4. Building Cores

All cores likely have multiple options to choose from but this will just go over what I've done so far.
Compiled core files end in .so and are kept in ~/.config/retroarch/cores/

Create directory to build our cores

cd ~
mkdir cores
cd cores

NES

libretro-fceumm

This could probably use optimized CFLAGS but it works as is

git clone --depth 1 https://github.com/libretro/libretro-fceumm.git
cd libretro-fceumm
make -j4

Move fceumm_libretro.so to cores dir

SNES

snes9x2010

This could probably use optimized CFLAGS but it works as is

git clone --depth 1 https://github.com/libretro/snes9x2010.git
cd snes9x2010
make -j4

N64

mupen64plus-libretro

This core is no longer being updated so you should use mupen64plus-libretro-next, but keeping this here just in case.

git clone --depth 1 https://github.com/libretro/mupen64plus-libretro.git
cd mupen64plus-libretro
platform=rpi4 make -j4

mupen64plus-libretro-next

git clone https://github.com/libretro/mupen64plus-libretro-nx.git
cd mupen64plus-libretro-nx
platform=rpi4 make -j4

PS1

git clone --depth 1 https://github.com/libretro/pcsx_rearmed.git
cd pcsx_rearmed
platform=rpi4 make -j4
Copy link

ghost commented Jan 2, 2021

Hi - much respect and thanks for maintaining this guide.

I'd like to report the retroarch (1.7.3+dfsg1-1) binary installed from the Raspberry Pi OS (12-2-2020 release) package manager appears to run fine (at least for SNES) using a corresponding bsnes package also available on the package manager, on the Rpi 400.

In the retroarch config menu, the Audio Driver needed to be set to alsa to enable sound - otherwise, this appears to work out-of-the-box for me.

@mjeshurun
Copy link

mjeshurun commented Jan 21, 2021

Thank you for this wonderful tutorial. I'm a Raspberry Pi/Linux noob, and I found it to be very helpful 🙏
Could someone, please, share the commands I should enter in terminal to build the PSP and PS2 emulators cores?
I wish I knew how to do it myself, but I'm too new to Raspberry Pi and Linux to know.
I'm using Raspberry Pi 4 4GB running Raspberry Pi OS with desktop.

@ematysek
Copy link
Author

@Unounited
Retroarch pre-compiled cores were not available when this was written.
x86 compiled code will not work on an ARM processor, you should download the relevant ARM compiled cores.

@Unounited
Copy link

Unounited commented Jun 1, 2021

My bad, I should have tested the x86 cores before I posted them. And they did not work, so I guess someone might have all the cores for retroarch that work on arm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment