Skip to content

Machine: Digitone II reboot over the development link (stock saves its working state first) - #2685

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

prodbysmolec wants to merge 143 commits into
repeat98:base/digitone-ii-nextfrom
prodbysmolec:machine/digitone-ii-reboot

Conversation

@prodbysmolec

Copy link
Copy Markdown
Collaborator

Digitone II: a reboot request for the development link. Builds on #1842 (the runtime loader), and through it on #1763, #1817, #1820 and #1821: this branch starts at #1842's head 3b2da45e4 until those merge into base/digitone-ii-next, then I merge that branch here so the diff holds only the reboot.

What works: on the host, everything (C host test and Python tests). What is open: it has not run on a unit yet; Lukas's session RAM-boots the test image next. Musically: an agent can restart the unit itself after a test, and the unsaved project state comes back as after a power cycle, so nobody has to reach for the power switch between runs.

  • What was wrong or hard: An agent driving a Digitone II over the link could not end a RAM boot or a loader session itself: only a person's power cycle brings the flashed OS back, and the power cycle is also what makes stock write its working state (the project as it stands, unsaved changes included) to the eMMC. A plain reset skips that write, so unsaved changes would be lost.
  • What this changes:
    • sdk/machines/digitone-ii/elekloader/base/link.c: reboot (0x15, the next id the Rytm link's format leaves free; the Rytm's 0x13 stays unused). Armed only (1), refused at UPGRADE OS NOW? (6), with a person at the unit (5), while the sequencer plays (new status 8, the loader's "unsafe" check), and while a RAM boot is asked for, an upload or trial is open, or stock's working-state header is mid-change (3). Taken, it answers with the bank stock will write. Four UI ticks later the UI tick checks the same again, calls stock's own working-state write (0x400f1f8a, the one stock's OS upgrade job calls before it erases the flash), then ends as the RAM boot's reset does (interrupts masked, stock's drain, data cache out and off, reset) with a mailbox MWBR. The gate sees it and ident's boot field reads 9 (a link reboot); bootdiag's marks say how far it came.
    • base.json: the three OS 1.12 addresses (STATE_AT, STATE_BANK_AT, STATE_WRITE_AT) and the description.
    • tools/dn2_link.py reboot: reads ident, sends reboot, then waits for an answer whose tick count is lower than before (the new run), and prints how long it took and the boot field. Success only for boot 9. bootdiag names a reboot's marks.
    • LINK.md: the request, status 8, boot status 9, "Where it runs" and a Reboot section with what was read in OS 1.12's code. Changelog entry.
  • How I checked it: npm run check -- --base upstream/base/digitone-ii-next (all green but the known unrelated src/community/usage-machine-migration.test.ts, a SQLite usage-table test this change does not touch). npm run board -- check: nothing needs a claim (no new hook or site: the reboot calls stock, patches nothing). sdk/tests/test_dn2_link.py (41 tests, all pass), with new tests:
    • dn2_link_host.c (link.c compiled for the host, stock stubbed): each refusal (not armed, the prompt, a person, playing, a RAM boot asked for, a trial open, the header mid-change), each with nothing written; the order answer, write, reset ("AWR"), nothing before the fourth tick; a change between the answer and the write (play, the prompt, a person, a disarm) cancels with nothing written; a header mid-change is waited for, then written, or given up after about a second; the gate's boot 9 after a software reset and ident reporting it, boot 2 without one.
    • test_dn2_link.py: the old run still answering is not taken for the restart; boot 0, 2 or a short reply after a restart fail; no restart fails and points at bootdiag; every refusal's text; every status and boot status in link.c has the host's text.
    • Two existing assertions changed, both lists of the link's commands: dn2_link_host.c sends every command the link does not have and expects status 2, so CMD_REBOOT joins the list it skips; test_there_is_no_request_for_an_address lists the host's commands, now with reboot (it names no address).
    • The built base: the compiled reboot_go checked in the package (jsr 0x400f1f8a, then the mask, the drain, the mailbox, the reset).

Tested on a unit: not yet. The test image for it, built from this branch: development package 457c4899c8b05a7dc05594006eb9d6ca396752117072ca3d8e5f2742e68fd48c (HELLO base f3688a7f…), built at 95148a3a1, linked with Voice Spread 0.1.0 by elekloader 0.11.0's patcher: .syx e16f8c7de92d9016c9c15b98a40ab7f07398d0794f730ec8d221399283367468.

What was read in OS 1.12's code (static, not yet seen on a unit)
  • 0x400f1f8a: when the bank to write (0x40296048) is 0 or 1, writes the 0xc4b114-byte block from 0x405ce85c to that bank's sector (table 0x401ffb08: 0x40000, 0x48000) through 0x400f1820, then reads the other bank's (0x4029604c) first sector, clears its first byte, writes it back, sets the bank to -1 and returns. Its only caller is the OS upgrade job (0x401091a4), right before the flash routine.
  • 0x400f1820 / 0x400f17ce go through stock's eMMC driver (0x4012ca60 / 0x4012c87a), which takes a mutex (0x4667bd00) and a bus mutex (0x446244b8), pushes the source's cache lines and waits on semaphores the transfer's interrupts signal: a task with interrupts on.
  • 0x400f19b4, the power-fail handler (registered at boot through 0x40001ce0), writes the same block by programming the eSDHC and the eDMA itself, polling, without the driver, then resets or returns depending on 0x40287a6c. Not called: it would take the controller from under the driver.
  • The block's header: COKi, then a checksum over the header only (0x400bb4b0), checked at boot (0x400bb5e8). Code that writes into the block (0x400bb67e) clears COKi while it copies and sets it again after, hence the header check before the write.
  • Boot (0x400cf102 → 0x400f2168) reads the header at 0x40000, else 0x48000, keeps that bank in 0x4029604c and reads the block; the UI task's start (0x4002f170 → 0x400f2008) points the bank to write at the other one.

Edge cases

Case Why this change makes it a risk How run Result
A reboot with unsaved changes the point: they must come back as after a power cycle not run: on the unit next not run: on the unit next
A reboot after a RAM boot the flashed base must come back, boot 9 not run: on the unit next not run: on the unit next
A reboot with a loader trial kept RAM modules must go, as at a power cycle not run: on the unit next not run: on the unit next
A reboot while the sequencer plays the write must never run under playback host test (refused 8, nothing written); not run: on the unit next pass on the host; not run: on the unit next
A reboot at UPGRADE OS NOW? a reset there must not touch a staged OS host test (refused 6) pass on the host; not run: on the unit next
Play started between the answer and the write the check at the request is not enough host test (cancelled, mark 8, nothing written) pass on the host; not run: on the unit next
The header mid-change at the write a cleared COKi written out leaves neither bank valid host test (waited for, then written; given up after about a second) pass on the host; not run: on the unit next
How long the UI stands still during the write the UI task blocks on the eMMC driver; FREEZE logs at 5 s not run: on the unit next not run: on the unit next
The answer reaching the host before the reset the host must know it was taken host test (order AWR); not run: on the unit next pass on the host; not run: on the unit next
A power cycle after a reboot the next start must read the bank the reboot wrote not run: on the unit next not run: on the unit next
  • What the guides lacked or got wrong, and where I fixed it: Nothing documented where stock keeps its working state or how it saves it; now in LINK.md's Reboot section, beside the request.

🤖 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 30 commits December 5, 2026 03:13
The 19 November records come from builds that still read through mem
(review on repeat98#1763, 1 December).

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

# Conflicts:
#	sdk/machines/digitone-ii/GOAL.md
…ii-ramboot

# Conflicts:
#	sdk/machines/digitone-ii/GOAL.md
…oader

# Conflicts:
#	sdk/machines/digitone-ii/GOAL.md
…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>
…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>
…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>
A development base's link takes `reboot` (0x15): armed, stopped, no UPGRADE OS NOW?,
no person, no RAM boot or loader session open, and stock's working-state header whole.
It answers with the bank stock writes; four UI ticks later the UI tick checks again,
calls stock's own working-state write (0x400f1f8a, the one its OS upgrade job calls
before erasing the flash) and resets as the RAM boot does, with a mailbox the gate
reports as boot 9. dn2_link.py reboot waits for the new run and prints the boot field.

Host tests for the refusals, the order (answer, write, reset), cancellation between
the answer and the write, and the gate. LINK.md: the request, status 8, boot status 9
and what was read in OS 1.12's code. Not yet run on a unit.

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.

1 participant