Skip to content

Improvement: send an Elektron OS upgrade over USB MIDI from the site's engine - #1762

Merged
repeat98 merged 6 commits into
repeat98:mainfrom
prodbysmolec:improve/elektron-os-upgrade-midi
Nov 23, 2026
Merged

repeat98 merged 6 commits into
repeat98:mainfrom
prodbysmolec:improve/elektron-os-upgrade-midi

Conversation

@prodbysmolec

@prodbysmolec prodbysmolec commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator
  • What was wrong or hard: The recipe says every Elektron machine is flashable from the site "by the stock OS upgrade over USB MIDI", but the site's engine had no sender for it: only Modwerk's Rytm link (Python) speaks Elektron's USB upgrade protocol. Piece 3 of the Digitone II goal needs it in the browser, and it is the same for every Elektron machine.
  • What this changes: src/engine/elektron/os-upgrade.ts: the protocol as the stock OS takes it from Transfer (and as elektroid sends it): a start (0x50) with the .syx file's size, then the file in 2 KiB writes (0x51), each with zlib's crc32 seeded with 0xffffffff, each answered before the next goes; it stops with a plain message on any refusal, missing answer or early "done", and resolves only when the last block is answered "done", when the unit asks UPGRADE OS NOW? and only YES on the unit erases the flash. Transport-free (UpgradeLine). os-upgrade-midi.ts: the Web MIDI line, the unit's ports by name and its SysEx joined across events. No page uses it yet; that comes with the machine page's flashing step. Tests pin the messages byte for byte to rytm_link.py's ek_upgrade_messages on synthetic files, check the 7-bit packing, the CRC, every refusal path against a simulated unit, and the MIDI line. A changelog entry.
  • How I checked it: npm run pr:ready (Ready); the tests above. The Rytm link sends these exact messages to units today (rytm_link.py flash).
  • Tested on a unit: stock OS 1.12 (7e5b8a73) sent to my Digitone II over USB with these exact messages by a host script (rytm_link.py's ek_upgrade_messages, which the tests pin os-upgrade.ts to): all 1,168 writes answered in 7.7 s, the unit asked UPGRADE OS NOW?, and it installed and works (record). The TypeScript sender and its Web MIDI line did not run on a unit; no page calls them yet.
    Edge cases
Case Why this change makes it a risk How run Result
A stock upgrade over USB, answered message by message every write must be acknowledged before the next the host script with the same messages, on a Digitone II pass: 1,168 writes in 7.7 s, YES on the unit, it installed
An image over the unit's update limit the unit stops answering near the end the page's first sends of an unpacked build (#1819's record) pass: the sender stopped and said the unit stays on its OS
NO at UPGRADE OS NOW? the page must report a refused install not run not run: not tried yet
An upgrade over MIDI DIN the sender is for USB not run not run: out of scope
  • What the guides lacked or got wrong, and where I fixed it: nothing: the recipe already names this route; the module says where the protocol comes from.

🤖 Generated with Claude Code

os-upgrade.ts sends a .syx as the stock OS takes it from Transfer (start 0x50, then 2 KiB writes 0x51 with
zlib's crc32 seeded with 0xffffffff), waits for each answer and stops on any refusal; the unit asks UPGRADE OS NOW?
after the last block, and only YES there erases the flash. A test pins the messages to Modwerk's Rytm link, which
sends this protocol to units today. os-upgrade-midi.ts is the Web MIDI line: the unit's ports by name and its SysEx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 19, 2026
@repeat98

Copy link
Copy Markdown
Owner

Thanks, this is a clean port of the Rytm link's sender, and pinning the messages to rytm_link.py's output is exactly what I'd want. Two small things before the unit run, both about not keeping a second copy of code the site already has:

  • pack7 is the same 8-in-7 encoding as encode8in7 in src/engine/elektron/codec/transport.ts. Please use that one.
  • MidiPort, MidiIn, MidiOut and MidiAccessLike are copied from src/engine/zoom/zoom-link.ts. Please import them from there, or move them into a small shared file that both links import, so there is one definition.

Merge main in when you push. It can stay a draft until your Digitone II has answered it (UPGRADE OS NOW?, and NO leaves the OS as it was), as you planned.

@repeat98

Copy link
Copy Markdown
Owner

I checked the port selector with a single mocked pair named Elektron Digitone II. Calling findUnit(access, 'Digitone') selected that pair. A musician asking to send an OS to the original Digitone could therefore be offered the Digitone II as the destination.

Please distinguish the model names while allowing normal port-name prefixes and suffixes, and cover the original and II models both alone and connected together. The older red scope job stopped before running the sender tests because it couldn't fetch its base commit. A refresh from main will pick up the checkout fix.

prodbysmolec and others added 2 commits November 22, 2026 19:10
…k MIDI types; tell Digitone from Digitone II

pack7 was a second copy of encode8in7 (codec/transport.ts): the messages use that one now. The MIDI port types come
from zoom-link.ts. findUnit matched 'Digitone' to a Digitone II's ports; a model name now matches as whole words,
with the system's prefixes and suffixes, but not when a word naming another model follows (II, MKII, Keys). Tests
cover the original and the II alone and connected together.

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

Copy link
Copy Markdown
Collaborator Author

Thanks, all three done:

  • pack7 is gone; the messages use encode8in7 from codec/transport.ts (the same encoding, and the test pinned to rytm_link.py's output still passes byte for byte). unpack7 stays as the decoder, since the site has no shared one yet.
  • MidiPort, MidiIn and MidiOut are imported from zoom-link.ts; MidiAccessLike is the Zoom link's type without its onstatechange (Pick<…, 'inputs' | 'outputs'>), so there is one definition.
  • Digitone vs Digitone II: findUnit matches the model name as whole words. Prefixes and suffixes the system adds (Elektron …, … MIDI 1, Windows' 2- …) are fine, but not a following word that names another model (II, MKII, Keys). Tests cover the original alone, the II alone and both connected together, each asked for by both names.

Merged main (picks up the checkout fix for the scope job); pr:ready Ready. It stays a draft until my Digitone II has answered it on a unit (UPGRADE OS NOW?, and NO leaves the OS).

@repeat98 repeat98 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Name matching and the shared types look right. Thanks!

@repeat98
repeat98 merged commit 9ab3511 into repeat98:main Nov 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants