Hardware Stuff

Before starting this I took the opportunity to shorten that 3 ft. power cable making things much more spacious! One note on the power extension cable, since it is only used for power there was no need to mess with the data wires. After cutting the cable I only had to reconnect the positive and negative wires and wrap it up with some electrical tape.

Wiring up the LED and Power button turned out to be pretty straightforward. Since the NES Satellite PCB has a path to GND via the work done on the controller ports, we only need to run the positive leads to the GPIO pins. Most of the heavy lifting is done at the software layer.

Wiring

LED Anode Pin to GPIO 16 with a 10ohm resistor inline

to with a inline Power Switch + Pin to GPIO 5

to I cut the trace beside the power switch + pin to isolate the pin. See images for reference.

Note: I didn't place a resistor inline between the power switch and the GPIO 5 pin. I read somewhere that GPIO 2 and 5 both have pull-up resistors on the board but I can't seem to find that reference now. It might be worth adding one anyway. Only 3.3v is being supplied to the NES Satellite board so I'm chancing it for now but don't blow up your Pi based on my bad advice!

So that is it for the hardware. On to the software bits!

Software

LED

Using a device tree overlay I effectively told the Pi to use the LED wired up to GPIO 16 instead of the onboard ACT LED. The external LED now functions like the onboard one did, blinking during periods of activity. If I recall the onboard ACT LED blinks in response to SD Card read/write activity. I configured the new one to respond to cpu activity instead. In depth information on device tree overlays can be found here https://www.raspberrypi.org/documentation/configur...

Dts stuff came from this post: http://www.sudomod.com/forum/viewtopic.php?t=1113#...

1) Create overlay 'source' file (with your editor of choice)

pi@retropie:~ $ vi act_led.dts

Make it look like this:

<p>/dts-v1/;<br>/plugin/;</p><p>/ { compatible = "brcm,bcm2708"; fragment@2 { target = <&leds>; __overlay__ { /* * External LED to show CPU activity. * Active-high, GPIO 16 */ ext_act_led: act { label = "ext_act"; linux,default-trigger = "cpu0"; gpios = <&gpio 16 0>; }; }; }; };</p>

Now we compile the overlay and copy the output to the overlays directory:

pi@retropie:~ $ dtc -O dtb -o act_led.dtbo act_led.dts pi@retropie:~ $ sudo cp act_led.dtbo /boot/overlays/act_led.dtbo

And now we need add this line to the bottom of /boot/config.txt ( sudo vi /boot/config.txt )

dtoverlay=act_led

Safe Shutdown Button

The Power Button on the unit does not function as a 'Power' button meaning that if the unit is in a halted stated and the button is pressed, it will not power on. Like all pi's, plugging in the power supply will turn the unit on. Given the unit is booted, when the power button is pressed, it will initiate a 'safe shutdown'. This is currently done via a python script running in the background listening for input on the GPIO 5 pin. In the future I would like to find a hardware solution to eliminate the potential overhead of this software solution. Note that I haven't experienced any slow down in game play due to this process running but I feel a hardware solution would be much cleaner.

This post was most helpful https://www.element14.com/community/docs/DOC-78055...

pi@retropie:~ $ mkdir scripts<br>pi@retropie:~ $ cd scripts<br>pi@retropie:~ $ touch shutdown_pi.py<br>pi@retropie:~ $ vi shutdown_pi.py

Add the following:

<p>#!/bin/python <br># Simple script for shutting down the raspberry Pi at the press of a button. # by Inderpreet Singh import RPi.GPIO as GPIO import time import os # Use the Broadcom SOC Pin numbers # Setup the Pin with Internal pullups enabled and PIN in reading mode. GPIO.setmode(GPIO.BCM) GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Our function on what to do when the button is pressed def Shutdown(channel): os.system("sudo shutdown -h now") # Add our function to execute when the button pressed event happens GPIO.add_event_detect(5, GPIO.FALLING, callback = Shutdown, bouncetime = 2000) # Now wait! while 1: time.sleep(1)</p>

Now edit /etc/rc.local (sudo vi /etc/rc.local)

<p>#!/bin/sh -e<br># # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.</p><p># Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s

" "$_IP" fi</p><p>sudo python /home/pi/scripts/shutdown_pi.py &</p><p>exit 0</p>

Now reboot and test everything out!