Repository navigation
Run the firmware in Hatari with EmuMD - #25
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyall work there, on an ST, an STE and a Mega STE, without a device or a flash.What changes
uintptr_t(display, chandler, GEMDRIVE, HTTP server, config). Thestrhintprotocol.his ARM-only, and the firmware copy uses memcpy when there is no XIP stream.reset.cincludes thehealth.hit uses. A releaserp.elfis byte-identical before and after (same build ID and date).emu/emumd, pinned atc3e83f4, which reads every--md-option.mdfw.inibuildsrp/srcas CMake does, with pico-sdk's lwIP and the mDNS responder.emu/standins.cstands in for hardware only: the watchdog and fault handlers, TinyUSB, and the card's remount logic.tools/dev/build_hatari_fork.shandmdfw.sh(from md-drives-emulator).md_settings.py, with a new--globaloption.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,--runprograms 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.emu/README.mdand the tools README.uintptr_trule, andemu/emumdin the never-modify list.emu/README.md.Checked
tools/dev/emu_check.py --run HELLODBG.TOS: PASS on ST (TOS 1.04), STE (1.62) and Mega STE (2.06).--mode g --reset warmand--reset coldalso pass.GDTEST.TOSon this branch reproduces the GEMDRIVE bugs users reported:Fseekreturns -37 (GEMDRIVE: Fseek() fails with -37 (EIHNDL): handle and offset are read in the wrong order #19).tools/dev/flash.sh releaseanddebugbuild. Thereleaseimage is identical to the one before these changes.