Breadboard RetroPie

by 陳亮 in Circuits > Raspberry Pi

24696 Views, 268 Favorites, 0 Comments

Breadboard RetroPie

IMG_5784a.jpg
IMG_5649a.jpg
Breadboard RetroPie Playing Super Mario
Breadboard RetroPie

This Instructables show how to build a Breadboard RetroPie, no soldering, no 3D printer, no Laser cutter required.

Building a game machine is a very good project to initial child studying electronics. However, most RetroPie projects built by adult, the main reason is building it require too many advance skills at the same time, soldering, 3D printing, or Laser cutting, metal case patching...

This project aims to make it simple, all things built on the breadboard, the first tools you should know while studying electronics.

The most beauty thing using breadboard is most things can be reused. When you want to build the next project you can unplug and reuse the components and also reuse the breadboard itself!

Preparation

IMG_5518.jpg
IMG_5517.jpg
IMG_5436.jpg
IMG_5515.jpg
IMG_5472.jpg
IMG_5367.jpg
IMG_5427.jpg
IMG_5428.jpg
IMG_5199.jpg
IMG_5501.jpg
IMG_5514.jpg
IMG_5516.jpg
IMG_5547.jpg
IMG_5613.jpg
IMG_5614.jpg
IMG_5654.jpg
IMG_5616.jpg
IMG_5622.jpg

Raspberry Pi Zero

I know it is cheap but very hard to buy one, if you want the built-in WiFi feature, Zero W is easier to get and also it can enable net play for your game machine

Micro SD card

Please check RPi compatible SD card list here: http://elinux.org/RPi_SD_cards

LCD Module

2.8 inch ili9341 LCD Module

Base Plate

A 165 mm x 112 mm plastic plate help to combine all component together

Breadboard

This project require connect Raspberry Pi Zero, 2.8 inch LCD, 12 controller buttons, power and audio components all together. So it require various size breadboard connected together:

  • 1 x 830 hole breadboard
  • 3 x 170 hole Tiny breadboards

Breadboard Wire

Breadboard's best friend

Fishing Line

0.3mm Nylon fishing line, it helps to fix pin header to Pi Zero without soldering

Pin Header

2x40 18mm pin header
Actually it only require 2x20 pins, but the pins is very easy broken while patching, so buy more for backup purpose

Button

Any breadboard friendly button is OK, I an using:

  • 10 x 12 mm buttons with button caps
  • 2 x 6 mm buttons

Battery Holder

2 x 2 AA Battery Holder

Power Switch

Any breadboard friendly switch is OK

DC-DC 5 V Regulator Module

Battery Holder, power switch and DC regulator combined to provide 5 V power supply to Pi Zero. I recommend using rechargeable battery for environment reason, 4 rechargeable AA battery provide 4.8 V power, it is a little bit lower than 5 V but Pi Zero can tolerate a little bit power shortage. If you always use rechargeable battery, DC regulator can be skipped.

Screw Terminal Block

3 x 2 pins screw terminal block, 2 for battery holder and 1 for speaker

Audio Component (Optional)

  • 33nf capacitor
  • 10uf capacitor
  • 47k Ohm resistor
  • NPN transistor (e.g. 2N2222)
  • A tiny speaker (can be found in old gadgets)

Others

A computer, a card reader and micro USB cable for flashing the RetroPie image and initial settings

Design Layout

Breadboard RetroPie_bb.png

Breadboard split into 2 breadboard panels. Lower panel base on my previous project (Pi Zero on the Breadboard); upper panel combined with 3 tiny breadboard.

At the lower panel:

  • Raspberry Pi Zero placed at the middle
  • Left side is direction buttons
  • Right side is 6 action buttons
  • Above Pi Zero is select and start buttons

At the upper panel:

  • LCD placed at the middle
  • Besides LCD is power button and audio components
  • Speaker placed above the LCD
  • Left and right side are 2xAA battery holder

Prepare Pi Zero on the Breadboard

IMG_5471.jpg

Please prepare Pi Zero on the Breadboard according to my previous instructables:

https://www.instructables.com/id/Pi-Zero-on-the-Br...

Install Game Buttons

IMG_5497.jpg
IMG_5202.jpg
IMG_5498.jpg
IMG_5500.jpg

Some buttons may need some adjustment to fit on the breadboard firmly.

The buttons layout just depends on your preference, the only thing need to follow is one button terminal connect to GND and another terminal connect to a Pi Zero GPIO.

Connect All Buttons 1 Terminal to GND

IMG_5503.jpg

Connect Buttons Another Terminal to a Pi Zero GPIO

IMG_5505.jpg

Here is the buttons connection summary:

GND -> Up    -> GPIO 22
GND -> Down  -> GPIO 17
GND -> Left  -> GPIO 27
GND -> Right -> GPIO 4
GND -> A     -> GPIO 26
GND -> B     -> GPIO 19
GND -> L     -> GPIO 13
GND -> X     -> GPIO 5
GND -> Y     -> GPIO 21
GND -> R     -> GPIO 20

Install Select and Start Button

IMG_5506.jpg
IMG_5507.jpg

Buttons connection summary:

GND -> select -> GPIO 16
GND -> start  -> GPIO 6

Decorate Button Caps

IMG_5508.jpg
IMG_5509.jpg
IMG_5510.jpg
IMG_5511.jpg
IMG_5512.jpg
IMG_5513.jpg

Measure and Cut Base Plate

IMG_5522.jpg
IMG_5519.jpg
IMG_5520.jpg

Make Sharp Corner Round

IMG_5521.jpg

Stick Breadboard Altogether

IMG_5523.jpg
IMG_5525.jpg
IMG_5526.jpg

Stick the Battery Holder

IMG_5527.jpg
IMG_5546.jpg

Install Battery Holder Wire to Terminal Block

IMG_5548.jpg
IMG_5549.jpg
IMG_5550.jpg
IMG_5551.jpg
IMG_5552.jpg
IMG_5553.jpg
IMG_5554.jpg

Connect Power Wire

IMG_5575.jpg
IMG_5576.jpg
IMG_5578.jpg

Install Power Switch

IMG_5581.jpg
IMG_5580.jpg
IMG_5579.jpg

Here is the battery power connection summary:

left battery holder -ve -> right battery holder +ve
left battery holder +ve -> power switch -> 5 V regulator (optional: only for non-rechargeable battery) -> breadboard 5 V
right battery holder -ve -> breadboard GND

Connect LCD Wire

IMG_5582.jpg
IMG_5583.jpg
IMG_5584.jpg
IMG_5585.jpg

Here is the LCD connection summary:

LCD Vcc   -> breadboard 5 V
LCD GND   -> breadboard GND
LCD CS    -> GPIO 8
LCD Reset -> GPIO 25
LCD D/C   -> GPIO 24
LCD MOSI  -> GPIO 10
LCD CLK   -> GPIO 11
LCD LED   -> GPIO 15

Install Audio Component

IMG_5657.jpg
IMG_5656.jpg
IMG_5655.jpg

Here is the audio component connection summary:

GPIO 18 -> 33nf capacitor -> breadboard GND
GPIO 18 -> 10uf capicitor -> NPN transistor base pin
NPN transistor emmitter pin -> breadboard GND
NPN transistor collector -> speaker -> breadboard 5 V

Install the LCD Modules

IMG_5658.jpg

Download RetroPie Image

Please download RetroPie image here:

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

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

Download Source

2 further source code required for the Breadboard RetroPie:

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

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

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

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

Flash the RetroPie Image

螢幕快照 2017-04-16 下午2.03.02.png

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.

Copy Files

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

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=/dev/mmcblk0p2 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-Ras...

USB Connect

IMG_5670.jpg

Insert the micro SD to Pi Zero and 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

P.S. default password is "raspberry", you should change it ASAP by "passwd" command

Configure LCD

Append to "/etc/modules"

spi-bcm2835

fbtft_device

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

options fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:15 speed=48000000 rotate=90 bgr=1

Ref.: https://retropie.org.uk/forum/topic/7464/ili9341-t...

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 ../..

Insert the follow line before "exit 0" in "/etc/rc.local"

/usr/local/bin/fbcp &

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

hdmi_force_hotplug=1

hdmi_group=2

hdmi_mode=87

hdmi_cvt=320 240 60 1 0 0 0

disable_overscan=1

dtparam=spi=on

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

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 your button definition, e.g. my definition:

static const int mk_arcade_gpio_maps[] = {22, 17, 27, 4, 6, 16, 26, 19, 20, 5, 21, 13};

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...

Design Your Own Button Layout

IMG_5783.jpg

Updated: 2017/05/18

Breadboard is very easy to plug and unplug the components, please feel few to try and design your own button layout.

If you have changed the GPIO connection, you may run the follow script to recompile the modules:

cd mk_arcade_joystick_rpi-master/

export MKVERSION=0.1.5

sudo -E dkms uninstall -m mk_arcade_joystick_rpi -v 0.1.5

vi mk_arcade_joystick_rpi.c

sudo rm -rf /usr/src/mk_arcade_joystick_rpi-0.1.5/

sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5/

sudo cp -a * /usr/src/mk_arcade_joystick_rpi-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

Enable GPIO 18 Mono Audio

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

dtoverlay=pwm,pin=18,func=2

Ref.:

https://learn.adafruit.com/adding-basic-audio-oupu...

https://retropie.org.uk/forum/topic/4269/popeye-pi...

Copy ROM Files

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

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

Boot RetroPie

IMG_5648.jpg
IMG_5647.jpg
Breadboard Retropie
  • Turn off the RetroPie:
sudo halt
  • Unplug the USB cable
  • Insert fully charged AA battery
  • Turn on the power switch
  • Follow screen instruction to config the game button
  • Select the console and game
  • Enjoy!

Happy Studying!

IMG_5649.jpg

Breadboard RetroPie is a good starting point of learning Raspberry Pi. It's time to start a Raspberry Pi project with your child!