Skip to content

Digitone II: the runtime loader in the development base, over the link - #1842

Draft
prodbysmolec wants to merge 142 commits into
repeat98:base/digitone-ii-nextfrom
prodbysmolec:machine/digitone-ii-loader
Draft

prodbysmolec wants to merge 142 commits into
repeat98:base/digitone-ii-nextfrom
prodbysmolec:machine/digitone-ii-loader

Conversation

@prodbysmolec

@prodbysmolec prodbysmolec commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Digitone II, piece 5: the runtime loader in the development base. Stacked on #1763, #1817, #1820 and #1821: this branch carries their current heads until they merge into base/digitone-ii-next; then I merge that branch here so the diff holds only the loader.

RUNTIME_POOL_AT is settled: #1910 put it on main, and with main merged, loader.c, the Octatrack base and its test are out of this diff.

  • What was wrong or hard: The Digitone II had no way to try a module without building and flashing a whole OS. The Octatrack's machine-neutral loader (sdk/runtime/loader) and its upload controller (sdk/runtime/upload) needed the Digitone II's glue, a transport, and a place for the pool: the base's area holds 256 KiB, the pool 2 MiB.

  • What this changes:

    • sdk/machines/digitone-ii/elekloader/base/runtime.c: the Digitone II's glue, the Octatrack's with OS 1.12's values. Stopped is the sequencer's playing word. Modules run from the uncached alias (+0x08000000). The instruction caches are invalidated with stock's CACR value minus DCINVA, since the boot value would drop dirty data lines at runtime. Patchable code is the OS's code in RAM (0x40000400-0x401d0800). The lock is interrupt level 4, so the frame interrupt (level 5) keeps the sound going. Paused tasks come from all sixteen task records, each found from stock's task_create calls. The trampolines sit on the core's ev_tick, ev_draw, ev_key and ev_enc; the encoder delta is the raw count, as Digitakt II mods read it.
    • link.c: an upload command (0x30) carries one controller frame, 7-bit packed, in its own slot (stock passes link messages up to at least 8 KB). The UI task runs it. A trial whose host is silent for ten seconds rolls back once the unit is stopped. ident also reports the modules live and the modules' test value itself (no address for the host to read, since Machine: Digitone II development link, stage one (read-only diagnostics over USB MIDI) #1763's reads are bounded).
    • The pool at a fixed address (RUNTIME_POOL_AT, from Octatrack base 0.8: playback admission, saved effects, restore outcomes, stock OS fixes and screen capture, with FM Synth 0.1.5 and Tape Echo 0.1.9 #1910 on main): the Digitone II uses DDR above what stock clears (0x46800000, 2 MiB), with staging after it.
    • scripts/machine-base.py: a dev base's shared stages repository sources (the loader, the controller, freestanding.c) beside its own.
    • dn2_link.py: loader, try [--seconds] [--keep], remove [--keep], keep, undo.
    • Docs: sdk/machines/digitone-ii/LOADER.md (how each value was found), LINK.md, GOAL.md, the loader's porting notes. Changelog entry.
  • How I checked it:

    • npm run pr:ready.
    • sdk/tests/test_runtime_loader.py (unchanged, green with and without the new define).
    • sdk/tests/test_dn2_link.py: new upload tests (the frame and its packing, the largest frame fits the slot, the response fields, removal packages, the pool and staging inside the free DDR). Its unittest.main() sat mid-file, so a direct run skipped later classes; it now ends the file.
    • sdk/tests/test_machine_base.py: shared staging, and a source must be staged. One existing assertion changed: "every dev source is a file of the machine's base folder" now also accepts a file staged by shared, and checks that the staged file exists (Jannik checked it on 1 December: the base branch already accepts a shared source, and this only adds the check).
      Tested on a unit (5 December 2026): development package a158dc917c68d70c61d895085da9f6451dafa6c54ee198a27a50dd061a641583 (HELLO base 44f30887…, .syx 436b2afe93075f937142da2face861bc140b7611729f3e868c1f95afbdabfb1b), built from this branch at 5a9aa0137 after base/digitone-ii-next was merged up. This head (3b2da45e4) rebuilds the same SHA-256: since 5a9aa0137 only LINK.md, GOAL.md, the host tool, its test and the record changed. The record, both sittings: docs/verification/2026-12-05-digitone-ii-dev-stack-on-a-unit.md. Results: a trial rolled back after 5 s; a trial kept with --base and the build's .identity, with corner_dot's dot on the screen; the removal kept; another build's .identity refused before sending; with the pattern playing from the link, a trial refused ("unsafe (the unit plays: stop it)"). Listening: the developer listened to Voice Spread chords on this package linked with Voice Spread and said it sounded good; this stack changes no sound path. The sound during a loader trial was not measured.
      Earlier, on 20 November: development package e4dfa5abc4b2fdbf701a03781ce38d7708e90a5b15ed9b3ace5e4619f4cccdc1 (.syx 9655e19e…), Digitone II OS 1.12, booted from RAM; the loader's trial, Keep, removal and hooks ran.
  • Details of the 20 November unit run:

    • Digitone II, OS 1.12, flashed with Machine: Digitone II RAM boot over the development link (piece 5, stage one) #1821's RAM boot base. The exact build of this pull request was booted from RAM over the link: .syx 9655e19e…988e, main CRC 304cfcdc, development package e4dfa5ab…cdc1, after merging main. The same steps ran first on the build before the merge.
    • Test modules: two original C modules, a tick counter and a hooks probe.
    • Results: trial and rollback, Keep, removal and its rollback, the host-gone rollback, a refusal while playing, and the key, encoder (±1/2/3/8) and draw hooks. The diagnostics log showed no FREEZE.
    • Record: docs/verification/2026-11-20-digitone-ii-runtime-loader-on-a-unit.md.
    • A stock-code site: a private test package patched jsr 0x40113e2a at 0x4002e4c0 (frame composition) to count redraws, ran, and its removal restored the stock bytes; ten keep/remove rounds, the log START only.
    • Not tested: stock copies, a switch while another task is paused inside a site, converted catalogue mods.

The developer's own stage: with nine modules live at once (nearly the whole pool), they played a pattern and turned knobs: "alles lingt normal" ("everything sounds normal").

Edge cases

Case Why this change makes it a risk How run Result
A trial while the sequencer plays the loader must never switch while audio-critical code runs PLAY over the link, then try pass: ENTER refused as unsafe, nothing changed
The host goes away during a trial a trial no one keeps must not stay a person's key presses refused the host mid-trial pass: rolled back by itself about 10 s later, stopped
Two modules at once positions, hooks and pool extents side by side try --keep of the tick counter, then corner_dot pass: two live, both hooks ran
A same-id replacement the loader swaps one position in place corner_dot kept, then a build with the dot moved left under the same id pass: still two live, only the new dot drawn
A site the core owns a module must never patch a base or core site a package for 0x4002e464, the core's tick site pass: refused at commit, the bytes unchanged
A full pool 2 MiB at a fixed address must refuse, not overrun eight modules with 280 KiB of bss each, kept one by one pass: seven fit beside two small ones, the eighth refused at verify; 9 live, frames to ticks 50:1, the log START only
A refusal leaves upload mode a refused package must not hold the loader the two refusals above, after the host fix pass: phase normal at once (before the fix, after about 10 s)
A stock-code site, patched and restored the switch writes stock code under the lock jsr at 0x4002e4c0, ten keep and remove rounds pass: patched while live, stock bytes after
Removal and its rollback a removal is a trial too remove, then undo, then remove --keep pass
A power cycle with modules kept RAM modules must go and the flashed base come back the developer power-cycled with a module kept pass: ident boot 0, the flashed base
A switch while another task is paused inside a site the paused-task check must refuse it not run: no way to hold another task inside a site on demand not run: the check never had to refuse
Stock copies (ABI 7) copies are reconstructed from stock bytes not run: no Digitone II package carries copies yet not run: no package to run it with
A module that takes a key or a turn a taken event never reaches stock not run: the probe module takes nothing not run: no module takes one yet
An offer made for another development build HELLO named the same base for every build host test dn2_link_host.c: link.c with one build's layout digest and the real upload controller, an offer bound to a second build pass: refused (MU_IDENTITY), the same offer for this build taken; on a unit (5 December): the host refused another build's .identity before sending; the unit's own refusal not run

Also: dn2_link.py's load leaves upload mode at once after a refusal (abort, then leave), and the example module sdk/machines/digitone-ii/examples/corner_dot.c ran on the unit.

  • What the guides lacked or got wrong, and where I fixed it: The loader's porting notes had no way for a base whose area is too small for the pool, no way to stage shared sources, and no warning that the ready lists miss waiting tasks. All three are now in sdk/runtime/loader/README.md#porting-to-another-machine. The verification records on this branch beyond the new one come from the stacked pull requests.

🤖 Generated with Claude Code

prodbysmolec and others added 30 commits November 19, 2026 03:03
…SB MIDI SysEx

Development bases (base.json's dev) observe stock's SysEx router at 0x4012197a (core-dn2 0.3's ev_sysex site) and
answer the Analog Rytm MKII link's ident and mem requests from ev_tick through stock's sysex_send on USB. A host
(tools/dn2_link.py) with a test of its frames, LINK.md, the goal row and a changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The status byte of stock's USB MIDI receive parser, 0x445090ac on OS 1.12, reads 0xF0 while a SysEx message arrives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not yet on a unit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…host on a unit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and the encoder pushes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot yet on a unit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…red rate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot on a unit)

DIAG, MARK and DIAG_STAGE are defined after their first use in link.c: move that block up before building.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The upload is copied to 0x47000000 before the reset, because the bootstrap reads the flashed MAIN OS into the staged
upload. Host ramboot and bootdiag; LINK.md; a test that the host's limits are the gate's. Not yet on a unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the same

Every Digitone II address link.c held (keys, the upload buffer, the RAM boot's copy and diagnostics, stock's boot
argument, wait and drain) is a cflag in base.json, as the owner asked for one link with each machine's addresses in
its recipe. The built package's sections, symbols and relocations are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the link

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oader

# Conflicts:
#	sdk/machines/digitone-ii/GOAL.md
prodbysmolec and others added 14 commits December 5, 2026 03:49
…site reads it

The base said version 2 but paged only the log (6,148 bytes), and
device-log.ts refuses a version 2 log without the crash and stall records
after it: on a unit, parseDeviceLog read nothing. LOG now pages
DIAG_IMAGE_BYTES as on the Octatrack, the records zero, and a test reads
a Digitone II image and refuses the log alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…silence

On a unit the port disappeared during the reset and rtmidi raised
InvalidPortError (or the port list changed under it), ending the command
after the RAM boot had gone through. ask_ident_once now treats a port it
cannot open as no answer yet. Host only: the package is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r not (measured on a unit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… about 2 s, not 3 (measured on a unit)

60 UI ticks at about 30 a second: a freeze request was refused until 1.67 s after a person's
press and accepted at 1.93 s (5 December 2026). Text only; the package is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-diagnostics

# Conflicts:
#	sdk/machines/digitone-ii/LINK.md
#	sdk/machines/digitone-ii/tools/dn2_link.py
…ii-ramboot

# Conflicts:
#	sdk/machines/digitone-ii/LINK.md
#	sdk/machines/digitone-ii/tools/dn2_link.py
…oader

# Conflicts:
#	sdk/machines/digitone-ii/tools/dn2_link.py
… of the base's HELLO identity)

The 2 s correction stays in LINK.md and the tool; link.c's comment follows with its next real change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prodbysmolec and others added 5 commits December 5, 2026 18:51
…INK.md and GOAL.md

One record for both sittings on the stack's development package a158dc91
(.syx 436b2afe), built from repeat98#1842 at 5a9aa01: the test procedure's fixed
steps first, each run or not run with why (the runner has no Digitone II
steps yet), then each PR's cases. Listening and the large flood's audio
stay open. The link row and LINK.md now point at it; the 19 November run
stays as history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at a late event costs a person

The link's events stay held back at UPGRADE OS NOW? however late stock
dispatches them; after the link has given up an event, a person's press of
the same key can be held back once, so their first YES may do nothing
(repeat98#1763 review, 5 December). The link row points at the new record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-diagnostics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ii-ramboot

The RAM boot row points at the 5 December record too: this version, where
ramboot's own marked YES answers the prompt, ran on a unit there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oader

The loader row points at the 5 December record: this head's RAM boot and loader ran on a unit there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prodbysmolec and others added 5 commits December 5, 2026 20:09
…er on 5 December

Over the unit's USB audio, with 250,000 foreign SysEx sent while a
pattern played, every trig interval stayed 0.48 to 0.52 s before, during
and after the flood, so the sound and the sequencer go on while the UI
stands still. The developer listened to Voice Spread chords on this
package and said it sounded good. The sound during the RAM boot's CRC
at UPGRADE OS NOW? and during a loader trial stays open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants