MONGOOSE

Game Console

This is a guide for building our own game console using a Raspberry Pi and Pico-8. Raspberry Pi is an inexpensive single-board computer. Pico-8 is the game console software. I wrote this guide because when I undertook this project, all of this information was not all in one place anywhere that I could find on the internet.

Things Needed

Raspberry Pi Zero

This guide is using the Raaspberry Pi Zero. The Zero is a cheaper version of the Raspberry Pi. It's not as powerful as a standard Raspberry Pi, but it's sufficient for this project.

This Raspberry Pi Zero Kit on Amazon is a great way to start. It not only comes with the Raspberry Pi Zero, but it also includes a case, and a variety of other needed cables and adapters.

Micro SD Card

The whole project is pretty small, so the cheapest SD Card will sufice.

Pico-8

The game console software itself! You can get Pico-8 from the www.lexaloffle.com.

Other Things

We'll also need another PC for downloading the Operating System and software and writing it to your SD card. Other things needed will be a keyboard, game controller, and a display. Some other optional accessories include a USB hub and battery pack.

Prepare SD Card

First, we'll need to put an operating system on the SD card.

Download Raspbian Lite. Be sure to choose the Raspbian Buster Lite option; we wont need the desktop. Then download balenaEtcher to write the image to your SD card. Raspbian is the operating sytem that the game console is built on. It's a fork of Debian Linux modified to be used specifically for the Raspberry Pi. Raspbian Lite does not have a desktop environment, that means everything will be done via the command line.

Aside: A Linux Primer

This project will be done almost completely in the Linux command line. There is not a lot to cover. I'll name a few of the programs that we will use, and some basic commands. To run a command that requires admin access, the command has to start with sudo. Sudo is short for Super User Do.

Programs

Raspi-config (Raspberry Pi Software Configuration Tool)
nano (a text editor)
tar (for unzipping files)

Commands

cd (change directory)
ls (list files and folders incurrent director)
pwd (print working directory)
ping (useful for testing network connection)
clear (clears screen)
ifconfig (print network information)
reboot (reboots computer)

Raspberry Pi Settings

Insert SD Card and boot up the Raspberry Pi. We'll start with adjusting some basic settings.

Login

We'll first be greated with a prompt wanting login credintials.

Here is the Raspberry Pi's default Admin Username and Password:

username: pi
password: raspberry

Connect WiFi

We'll get started by launching the Raspberry Pi Software Configuration Tool (raspi-config)

Type in this command and press enter

sudo raspi-config

Select Wi-Fi under the Network Options. We'll need to supply your country, SSID (Wi-Fi network name), and Passphase (or password).

2 Network Options
N2 Wi-Fi

If you typed in something incorrectly, or need to add another network, you can access the file where these settings are store by typing the following:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Look for the section below and edit the values in quotation marks. If you need to add another network, copy and paste these four lines at the bottom and replace the credentials.

network={
ssid=”Test Wifi Network”
psk=”SecretPassWord"
}

Keyboard Layout

Raspberry Pis come with the English (UK) keyboard layout by default. We'll want to change the keyboard layout to English (US). Launch raspi-config

sudo raspi-config

Choose Change Keyboard Layout under Localization Options.

4 Localization Options
3 Change Keyboard Layout

Choose Generic 101-key PC
English (US)
[AltGr] The default for this layout
No compose key

Update OS

Get an updated list of upgrades available for packages on the Raspberry Pi

sudo apt-get update

Install the available upgrades to all packages. This will take several minutes. There will be prompts asking permission for it to continue. Type y for yes.

sudo apt-get upgrades

Transfer Pico-8 to Pi

Time to download and trasfer Pico-8 onto the Raspberry Pi. We'll adjust a few more settings on the Pi, then move to our computer to continue this task.

Enable SSH on Pi

First, we'll need to enable SSH on the Pi. SSH is Secure Shell and will allow us to connect to the Raspberry Pi from another computer.

Run raspi-config and enable SSH under the Interface Options

sudo raspi-config

5 Interfacing Options
2 SSH

Change User Password on Pi

With SSH enabled, we'll want to change the default password for user Pi for security reasons. I actually don't know if enabling SSH will introduce security issues with the ultimate setup, but it's an easy step, so we'll do it.

sudo raspi-config

1 Change User Password

FTP From Computer

Transfer Pico-8 to the Raspberry Pi. We'll need a FTP (File Transfer Protocal) program. I use Mozilla's FileZilla. To transfer the files, we'll need to supply your FTP program with your Raspberry Pi's IP address. You can get your IP address by running ifconfig on your raspberry pi.

ifconfig

Look for the inet value, it'll be 192.168._._. We'll also have to supply your Username (Pi) and Password (Raspberry or whatever we changed it to in a previous step). Use 22 for the port.

Download Pico-8 making sure you select the Linux version. Make a new directory home/pi/pico8 and upload the files there.

Get Pico-8 working

We'll have to grant run permissions for the Pico-8 executable

sudo chmod a+x pico8

Install wireingpi

apt-get install wiringpi

Install libasound2-dev

apt-get install libasound2-dev

Download sndio-1.2.0.tar.gz and oad it to your raspberry pi (using FTP) to home/pi/sndio.

Change to the newly made directory

cd /home/pi/sndio

Unzip the archive

tar -xf sndio-1.2.0.tar.gz

Change into the newly created directory

cd sndio-1.2.0

Run the configure program in this directory

./configure

Follow the onscreen instruction to compile and install sndio

make
sudo make install

Pico-8 should be ready to go! Change into the pico-8 directory

cd /home/pi/pico8

Launch Pico-8

./pico8

Everything is good to go! The only step left is to make Pico-8 run with Raspberry Pi is booted up.

Make Pico-8 Launch at Startup

Almost done! Now we need to make Pico-8 launch at startup. We will write imple script that runs the Pico-8 executable. We will then use a vice called Systemd to run that script at startup.

Write a script

Change to the directory that will store the script file.

cd /user/local/sbin/

Use the touch command to create a text file e named pico8.sh

sudo touch pico8.sh

Use nano to edit the file

sudo nano pico8.sh

Edit the file to look like below. Use CTRL+X to Exit Nano. Type Y when asked if want to save changes, then press enter to overwrite the file.

#! /bin/bash
/home/pi/pico-8/pico8

We'll need to give all users permission to execute this file

sudo chmod a+x pico8.sh

Create a Startup Service

We'll need to create a service that will run at startup. We'll use Nano edit the startup service file

sudo nano /etc/systemd/system/my-startup.service

Edit the file to look like the below

[Unit]
Description = My startup
[Service]
ExecStart = /usr/local/sbin/pico8.sh
[Install]
WantedBy = multi-user.target

Use systemctl to check the status of the vice. The following command will help us ensure we created the Startup vice correctly and will help us diagnos any problems incase something typed incorrectly.

systemctl status my-startup.service

We'll see that the service is inactive, so let's get it started

sudo systemctl enable my-startup.service

Finished!

Reboot and the Pi should launch straight into Pico-8!