Skip to content
CommanderCoderPublic

About

A small expansion-bus interface for 1970s and 1980s desktop machines

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pico-xb80

pico-xb80 is a small expansion-bus interface for 1970s and 1980s desktop machines, designed to allow a Raspberry Pi Pico 2 board to present an SD card-backed storage device to a Sharp MZ80K system.

https://youtu.be/xSwXQkPeJl4?si=bnu4Bi942s_XvJiR

Short Video of the pico-xb80

Supported hardware

Currently supported:

Possible future targets with additional effort:

What it does

The project uses a Pico 2 board and an SD card to provide a file system to the Sharp MZ80K through the expansion bus. A small monitor ROM extension and host-side software allow the machine to access files stored on an SD card in a way that is compatible with the existing monitor and tape-handling model.

The software stack includes:

  • SD card interface support for the Pico 2 board configuration used here, over hardware SPI where the wiring allows it and bit-banged 1-bit native SD mode otherwise
  • fatfs by ChaN
  • a custom expansion-bus implementation using the Pico PIO and DMA subsystems
  • Sharp MZ80K-specific glue logic and ROM support for monitor commands such as *FD

Hardware overview

Off-the-shelf components are used to keep the project accessible and inexpensive.

This is a prototype-style design intended to be simple to build and experiment with. A dedicated single-board version may be possible in the future, but the current approach uses the Olimex board for flexibility.

Development environment

The project is built and developed with:

Z80 code tooling

Important: you will need to build your own copy of sjasmplus for your platform.

The repository includes support for:

  • sjasmplus for assembling Z80 code into machine-code binaries
  • bin2header.py to convert binary output into a C header suitable for inclusion in the Pico firmware

Utility tools

The project includes a small set of helper scripts for working with Sharp MZ80K file images:

  • filehandle_path.py — scans a Sharp MZ80K binary for tape-handler calls and rewrites them to use the SD-backed handlers
  • mz_tape_info.py — inspects file images and reports the file type plus whether they have already been patched

Build and upload

Wiring

Only the right-hand column of pins is used from EXT1 and EXT2 on the Olimex board.

Olimex EXT1 MZ80K XB Signal
P1 nc
P3 A25 (mark) D0
P5 A24 D1
P7 A23 D2
P9 A22 D3
P11 A21 D4
P13 A20 D5
P15 A19 D6
P17 A18 D7
P19 nc
P21 nc
P23 nc
P25 nc
P27 nc
P29 nc
P31 B10 NWR
P33 B8 NRD
P35 B6 NIOREQ
P37 B4 NMREQ
P39 B3 GND
Olimex EXT2 MZ80K Signal
P1 nc
P3 A16 A0
P5 A15 A1
P7 A14 A2
P9 A13 A3
P11 A12 A4
P13 A11 A5
P15 A10 A6
P17 A9 A7
P19 nc
P21 nc
P23 A8 A8
P25 A7 A9
P27 A6 A10
P29 A5 A11
P31 A4 A12
P33 A3 A13
P35 A2 A14
P37 A1 A15
P39 nc

sharp-mz80k-bus-pins

Building

From the project root:

cmake -S . -B build -G Ninja
cmake --build build

Uploading

To put the Pico into bootloader mode:

  • hold the BOOT button
  • connect the board to your computer via USB

Then upload the firmware using VS Code with the Pico extension, or use the project task configuration already provided in the workspace.

SD card layout

Create an SD card with a root-level folder named MZ_FD. Place the files you want to access inside that directory and give them the .MZF extension. The file 0000.MZF is loaded whenever *FD is used from the monitor.

Patch workflow

Because the monitor ROM cannot be modified in software, a replacement ROM or a patched program image is required to redirect tape-file operations to the SD-backed handlers.

The helper scripts make this easier:

  • mz_tape_info.py identifies files that use tape-file logic
  • filehandle_path.py patches those files to call the SD-handler routines instead

Power

The board can be powered either from the host laptop USB port or from a standard USB power supply.

Operating instructions

See OPERATING.md for instructions on using the interface from the Sharp monitor ROM.

Reference and acknowledgements

Thanks to:

This project also benefited from discussions and examples from several AI systems used during development, but the project itself is intended to stand on its own technical merits.

Technical notes

The software:

  • SD Card interface software (initially from prompts to Claude.ai). The Olimex Pico2-XXL has two variants. One use 1-bit communication protocol and the other uses the 4-bit protocol. My board used 1-bit so the software was originally built for this.

    SdCard::detect_board_revision() works out which board it is running on first, since the two Olimex revisions wire the card differently. Revision A puts SD_DAT0 on GPIO12 and leaves R24 - the link between GPIO9 and the card's CS pin - unpopulated, so it can only be bit-banged. Revision B moved SD_DAT0 to GPIO24 (GPIO12 collides with the RP2350's HSTX/HDMI block) and ships wired for SPI. The check is electrical, not a conversation with the card: it looks for the 10k pull-up the SD_DAT0 net carries on the board, so it needs no card in the socket and sends no commands - which matters, because a CMD0 seen with CS low latches a card into SPI mode until it is next powered down.

    That gives two transports, picked at startup by SdCard::initialize():

    • SPI - used on Revision B. The card is driven by one of the RP2350 SPI blocks, so a sector moves as 512 hardware-clocked bytes at 12.5MHz rather than 4096 bit-banged GPIO transitions. This needs CS on a GPIO and CLK/DI/DO on pins that can carry the SCK/TX/RX functions of a single SPI instance - GPIO9/10/11/24 are all spi1, so they qualify.
    • 1-bit native SD - used on Revision A, and the fallback everywhere else: whenever the wiring cannot carry SPI or the card does not answer the SPI probe. CMD/CLK/DAT0 are bit-banged at roughly 500kHz with the CPU busy-waiting for the whole sector.

    If the detected wiring fails to initialise, the other revision's wiring is tried before giving up.

  • Expansion Bus - provides a shared memory on the address bus. Pico PIOs rapidly reads addresses and data which several DMAs pump in and out of 64Kx16bit words (128Kb).

    • heavily influenced by ATOM-DVI after speaking with Chris about his project at an ABUG event.
  • pico-xb80_mz80k - the specific Sharp MZ80K interface.

    • Z80 ROM this is shared on the bus at 0xF000 so that the Monitor ROM can jump to it with an *FD command.
    • Mailbox addresses so that the Z80 can send and receive commands and data to/from the Pico
    • Communcation with the SD card via the SD Card interface and fatfs

About

A small expansion-bus interface for 1970s and 1980s desktop machines

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages