Chronworks


Being a vintage computer geek to me old technology is like crack to an drug addict. Whenever I see a retro project I want it. For a long time I've coveted Lee Hart’s COSMAC ELF Membership Card. In the 70’s I missed the COSMAC ELF “movement” because I was already building my own 8008 computer. I finally gave into the urge and ordered a kit from Lee. When the kit arrived I quickly jumped in and built it. Lee’s Membership card is a very well thought out and constructed project. I bought all the options with my kit, which includes the main board, a little front panel, all the parts, and even an Altoids can. After completing the project I ran through all of the examples included in the documentation. Yea, it worked perfect!

Once I got past the initial construction and testing I was in the “what’s next” phase. I now wanted to try running basic on the COSMAC ELF Membership card. Aside from the front panel, which is not really an option for loading long programs, I ether needed to burn BASIC in a EPROM, or use another computer to load BASIC into the ELF’s memory. Josh Bensadon wrote a Quick BASIC program which uses a PC’s parallel port to upload software to the Elf’s memory. Being that PC's with parallel ports are getting nearly as rare as an 1802 I opted for a more modern approach, a Raspberry Pi 3.

In the last few years the Raspberry Pi has become one of my go-to embedded platforms. Running Linux they support all of the expected development tools that I have been accustomed too. The Raspberry Pi has a 40 pin expansion header that supports a variety of parallel and serial I/O. In the case of the ElfPi interface I specifically use the SPI and the standard serial port. The SPI signals are used to interface to MCP23S17 16 Bit I/O Expander chips. These IC's are used for the actual control and transfer of data to the COSMAC Elf's memory. The standard serial port is brought out of the Raspberry Pi at 3.3v TTL levels and interfaces to the Elf's bit banged serial port.

I designed a little daughter board that sits atop of the Raspberry Pi. The ElfPi consists of two MCP23S17's, ten reisistors, three capacitors, and a bunch of connectors. The board can either source power from the Pi, or power the Pi. Being all through the hole parts it is simple to solder together in less than an hour. The design files, BOM, and a link to order boards are at the bottom on the page.

ElfPi Bill of Materials

The larger part of the project was the software interface. I ended up with a tiny amount of feature creep. Originally I had only intended to support upload and download functionality. After thinking through the software interface it became clear that a minimal HEX editor would really add to the flexibility. The ElfPi software will read and write both binary and Intel format HEX files. When reading a file from disk there is an option to zero or set the entire memory buffer to a preselected value. The editor function is really nice when you need to add a jump instruction to a program loaded at a higher memory location. The entire process consists of reading in the file, adding a C0 80 to the beginning of the memory buffer, writing the buffer to memory, and then selecting RUN.

You can typically navigate by hitting the first letter of the functions name on the menu, or navigate with the cursor keys. When you are in an actual function use the TAB key to move between fields. When inside the HEX editor the "h" key will get you a minimal help screen. "Q" or "Esc" will get you out. The ElfPi software interface looks very DOS like. I've written it with ncurses which allows it to work just fine in a standard ssh terminal window. The interface is very quick to navigate and I believe reasonably intuitive. I still have a bit work on the software. If you have a comment, please pass it on.

The other nice addition of running from the Pi is that I also use it for my serial terminal. I'm running minicom on my set up. So once I start BASIC I simply jump over to another window and start communicating with the COSMAC Elf using minicom. I've run both Tiny BASIC and Chuck's Super Monitor. You can run the Pi with a monitor, keyboard, and mouse connected, or in a headless mode as I do and just ssh into the pi from another computer.

To install and run the ElfPi software you need to enable the SPI interface on the Pi as well as install ncurses. The ElfPi software is all written in C and complies with a single make command. Being somewhat lazy the source is in a single monolithic file. Also typical of my programming style is the lack of comments and my special formatting. At just under 2800 lines it's actually pretty readable as I typically use logical function names. Because the ElfPi program access the SPI ports you will need to either sudo the program, suid the program, or just run it as root.


### Enable SPI

raspi-config

 Select (5) Interface options

 Select (P4) SPI


By default the Raspberry Pi will be running a serial console on ttyS0. Before running minicom you will need to disable the console on ttyS0.

### Disable console on serial port

 raspi-config

 Select (5) Interface options

 Select (P6) Serial

	No console
	enable hardware



### Install minicom

apt-get install minicom

 Should be ttyS0



### Install todos and fromdos ...  Just nice handy utilities

apt-get install tofrodos



### Instructions to complile the a18 compiler

 unzip a18.zip

 ln -s A18.H a18.h
 gcc -I. -o a18 a18.c a18util.c a18eval.c


Tue Dec 19 10:33:23 MST 2017
Copyright C 2017, Len Bayles