PieInvaders

This is a guide that describes how to get started with the RetroPie GPIO Adapter. It is organized as a step-by-step guide: Starting with the sole components and the PCB the hardware assembly is described in the first part. The second part then guides you though the software topics by describing how to test the button and how to enable SNESDev for polling the controllers.

Hardware: Assembly of the RetroPie GPIO Adapter

The assembly of the RetroPie GPIO Adapter can be done as following:

[tabs type=”horizontal”]
[tabs_head]
[tab_title]Revision 2.X[/tab_title]
[tab_title]Revision 1.5 to 1.7[/tab_title]
[tab_title]Revisions 1.0 to 1.4[/tab_title]
[/tabs_head]
[tab]

  1. Make sure that you have all components: 2×5 pins male header, 2×13 pins female header, polyfuse, button, PCB:
    rpga2_1
  2. Solder the 2×5 pins male header. As you can see on the picture, you might want to use a tool as some sort of fixture during the soldering:rpga2_2
  3. Solder the fuse and the button:rpga2_3
  4. Solder the 2×13 pins female header. Again, you might want to put something under the adapter to ease the soldering in this step:
    rpga2_4
  5. Visually check for unintentional solder bridges. We also recommend to check with a multimeter at least for a short circuit between VCC and GND.

[/tab]
[tab]

  1. Make sure that you have all components: 2×5 pins male header, 2×13 pins female header, polyfuse, button, PCB:IMG_1990_small
  2. In contrast to revisions 1.0 to 1.4 of the adapter, you do not need to solder the SMD parts (74HC125 and 10K resistor) yourself.IMG_1996_small
  3. Solder the 2×5 pins male header. As you can see on the picture, you might want to use a tool as some sort of fixture during the soldering:IMG_1991_small
  4. Solder the 2×13 pins female header. Again, you might want to put something under the adapter to ease the soldering in this step:IMG_1992_small
  5. Solder the fuse and the button:IMG_1994_small
  6. Visually check for unintentional solder bridges. We also recommend to check with a multimeter at least for a short circuit between VCC and GND:IMG_1995_small

[/tab]
[tab]

  1. Make sure that you have all components: Resistor, IC74HC125, 2×5 pins male header, 2×13 pins female header, polyfuse, button, PCB:a1
  2. Solder the resistor and the 74HC125. Take care for correct orientation: Pin 1 must be directed towards the fuse holes:a2
  3. Solder the 2×5 pins male header. As you can see on the picture, you might want to use a tool as some sort of fixture during the soldering:a3
  4. Solder the 2×13 pins female header. Again, you might want to put something under the adapter to ease the soldering in this step:a4
  5. Solder the fuse and the button:a5
  6. Visually check for unintentional solder bridges. We also recommend to check with a multimeter at least for a short circuit between VCC and GND:a6

[/tab]
[/tabs]

Hardware: Connecting the ribbon cable with the adapter

The RetroPie GPIO Adapter was constructed such that it is able to poll up to two game pads that make use of a shift-register for serializing the status of each component of the game pads. The SNES and NES controllers work in this way. In the following it is described how to connect two SNES sockets to the ten-wire ribbon cable.

The ribbon cable is used to connect the SNES sockets with the 2×5 pin header of the RetroPie GPIO Adapter.

One end of the ribbon cable gets a crimp connector. To make the description easier in the following take care for the salient on the crimp connector so that the pin out looks like this:

 

With the assumption that the salient faces upward, the pin out of the 2×5 header on the RetroPie GPIO Adapters revision 1.X look as shown in this figure:

ImageUploadedByTapatalk1368731520.973453

Ribbon cable pinout on the RetroPie GPIO Adapter revision 1.X

The RetroPie GPIO Adapter revision 2.X get the ribbon cable attached in this way:

RPGA2Ribbon

Ribbon cable pinout on the RetroPie GPIO Adapter revision 2.X

Hardware: Connecting SNES sockets with the ribbon cable

Now, you need to solder the ten wires of the ribbon cable to the pins of the two SNES sockets. The pictures above show the pin out of every single wire of the cable as well as the pin out of a SNES socket. You need to rip up the ribbon cable, dismantle the insulation and solder each wire to the according pin of the SNES sockets. The result might look similar to what is shown in this picture:ImageUploadedByTapatalk1368677420.984039

Hardware: connecting the RetroPie GPIO Adapter with the Raspberry Pi

During the design of the board I was not aware of the “safe mode” of the Raspberry Pi: Adding a jumper between pins 5 and 6 of P1 results in /boot/config.txt being ignored (except for avoid_safe_mode) and a default cmdline.txt is applied, followed by loading kernel_emergency.img. As stated in the official forum

if you connect external hardware to that pin, the worst that will happen is it falsely triggers safe mode.

To avoid this safe mode when the adapter is attached a setting has to be made in /boot/config.txt. This could be done, for example, by opening the config.txt with

sudo nano /boot/config.txt

adding

avoid_safe_mode=1

and saving the changes with “Ctrl-X”, which has to be confirmed with “Y”.

The adapter must be put on the GPIO pins of the RPi such that the 2×5 pin header faces inwards the PCB of the RPi.

Software: A tool for testing the button

In order to check the correct assembly of the adapter, you can test the button first. A simple command line tool is contained in the SNESDev repository. You can install SNESDev either by using the RetroPie Setup Script or by following the instructions on the welcome site of the SNESDev repository. The command line tool testButton is contained in the subfolder supplementary/testButton/. While the tool is running it continuously prints the status of the button to the console. You can exit the program with “Ctrl-C”.

SNESDev, which is described in the next section, counts the numbers of button presses and reacts differently to these: If you press the button 3 times, the press of the ESC key is simulated. If you press the button 5 times, the shutdown command is executed.

Software: SNESDev for polling the game pads and the button

SNESDev is a user-space device driver especially written for the RetroPie GPIO Adapter. It implements two (S)NES game controllers and a virtual keyboard for up to two (S)NES controllers and a button that are connected to the GPIO pins of the Raspberry Pi via the RetroPie GPIO Adapter.

SNESDev can be enabled from within the RetroPie Setup Script. You find the option for that in the when you select “Setup” in the main menu of the script. The RetroPie Setup Script can also be used to install a kernel-space driver for polling various game pads, which is also known as “gamecon driver”. Do not enable the gamecon driver and SNESDev at the same time, because both access the GPIO pins and they do interfere with each other. It is recommended to use SNESDev as driver for the RetroPie GPIO Adapter.

You can either install SNESDev manually: a complete installation guide can be found here in the repository of SNESDev. Alternatively, you can use the RetroPie Setup Script for installing and configuring SNESDev. IMPORTANT: As described in the README of SNESDev, you might need to configure the correct version of the RetroPie GPIO Adapter. The default version is 2.X. If you find a revision number 1.X on your RetroPie GPIO Adapter you need to set the configiration parameter “adapter_version” to “1x”.

The correct connection with the game pads can be tested from command line with the tool jstest, which is installed with the command sudo apt-get install joystick.

If you want to test your first game pad, you run jstest /dev/input/js0 and get an output similar to this:

Axes: 0:      0  1:      0: Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off

To test your second game pad you can use the command jstest /dev/input/js1. If you are using Emulation Station and want it to show the input configuration screen again, you  need to delete the file /home/pi/.emulationstation/es_input.cfg to have Emulation Station show the configuration screen again.

Video Guide

Here is a short video that should also support you with the installation:

[lightbox full=”http://www.youtube.com/watch?v=JlYf3FJZ4ys” title=”RetroPie GPIO Adapter: Software Installation Guide”][/lightbox]

Conclusions

This concludes the tutorial for getting started with the RetroPie Adapter. If you feel that any information is missing in this guide feel free to give comments!