A couple of entries back I was pondering which project to do next after Juno First. Since then, I have been working on the semi-secret Harmony/Melody cart project. This project is now close to completion, and so I think it is safe to write some details about it here. To keep things simple, I'll only talk about the Harmony cart. The Melody cart is the same, but without the SD card and USB options.
The Harmony cart project was started by batari around a year ago. As I understand it, there were several main motivators:
- To make it easier and cheaper for Al to assemble homebrew games. The Harmony cart provides a single PCB that can be pre-assembled into a cart and then flash-programmed for a specific game. This does away with the need for different PCBs, depending on the bank-switching type, and the need for programming and soldering EEPROMs.
- To provide a cart capable of running Batari Basic games that use the SARA superchip. The SARA superchip provides 128K extra RAM for games, but these chips are difficult to obtain and require a special PCB. The Harmony cart emulates the SARA superchip in software, which allows homebrew SARA games to be mass-produced for the first time.
- To develop a novel hardware platform for the 2008 holiday cart. The holiday cart didn't get done in the end, but the hardware is now available for future years.
- To produce a cut-down version of the Chimera cart. The Chimera has some common elements with the Harmony cart, but was much more ambitious. Unfortunately the Chimera project has stalled, but the Harmony will provide some of the same features.
The hardware of the harmony cart is very straightforward. It is basically just an ARM7 micro-controller (an LPC2103) connected directory to the cartridge port of the Atari. Batari discovered that this chip was fast enough to service requests from the Atari and emulate all of the different bank-switching types entirely in software. The ARM micro-controller contains 32K flash memory, which can be used to store the game binary permanently, and also 8KB RAM, which can be used to do the bank-switching and store any game data. The LPC2103 costs only a few dollars, and so Harmony carts can be produced more cheaply than carts which require CPLDs.
The software on the harmony cart is also very straightforward. It doesn't attempt to synchronize clocks with the Atari. Instead, it just sits in an permanent loop, servicing requests from the Atari as follows:
1) Wait for an address request from the Atari (A12 high). 2) Read address bus (A0-A11). 3) Fetch data from flash memory at the requested address (may perform bankswitching here). 4) Assert data on the data bus (D0-D7). 5) Wait until there is a change of address (A0-A12). 6) Repeat forever.
This approach is necessary as the cartridge port doesn't output the 6502 clocks (phi1 and phi2) and also doesn't have a R/W line to distinguish between reads and writes. The wait for A12 at the beginning has the effect of keeping the ARM and Atari loosely synchronized.
The ARM processor runs at 70MHz and the Atari runs at 1.2MHz, which sounds like the ARM would have plenty of overhead. Unfortunately this is not the case. The flash memory of the ARM takes 4 cycles to access, and the ARM can only perform I/O at a fraction of the full clock speed. Also, the data must be placed on the Atari data bus within a short time of A12 being asserted. It works out that the ARM is only just capable of keeping up with the Atari. If the Atari were any faster, then this approach would not work. Fortunately it does work, and batari has managed to implement all of the main bank-switching schemes on the Harmony.
I got interested in the Harmony project around the time batari had the basic hardware implemented and working. My interest was sparked by the SPI bus on the LPC2103 chip. This bus enables a range of peripherals to be connected to the chip, including an SD card slot. I decided to attempt to write an SD card driver for the Harmony. This is non-trivial as the driver has to fit into the 8KB of memory (since the 32K of flash is used to hold the actual game). The driver needs to be able to read data from the SD card (across the SPI bus), parse the FAT file system, display a menu on the Atari, load the game from the SD card into flash, and auto-detect the bankswitching type.
I'll save the actual implementation details of the driver for another entry. For now, here are some photos, which show the progress on the project.
- My first Harmony cart (which I built from batari's schematics). It is basically an Olimex LPC2103 prototyping board wired up the the Atari. Most of the early SD driver development was done on this board:
- My first Harmony PCB. This is an early revision of the Harmony PCB, assembled by batari. I wired it up to an SD card socket and an LED for debugging:
- The near-final Harmony cart. This is the final (hopefully) prototype of the Harmony cart, assembled by batari:
- A screenshot of the Harmony SD card menu on an old CRT TV that I use for Atari development. This version of the menu was written by Thomas Jentzsch.