top of page
  • Pasi

Building Phat Pocket Arcade: Case Assembly and RetroPie Modding

Päivitetty: 7. tammik. 2021

This post is the first part about the steps I needed to get my old Commodore 64 PAL game running on Raspberry Pi Zero, Adafruit Arcade Bonnet, and a small QVGA 320x240 TFT display, an analog joystick, and four action push buttons. In this and following posts, I'll include all essential steps to get the game running adequately on this hardware combination, right from boot. Note that wiring the components together has been covered in previous post. If you use these instructions, make sure you have followed the instructions on how to connect the components together first. If your hardware setup differs, for example, you use something else than Arcade Bonnet as your joystick interface, you will need to adapt the steps accordingly.

So let's get started.

RetroPie SD Card

Step 1: Download RetroPie

RetroPie is a game systems emulator distribution for Raspberry Pi. Based on EmulationStation, it includes a number of emulators for different gaming systems. SD card image for Raspberry Pi can be found from RetroPie download page. Make sure to pick the right image, in my case this was RetroPie 4.3 for Raspberry Pi 0/1.

Step 2: Burn image on the SD card

You'll need an 8 Gb micro SD card. Insert the card in your SD card reader/writer, and burn the RetroPie image to the card. On my mac, I used Etcher, which is user friendly application for burning the image to the card:

Etcher is also available for Linux and Windows. If you are on e.g. Ubuntu, and wish to use command line, you can try dd command, further details here.

A quick look at the case model

While I was preparing these videos, I received the 3D printed case parts. Those required some corrections (read: file and Dremel work) before I managed to succesfully assemble the console from the designed parts. Details of the 3D models may be a topic for another post, so here is just brief look into the CAD file in FreeCAD:

Customizing RetroPie

Step 3: Boot to RetroPie, configure keyboard

Before showing how the RetroPie SD card prepared earlier works in the console that was just put together, I'll show some issues I encountered in printing the case CAD model:

First step after booting to RetroPie is to configure a game controller. I will be using Arcade Bonnet board for this, and set it up later. To be able to navigate in RetroPie in the meanwhile, I attached keyboard using a USB hub to Phat Pocket Arcade and configured the keyboard as my input controller.

Step 4: Configure resolution

I modified resolution to a smaller one next. This is not necessary to do at this point, but helped me to make the screen more readable on the videos.

Changing display resolution (from Raspi-config)

  • Navigate to RetroPie Configuration > Raspi-Config

  • Choose Advanced Options > Resolution

  • Select a resolution that works for the display. I used first option: CEA Mode 1 640x480 60Hz 4:3

  • Exit and Reboot for change to take effect

Step 5: Connecting to network

Connecting to you home network allows you to easily transfer files to and from the system and log in using SSH if needed:

  • Navigate to RetroPie Configuration > WIFI

  • Choose Connect to WIFI network

  • Select your WIFI network

  • Enter your network WIFI key

  • Wait until connected

  • Exit

Step 6: Overclocking

Overclocking boosts performance a bit, which helps in getting better framerate out of the small display.

  • Exit to command prompt from RetroPie main menu (Press F4)

  • Edit /boot/config.txt

  • Add overclocking parameters. Use your own judgement what settings work for your Raspberry Pi, since setting these parameters too high may introduce problems. My settings were:





Step 7: HDMI Parameters

  • While editing /boot/config, also add HDMI parameters

hdmi_cvt=640 480 60 1 0 0 0



More info on these settings in boot config can be found from Raspberry Pi documentation.

Using Arcade Bonnet as input controller

Step 8: Download and install Arcade Bonnet software

  • From RetroPie command prompt (press F4 from RetroPie main menu) type the following:

curl -O sudo bash

  • For installer script prompts respond as follows:

Disable overscan? y

Install GPIO-halt utility? n


Let installer script complete before continuing, then say n when asked if you want to reboot.

Step 9: Enable audio amplifier

Wiring a speaker to Arcade Bonnet audio outputs allows to use it as audio output device.

  • From RetroPie command prompt type the following:

curl -sS | bash

  • Reboot then exit to command prompt and execute i2samp again:

curl -sS | bash

  • Test the amplifier when prompted by the script and make sure you can hear test sounds from speaker.

These instructions are based on setup instructions on Adafruit website

Step 10: Arcade Bonnet key mapping

I'm using both analog stick and digital direction keys pins from Arcade Bonnet. For basic navigation in menus in both RetroPie menus and Commodore 64 emulator that will be set up later, I use Arcade Bonnet analog stick. For the four action buttons, that is, buttons A and B, and Select and Start buttons I use the direction key pins from Arcade Bonnet. For this remapping from Arcade Bonnet input signals to key presses is needed.

  • From RetroPie command prompt (press F4 from RetroPie main menu) edit the file:

sudo nano /boot/

  • Change the mapping and save the file, I used the following mapping:


# See /usr/include/linux/input.h for keycode names

# Keyboard Bonnet EmulationStation

e.KEY_LEFTCTRL, # 1A 'A' button

e.KEY_LEFTALT, # 1B 'B' button

e.KEY_A, # 1C 'X' button

e.KEY_S, # 1D 'Y' button

e.KEY_5, # 1E 'Select' button

e.KEY_1, # 1F 'Start' button

0, # Bit 6 NOT CONNECTED on Bonnet

0, # Bit 7 NOT CONNECTED on Bonnet

e.KEY_ENTER, # 4-way down D-pad down

e.KEY_5, # 4-way up D-pad up

e.KEY_LEFTALT, # 4-way right D-pad right

e.KEY_1, # 4-way left D-pad left

e.KEY_RIGHT, # Analog right

e.KEY_LEFT, # Analog left

e.KEY_DOWN, # Analog down

e.KEY_UP # Analog up


The changed mappings are in bold text above.

  • Save the file and reboot from command line to take the changed Arcade Bonnet key mapping into use:

sudo reboot now

After saving and rebooting, the Phat Pocket Arcade controls would work for navigating in RetroPie, however, since I had mapped the keys for START/SELECT for RetroPie in step 3 above and also because I had analog stick directions rotated because of wiring the bonnet to the thumbstick, I needed to repeat configuring input for RetroPie. You can do the same, if needed.

Enabling QVGA mini display

These steps depend on the display type and how it is connected to Raspberry Pi. My display is based on ili9341 chip, and controlled by the SPI interface.

Step 11: Enable SPI interfacing

  • Navigate to RetroPie Configuration > Raspi-Config

  • Select Interfacing Options > SPI

  • Select Yes

If you did not disable overscan when running Arcade Bonnet installer, you can do it now:

  • Go back Raspi-Config main menu level

  • Select Advanced Options > Overscan

  • Select No

  • Exit Raspi-Config by selecting Finish

Step 12: Enable kernel modules for display

Next, add the kernel modules needed by the display:

  • From RetroPie command prompt (press F4 from RetroPie main menu) edit the file:

sudo nano /etc/modules

This is how I modified mine, additions in bold:

# /etc/modules: kernel modules to load at boot time.


# This file contains the names of kernel modules that should be loaded

# at boot time, one per line. Lines beginning with "#" are ignored.





  • Save the /etc/modules file

  • Next, create configuration file for fbtft device:

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

  • in the file type in options line:

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

Note: values for these options depend on the display type and how it is connected. Name parameter indicates the chip type, gpios parameter lists GPIO pins that are used by the display. Speed and fps settings I found by experimenting with my display based on some examples I found from internet. bgr=1 parameter is needed to get correct colors, and rotate=90 was required to to orient the screen properly for a QVGA display designed to be used in portrait orientation. Custom parameter was required, though it does not need a value. More info on fbtft_device and parameters here.

  • Reboot:

sudo reboot now

Step 13: Smoke test for small display

  • After reboot, exit to command prompt again (F4)

  • Test the display using con2fbmap utilty:

con2fbmap 1 1

Terminal input and output should switch to small QVGA display. If not, something is wrong or missing

  • Switch back to original display using

con2fbmap 1 0

Step 14: Add framebuffer copy utility

This utility will take care of mirroring the screen to the small display.

  • Get source for fbcp and build:

sudo apt-get install cmake

git clone

cd rpi-fbcp

mkdir build

cd build

cmake ..


sudo install fbcp /usr/local/bin/fbcp

  • After successfully making fbcp command you can check that it works by using:


Right after this, the small mini display should show the same screen as the HDMI display.

  • Set fbcp to run at startup by adding it to /etc/rc.local

sudo nano /etc/rc.local

  • Add following line at the end of the file, before line with exit 0;

nice -5 fbcp &

  • Save the file and and reboot:

sudo reboot now

After this, the mini display should start mirroring the big display a short while after the system is booted.

Most of this section on getting the small display working is based on this post on sudomod by user moosepr. Now RetroPie can be used completely using Phat Pocket Arcade controls and display. In the next blog post, I will cover setting up my own game, Little Knight Arthur on the console as the single game to be played on the system.

Most of you probably would like to run multiple games and that is straightforward, by just adding more game files to the system. In that case, you probably want the system boot to RetroPie main menu just as it does now after these setup steps. However, I recommend updating the RetroPie theme to one that is designed for small screen. Some of those themes are easy to install using RetroPie Confituration/Tools option. Here is a video of setting up one of those themes:

Phew! That was a lot of steps! Thanks for reading, should you have comments and especially corrections to my instructions here, please do send me feedback and let me know.


98 katselukertaa

Aiheeseen liittyvät päivitykset

Katso kaikki
bottom of page