How to Recreate a 1984 Macintosh 128K on a $5 RP2040 Pico
This article details how a developer rebuilt the original Macintosh 128K using a low‑cost RP2040 microcontroller, covering the hardware design for VGA output, the software stack built around the Musashi 68‑bit emulator, performance‑tuning tricks, and the remaining limitations such as running MacPaint.
pico-mac is a self‑contained system that runs on a Raspberry Pi RP2040 MCU (installed on a Pico board). It generates a monochrome VGA signal, accepts USB keyboard and mouse input, and emulates a Macintosh 128K computer together with its floppy‑disk storage. The RP2040’s 264 KB of RAM comfortably holds the Mac’s 128 KB memory plus the emulator’s data, and the board’s 2 MB flash stores the OS and disk images.
Macintosh 128K hardware
Motorola 68000 CPU @ ~8 MHz.
Flat 128 KB RAM map with VIA, SCC and IWM floppy‑controller registers.
No external interrupts, slots, DMA controller or expansion cards.
Fixed 512×342 1 bpp video frame buffer.
Emulator (umac) construction
The Musashi 68 K interpreter (written in C) was chosen for its simple API and ready‑made example. Development proceeded in the following stages:
Create a command‑line program that loads the Mac ROM, allocates RAM and configures Musashi.
Add address decoding so CPU reads/writes are routed to RAM or ROM, using an “overlay” register to map ROM at address 0.
Implement a minimal MMIO framework for the VIA, SCC and IWM registers.
Handle special ROM‑only accesses such as RAM‑size probing.
Initialize RAM with known patterns to verify the video frame buffer.
Patch the IWM driver to return realistic values and avoid crashes.
Detect the “unknown disk” icon as a sign that the ROM is executing correctly.
Integrate an SDL2 front‑end to provide real‑time video, mouse and keyboard handling.
VGA output on the RP2040
The video path uses the RP2040’s PIO state machines and DMA. Three DMA channels were experimented with:
Channel 1 writes video data to the PIO TX FIFO.
Channel 2 programs channel 1 with configuration data.
Channel 3 streams the actual frame buffer.
The final design employs double‑buffering and re‑programs the DMA during H‑sync IRQs, eliminating visible flicker and reducing CPU load.
Performance optimisation
Initial execution speed was ~300 KIPS (≈0.3 MIPS). To reach the target ~1 MIPS the following techniques were applied:
Over‑clock the RP2040 from 125 MHz to 250 MHz (≈30 % gain).
Mark hot functions with __not_in_flash_func() so they run from RAM, avoiding flash‑cache misses.
Remove Musashi’s large cycle‑accurate lookup tables, which are unnecessary for the Mac.
Run a real Mac session (Missile Command) to collect opcode usage statistics and move the 200 most‑frequent opcode handlers to RAM (≈17 KB RAM overhead).
These changes raised performance to about 1.4 MIPS, allowing smooth gameplay of Missile Command.
RP2040 memory access characteristics
The RP2040’s fast RAM can be accessed in a single cycle by multiple masters (CPU, DMA). Most code runs from external QSPI flash via XIP at 125 MHz, incurring a ~20‑cycle latency on a cache miss. When over‑clocked, the flash still runs at 125 MHz, doubling the miss penalty. By placing the interpreter’s dispatch tables and hot loops in RAM, the bottleneck is mitigated.
Remaining limitations
Video, mouse and basic applications (MacDraw, MacWrite) work, but MacPaint cannot run because it expects more than the 128 KB RAM configuration provides. Custom ROM patches to support 192 KB–256 KB configurations were explored, but the ROM’s memory‑test code assumes power‑of‑two sizes, making it difficult to run MacPaint without further hacking.
Resources
Project page: https://axio.ms/projects/2024/06/16/MicroMac.html
GitHub repository with build instructions: https://github.com/evansm7/pico-mac
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
