Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

RetroArch on Raspbian: the tutorial

Thu Sep 19, 2013 6:07 pm

Why RetroArch?


Because it offers a common backend for emulators and other ports like native engine reimplementations (scummvm, prboom, cavestory) so they can run as intended:
-No slow X11 protocol involved (wich causes high CPU usage and audio/video/control lag)
RetroArch CAN use a direct EGL backend. Even better, it can use Raspberry Pi native 2D API, Dispmanx! You can't get better than this, really :D
-Butter-smooth scroll at native phisical monitor refresh rates: for example, if a NES emulator runs at 60.1Hz and your monitor runs at 59.995 Hz, you would get occasional desynced audio OR video frames (jerky scroll not caused by internal emulated system slowdowns). That's UGLY. RetroArch makes it's NES emulator run at your monitor refresh rate, so unless you use some CPU while playing, you'll always get perfect srcoll.
-No need for a specialized GNU/Linux distro: just use your X-less Raspbian system to play these classics!
-Native linux input, no SDL required AT ALL!
-Of course, full screen scaling with adjustable ratio, size and pixed shaders for simulation phosphor crt magic (without the radiation :D) or the GameBoy screen.

TUTORIAL ITSELF

Making RetroArch and some cores work on the Pi is very easy! In fact, it's easier than it is on an X86 PC.

First, we are going to install some development libraries an the git utility, wich we need:

Code: Select all

sudo apt-get install libasound2-dev git-core
Next, we will create the directory where our RetroArch+libraries will go:

Code: Select all

mkdir ~/retro
We are first building the main executable (RetroArch) and then we will build some dynamic libs (wich are the "libretro ports", ie, emulation libraries for each system, or native source ports):

1) We clone the git repo:

Code: Select all

git clone --depth 1 git://github.com/libretro/RetroArch.git
2) We enter the cloned sources directory:

Code: Select all

cd RetroArch
3) We configure the sources for compilation. We disable some features here, to get a lighter executable with just the stuff we need. GLES and VG will be disabled with these. My dispmanx driver the most optimal solution on the Pi:

Code: Select all

 
./configure --disable-vg --disable-opengl --disable-gles --disable-fbo --disable-egl --enable-dispmanx --disable-x11 --disable-sdl2 --enable-floathard --disable-ffmpeg --disable-netplay --enable-udev --disable-sdl --disable-pulse --disable-oss --disable-freetype --disable-7zip --disable-libxml2 
3.5) Optionally, we can add some optimization flags. We edit config.mk and leave CFLAGS, CXXFLAGS and ASFLAGS lines like this:

Code: Select all

CFLAGS = -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
Then we can edit Makefile.common and comment this line if we're not doing debug work:

Code: Select all

DEBUG_FLAG = -g
4) We compile RetroArch!

Code: Select all

make V=1
5) Now we move it to our RetroArch directory:

Code: Select all

mv retroarch ~/retro
Now, let's go for some emulation libraries. What about a fullspeed MegaDrive + MegaCD emulator running fullscreen at a constant and solid 60FPS with NO TEARING and smooooooth scroll as in real hardware? (My Pi is running at 950 MHz) :D

1) We clone the repo:

Code: Select all

git clone https://github.com/libretro/picodrive.git
2)We make some adjustments to the sources:

Code: Select all

git submodule init && git submodule update
3)We configure the sources.

Code: Select all

./configure
4)We build them:

Code: Select all

make -f Makefile.libretro platform=armv6e
We will get a file called picodrive_libretro.so. That's our sega emulation library :D
We move it to the same directory where RetroArch is:

Code: Select all

mv picodrive_libretro.so ~/retro
Now let's go for PC-Engine emulation!

The process is very similar to the other two: clone, configure, build, and move the resulting *.so file to our retro dir, so I won't be detailing the steps:

Code: Select all

git clone https://github.com/petrockblog/mednafen-pce-libretro.git
make
mv *.so ~/retro
Now for the NES core:

Code: Select all

git clone git://github.com/libretro/fceu-next.git
pushd fceumm-code
make -f Makefile.libretro
mv *.so ~/retro
....and so on :D

Now, we go to our retro dir and run some Sega MegaDrive game:

Code: Select all

cd ~/retro
./retroarch -L picodrive_libretro.so sega/Sonic.md
We can use joysticks, etc. But that's beyond the scope of this tutorial.

Now let's say we want to run a Nintendo game:

Code: Select all

cd ~/retro
./retroarch -L fceumm_libretro.so nes/Mario.nes
..etc.
Other tested cores wich work perfectly are: prboom, nxengine, gambatte...
You can find their repositories here:

https://github.com/libretro

Have fun!
Last edited by Vanfanel on Sat Mar 21, 2015 5:52 pm, edited 5 times in total.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Thu Sep 19, 2013 7:34 pm

Vanfanel
Nice one! I will add to the Emulation Thread.
"The list of things I have heard now contains everything!"

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Thu Sep 19, 2013 7:48 pm

Thanks, Whelsy

Did you find a better pce libretro repository? The one I am using (in this tutorial) results on too slow SuperGrafx games, too.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Thu Sep 19, 2013 8:34 pm

Vanfanel
I found one elsewhere* and it is the pce_fast module but its approx 48 fps at 900MHz (For CD and SGX), I have Mednafen on another Image built with the pce_fast module and it runs at the same speed. But as mednafen offers 'Frameskip' its not slow! (However, the scrolling is TERRIBLE!). Like I always say emulation it always a 'Compromise'. If you want to try it ill post for you.

*Looking at the folders/files its the same one u have from Petrock's GIT
"The list of things I have heard now contains everything!"

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Thu Sep 19, 2013 11:21 pm

That's strange. PCE CD shouldn't cause any additional CPU load! (unless you're using ISO+MP3 for the games, a VERY bad idea).
And "plain" PCE games are rock-solid 60FPS here. Have you compiled RetroArch with the EXACT configure optiones I specified or are you using X11 graphics?

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Fri Sep 20, 2013 7:58 am

Vanfanel
No, I just did a 'default' build for testing purposes (with of course the obligatory NO X11!). ROM games are fullspeed SGX and CD games (I'm using standard .bin & .cue files) are not, as Mednafen produces similar (although not as impressive/fast) results I assumed it was normal (i.e. the extra processing required to stream the Red Book Audio). I am going to compile it again using some of your enable/disable features for further testing. Just one point (for others using the Tutorial including myself) are you using Arch as typing 'git clone git://github.com/libretro/RetroArch.git' etc. in Wheezy produces a bash error? (I don't tend to do this relying on downloading the zip file from the website).

Update - Sussed it you require the git dialog to be installed! May be advisable to add that to the Tutorial.
Last edited by welshy on Fri Sep 20, 2013 3:20 pm, edited 1 time in total.
"The list of things I have heard now contains everything!"

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Fri Sep 20, 2013 1:33 pm

Vanfanel
Added to the 'Emulation on the Raspberry' Pi Thread.
"The list of things I have heard now contains everything!"

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Fri Sep 20, 2013 5:09 pm

Doing 'git clone git://github.com/libretro/RetroArch.git' works here without any problem. What's the error you're getting?

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Fri Sep 20, 2013 5:18 pm

Vanfanel
A bash error, it doesn't understand 'git'.
"The list of things I have heard now contains everything!"

User avatar
LemmeFatale
Posts: 253
Joined: Fri Feb 01, 2013 8:47 pm
Location: UK

Re: RetroArch on Raspbian: the tutorial

Sat Sep 21, 2013 12:29 am

You don't have it installed, it sounds like. Try running the following;

Code: Select all

sudo apt-get install git-core
Once that's done, I believe that part of Vanfanel's instructions should work fine. :)
Classic - Raspberry Pi Model B (512MB) with Motorola Atrix Lapdock
Lemcon-One - Raspberry Pi Model B (256MB) PiMAME TV-Box

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Sat Sep 21, 2013 9:57 am

I successfully compiled the pcsx_rearmed Core which works fine but its 'Flickery' RetroArch is giving the following error -
Failed to create image for buffer
[GL] Failed to create EGL image
I added the submodule updates and then compile with -
1. make -f Makefile.libretro platform=armv6e
and
2. make -f Makefile.libretro
Same results. Does anybody know what the issue is?
Last edited by welshy on Tue Sep 24, 2013 3:13 pm, edited 1 time in total.
"The list of things I have heard now contains everything!"

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Sat Sep 21, 2013 10:26 am

I only test/use emulators that will offer a perfect experience (rock solid 60FPS) on the Pi.
Why try to emulate something that's going to be slow and buggy on the Pi as the PSX? Better try PrBoom (Native), NxEngine (Native port also) or the INCREDIBLE Gambatte.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Sat Sep 21, 2013 11:22 am

Vanfanel
I'm only testing to see which cores work effectively performance wise, no doubt people are going to ask!

Cores Tested with Image 2013-02-09-wheezy-raspbian on a 256 & 512MEG RPi with a 64MEG GPU Split and 900MHz OverClock -

Stella (Sound 'Delay' Issue identified by Vanfanel, See Below)
QuickNES (No Issues)
Fceu-next ('Clone' Save file Issue identified by Vanfanel, See Below)
iMAME4ALL (No Issues)
Mednafen-pce (No Issues PC Engine Hu-Cards, SGX and CD games not 100%)
Picodrive (No Issues ROM and CD, 32X not 100%)
PocketSNES (SuperFX games not 100%)
Pcsx_ReARMed (Not 100%, use Frameskip (Core Options))
TyrQuake (No Issues)
Prboom (No Issues)
Last edited by welshy on Mon Oct 07, 2013 1:23 pm, edited 1 time in total.
"The list of things I have heard now contains everything!"

kalehrl
Posts: 350
Joined: Tue Jul 24, 2012 10:49 am

Re: RetroArch on Raspbian: the tutorial

Sun Oct 06, 2013 12:24 pm

I compiled RetroArch following the instructions and when I launch it I get:

Code: Select all

RetroArch [WARN] :: system_directory is not set in config. Assuming system directory is same folder as game: "".
RetroArch [ERROR] :: Couldn't find any audio driver named "ext"
RetroArch [ERROR] :: Fatal error received in: "find_audio_driver()"
I tried adding audio_driver = alsa in the cfg file but it still doesn't work.
Could it be because I'm using analogue audio and video?

EDIT:

Fixed it by installing libasound2-dev, running make clean and recompiling.

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Sun Oct 06, 2013 12:53 pm

@kalehlr:

run "./retroarch --features"

You should see:

Code: Select all

ALSA:
		audio driver: yes
somewhere in the output.
If you don't then you haven't ALSA support compiled in, so you should do:

Code: Select all

sudo apt-get install libasound2-dev
re-run the configure script and make again. It should work then :)
If not, ask here again.

(Instructions updated to reflect what LemmeFatale and Kalehr have reported)
Last edited by Vanfanel on Sun Oct 06, 2013 1:03 pm, edited 1 time in total.

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Sun Oct 06, 2013 1:03 pm

@whelsy:

-Don't you get an incremental sound delay when you play Stella?
Load a game, and start playing: Take Pitfall for example. Play for a while, like 3-4 minutes. Then jump and observe the jump sound lags way behind the video. Can you reproduce that?

-As for fceumm (fceu-next), have you noticed it creates files with illegal names in the directory containig the RetroArch executable?
Load a game wich has saveram support (Zelda, for example), and make a simple ls of the directory with the retroarch exe.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Sun Oct 06, 2013 1:08 pm

Vanfanel
Its probably due to the firmware bug again (as with the Stella Binary, mine seems fine as it was Built with 2013-02-09 (Pre Fix)), it has been verified and fixed

See Here - http://www.raspberrypi.org/phpBB3/viewt ... 78&t=57035

Edit - Yup, same issue here! Although there is nothing on close to identify it like a pcm_underrun warning?
"The list of things I have heard now contains everything!"

Vanfanel
Posts: 518
Joined: Sat Aug 18, 2012 5:58 pm

Re: RetroArch on Raspbian: the tutorial

Sun Oct 06, 2013 2:01 pm

@whelsy: No, there's nothing to identify the problem this time.
It has nothing to do with the old, now fixed Stella problem, don't worry. It's a libretro port oroblem I believe. I will run some tests and report to the libretro porter.

Can you replicate the fceumm issue, too?

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Mon Oct 07, 2013 8:50 am

Vanfanel
fceu-next Core
Yes same thing, it saves a Legend of Zelda.srm file in the roms folder and a 'gibberish/symbols' named file in the retroarch exe folder with the same information on it. I have edited the 'Core Test' post above identifying these issues.
"The list of things I have heard now contains everything!"

fivealive
Posts: 15
Joined: Tue Oct 08, 2013 9:29 am

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 9:40 am

I have run into an issue running these instructions and don't know what to do, here is the error I get :


pi@raspberrypi ~/RetroArch $ make -f Makefile.libretro platform=armv6e
make: Makefile.libretro: No such file or directory
make: *** No rule to make target `Makefile.libretro'. Stop.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 10:59 am

fivealive
A problem with the RetroArch executable or one of the 'Cores'? Please be a bit more specific and I will try to assist. From the output you may be trying to execute the command in the wrong folder where the isn't a makefile, was it PicoDrive you were trying to Build?
"The list of things I have heard now contains everything!"

fivealive
Posts: 15
Joined: Tue Oct 08, 2013 9:29 am

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 11:37 am

I was running this command


make -f Makefile.libretro platform=armv6e



Also of note I was copying and pasting the instructions into the terminal

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 11:40 am

fivealive
Yes I read that, but which folder were you in and what 'Core' were you attempting to Build? You can do all this in XWindows via a Terminal if your not used to command line through Console, then its easier to asses where your going wrong.
"The list of things I have heard now contains everything!"

fivealive
Posts: 15
Joined: Tue Oct 08, 2013 9:29 am

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 11:46 am

Be honest I have no idea, I was just copying and pasting the instructions, exactly as the order they are in, so I would imagine what ever directory I was supposed to be in. I know nothing about Linux.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: RetroArch on Raspbian: the tutorial

Tue Oct 08, 2013 11:56 am

fivealive
Ok, no probs, Vanfanel is very experienced so predominantly uses command Line. All the steps can be done in XWindows by simply making folders then transferring the contents (as you normally would in Windows systems) but I would have to rewrite the process! Perhaps a simpler Build would be advisable until your more confident in Linux, or start with a 'Fresh' wheezy Image and follow the steps EXACTLY! (if you have missed a step it will error). Was there a particular emulator you wished to use?
"The list of things I have heard now contains everything!"

Return to “Gaming”