Skip to content

Run the firmware in Hatari with EmuMD - #25

Merged
diegoparrilla merged 5 commits into
release/v1.2.0from
epic/21-emumd
Dec 2, 2026
Merged

diegoparrilla merged 5 commits into
release/v1.2.0from
epic/21-emumd

Conversation

@diegoparrilla

Copy link
Copy Markdown
Contributor

The DevOps firmware now runs in EmuMD's fork of Hatari: its own C code built for the workstation, the real cartridge image on the ST's port, a folder as the microSD card, and the firmware's Wi-Fi through the workstation's network. GEMDRIVE, the Runner, the setup menu, the HTTP API and sidecart.py all work there, on an ST, an STE and a Mega STE, without a device or a flash.

What changes

  • Firmware: cartridge-window and flash addresses are kept in uintptr_t (display, chandler, GEMDRIVE, HTTP server, config). The strh in tprotocol.h is ARM-only, and the firmware copy uses memcpy when there is no XIP stream. reset.c includes the health.h it uses. A release rp.elf is byte-identical before and after (same build ID and date).
  • EmuMD: submodule emu/emumd, pinned at c3e83f4, which reads every --md-option. mdfw.ini builds rp/src as CMake does, with pico-sdk's lwIP and the mDNS responder. emu/standins.c stands in for hardware only: the watchdog and fault handlers, TinyUSB, and the card's remount logic.
  • Tools:
    • tools/dev/build_hatari_fork.sh and mdfw.sh (from md-drives-emulator).
    • md_settings.py, with a new --global option.
    • emu_check.py: builds, boots three machines side by side, and checks that GEMDRIVE's folder is ready, the HTTP API answers, the Runner starts, --run programs exit with 0, [G] installs GEMDRIVE, and warm and cold resets boot the firmware again.
    • target/atarist/test/gemdos-io/GDTEST.TOS: GEMDOS read and seek checks.
  • Docs:
    • emu/README.md and the tools README.
    • CLAUDE.md: the two benches, the uintptr_t rule, and emu/emumd in the never-modify list.
    • AGENTS.md: the stale 8 KB limit, workspace path and template name fixed.
    • A README paragraph pointing at emu/README.md.

Checked

The firmware takes the address of the cartridge window and of its flash
sectors and does arithmetic on it in uint32_t. That is exact on the
RP2040, where a pointer is 32 bits, but it cuts the pointer in half on a
64-bit computer, which is where EmuMD builds this firmware to run it in
Hatari. uintptr_t is 32 bits on the RP2040 too: a release build is
byte-identical before and after.

Also for that build: tprotocol.h's strh is ARM only, so other targets
store the halfword in C; the firmware copy into the window uses memcpy
when there is no XIP stream; and reset.c includes health.h for the
health_markReset() it calls instead of relying on reset.h to bring it.
EmuMD (submodule emu/emumd, pinned where md-drives-emulator pins it)
builds the firmware's own C code for this computer and runs it in its
fork of Hatari, with a Multi-device on the cartridge port and a folder
as the microSD card. The ST boots the DevOps cartridge to its setup menu
without a device or a flash.

mdfw.ini builds rp/src as rp/src/CMakeLists.txt does, with EmuMD's lwIP
built from pico-sdk's copy and the mDNS responder. EmuMD stands in for
the template's hardware layer itself; emu/standins.c covers what else
this firmware needs from the files left out: health.c (watchdog, fault
handlers, stack guard), usbcdc.c (TinyUSB) and the card's remount
logic, which a folder never needs. sdcard.c's directory listing is the
firmware's own, copied out by tools/dev/emu_sdcard_logic.py.

tools/dev/build_hatari_fork.sh builds EmuMD's Hatari into
tools/dev/builds/emumd-cache once, and tools/dev/mdfw.sh runs EmuMD's
mdfw with that cache. Both come from md-drives-emulator.
EmuMD's Hatari joins repeated --md-option values with semicolons, and
the runtime pinned before split them on newlines: with a forwarded port
and a flash file both given, the firmware got neither. EmuMD fixed that
upstream (6b1cde1); its main also presses a template firmware's SELECT
on a schedule. The new pin needs its own Hatari: run
tools/dev/build_hatari_fork.sh again.
tools/dev/emu_check.py builds the EmuMD plugin and boots an ST, an STE
and a Mega STE side by side, each with its own card and flash. It turns
Wi-Fi on in the Booster's settings, as the Booster does on a device, so
the firmware joins EmuMD's network with its port 80 forwarded here, and
checks that GEMDRIVE's folder is ready, the HTTP API answers, the boot
countdown starts the Runner, programs given with --run exit with 0
through sidecart.py, [G] installs GEMDRIVE (--mode g), and a warm or
cold reset boots the firmware again (--reset). Each run keeps its log,
a screenshot, the debug channel and its card.

tools/dev/md_settings.py, from md-drives-emulator, edits settings in an
EmuMD flash file; --global reaches the Booster's sector, where Wi-Fi is.

GDTEST.TOS (target/atarist/test/gemdos-io) checks GEMDOS reads and seeks
on the GEMDRIVE drive: a 1-byte read, an odd-length file read whole, a
4130-byte read with guard bytes, and Fseek from the end, the position
and the start. Its exit code is the number of failures and it leaves
its report in GDTEST.LOG. On this firmware it fails six checks, the
same ways users reported.
emu/README.md has the set-up, the check, running it by hand with the
HTTP API forwarded, what emu/ adds, and the gotchas. CLAUDE.md gets the
two benches (EmuMD first, the device for the bus, timing, USB, the
radio and sign-off), emu/emumd in the never-modify list, and the
uintptr_t rule for window and flash addresses. AGENTS.md loses three
things that were wrong: an 8 KB cartridge limit (it is 10 KB), a
workspace path from another machine, and the template's name.
@diegoparrilla
diegoparrilla merged commit ef191e3 into release/v1.2.0 Dec 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant