Game Boy Zero - Handheld Edition (DIY)

Hey all!

Thanks so far for the great support on tindie. What a great community!

Okay, so i have had a few questions (which i totally love your feedback) about installation processes on the Raspberry Pi Zero.

Let’s do this.

Gameboy Zero - Pocket Installation

This document is intended for a somewhat advanced user base, but we have made it simple enough to follow along for anyone

Prerequisites

  1. Fresh RetroPie install mounted on an SD Card
  2. Raspberry Pi Zero (preferably WiFi edition)
  3. Keyboard
  4. OTG USB Cable (to plug in a USB A type keyboard)
  5. Mini HDMI (you know, to see things on a screen)

Step 1

Setup Raspberry Pi requirements

With your Keyboard and HDMI cable plugged in, go ahead and turn on your Raspberry Pi Zero
Allow it to go through the boot requirements (RetroPie will reboot once on it’s own)

Once the Raspberry Pi boots into RetroPie, it will start EmulationStation automatically.

You will see a screen telling you to either set up a controller or press F4 to exit.

  • Press F4 to exit to terminal

WiFi

Once the Raspberry Pi reboots into EmulationStation, use your keyboard and navigate to RetroPie configuration

Select WiFi and enter your SSID/PSK information as necessary

Once you have connected to your WiFi network, you can go back to your laptop and continue via SSH from there

Optional

Should you choose to work completely from terminal, hit F4 from the EmulationStation menu to get to terminal

sudo iwlist wlan0 scan
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
network={
  ssid="your ssid"
  psk="your password"
}
sudo systemctl daemon-reload
ifconfig wlan0

If you have done your WiFi correctly from here you can use SSH

ssh pi@[ip address]

Config

  • Run the Rapsberry Pi configuration program
sudo raspi-config

In the Interfaceing Options menu, you will need to

  1. Enable SSH
  2. Enable SPI

In the Advance Options menu, you will need to

  1. Expand Filesystem
  2. Disable Overscan

Once these are complete, you will be asked to reboot you Raspbery Pi.
Do so.

Step 2

We will now be connecting the 2.8" ILI9341 TFT LCD module, so you can set your other keyboard aside for now

From you computer (not the Raspberry Pi)

TFT Device

Enter the following to add a Loadable Kernel Module for the TFT Device

sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24 speed=80000000 fps=60 bgr=1 rotate=90

Confirm the module has been loaded

dmesg | tail 

See the TFT LCD module details

fbset -fb /dev/fb1

Lets test that we can show ‘stuff’ on the TFT LCD module (this will simply add static noise)

cat /dev/urandom > /dev/fb1

Map the console to the TFT LCD Module
you should now see a scaled terminal window on the TFT

con2fbmap 1 1

Should you ever need to stop the mapping, reverse the command

# switch tft to hdmi
con2fbmap 1 0

Note: if you need to remove the module, simply

sudo modprobe -r fbtft_device

Step 3

Automate the above on startup

Open the modules file

sudo nano /etc/modules

Add these lines to the bottom

spi-bcm2835
fbtft_device

Hit ‘CTRL+X’ and ‘Y’ to confirm the save

Create a configuration file for the TFT LCD Module

This will create an empty file named fbtft.conf

sudo nano /etc/modprobe.d/fbtft.conf

Add this line to the empty file

options fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24 speed=80000000 fps=60 bgr=1 rotate=90 custom=1

Hit ‘CTRL+X’ and ‘Y’ to confirm the save

Installing the Framebuffer Copy tool

The following lines will download and install the Frambuffer Copy tool in a folder in the root directory

cd
sudo apt-get install cmake
git clone https://github.com/tasanakorn/rpi-fbcp fbcp
cd fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
fbcp

Hit CTRL+C to exit ‘fbcp’

Add Framebuffer Copy to our boot sequence

In order to have a command or program run when the Pi boots we will edit the ‘rc.local’ file

sudo nano /etc/rc.local

Add the following just before the exit 0 line

fbcp&

Hit ‘CTRL+X’ and ‘Y’ to confirm the save

Your file (if you have no other commands running) will look something like this

### replace with this
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

fbcp&

exit 0

Step 5

USB Audio Configuration

Plug in your USB Audio Card, and list your usb devices

lsusb

Now run the sound modules probe

cat /proc/asound/modules

You will see something like

 0 snd_bcm2835
 1 snd_usb_audio

The snd_bcm2835 is the default, we wan’t to force the USB output so, we will edit the conf file

sudo nano /etc/modprobe.d/alsa-base.conf

Add these lines

options snd_usb_audio index=0
options snd_bcm2835 index=1
options snd slots=snd-usb-audio,snd-bcm2835

Reboot, and return to terminal (F4) once EmulationStation has restarted

List out the module probe

cat /proc/asound/modules

You will see something like

 0 snd_usb_audio
 1 snd_bcm2835

Success, enjoy the sound

Step 6

Now we are ready to configure the GPIO on the Raspberry Pi as a controller

Install RetroGame

cd
curl -O https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/retrogame.sh
sudo bash retrogame.sh

When you run the retrogame.sh file, you will be presented with a menu.

Select the PiGRRL 2 Controls option, and the program will continue to install some modules.

Once complete, you will be asked if you want to reboot.

Don’t reboot just yet

Step 7

You will now be assigning keyboard inputs to action buttons of the controller (GPIO pins on the Raspberry Pi)

RetroGame Configuration

Edit the RetroGame configuration file

sudo nano /boot/retrogame.cfg

You can replace the entire file with the following

  • pro tip:Hit CTRL+K on you keyboard to delete lines*
# Here's a pin configuration for the PiGRRL 2 project:
LEFT      		22  # Joypad left
RIGHT     		20  # Joypad right
UP         		 7  # Joypad up
DOWN      		12  # Joypad down
LEFTCTRL  		19  # 'A' button
LEFTALT    		 5  # 'B' button
Z          		 6  # 'X' button
X         		13  # 'Y' button
RIGHTSHIFT      26  # 'Select' button
ENTER     		16  # 'Start' button
A         		18  # Left shoulder button
S         		27  # Right shoulder button
Q         		15  # Left trigger button
W         		17  # Right trigger button
ESC       		16 26  # Exit ROM; PiTFT Button 1

Hit ‘CTRL+X’ and ‘Y’ to confirm the save

EmulationStation Input Configuration

This is really just a visual check to ensure your file looks as below

Open the EmulationStation Input configuration file

sudo nano ~/.emulationstation/es_input.cfg

Ensure that your file’s content are exactly as below

<?xml version="1.0"?>
<inputList>
  <inputAction type="onfinish">
    <command>/opt/retropie/supplementary/emulationstation/scripts/inputconfiguration.sh</command>
  </inputAction>
  <inputConfig type="keyboard" deviceName="Keyboard" deviceGUID="-1">
    <input name="pageup" type="key" id="97" value="1"/>
    <input name="start" type="key" id="13" value="1"/>
    <input name="up" type="key" id="1073741906" value="1"/>
    <input name="a" type="key" id="1073742048" value="1"/>
    <input name="b" type="key" id="1073742050" value="1"/>
    <input name="down" type="key" id="1073741905" value="1"/>
    <input name="pagedown" type="key" id="115" value="1"/>
    <input name="right" type="key" id="1073741903" value="1"/>
    <input name="x" type="key" id="122" value="1"/>
    <input name="select" type="key" id="1073742053" value="1"/>
    <input name="y" type="key" id="120" value="1"/>
    <input name="left" type="key" id="1073741904" value="1"/>
  </inputConfig>
</inputList>

If all is good as above, hit CTRL+X to exit the editor and

Step 8

The final reboot, you can now unplug the HDMI from the Raspberry Pi

sudo nano /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:6x12 logo.nologo

Reboot

sudo reboot now

RetroPie will reboot and start EmulationStation (all on the tiny screen)

Once EmulationStation is up, you will again see the ‘No Device Configured’ screen… …Don’t Panic

With your keyboard plugged in, press and hold ‘Enter’ until the Controller Configuration shows up on the screen

Hit your keys on your keyboard as mapped above, skip the analog sticks

  • pro tip: When you get to the section*

Step 9

This one is all on you

We DO NOT provide any system or game ‘roms’, for that you will need Google.

Looking for no frills multi system emulator that fits in your *pocket Look no further! This is it, Game Boy Zero - Handheld Edition Designed by Handheld … The Game Boy Zero - Handheld Edition 2.0 is an all in one Core Ball solution for playing your favorite retro, classic games Design around a Raspberry Pi Zero , you can play up to and including PlayStation 1 games.