I usually operate my RC2014 Z80-based retro computer using the Pi Zero Serial Terminal module. This RC2014 module hosts a Raspberry Pi Zero and connects the Pi’s main serial port to the serial RX and TX lines on the RC2014 bus. It is intended to be used with PiGfx, a bare-metal ANSI terminal emulator. The idea is you’d hook up a monitor and a USB Keyboard to the Pi Zero, and use it locally as a standalone dumb terminal. It’s a brilliant solution, especially since actual terminals are getting hard to find.
I don’t use it that way. I prefer to run Raspbian on the Pi Zero and use a terminal emulation program (typically minicom) to talk to the RC2014. In local mode, Raspbian makes much prettier text on the screen (as of the version of PiGfx I tried), even using the composite video output. What’s more, Raspbian supports networking so I can use the RC2014 without sitting right in front of it. Raspbian of course supports all flavors of the Raspberry Pi, so I can use a Raspberry Pi Zero W instead of a plain Zero, and get built-in WiFi networking. PiGfx doesn’t yet support the Zero W, though it is on their TODO list.
So my typical working configuration has me sitting across the room from the RC2014, at a Mac with several large monitors, connected to the Zero W via ssh over WiFi, running minicom to communicate with the RC2014. There’s a problem with this setup, though. Given the parlous state of most of the software I’m trying to run (or write) on the RC2014, it’s just not that unusual that I need to push the reset button. Getting up and walking across the room to push the reset button seems inelegant. It’s also enough of a pain that I will waste time trying to find a way to un-stick the Z80 from the serial console to avoid doing it. I need a reset button I can activate remotely.
Luckily there are plenty of unused GPIO pins on the Pi, and it’s pretty easy to interface one of them to the /RESET signal on the RC2014 bus. That’s what this mod does. We’ll use GPIO4, because it’s mechanically handy and not shared with any other functions on the Pi. Note that it is not OK to hook these signals up directly, since /RESET is a +5V signal and the Pi is only rated for +3.3V.
The transistor pulls the /RESET signal down to ground when GPIO4 is high. When GPIO4 is low, the transistor does nothing.
Unplug the Raspberry Pi from the Serial Terminal module. We’ll be installing the components on the Serial Terminal module underneath the Pi.
There’s lots of room on the module circuit board that’s not used. Hold it up to the light to see that there isn’t even a ground plane over most of the area of the board. Drill five holes as shown below. I used a #66 drill bit, but the diameter of the hole isn’t critical. The lower three holes in a triangular pattern are for the transistor. The upper two are for the resistor; the right hole is near the base of the transistor, and the left hole is approximately over the fourth pin from the left of the Raspberry Pi connector. The two resistors shown here are standard parts on the Serial Terminal module. I drilled the holes freehand. Just get them close.
Install the components on the front of the board. Make sure the transistor is oriented with the flat side toward the Raspberry Pi connector, as shown. You’ll need to bend the transistor’s leads out a little to reach the holes. Make sure the transistor sits reasonably close to the board, so it won’t interfere with the Raspberry Pi.
Make the connections on the back side of the module board. One side of the resistor and the base of the transistor are adjacent, so just bend the leads together, solder, and trim. The other side of the resistor should be able to reach the Raspberry Pi connector; bend it over and solder it to the GPIO4 pin, which is the fourth from the end. Use some wire if it doesn’t reach. The emitter of the transistor is close to the end of the pre-existing 22K resistor that just happens to be GND, so bend that lead over to touch the existing pad, solder, and trim. Add a piece of thin solid wire (I used 24 gauge telephone wire) between the collector of the transistor and the /RESET pin on the RC2014 main bus. /RESET is two pins over from the +5V pin, which has traces connected to it. There’s no particular need to insulate or strain relieve any of these connections, but you might want to drop a bit of superglue on the two longer leads. Re-install the Pi.
Now we just need a bit of software to function as our reset button. Here’s what I came up with. Name it rcreset.py
import RPi.GPIO as GPIO
# no extra delay required; the pulse is about 10 uS naturally
# don't call GPIO.cleanup(), we want the pin to stay low.
# That's why we turn off warnings above; when we run this
# program a second time it would warn that we were already
# using the pin.
I chose to use Python because Python. I chose Python 3 instead of old-fashioned Python because 2019, though this script would probably work the same either way. I chose RPi.GPIO instead of gpiozero because the startup time for gpiozero seemed excessive. This script runs in about 650ms, which is fast enough. There are lots of other ways this script could be written.
As noted in a comment in the script, the pulse generated is usually about 10 microseconds long. Raspbian is not a realtime operating system, so it could be longer. The Z80 data sheet calls for the reset pulse to last for at least three full clock cycles, so this pulse will work for any Z80 clock faster than about 400 kHz. If your clock is sometimes slower than that, you might want to insert an appropriate delay into the script. Reset won’t work at all if the clock is stopped.
You’ll need to adjust the permissions of the Python script:
chmod +x rcreset.py
You’ll probably want to place it somewhere on your regular search path, such as /usr/local/bin.
Finally, we need to deal with how GPIO4 behaves when the Raspberry Pi starts up. By default, it starts out as an input with a weak pull-up, and stays that way until the boot process is nearly complete, and then switches to a high impedance state. The initial state holds the RC2014 in reset for many seconds, and then the high-impedance state leaves it vulnerable to spurious resets due to noise. We could use a similar Python script on startup, but that won’t run until rather late in the boot process, and if we happen to be using the local console we’ll be stuck waiting for the Raspberry Pi to boot up for no good reason. Instead, let’s use some magic words to get GPIO4 configured early in the boot process. Make sure you’re running a version of Raspberry Pi firmware that’s newer than March 18, 2018, and add these lines to /boot/config.txt:
# Drive the GPIO pin used by RC2014 reset as early as possible
With those magic words, GPIO4 goes low within a second or two of power-up, and stays that way. Much better.
So now when I’m sitting across the room and the RC2014 locks up on me, I open another ssh session to it and type
I could also use a local command on my Mac or Linux host. This could be assigned to a hot key or other shortcut to eliminate all the excess typing:
ssh email@example.com /usr/local/bin/rcreset.py
This works best if ssh has already been set up to authenticate to the Pi without requiring a password. Like this.
One final note. If you also use the RC2014 Dual Clock and Reset module, there’s a potential issue with contention on the /RESET line. I have a mod for this, too, which I recommend you install before installing the remote reset mod. See my previous post for details.
P.S. The reset script can be run from inside minicom, so there’s no need for a separate session.
1. On the Pi, create a directory to contain minicom scripts, if you don’t already have one. I named mine .minicom and put it in the home directory.
2. Create a script file inside that directory. Name it something like rcreset and put this in it:
3. Run minicom. Ctrl-A O to open configuration. Choose Filenames and paths. Choose C to enter the script directory path. Enter /home/pi/.minicom or whatever you called your script directory. On the way out of the configuration menu, choose Save setup as dfl to make the change permanent.
Then to reset the RC2014 in minicom, hit Ctrl-A G to run a script. The first time, you’ll need to hit C and type in the name of the script (rcreset). Then hit enter to run it. Thereafter in that session you can just hit Ctrl-A G Return to reset the RC2014.