Tutorial  Updated

Build and run RetroArch for Arch Linux (multi-consoles emulator)

This is a partial rewrite of the guide I wrote for r/SwitchHacks

Here is a short guide to quickly explain how to run RetroArch on Arch Linux on your Switch. RetroArch is a multi-platform multi-consoles emulator. It's basically like an empty shell in which you put your emulator ; they are called "cores". RetroArch loads a core for the desired console, which then loads and boots the game you feed it.

This is not a guide for using RetroArch, there are plenty out there. This is rather a guide to explain how to make it run on the Switch. You should build it yourself rather than using pre-compiled binaries because each binary is suited for the system it's been compiled on, in terms of features and drivers. For instance, if you don't have freetype or opengl installed you won't be able to use a RetroArch binary with XMB support enabled.

Anyway - I will assume that you already have a working copy of Arch Linux on your Switch, with sudo and GPU acceleration enabled. If you don't, go check my other guide (it's in this category). I will also assume that you know how to open and use a terminal (warning : gnome-terminal doesn't work yet).

To make the best out of RetroArch, I personnally recommend the KDE image that Gigaa made. I also recommend that you open a SSH terminal on your Switch, because you know, the onscreen keyboard is not very practical. Be aware that Wi-Fi and Bluetooth won't work at the same time, it will crash your console. Fixed with GNOME and KDE images.

List of known working cores :
  • vba-next
  • snes9x2010
  • beetle-psx (runs at approx. 50fps with "normal" power setting, however this causes power failures)
  • dosbox
List of known not working cores :
Building RetroArch

Code:
$ sudo pacman -S freetype2
$ sudo pacman -S base-devel
$ sudo pacman -S git
$ git clone --depth 1 https://github.com/libretro/RetroArch
$ cd RetroArch
$ ./configure
$ make

You can then run RetroArch with "./retroarch". It should start with the XMB menu working out of the box. To remove the black squares and add a nice font, go to the Online updater and download the assets. You can use RetroArch with the onscreen keyboard, although this is not very convenient.

You can improve performances of the XMB menu by going into Settings > User interface > Appearance and then disabling text shadows and using the simplified ribbon as a background.
Use backspace to go back in the menus. Escape will quit RetroArch. Don't thank me.

Building cores

As the buildbot doesn't contain the linux-aarch64 cores yet, you will have to build them yourself. Be careful as some cores need a JIT compiler to run at full performances (like parallel-n64) : they will need a "ARM64" JIT (simply "ARM" compilers will not work). If a core needs a JIT but don't offer a ARM64 / AARCH64 JIT, don't bother compiling it.

This being said - identify the core you want to build. I do this by going to the libretro organization on GitHub and typing in the name of the console I want the core of. Some consoles have a shitload of cores, just take the best one based on the date / description /last commit / README. Be careful as some cores have specific build instructions (typically written on the README).

For this example I will take vba-next, the libretro port of the VBA emulator (GBA). Just clone the corresponding repository and make the core :

Code:
$ git clone --depth 1 https://github.com/libretro/vba-next.git
$ cd vba-next
$ make

This will give you a file called "vba-next.so" : this is your core. To have it recognized by RetroArch, copy it in the right directory (run RA at least once so it creates it) :

Code:
$ cp vba-next.so ~/.config/retroarch/cores

You can then run RetroArch and load the core, then your game ! Enjoy <3
Feel free to report any core you tried, I'll add them to the list at the beginning of this post !
 
Last edited by natinusala,

SomeSHET

Member
Newcomer
Joined
Apr 27, 2018
Messages
14
Trophies
0
Age
24
XP
142
Country
United States
I get this error at the end when building RetroArch

Building the cores work fine though, thanks!
 

Attachments

  • Screenshot from 2018-04-29 01-34-24.png
    Screenshot from 2018-04-29 01-34-24.png
    70.5 KB · Views: 716
Last edited by SomeSHET,

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
I get this error at the end when building RetroArch

Building the cores work fine though, thanks!

Why in the heavens do you have EGL in here ? It's supposed to be disabled when running ./configure...

Try to run "HAVE_EGL=0 make" instead of just "make"
 

Samus20XX

Well-Known Member
Member
Joined
Mar 21, 2018
Messages
107
Trophies
0
XP
274
Country
United States
Sound + joycons working?

This is really good stuff man. I appreciate your work a whole bunch. Cheers homie.
 

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
How well does beetle-psx run?

It ran fine without the GPU profile fix, now it should run even better - I am currently rebuilding RetroArch on my fresh GNOME image, I'll report once I test it

Sound + joycons working?

This is really good stuff man. I appreciate your work a whole bunch. Cheers homie.

Nope, unfortunately there's still no sound nor joy-cons support (even through Bluetooth). However, @shinyquagsire23 has succeeded to write a wired joy-con protocol implementation, we'll just have to wait for it to be ready and (most importantly) ported to Linux.
 
  • Like
Reactions: lordelan

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
Great work and beat me to a working version with a tut!
Anyone have a link for the gigaa image?

It's in my guide :) Be careful as the "normal" power mode can cause power failures as it's not meant to be used undocked
 

saneatsu

Well-Known Member
Newcomer
Joined
Apr 28, 2018
Messages
54
Trophies
0
Age
32
XP
209
Country
United States
Why in the heavens do you have EGL in here ? It's supposed to be disabled when running ./configure...

Try to run "HAVE_EGL=0 make" instead of just "make"

I'm having the same issue, I tried the HAVE_EGL=0 make, and got the same error. I'm currently starting from scratch (removing the git and re-cloning). Not sure why it fails though as I saw in the original ./configure that you disable the EGL. So no real idea what's going on here, except I noticed that you changed the ./configure to just configure.
 

saneatsu

Well-Known Member
Newcomer
Joined
Apr 28, 2018
Messages
54
Trophies
0
Age
32
XP
209
Country
United States
The --disable-egl option means "I have EGL but I don't want to use it". Just ./configure works fine
So I've since learned a few interesting things.

1.) Retroarch does build just fine if you use the basic ./configure. If you've already tried to run make and still get the EGL error you MUST run "make clean" first then ./configure and make. In fact using the --disable-egl seems to tell the compiler that wayland is present and you should set a flag to NONE which interestingly wayland cannot use. Thus leaving it completely out when you configure forces the compiler to check if wayland & EGL support is there. Strangely you can install wayland through pacman, this doesn't solve the underlying function error BUT if you ./configure even with wayland support retroarch will still build without it as the EGL support is detected as not present. It's funny that they seem to have gone out of their way to do this check and trying to circumvent it causes more problems.

2.) Retroarch looks for a retroarch folder in /usr/share (when compiled from src), if you run retroarch as alarm then you will not have permissions to that folder. You can run retroarch as "sudo ./retroarch" but if you do you MUST run it that way every time if you want settings to stick. It is simpler to just "sudo chmod 757 -R /usr/share/retroarch". This will allow you to download the asset file as the alarm user so you don't have to always run retroarch as sudo. Now I'm sure there's a reason I'm getting this error that I'm not realizing and my chmod bypass is a little sketchy given the location, but I don't see any glaring issues with doing it that way. (To answer any questions you only have to do this once on that folder).

3.) You can go one step further and install retroarch using "make install" however the /usr/share issue is still present. All this lets you do is run retroarch from a shortcut on the desktop (you still have to make that) or from the terminal just by the command "retroarch".

4.) Retroarch is horribly sensitive when it comes to navigating the interface. Not sure if that is due to lag from VNC or not, but I have a hell of a time navigating the menu.

5.) Great proof of concept, can confirm this works on Gigaa's Arch KDE rootfs 3 just fine. It's just picky.

Overall amazing work. The switch will certainly become one of the best emulation systems that exist, it's just going to take time and better people than me to get it done. I'm in no way new to linux, I just don't have experience writing display/wifi/sound/bluetooth drivers. However, something interesting of note, could the reason wifi not be working on first boot be due to the RCM mode not initializing things as it "assumes" that it is in recovery mode?

Also the issue with the bluetooth and wifi remind me of the Palm TX back when people were porting linux to that. I know it's a vastly different system (still arm IIRC) and a MUCH newer BT stack, but it's funny to see how bluetooth issues can continue to crop up from generation to generation.
 
Last edited by saneatsu,
  • Like
Reactions: lordelan

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
2.) Retroarch looks for a retroarch folder in /usr/share (when compiled from src), if you run retroarch as alarm then you will not have permissions to that folder. You can run retroarch as "sudo ./retroarch" but if you do you MUST run it that way every time if you want settings to stick. It is simpler to just "sudo chmod 755 -R /usr/share/retroarch". This will allow you to download the asset file as the alarm user so you don't have to always run retroarch as sudo. Now I'm sure there's a reason I'm getting this error that I'm not realizing and my chmod bypass is a little sketchy given the location, but I don't see any glaring issues with doing it that way. (To answer any questions you only have to do this once on that folder).

What ? My copy looks for ~/.config/retroarch, not /usr/share ?

4.) Retroarch is horribly sensitive when it comes to navigating the interface. Not sure if that is due to lag from VNC or not, but I have a hell of a time navigating the menu.

I agree, just don't use the mouse and go with the keyboard

Overall amazing work. The switch will certainly become one of the best emulation systems that exist, it's just going to take time and better people than me to get it done. I'm in no way new to linux, I just don't have experience writing display/wifi/sound/bluetooth drivers. However, something interesting of note, could the reason wifi not be working on first boot be due to the RCM mode not initializing things as it "assumes" that it is in recovery mode?

Lakka is going to be the ultimate retro gaming experience on the Switch :D
 

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
That's... interesting. I've played with RA (and Lakka) quite a lot and never saw this. Did you build it as root ?

Anyway you can specify the config file when launching it, IIRC it's `./retroarch --config ~/.config/retroarch/retroarch.cfg` but you will have to create the cfg file yourself and put all the other directories here (system, assets, cores, etc). Do you want mine, it's already setup ?
 

saneatsu

Well-Known Member
Newcomer
Joined
Apr 28, 2018
Messages
54
Trophies
0
Age
32
XP
209
Country
United States
That's... interesting. I've played with RA (and Lakka) quite a lot and never saw this. Did you build it as root ?

Anyway you can specify the config file when launching it, IIRC it's `./retroarch --config `

I did try building as root when I was getting the EGL that SomeShet got, but I ran a make clean then built as alarm. Odd and I'll probably just re-build it when the next update to Arch or Ubuntu rootfs is updated.
 

natinusala

Win32 error 31 is not an error
OP
Member
Joined
Dec 1, 2012
Messages
1,032
Trophies
0
Age
44
XP
2,914
Country
France
I think that building as root broke the configuration. I'd suggest you just nuke everything and start over from a clean clone.
 

saneatsu

Well-Known Member
Newcomer
Joined
Apr 28, 2018
Messages
54
Trophies
0
Age
32
XP
209
Country
United States
I think that building as root broke the configuration. I'd suggest you just nuke everything and start over from a clean clone.

Yeah but where's the fun in that :P. It seems to work fine now that I've gone through and chmod'd the /usr/share/retroarch folder. I'll probably nuke the SD at some point though and start fresh.
 
  • Like
Reactions: natinusala

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: https://www.keepretro.com/products/miyoo-a30