Skip to content

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

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

prodbysmolec wants to merge 100 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. Please look at that.
      Tested on a unit: development package e4dfa5abc4b2fdbf701a03781ce38d7708e90a5b15ed9b3ace5e4619f4cccdc1 (.syx 9655e19e…), Digitone II OS 1.12, booted from RAM; the loader's trial, Keep, removal and hooks ran.
      To run again on this head (before HELLO named the build, the record above is for the earlier package): trial, Keep, removal and the refusal while playing on the resulting dev package, try --base with its .identity accepted and another build's refused, and the package's SHA-256 in the record.
  • Details of the 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: not run, the unit is on stock 1.12 right now

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>
prodbysmolec and others added 9 commits November 25, 2026 12:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto the loader: ident sends the modules' test value itself

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

# Conflicts:
#	sdk/tests/test_dn2_link.py
…n names

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

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

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

Copy link
Copy Markdown
Collaborator Author

Point 1 is done, and the stack now carries #1763's bounded interface all the way down (4bb7a28). Not run on a unit yet (not on USB today).

@repeat98

Copy link
Copy Markdown
Owner

Thanks, no mem anywhere in the stack now, and ident sending the test value itself is the right way round.

One small new thing for when you do the unit run: UPLOAD_BASE and UPLOAD_BASE_TEXT are still in src/engine/elektron/dn2-link.ts, with the comment that they are the base identity upload_start() reports. Since HELLO names the build, no base reports that any more, and nothing outside the tests uses it. Please remove both, or reword them as the older dev bases' identity only, and give dn2-link.test.ts its own value so nothing binds an offer to the fixed string by mistake.

The rest is as in my last comment: the rerun on this head's dev package with its SHA-256 and the .identity checks, and the stack merged down once #1763, #1817, #1820 and #1821 are in base/digitone-ii-next.

prodbysmolec and others added 17 commits November 26, 2026 10:30
…chine/digitone-ii-link

# Conflicts:
#	src/engine/elektron/dn2-link.ts
…nto machine/digitone-ii-diagnostics

# Conflicts:
#	src/engine/elektron/dn2-link.ts
…oader

# Conflicts:
#	sdk/runtime/loader/README.md
#	sdk/tests/test_machine_base.py
The unit refuses 0x21 since the link became bounded, so mem, MEM_MAX,
read() and the readLog that read through them are gone, with their
tests. repeat98#1820 brings the log back through log OFF (0x24). The fake unit
now refuses every command link.c does not serve.

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

# Conflicts:
#	src/engine/elektron/dn2-link.test.ts
#	src/engine/elektron/dn2-link.ts
Since HELLO names the build (its layout digest), no base reports the
fixed text's SHA-256 any more, and nothing outside the tests used it.
dn2-link.test.ts names its own test base so nothing binds an offer to a
fixed string by mistake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a unit, the link held YES while an OS upload completed, then
'release' posted YES's key-up, and stock started the flash: it answers
the prompt on the release as on the press. At the prompt mw_link_key now
takes every key event the link posted, releases included, and counts it
as refused; a person's YES and NO still reach stock. The host test
asserted the old behaviour and now checks the release is taken (it fails
against the old dispatch).

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

# Conflicts:
#	sdk/machines/digitone-ii/LINK.md
With the link's releases held back at UPGRADE OS NOW? (repeat98#1817), ramboot's
YES would be held back too: until now its press was taken at dispatch
and only its release reached stock, which answered the prompt with it.
The two events ramboot posts for the upload it checked (length and
CRC32) are now marked in the pending queue and pass; any other key event
the link posted is still taken. The host test checks both reach stock,
and fails when the release is posted unmarked.

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

# Conflicts:
#	sdk/tests/dn2_link_host.c

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