Skip to content

feat: BBC Micro MMC/SD card support (MMFS) #645

@mattgodbolt

Description

@mattgodbolt

Summary

Add MMC/SD card support for the BBC Micro via MMFS (the dominant BBC SD card solution), enabling loading software from SD card images.

Background

The Acorn Atom's AtoMMC2 SD card interface is being added as part of the Atom support work (#505, #644). Research into whether the BBC could share that code shows the architectures are fundamentally different — no code sharing is possible, but BBC MMC support is a worthwhile standalone feature.

How AtoMMC2 (Atom) works

A PIC/AVR microcontroller sits between CPU and SD card, presenting a high-level file API (open/read/write/close) via memory-mapped registers at 0xB400. The emulator (mmc.js) emulates the MCU firmware.

How MMFS (BBC) works

The CPU bit-bangs raw SPI directly to the SD card through the User Port VIA (6522 at 0xFE60). The MMFS ROM software on the BBC side handles the entire SD card protocol and FAT filesystem parsing. There is no microcontroller intermediary.

Aspect AtoMMC2 (Atom) MMFS (BBC)
Hardware MCU + SD card Raw SPI to SD card
Interface Command/response registers VIA port B bit-banging + shift register
Protocol level High-level file ops Raw SPI + SD card commands + FAT
What emulator simulates MCU firmware (file API) SD card hardware (SPI responses)
Address space 0xB400-0xB40F 0xFE60-0xFE6F (User VIA)

Implementation approach

1. SPI SD card emulation (new module)

Emulate an SD card's SPI interface — accept SPI commands and return data blocks from a virtual disk image (raw FAT16/FAT32). Key commands needed:

  • CMD0 (GO_IDLE_STATE), CMD8 (SEND_IF_COND), CMD55+ACMD41 (SD_SEND_OP_COND) — initialisation
  • CMD17 (READ_SINGLE_BLOCK), CMD24 (WRITE_SINGLE_BLOCK) — data transfer
  • CMD58 (READ_OCR) — card identification

2. VIA shift register emulation

The 6522 shift register modes 2 and 6 are currently not fully implemented in jsbeeb's VIA (src/via.js). These would need proper emulation for TurboMMC fast transfers. The slower bit-bang path through port B is simpler and could be implemented first.

3. User Port peripheral hookup

The UserVia class already has a userPortPeripheral interface with read()/write() methods. The SD card SPI emulator would plug in there.

4. MMFS ROM

The MMFS sideways ROM needs to be loaded. Available from hoglet67/MMFS releases. There's also a MMC_MemoryMapped.asm variant that uses single-byte I/O at 0xFE1C (Beeb) / 0xFEDC (Master) which might be simpler to emulate initially.

References

Complexity estimate

This is a substantial feature. The memory-mapped variant of MMFS might be the easiest starting point since it avoids VIA shift register emulation. The bit-bang SPI path through port B is the next step, and TurboMMC (shift register) would be the final tier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acorn-atomSpecific to the Acorn atomdiscIssues with the disc emulation or accessfeatureA feature requestinputIssues with input, keyboard, mouse, etc

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions