Turn a Raspberry Pi 2 into a Retro Games Emulator

I recently bought 2 new Raspberry Pi 2’s for different projects. The first project was to make a Retro Game emulator using the Raspberry Pi 2 as I’d tried to do this previously on an Odroid C1 and a Raspberry Pi 1 but each had their own issues that made me look to the 2nd model Raspberry Pi.

To do this you will need the following:

– Raspberry Pi 2 (http://au.rs-online.com/web/p/processor-microcontroller-development-kits/8326274/) $48AUD
– Suitable MicroSD Card (8gb or Above) I used one of these (http://www.officeworks.com.au/shop/officeworks/p/sandisk-16gb-ultra-sdhc-memory-card-br190829) $14.95AUD
– Digitech USB2.0 Bluetooth® V4.0 Class 2 Dongle (http://www.jaycar.com.au/p/XC4956) $19.95AUD
– Sony Sixaxis Dualshock 3 controller mine was purchased from Playhard Gaming Greenhills $34.95
– Micro USB Cable (A-B  Type) – Did not purchase as I already had one
– Mini USB Cable (A-B  Type) – Did not purchase as I already had one
– 5VDC 2A USB Power Supply (Or use a 10W Apple one, or Intel Compute Stick Power Adaptor, or Samsung Note 3 Adaptor)
– A monitor/TV with a HDMI input

For me the total cost of this project ended up being $121.50AUD (if you include the RPI case) as everything else I had available so did not need to buy. If you needed to buy a power supply and the USB cables, the whole thing should still come in under $150.

Step 1 – Download the Raspberry Pi 2 Lakka.tv Image

CAUTION: Using the dd command listed in step 1 can have severe consequences if you use the wrong disk number, how severe you ask? Loss of all your data… so please read and understand before you use the command

You can obtain the Lakka image by going to here http://www.lakka.tv/get/linux/rpi2/ and downloading the file. Once it is downloaded on that site if you click next it will explain how to flash the image to your SD card. I’ve linked to the rpi2 page as they update the downloads frequently with bug fixes.

Once downloaded make sure you unpack the *.gz file, as we want just an *.img file for doing the image to SD card.

The next thing you will need to do is determine what disk number your SD card has. The instructions below are for OSX. If you are using windows you should follow these instructions: http://www.lakka.tv/get/windows/rpi2/install/

In terminal run the command diskutil list BEFORE you insert your SD Card. Then, insert your SD card and run the same command again. You should be able to compare the two results of the command and determine what disk number your SD card actually is.

Screen Shot 2016-01-31 at 4.01.09 pm

Once you know your SD cards disk number the commands to run are as follows:

Unmount the SD Card:

sudo diskutil unmountDisk /dev/diskX <—where X is the disk number

You should then see this

Unmount of all volumes on disk2 was successful

You can now image the sd card using the command below:

sudo dd if=pathtolakkafile of=/dev/diskX <—-where X is the disk number of the SD card

Then its best to leave the computer for a good while, because the dd command doesn’t actually give any progress indicators. It simply shows when it is completed. Below is a screenshot of me running each command above.

Screen Shot 2016-01-31 at 4.01.09 pm

Once the disk is imaged – the terminal will return to a standard prompt. At this point you can now eject the SD card using finder or run the diskutil unmountDisk /dev/diskX command again so that you can safely remove the card.

Note: if you read the top of the post you would of seen the caution message about using the dd command like this. If you get the disk number wrong dd will not stop and the command is not reversible it will write over the top of whatever disk you said to write to no questions asked – so please be ultra careful when using this command and make sure you are using the right disk number before pressing enter.

Step 2 – Booting up for the first time

Plug the MicroSD card into the Raspberry Pi 2, connect it to your HDMI screen, plug in the bluetooth USB dongle and connect the Pi to your network using an ethernet cable. When all of those things are connected it’s time to power up the device – so plug that USB cable into the Pi to fire it up.

If you watch the screen you will notice on first boot in the top left of the screen there will be information about the file system expanding, make sure you let the system go through this entire process then reboot. This basically is the system expanding the filesystem on the SD card to allow you to be able to use the full amount of storage space on the MicroSD card.

Once the system as rebooted you should first see the Lakka.tv logo then when fully booted you will see the orange Lakka.tv menu. If you’ve got this far thats great, your system is likely to work as expected!

Step 3 – Find the network address of your device if necessary

Lakka uses the avahi-daemon to allow network discovery via the name LAKKA however trying to connect to a device called LAKKA does not always work. If it does not I suggest reviewing your DHCP clients list on your network to determine what IP was given to the system – this is beyond the scope of this tutorial so I will not go into that process here (tweet me/DM me and I’ll explain it if you need it). You will need to do this so that you can complete the next step

Step 4 – Log into the device using SSH

To login to the device the command is as follows:

ssh root@lakka.local

if that does not work the command is:

ssh root@IPADDRESS e.g. ssh root@192.168.1.16

You will be asked for the password, the password is root.

Step 5 – Pair your Sony Playstation controller

At this step I assume you are already logged into the device by SSH – if you are you should now follow the instructions on pairing the controller here: http://www.lakka.tv/doc/Wireless-Dualshock/ 

Follow the instructions carefully, particularly the part about plugging the controller in by USB – if you don’t do this the controller will never pair.

A few things to note, for me the once I pressed the PS Home button the controller showed its MAC Address but I did not get a message to authorise the controller. If this happens, unplug the controller and press the PS Home button again and you should see the authorise message. Once you have seen that you can simply continue on with the rest of the commands. Make sure you add the local rules so that bluetooth stays on after a reboot.

Once the controller has been paired you should be able to move around in the Lakka menu simply using the controller – it will autoconfigure itself. Your controller should have the number 1 LED lit to show it is connected.

I’ve not tested adding a second controller but have been told that you basically follow the same process for controller number 2 – and the second controller will light the number 2 LED to show it is in fact, controller number 2.

Below is a screenshot of me going through this process, unfortunately my connection dropped during the SSH connection so theres a reconnection in there as well:

Screen Shot 2016-02-01 at 7.06.46 AM

Step 6 – Add your games to the system

Now that you’ve got your controller and everything else ready to go you just need to add games to the system. This part is quite simple, in Finder you should see a device called LAKKA – click on this then open the ROMS folder, you can now simply drag and drop your games into this folder from your computer. Remember LAKKA needs the files unzipped or it can not open them so make sure you unzip your roms before you copy them across.

Remember for certain consoles you will also need a BIOS file (e.g. Sony Playstation) the BIOS files need to be added to the System folder using the same method above to access the folder (click Lakka in Finder, then click the System folder and then drag and drop your BIOS files to it)

I found it was better to do small amount of data at a time instead of a large file transfer of everything at once.

Step 7 – Play!

I found the easiest way to get started was go to load content then press the circle button on the controller, you should then get a list of all the games you added in step six – highlight the one you want to play then press circle again and it should begin to load.

If you want to change games, simply press the PS Home button, then goto close content. In the LAKKA menu’s the circle button is select/next and the X button is go back.

Notes:

I’ve only tested Sega Master System, Nintendo 64 and Playstation one at this point. So far the only games that did not work well were Nintendo 64 – they were a little too laggy to play but everything else worked quite well. Below is a video of me testing PSX with the Sixaxis controller – works quite well!

Once you’ve loaded everything on to the Raspberry Pi you don’t really need network access to it any more so you should be able to safely move it to another device, or take it somewhere else to play.

 

 


Posted in Linux, Raspberry Pi


Leave a Reply

Your email address will not be published. Required fields are marked *