Introduction: 1.3 Inches RetroPie Zero

This instructables show how to use a 1.3" Retina grade IPS LCD HAT to make a tiny RetroPie Zero.

Step 1: Preparation

RPi Zero

Both Raspberry Pi Zero and Raspberry Pi Zero W is ok. WiFi version can make subsequent setup easier but in contrast it may draining more power continuously, i.e. shorter battery life.

LCD HAT

Waveshare released 2 LCD HAT for RPi Zero, both have a tiny square LCD. The newer version have a 240 x 240 1.3" IPS LCD. It is 261 PPI and within the apple defined retina display range (218 - 458 PPI). This resolution is capable to emulate many retro game console in the CRT TV age, e.g. NES at 256 x 240 resolution, we can cut 8 pixels from both left and right overscan area and make it become 240 x 240.

Pin Header

To closely fit for the Waveshare 1.3" LCD HAT, it require a 8 mm tall 2 x 20 pins header. But I cannot buy one with 8 mm tall, so I will modify from a 12 mm tall pin header.

LiPo Battery

The interior size between RPi and LCD HAT can fit for a 5 mm x 23 mm x 45 mm battery, any LiPo battery with protection circuit that within this dimension should be ok.

Tiny LiPo Charge Board

I have some 10 mm x 10 mm tiny 5 V LiPo charge board in hand. It is small enough for this project, but the limitation is it only can charge the battery up to 50 mA current. A 400 mAh battery require over 8 hours for fully charged.

Power Switch

A tiny power switch.

Wrist Strap

Since this Game pad is so tiny and easy to slip from hand, it is recommended wearing a wrist strap while playing it.

Screw

The 3D printed case require four 14 mm M2.5 flat-head screws for assembly.

Ref.:

https://www.waveshare.com/wiki/1.3inch_LCD_HAT

https://www.waveshare.com/product/modules/oleds-lc...

Step 2: 3D Print Case

3D print the case model you can find in Thingiverse:

https://www.thingiverse.com/thing:3328994

For ease of illustration, I print each part in different colors:

  • Layer123.stl - Carbon Black
  • Layer4.stl - Translucent Yellow
  • Layer5.stl - Translucent Orange
  • Layer678.stl - Translucent Red
  • ButtonHead.stl - Translucent Red, Translucent Blue and Translucent Green
  • CrossButtonHead.stl - Gundam Red

Step 3: Direct Battery Power

This tiny gamepad has no room to fit in a step up circuit board, is it possible a LiPo battery direct power the RPi Zero (W) without step up?

There are some unofficial discussion about is it require full 5 V power supply for RPi Zero (W).

According to the RPi Zero reduced schematics, there are only 2 pins direct connected to 5 V, it is USB plug and PAM2306 regulator. All other parts powered by regulated 3.3 V and 1.8 V.

Assume we do not use any external USB device while powered by battery, the key factor is the regulator.

According to PAM2306 datasheet, there are still keep over 90% efficient for 3.3 V output when the input voltage dropped to 3.5 V.

RPi Zero average draw around 100 - 200 mA and the LiPo is around mAh, the discharge rate is around 0.5 C. It can still utilise 90% of LiPo capacity before drop below 3.5 V.

Ref.:

https://www.raspberrypi.org/forums/viewtopic.php?t...

https://www.raspberrypi.org/documentation/hardware...

https://www.mouser.hk/datasheet/2/115/PAM2306-3367...

https://electronics.stackexchange.com/questions/32...

https://www.quora.com/Is-it-possible-to-see-the-ch...

Note:

According to my simply test, the battery can last over 90 minutes while WiFi turned on. It should last longer if using RPi Zero.

Step 4: Pin Header Patch

Waveshare LCD HAT use low profile female pin header, it can make the product more slim. But we need a corresponding low profile male pin header at RPi Zero to make it. The male pin header should be 8 mm tall, but I cannot find on the web. So patch it from a 12 mm male pin header.

It require some patient to trim 40 pins the same length.

Step 5: Soldering Work

Solder all pin headers with RPi Zero.

Here are the connection summary of power circuit:

Waveshare Pin 2 -> Charge Board +vin, Power Switch Pin 1
Waveshare Pin 6 -> Charge Board -vin
                   Charge Board -vout -> LiPo -ve
                                         LiPo +ve -> Power Switch Pin 2
                   Charge Board +vout             -> Power Switch Pin 3
  • When Power Switch closed pin 1 and 2, it is Battery Powered Mode
  • When Power Switch closed pin 2 and 3, it is Battery Charging Mode / Power Off

Note:

Waveshare LCD HAT pin header is at the bottom, so the pin arrangement is upside down

Step 6: Assembly Layer 4

  • Put Layer 4 under LCD HAT
  • Fit the power switch in Layer 4
  • Put charge board and battery inside Layer 4 frame

Step 7: Assembly Layer 5

Put Layer 5 over Layer 4

Step 8: Plug in RPi Zero

Step 9: Assembly Layer 678

Put Layer 678 over RPi Zero.

Step 10: Put Screw Into Screw Hole

Step 11: Put Buttons Head on LCD HAT

Step 12: Assembly Layer 123

Put Layer 123 on the LCD HAT.

Step 13: Screw Up the Screws

Step 14: Assembly Cross Button Head

Put the cross button head into the cross button.

Step 15: Download RetroPie Image

Download RetroPie image here:

https://retropie.org.uk/download/

Select "Raspberry Pi 0/1" option to download the image for Raspberry Pi Zero

Step 16: Download Source

2 further source code required for the Breadboard RetroPie:

mk_arcade_joystick_rpi:

https://github.com/recalbox/mk_arcade_joystick_rpi

rpi-fbcp:

https://github.com/tasanakorn/rpi-fbcp

Simple click "Clone or download" button and then "Download ZIP" from both source web page.

Step 17: Prepare ROM Files

For the non license free game, I think you should only use the ROM that you have the original game.

Or you may find some license free games here:

http://pdroms.de/files

http://www.doperoms.com

Step 18: Flash the RetroPie Image

The steps to flash RetroPie image to the micro SD card is as same as flashing Raspbian image. If you are not familiar the flashing steps, please follow the steps provided by Raspberry.org:

P.S. remember to replace the image file name with the RetroPie image.

Step 19: Copy Files

Copy "mk_arcade_joystick_rpi-master.zip", "rpi-fbcp-master.zip" to the RetroPie micro SD just created.

Step 20: Configure Micro SD

We need further config after RetroPie boot, before that, we need to enable DWC2 USB controller to make network connection between computer and Pi Zero.

Edit the config.txt in micro SD, append the follow line at the tail:

dtoverlay=dwc2

Edit the codlin.txt in micro SD, insert "modules-load=dwc2,g_ether" after "rootwait" keyword. The result should be something like that:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=14a75fe9-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet loglevel=3 consoleblank=0 plymouth.enable=0 quiet init=/usr/lib/raspi-config/init_resize.sh

Create a blank file called "ssh" in the micro SD to enable openssh server, e.g. in my Mac:

touch /Volumes/boot/ssh

Ref.:

https://www.instructables.com/id/Connect-to-a-Rasp...

Step 21: USB Connect

  • Insert the micro SD to Pi Zero
  • Set the power switch to Battery Charge Mode
  • Connect the Pi Zero 2nd USB socket (labelled "USB") to the computer.

Wait around a minute, you should find a new network adaptor in your computer. Type the follow command connect to the Pi Zero:

ssh pi@retropie.local

Note:

Default password is "raspberry", you should change it ASAP by "passwd" command

Step 22: Configure LCD

Append to "/etc/modules"

spi-bcm2835
flexfb
fbtft_device

create the "/etc/modprobe.d/fbtft.conf"

options flexfb setaddrwin=0 width=240 height=240 init=-1,0x11,-2,120,-1,0x36,0x70,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3
options fbtft_device name=flexfb gpios=reset:27,dc:25,cs:8,led:24 speed=125000000 bgr=1 fps=60 custom=1 height=240 width=240

Step 23: Enable Fbcp

Extract source files:

unzip /boot/rpi-fbcp-master.zip

Compile and install:

cd rpi-fbcp-master/
mkdir build
cd build
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
cd ../..

Create new file "/etc/init.d/fbcp":

#! /bin/sh<br>### BEGIN INIT INFO
# Provides:          fbcp
# Required-Start:    kmod
# Required-Stop:     kmod
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description:
# Description:
### END INIT INFO
case "$1" in
  start)
  /usr/local/bin/fbcp &
  ;;</p><p>  stop|restart|reload|force-reload)
  killall fbcp
  exit 0
  ;;</p><p>  *)
  log_success_msg "Usage: $0 start"
  exit 1
esac

Make the file executable:

sudo chmod +x /etc/init.d/fbcp

Set it init at startup:

sudo update-rc.d fbcp defaults

Append the follow line in "/boot/config.txt" at the tail:

disable_overscan=1
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt=240 240 60 1 0 0 0
dtparam=spi=on

Ref.: https://github.com/tasanakorn/rpi-fbcp

Step 24: Configure Joystick

Extract source files:

unzip /boot/mk_arcade_joystick_rpi-master.zip

Edit buttons definition:

cd mk_arcade_joystick_rpi-master/
vi mk_arcade_joystick_rpi.c

Find the "static const int mk_arcade_gpio_maps[]" row and update to HAT button mapping:

static const int mk_arcade_gpio_maps[] = {6,19,5,26,13,21,16,20,0,0,0,0};

Compile and install module:

sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5/
sudo cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.5/
export MKVERSION=0.1.5
sudo -E dkms build -m mk_arcade_joystick_rpi -v 0.1.5
sudo -E dkms install -m mk_arcade_joystick_rpi -v 0.1.5

Test the buttons:

sudo modprobe mk_arcade_joystick_rpi map=1
jstest /dev/input/js0

Append to "/etc/modules":

 mk_arcade_joystick_rpi

create the "/etc/modprobe.d/joystick.conf":

options mk_arcade_joystick_rpi map=1

Ref.: https://github.com/recalbox/mk_arcade_joystick_rp...

Step 25: Copy ROM Files

Copy ROM files from "/boot" folder to "~/RetroPie/roms/$CONSOLE" folder

Ref.:

https://github.com/retropie/retropie-setup/wiki/Tr...

Step 26: Raspi-config

Run:

sudo raspi-config
  • WiFi: 2 Network Options -> N2 Wi-fi -> fill your WiFi details
  • Not wait network: 3 Boot Options -> B2 Wait for Network at Boot -> No -> OK
  • Timezone: 4 Localisation Options -> I2 Change Timezone -> select your timezone
  • Disable serial port: 5 Interfacing Options -> P6 Serial -> No -> No -> OK

Ref.:

https://www.raspberrypi.org/documentation/configur...

Step 27: RetroPie Setup

Run:

sudo ~/RetroPie-Setup/retropie_setup.sh

Fine tune for 1.3" LCD: C Configuration / Tools -> 805 configedit -> 1 -> 0 -> 2 Render Resolution -> O Video output resolution -> OK -> Cancel -> Cancel -> Cancel

Change theme to fit tiny screen (require WiFi connected): 812 esthemes -> 14 Pixel-tft -> OK -> 1 carbon -> 2 Uninstall

Ref.:

https://github.com/retropie/retropie-setup/wiki/th...

Step 28: Native Resolution

The LCD HAT have 3 buttons and 1 extra push button in the cross button, it can map to the retro game console that only have 4 buttons (select, start, A and B). The highest resolution for this type of game console should be NES, it have 256 x 240 resolution. It can just fit for the 240 x 240 LCD display if simply crop the horizontal overscan area.

If you only play NES game only like me, you can apply the follow configuration to gain native resolution display.

Append "/opt/retropie/configs/nes/retroarch.cfg":

video_fullscreen_x = "0"
video_fullscreen_y = "0"
video_scale_integer = true

Append "/opt/retropie/configs/all/retroarch-core-options.cfg":

quicknes_use_overscan_h = "disabled"

Step 29: Controller Configuration

Joypad settings for EmulationStation:

vi /opt/retropie/configs/all/emulationstation/es_input.cfg

Input text:

<?xml version="1.0"?>
<inputList>
  <inputAction type="onfinish">
    <command>/opt/retropie/supplementary/emulationstation/scripts/inputconfiguration.sh</command>
  </inputAction>
  <inputConfig type="joystick" deviceName="GPIO Controller 1" deviceGUID="15000000010000000100000000010000">
    <input name="start" type="button" id="11" value="1"/>
    <input name="down" type="axis" id="1" value="1"/>
    <input name="right" type="axis" id="0" value="1"/>
    <input name="select" type="button" id="10" value="1"/>
    <input name="left" type="axis" id="0" value="-1"/>
    <input name="up" type="axis" id="1" value="-1"/>
    <input name="a" type="button" id="0" value="1"/>
    <input name="b" type="button" id="1" value="1"/>
  </inputConfig>
</inputList>

Joypad settings for Retroarch:

vi /opt/retropie/configs/all/retroarch/autoconfig/GPIO\ Controller\ 1.cfg

Input text:

input_device = "GPIO Controller 1"
input_driver = "udev"
input_start_btn = "11"
input_exit_emulator_btn = "11"
input_down_axis = "+1"
input_right_axis = "+0"
input_state_slot_increase_axis = "+0"
input_select_btn = "10"
input_left_axis = "-0"
input_state_slot_decrease_axis = "-0"
input_up_axis = "-1"
input_a_btn = "0"
input_b_btn = "1"
input_reset_btn = "1"
input_enable_hotkey_btn = "10"

Step 30: Speed Up Boot Time

Run:
sudo systemctl disable asplashscreen
sudo systemctl disable dphys-swapfile
sudo systemctl disable hciuart
sudo systemctl disable keyboard-setup
sudo systemctl disable nmbd
sudo systemctl disable raspi-config
sudo systemctl disable smbd
sudo systemctl disable nfs-config

Step 31: Optional Tuning

Fine tune "/boot/cmdline.txt":

  • Disable USB Ethernet Gadget
  • no logo
  • fastboot
  • quiet
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=14a75fe9-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait loglevel=3 consoleblank=0 plymouth.enable=0 logo.nologo fastboot quiet
#dtoverlay=dwc2

Step 32: Boot RetroPie

  • Turn off the RetroPie:
sudo halt
  • Unplug the USB cable
  • Set the power switch to Battery Powered Mode
  • Wait around half minute to boot up
  • Follow the screen instruction to config the game button
  • Select the console and game you have uploaded

Step 33: Emulation Station Power Option

Press start button (push down the cross button) to enter the Emulation Station configuration screen.

UI SETTINGS -> SCREENSAVER SETTINGS -> SCREENSAVER AFTER -> 1 minute

OTHER SETTINGS -> POWER SAVER MODES -> INSTANT

Step 34: Tie Wrist Strap

Step 35: Enjoy!

It's time to show off what you have made and play with it.

Step 36: Gallery: Color Mix & Match

Big and Small Contest

Runner Up in the
Big and Small Contest