Skip to content

Machine: Digitone II development link, stage one (read-only diagnostics over USB MIDI) - #1763

Open
prodbysmolec wants to merge 23 commits into
repeat98:base/digitone-ii-nextfrom
prodbysmolec:machine/digitone-ii-link
Open

prodbysmolec wants to merge 23 commits into
repeat98:base/digitone-ii-nextfrom
prodbysmolec:machine/digitone-ii-link

Conversation

@prodbysmolec

@prodbysmolec prodbysmolec commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator
  • What was wrong or hard: Piece 4 of the Digitone II goal: the Digitone II had no USB link, so neither an agent nor the page could read anything from a unit. The recipe says to extend the Rytm's SysEx link rather than design a new one. It changes the Digitone II base's development variant, so it goes to the cumulative base draft Digitone II base (cumulative): the Digitakt II base for OS 1.12 #1767 (base/digitone-ii-next), which already holds Machine: Digitone II base for OS 1.12 (from the Digitakt II base) #1760.
  • What this changes: Stage one, read-only, development bases only (base.json's dev, machine:base --dev, as the Rytm's link): base/link.s observes stock's SysEx router at 0x4012197a (the site core-dn2 0.3's ev_sysex uses; the replaced lea SYSEX_TABLE,a3 is checked by SHA-256 like every site) and passes the message (a1), length (d1) and source (d2) to link.c, then restores every register and lets stock route as before. link.c keeps the link's own messages from USB in a ring and answers them from ev_tick through stock's sysex_send (0x401236d2, port 2), in the Rytm link's wire format: ident (link version, received, dropped, ticks) and mem (up to 128 bytes of DDR or SRAM). No keys, screen, remote YES or RAM boot yet. A host (sdk/machines/digitone-ii/tools/dn2_link.py: ident, mem, and screen, which reads stock's frame pointer and the 128x64 frame through mem and prints it or writes a PNG) with tests of its frames and the screen layout; the link waits a tick while stock's USB MIDI parser is mid-SysEx (0x445090ac); LINK.md, the goal row, the base README and a changelog entry.
  • How I checked it: npm run pr:ready (Ready). On my own stock 1.12 with the reviewed toolchain: npm run machine:base -- digitone-ii --dev builds the development package 7b14964a… (.run 4,712, .bss 3,572 bytes; 15 sites; the codegen check passes); linked with hello-marker-dn2 and verified (sections 2, 4, 5, 7 and 8 byte for byte, the in-place depack, 1.9 MB container under the unit's limit). The release variant is unchanged (7a60d82e…).
  • Tested on a unit: development base 3ef5b3f0 with hello-marker-dn2 (.syx f580bf70; the first build, 7b14964a, before the mid-SysEx wait, too), my Digitone II on OS 1.12, flashed with Transfer: ident answered every request (received counted up, dropped 0, ticks rising), mem 0x47f00000 64 returned the start of the package's .run as built with its relocation filled in, screen showed the unit's screen as it was (pattern A01, UNTITLED, 120.0, the SYN 4 page), and requests out of range came back with status 4 (record). Not tested: a request while other SysEx runs on USB, a request over DIN, long sessions.
    Edge cases
Case Why this change makes it a risk How run Result
Requests answered and counted the link must not drop or miss requests ident repeatedly on the unit pass: received counts every request, dropped 0
Out-of-range reads mem must refuse outside DDR and SRAM and over 128 bytes mem 0x0 16, mem 0x47f00000 200 pass: status 4 both
The screen through mem the frame pointer and layout must be right screen on the unit pass: the screen as shown
A link message from MIDI DIN the link must ignore it not run not run: no DIN sender at the time
A request while other SysEx arrives on USB the wait for stock's parser not run not run: one cable cannot interleave two SysEx
  • What the guides lacked or got wrong, and where I fixed it: LINK.md says what is not ported yet, among it the Rytm's wait while stock is mid-SysEx on USB, whose Digitone II address is not found.

🤖 Generated with Claude Code

prodbysmolec and others added 2 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>
@prodbysmolec
prodbysmolec changed the base branch from main to base/digitone-ii-next November 19, 2026 08:40
prodbysmolec and others added 3 commits November 19, 2026 20:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gitguardian

gitguardian Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

prodbysmolec and others added 2 commits November 19, 2026 20:38
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>
@prodbysmolec
prodbysmolec marked this pull request as draft November 19, 2026 20:07
prodbysmolec and others added 4 commits November 19, 2026 21:13
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>
@prodbysmolec
prodbysmolec marked this pull request as ready for review November 19, 2026 20:19
prodbysmolec and others added 3 commits November 19, 2026 21:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the Digitone II link work. Two things before this can go further:

  1. GitGuardian flagged one possible secret in this pull request. Please open its details, check what it found, and remove it from the commits if it is real. If it is a false positive (for example a test byte pattern), say so here.
  2. Please merge the current main into your branch and run npm run pr:ready until it says Ready, so the pull request shows only your link change. This one belongs on the cumulative base pull request #1767, so the checks will also need to be green after that merge.

See https://github.com/repeat98/modwerk/blob/main/docs/DEVELOPER_WORKFLOW.md#make-it-mergeable for the steps.

@repeat98

Copy link
Copy Markdown
Owner

The screen reader can accept the wrong chunk. In dn2_link.py, requests made within the same tenth of a second reuse the sequence number, and mem() discards the address echoed by the unit. A late reply for the previous chunk can therefore match the current request. A short reply also gets passed on to the screen decoder.

Please advance the sequence per request and check the echoed address and exact decoded length before accepting a chunk. A host test with a delayed previous reply and one with a short reply would cover both cases without a unit.

prodbysmolec and others added 3 commits November 22, 2026 18:08
…m reply only for its address and exact length

A late reply to the previous chunk or a short reply could reach the screen decoder. Host tests cover both without
a unit.

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

Copy link
Copy Markdown
Collaborator Author

Thanks, fixed in 6d07f4c:

  • Every request now takes the next sequence number (a counter seeded from the clock, so two runs in a row start apart).
  • mem() accepts a reply only if it echoes the requested address and carries exactly the packed length of the requested bytes (link.c's pack(): n + ceil(n/7)). Anything else is skipped, and if no fitting reply arrives the read fails, so screen never decodes a short chunk.
  • Host tests in sdk/tests/test_dn2_link.py (no unit needed): a late reply for the previous chunk ahead of the real one, a reply with the previous sequence number, a short reply (both exchange and screen), a refusal, and the packed length.

GitGuardian: false positive. It flags src/community/agent-sessions.test.ts in 19be13a, the scrubber test's made-up tokens from main. It only showed up because the branch was behind. Merged upstream/base/digitone-ii-next and upstream/main; npm run pr:ready says Ready.

@repeat98

Copy link
Copy Markdown
Owner

The host tests cover reply ordering and length. One device-side issue remains. A USB client can ask for bytes at an address it chooses anywhere in the supported RAM regions. That gives a client access to unrelated instrument state when it asks for a screen capture.

Could you expose the screen and link counters as bounded diagnostic operations, with the device selecting the data each operation returns? Please cover refusal of reads outside those diagnostic buffers. The panel and log PRs can then build on that narrower interface.

prodbysmolec and others added 4 commits November 25, 2026 11:22
…chine/digitone-ii-link

# Conflicts:
#	sdk/machines/digitone-ii/GOAL.md
…screen), no read at a client's address

mem (0x21) is gone. screen OFF (0x20) copies the frame on the screen at OFF 0 and sends
eight 128-byte parts of that copy with its number, after checking stock's frame pointer
lies wholly in DDR. A host C test compiles link.c and covers both requests and every
refusal: offsets past or between parts, a part before any copy, a pointer outside DDR,
the old mem at any address, every other command and another link version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n command, eight parts of one copy

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

Copy link
Copy Markdown
Collaborator Author

What changed: the unit now chooses what each request returns. mem (0x21) is gone. A USB client gets the link's counters (ident) and the screen (screen), and nothing else of the instrument's state. Not run on a unit yet: the Digitone wasn't on USB today. I'll run it and add the record before asking for the merge.

  • screen OFF (0x20), as the Rytm link's but in 128-byte parts. screen 0 makes the unit read stock's frame pointer itself, check that the 1,024 bytes lie wholly in DDR, and copy the frame. screen 128 … screen 896 send the rest of that copy. Every reply carries the offset and the copy's number, so the eight parts are one frame even if stock draws in between (no tearing any more), and the host refuses a part from another copy.
  • Refusals, all with nothing but the status:
    • status 4: an offset past the frame or between parts; a part before any screen 0; a frame pointer outside DDR (never read);
    • status 2: the old mem at any address, every other command, and another link version.
  • Host C test sdk/tests/dn2_link_host.c (run by test_dn2_link.py): it compiles link.c with sysex_send, the parser state and the frame pointers stubbed, and checks both requests and every refusal above. That includes a draw between the parts (the frame still comes back whole), a pointer 1 byte short of fitting, and the old mem aimed at the test frame, at 0x40000000, 0x47f00000, SRAM and the frame pointers. Against a link.c that takes offsets between parts, or that skips the DDR check, it fails.
  • Host side: dn2_link.py and the site's client (dn2-link.ts, screen()) use screen and check offset, copy and length. mem and diag stay in the site's client only for Machine: Digitone II diagnostics log, the Octatrack's layout, over the development link #1820's log read; that PR moves the log to a bounded operation of its own on this interface.
  • Merged main and base/digitone-ii-next. The dev base builds (15 sites, .run 4,820 bytes); test_dn2_link.py 14 of 14, dn2-link.test.ts 13 of 13, and npm run check passes up to the board step. That step reports claims of Digitone II base (cumulative): the Digitakt II base for OS 1.12 #1767 or of main's mackity depending on the base it compares with, because base/digitone-ii-next is behind main; this PR adds no module, hook or migration.

Guides: LINK.md (requests, refusals, "the unit chooses"), the goal row, and the SDK guide's line on the link.

prodbysmolec added a commit to prodbysmolec/modwerk that referenced this pull request Nov 25, 2026
… key link

link.c keeps the keys and turns and takes repeat98#1763's screen in place of mem; one host fixture covers both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prodbysmolec added a commit to prodbysmolec/modwerk that referenced this pull request Nov 25, 2026
…omes in parts the unit reads itself (log OFF)

mem is gone, so link.c answers log OFF (0x24) with up to 128 bytes of diag.c's log and its seq; dn2_link.py diag --save
and the site's readLog read part 0, the rest, then part 0 again, and keep only a log that stood still.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prodbysmolec added a commit to prodbysmolec/modwerk that referenced this pull request Nov 25, 2026
…t: bootdiag gets its own request

With mem gone, bootdiag (0x25) sends the gate's 15 words and the two marks the base itself writes; the host reads them
with one request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prodbysmolec added a commit to prodbysmolec/modwerk that referenced this pull request Nov 25, 2026
…nto the loader: ident sends the modules' test value itself

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

Copy link
Copy Markdown
Collaborator Author

To let you review the whole interface in one place: the later PRs now build on it. Each was merged down the stack and pushed, and none of them reads memory at an address a client names.

Request cmd PR The unit sends
ident 0x01 #1763 (#1842 adds the loader's words) the link's counters; the loader's test value itself, not its address
screen OFF 0x20 #1763 eight 128-byte parts of one copy of the frame
diag 0x22 #1820 the log's size, frames, ticks
log OFF 0x24 #1820 up to 128 bytes of diag.c's log from OFF, with its seq; offsets past it or between parts are refused
bootdiag 0x25 #1821 the RAM boot gate's 15 words and the two marks the base writes

The site's client (dn2-link.ts) follows it: readLog reads the log in parts and keeps it only when it stood still, and each part takes its own turn, as in #1846.

@repeat98

Copy link
Copy Markdown
Owner

Thanks, this is the interface I asked for: ident and screen with the unit choosing the bytes, mem refused with status 2, and the refusals in dn2_link_host.c.

Two things before this goes into base/digitone-ii-next:

  1. A unit run on this head. The record covers builds 7b14964a… and 3ef5b3f0… from 19 November, which still read the screen through mem. Please flash this head's dev package and add its SHA-256 to the record, with:
  2. The description. It still says the link answers mem with up to 128 bytes of DDR or SRAM and that screen reads through mem, and the edge-case table's out-of-range row is about mem. Please update it to the bounded requests and add rows for the refusals above.

@repeat98

Copy link
Copy Markdown
Owner

One more thing, and this one is on me: I just merged main into base/digitone-ii-next (1816db92c), so your diffs here stop showing main's files. It brought main's shared Elektron link wire (src/engine/elektron/link-wire.ts, which dn2-link.ts now imports from), so the stack conflicts with the base branch in one place: the top of dn2-link.ts. Please keep the base branch's export { … } from './link-wire.ts' line and your LINK_COMMANDS with screen, and drop the local LINK_HEADER, which link-wire.ts now provides. Merge base/digitone-ii-next into #1763 (merge, don't rebase), then carry it up through #1817, #1820, #1821 and #1842. #2003 needs the same merge; its only conflict is its row in docs/MACHINE_RECIPE.md, where the base branch's Digitone II row is the current one.

…chine/digitone-ii-link

# Conflicts:
#	src/engine/elektron/dn2-link.ts
@repeat98

Copy link
Copy Markdown
Owner

Thanks for the merge. dn2-link.ts is resolved the way I asked.

One more thing for this PR: the site's client still has the old mem. The unit now refuses 0x21 with status 2, but src/engine/elektron/dn2-link.ts still lists mem: 0x21 in LINK_COMMANDS and exports MEM_MAX and mem(). dn2-link.test.ts (lines 53–66 and 97) also still tests a simulated unit that answers mem. Please remove all three and test mem's refusal instead, so the client and link.c describe the same interface.

The unit run on the top head and the description update from my last comment are still open. After that, please carry the base merge up through #1820, #1821, #1842 and #2003.

For you: I pushed 0c515f096 to base/digitone-ii-next. It fixes a lint error my merge of main introduced in MachinePages.tsx. Merge it in with the next round. It doesn't touch your files.

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>
@repeat98

Copy link
Copy Markdown
Owner

Where the stack stands: the code review points on #1763, #1817, #1820, #1821 and #1842 are all answered now. Thanks for the quick round this morning. What's left is the unit session and the descriptions. The checklist below gathers every case my comments asked for, so one sitting covers the whole stack, plus #2003 and #1819.

I pushed to two of your branches. Please pull before you work on them:

My mem and UPLOAD_BASE commits lost the race to yours, so nothing changed there. The base branch also has 0c515f096, a lint fix for my own merge. It comes along with your next base merge.

Next step (yours, on the unit): the session below. Then put its record, with the package's SHA-256, on each PR, refresh the descriptions, and mark them ready. I merge them down in order: #1763 → #1817 → #1820 → #1821, then #1842.

One unit session: the checklist

A. The dev package of #1842's head. It carries #1763, #1817, #1820 and #1821. Note its SHA-256 first.

For the refusals, the CLI has no raw request, so send one through the tool's own ask (it prints the status):

python3 -c "import sys; sys.path.insert(0,'sdk/machines/digitone-ii/tools'); import dn2_link as d; d.CMD['mem']=0x21; print(d.ask(*sys.argv[1:2], *map(int, sys.argv[2:]))[2])" <cmd> <values…>

#1763, the link:

  • Right after boot, before any screen: screen 128 → status 4
  • ident answers; screen --png reads a whole frame (eight parts, one copy number)
  • mem 1207959552 16 (the old 0x21) → status 2
  • screen 64 (not a multiple of 128) → status 4

#1817, keys:

  • hold a key, then disarm: stock gets the release once
  • After an OS upload completes: press YES and a turn from the link → both status 6, and UPGRADE OS NOW? still waits
  • Your own YES and NO at the prompt while the link holds a key: both reach stock
  • The link holds YES while an upload completes, then let YES: does the prompt stay open? If stock acts on the release, the link must hold that release back too

#1820, diagnostics:

  • diag --save log.bin, then parseDeviceLog reads the file
  • freeze 3 right after you press a key → status 5; again after about 3 s → accepted
  • log past the log's end and log 64 (between parts) → status 4

#1821, RAM boot:

  • ramboot <image> boots from RAM (ident boot 1 with the image's CRC); bootdiag reads through 0x25
  • ramboot with a CRC that doesn't match the staged upload → status 7, and UPGRADE OS NOW? still waits for a person
  • How long the unit stands still while the CRC runs over a full-size image, and whether the sound keeps going
  • Several RAM boots in a row (or mark that row as open in the table, the record and "Not tested")

#1842, loader:

  • Trial, Keep, removal, and the refusal while playing
  • try --base <this build's .identity> accepted; .identity of another build refused

B. #2003, Voice Spread, on the plain base (no link, as the page builds it)

  • The pinned package 9ce8ff19…; note the image's SHA-256
  • VOICE SPREAD 75 + FILTER SPREAD LOW, save, power-cycle: both come back. A project saved without the module: both read OFF
  • Listening, in your own words: chords at 100, then OFF; FILTER SPREAD HIGH; a mono track (bass or kick) with the spread on
  • One pan lock and one LFO on filter frequency with the spread on

C. #1819, installing from the page

  • A send from this head's page build, answered with YES, then one with NO; the image's SHA-256 in the record

@repeat98

Copy link
Copy Markdown
Owner

Where the stack stands: the code points from my last round are answered. Holding back the link's key events at UPGRADE OS NOW? (#1817) and letting only ramboot's own marked YES through (#1821) are what the prompt needs, and it's good you caught the release case on the unit. What's left is the unit session and the descriptions, then I merge the five down in order.

Three additions to the unit session:

  1. Machine: Digitone II development link, stage two (panel keys and encoders over USB MIDI) #1817's commit says stock started a flash when the link released a held YES at the prompt. That's a unit result, so please put it in Machine: Digitone II development link, stage two (panel keys and encoders over USB MIDI) #1817's record with the build it ran on, and update the row "A remote YES at UPGRADE OS NOW?", which still says the release is allowed.
  2. ramboot's YES now reaches stock a different way (both events are marked, instead of the press being taken and the release passing). Please show on the top head that one ramboot still boots from RAM, and that hold YES, a completed upload, then release leaves the prompt waiting.
  3. Machine: Digitone II RAM boot over the development link (piece 5, stage one) #1821's row "A cancelled request, a failing check" hasn't run yet. Since ramboot answers the prompt itself, please run one ramboot whose gate check fails: it should boot the flashed OS and leave the flash alone.

The rest stands as before: one session on #1842's head cfc60fb5d, with the package's SHA-256 on each PR, and the descriptions brought up to date (the mem rows here, #1820's missing freeze/log rows, #1821's repeated-RAM-boots row). Then mark them ready.

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