Tutorial 0: Building a Portable Raspberry Pi 4B Retro Gaming Console
Raspberry PI 4B, 7" Screen, External Speaker, Gamepad, Battery, Awesomeness!
-
Author: Brian A. Ree
Sections
0: Parts Needed
- A Raspberry PI R4 B: ~ $62.00
link
- A Raspberry PI 7" Screen: ~ $64.00
link
- A Set of Micro SD Cards: ~ $19.00:
link
- A Raspberry PI 4B 7" Screen Case: ~ $28.00
link
- Raspberry PI Power Supply with Switch: ~ $10.00
link
- Raspberry PI Battery Power Supply 3A: ~ $16.00
link
- External Mini Speaker: ~ $16.00
link
- GameSir Wired Gamepad: ~ $22.00
link
-- 1: Introduction and Tutorial Goals --
Welcome to my first Raspberry PI tutorial! This is a build tutorial that will show you how to make a portable Raspberry PI 4B with a 7" screen,
a battery power supply that can run at 3 amps for a few hours, an external speaker, a wireless gamepad, and plug-in power supply with a switch.
What is all this for? Basically building the ultimate Raspberry PI 4B portable gaming console that let's you retro game almost anywhere. It also gives you the
flexibility to use different controllers and headphones, even a keyboard for your ScummVM or DOSBOX games. The total cost will run you about $250
and you'll have to prepare the SD and hardware yourself but the end result is pretty awesome. Let's hop to it, shall we.
-- 2: Preparing Your SD Card --
You'll need to get a copy of the latest version of Lakka. I recommend using Lakka because it has support for
Raspberry PI 4B and it's a really solid retro gaming OS. You can find different versions of Lakka here
or you can download the latest Raspberry PI 4B version directly from here.
You'll need the ability to write to an SD card to complete this next step. So find a computer with SD support or purchase an SD card to USB
adapter and you should be good to go. Let the download complete and then follow the instructions below for your operating system.
Writing an OS Image on Linux
This step will cover writing to your your micro SD card. If you've connected your micro SD card, please eject it. We're going to get the device in Linux for the memory module
and we want to be able to detect that new device so we don't accidentally write to our Hard Kernel bootable micro SD card.
For this step you're going to need to open up a terminal. On the top left hand side of the screen bring up the list of applications, and utilities.
Click on System Tools, then locate the MATE Terminal program entry as depicted below. Click it and you'll have a terminal window
to work with.
In the terminal type the following command:
sudo fdisk -l
Note the list of drive devices that are shown. Now connect your memory module and run the command again. Note the new entry in the list and write it down or copy
and paste it into a text document. This step verifies that we'll be writing to the proper memory module. For the purposes of writing this tutorial
let's assume that the device is dev/sdx. Next we will unmount the device by using some sweet terminal commands.
Unmount the partitions by running:
sudo umount /dev/sdx*
It may give an error saying the disk isn't mounted - that's fine. Now we'll write the contents of the image file onto the SD card by running
the following command.
sudo dd bs=1M if=/path/to/file/your_image_file_name.img of=/dev/sdx
If your file has a .img.xz extension instead of a .img extension you can right-click the file in MATE using normal file operations
and extract it to a .img file. You can also use the following command to do both operations in one step.
sudo xz -d < /path/to/file/your_image_file_name.img.xz - | dd of=/dev/sdx
Remember in this case the /path/to/file/your_image_file_name.img.xz or /path/to/file/your_image_file_name.img is the
path to the ubuntu-18.04.3-4.9-mate-odroid-n2-20190812.img.xz file we want to write and /dev/sdx is the device name we figured out earlier.
You can navigate to where the file is located using the MATE desktop. Right-click the window and select the Open Terminal command to open a terminal at the location of the target
file.
In this case your terminal commands would be:
sudo dd bs=1M if=your_image_file_name.img of=/dev/sdx
or
sudo xz -d < your_image_file_name.img.xz - | dd of=/dev/sdx
Let the operation run to completion and you'll have a fresh new bootable memory module to use on your device. What is more you
can use these steps to try different Raspberry PI operating system images. Just look around the internets for other OS options
to try. For our purposes we are ready to move onto the next step of this tutorial. I will take a moment to demonstrate other ways to
write the image to the memory module. It is important to note that the eMMC module and the micro SD card behave the same at this point.
Linux just views them as a memory device to write to.
If you are working with Ubuntu MATE or something similar you can use a gui method to write the image to your memory module of choice.
Once the image file has finished downloading find the file in your Downloads folder and right-click on it.
Select the Open With Disk Image Writer option. You should see a window pop-up similar to what's shown below.
Select the proper destination to write the image. ALERT: Be very careful here, make sure you are choosing the target memory module
and not the boot SD card!!!
Writing an OS Image on a Mac
To write the OS image file on a Mac we recommend getting a great piece of free software, Balena Etcher.
You could also probably run the Linux commands listed above in a terminal on a Mac but let's try something new. Download and install Balena Etcher.
The software handles writing .img.xz files so you don't have to worry about decompressing the OS image. Locate your OS image file.
Note: The screen shots below show a different file being written then the one we are working with. The process is the same, no worries.
Next, fire up Balena Etcher and answer any prompts for higher privileges that might pop up.
Double check that you're indeed flashing the correct device and that it is the correct approximate size!!
Start flashing the device and wait for the process to complete.
Writing an OS Image on Windows
To write the OS image file on a Mac we recommend getting a great piece of free software, Win32 Disk Imager.
Now if you are running Ubuntu Linux under Windows 10 you could also probably run the Linux commands listed above in a terminal.
You could also install the Windows version of Balena Etcher and follow the directions for that software listed above.
I want to show you a new way so that you have a bunch of options and tools you can use to make your own bootable memory modules.
You'll have to decompress the .img.xz file before we can write it to the memory module. Get a free copy of 7-Zip.
Install it and use it to decompress the .img.xz file you should have a nice fresh .img file in a few minutes.
Once your .img file is decompressed and ready to use open up Win32 Disk Imager and navigate to the .img file you want to
write to your micro SD card. ALERT: Be sure to select the proper drive letter to write to!! If you have any doubts just eject the micro SD card
and take note of which drive letters go away. Some card, especially if they have a bootable OS on them, will mount as two drive letters. It is ok
to simply choose one of them. The screen shot below shows Win32 Disk Imager in action, it is being used to write a different .img
file, just ignore that part.
Once you have everything setup click the Write button at the bottom of the window and let the software do its thing.
Be careful that you click the correct button. It can become confusing at times which direction the read or write operation is going,
especially if you've done a few card in a row using different operations. There will be some hint text that will explain
what the button you're about to click does. I always read it and double check that it is indeed what I want to do.
-- 3: Small Lakka Fix --
Now that you have your SD setup you may need to perform a small Lakka fix. You can wait until your device is all setup
and run some tests to see if this is necessary but if you are running Lakka 2.3.2 for Raspberry PI 4B you may need to
make a small change to the files on the boot partition. One way to tell if you need the fix is if your Sega CD emulator fails
and crashes out.
If you are able to SSH into your Raspberry PI and verify the logs you'll see an error similar to the following.
[INFO] [MIDI]: Initializing ...
ALSA lib /mnt/data/PROJECTS/Lakka-LibreELEC/build.Lakka-RPi4.arm/alsa-lib-1.1.9/src/seq/seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
[ERROR] [MIDI]: snd_seq_open failed with error -2.
[ERROR] [MIDI]: Initialization failed (list of input devices unavailable).
It's a quick and easy fix. You can adjust the Fat32 boot partition from Windows or Mac.
- Link to Issue
- Link to Fix
You can download the file's in question from here.
Make a backup of the original files in your SD card's boot partition. Rename the new files to match one's you are
replacing and you're good to go.
-- 4: Portable Console Build --
You're all ready to build the actual console, putting the 7" screen, case, and Raspberry PI 4B together.
Now, we won't be installing drivers for the touch screen features of the official Raspberry PI 7" screen.
We really won't need it, we're going to be gaming with a proper controller, also I'm not sure Lakka would support the
touch screen drivers so you can skip the first part of the build process, or you can experiment and see if you
can get it to work. A detailed build tutorial can be found here.
You can also try this link.
Once you're done with the build process you should have something all setup as depicted in the photos below.
Note that the audio plug extender is part of the external speaker I recommend as part of the project.
Now, let's give it a whirl with a decent set of attachments. I'm using a wireless version of the GameSir controller listed
above. I also have a USB Wifi dongle so I can download updates, and I'm using the battery powered option for a power supply.
For extra information on how to setup certain emulators and configure different controllers in Lakka check out some of the tutorials
on retro gaming consoles here. Enjoy!!