Skip to content

Improvement: reserve 64 KiB for the Syntakt base - #2454

Open
GSM1980 wants to merge 5 commits into
repeat98:base/syntakt-nextfrom
GSM1980:base/syntakt-64k
Open

GSM1980 wants to merge 5 commits into
repeat98:base/syntakt-nextfrom
GSM1980:base/syntakt-64k

Conversation

@GSM1980

@GSM1980 GSM1980 commented Nov 30, 2026 •

Copy link
Copy Markdown

The Syntakt OS 1.42 development base reserves 64 KiB of MAIN RAM at 0x46000000 through 0x4600ffff. With the native sample builder, 64 full stock slots produce a 30,720,256-byte aggregate that can overwrite this window.

The base copies its resident image before the stock BSS clear. It follows Synfact 2.0.1’s sample streaming design and generates pages on demand for the native MAIN sender. The stock AUDIO parser receives the same sample counts and PCM. Temporary read memory is released after the last mailbox copy.

Authorship and licence

I am GSM1980, the author of Synfact. I am contributing Synfact's resident memory reservation and stock sample streaming design to Modwerk. The implementation in this PR was written for Modwerk and is licensed GPL-3.0-or-later.

How I checked it

  • Built from the official 1.42 file. The build passed five guarded site checks, retained 16,515 bytes of in-place depack margin, and left 62,632 bytes free in the resident window.
  • Ran the patched boot copier, native MAIN sender and native AUDIO sample parser under Unicorn. The test checks both DDR aliases, the page indices, all received bytes, each slot descriptor and the final sender state. The fixture supplies eMMC reads, allocator calls and mailbox delivery. PCM varies within each sample at a period independent of sector and page sizes, so repeated or shifted spans fail the byte comparison.
  • All 99 tests in the Elektron engine passed, including Syntakt and stock-write tests. The app TypeScript check passed.
  • The broader local SDK check hit Windows symlink and DACL restrictions and missing host tools in unrelated SDK tests. The Syntakt firmware build, emulator cases and Elektron engine tests completed separately.
  • I ran npm run pr:ready -- --base-branch base/syntakt-next. The script in this branch still checks upstream/main and stops there. The review follow-up passed the licence, machine metadata, module metadata, documentation, SDK import and PR description checks. The full local run stopped in the catalog suite. The scaffold test passed on rerun after supplying python3, and the Octatrack publication fixture still timed out.
  • Build MWB1, SysEx SHA-256 a4dd78cec2f9671bd006b45f6c4565064637d679cb8ce97f7039fde1668ee0f0.

Tested on a unit: Elektron Syntakt, OS 1.42 base MWB1, SysEx SHA-256 a4dd78cec2f9671bd006b45f6c4565064637d679cb8ce97f7039fde1668ee0f0. On 30 November 2026, I confirmed normal boot and stock operation with empty slots, normal boot and playback of all 64 five-second samples, a successful cold boot, and normal operation after restoring official OS 1.42. USB MIDI confirmed 240,000 frames in every slot and byte-identical PCM in slots 1, 17 and 64. Some generated test tones clicked in an initial pass. The known sample did not reproduce the clicks during the repeat.

Hardware memory retention with reverb and delay

MWT1 is a local diagnostic build derived from MWB1. Its SysEx SHA-256 is cb9546803cdd99e8d664ae1224d5fff6d563790a58eb1085976e77ef9da1daa5. The checker runs from on-chip SRAM and compares all 65,536 bytes of the MAIN reservation.

  1. Before the stock BSS clear, the probe copies the 588 bytes of resident code into SRAM and fills the 62,624-byte aligned spare area with a different 32-bit value at each address. Each word is its address XOR 0xa55a3cc3.
  2. After boot with all 64 stock sample slots full, the first press of the TRIG page button captures the remaining 2,324 bytes of live data and alignment padding. That gives the checker a reference for bytes the base legitimately writes during sample loading.
  3. Play a pattern with delay and reverb sends, stop the sequencer, let the tails decay, and press TRIG again. This compares every word to its reference through the cached DDR window at 0x46000000 and its uncached alias at 0x4e000000. The second check reuses the references from steps 1 and 2.

The contributor reported RUN L0 A0 on the Syntakt. L is the mismatch count for the cached view and A is the count for its uncached alias. Both were zero. The result checks the contents at readback. Writes that changed and restored a word between observations could escape it.

Edge cases

Case Why this change makes it a risk How run Result
64 slots of five seconds The aggregate used to overwrite the base Linked MAIN sender and stock AUDIO parser with a guarded 64 KiB window Pass. 15,001 pages, all 30,720,256 payload bytes and all 64 descriptors verified
Count and PCM split across pages; oversized slot Record framing, padding and validation moved to the base Mixed synthetic slot lengths Pass
Empty stock slots The sender still needs a valid native table and completion 64 empty slots Pass
eMMC PCM read fails A failed read could leak stale scratch data Fail PCM reads for one slot Pass. Affected PCM is zero-filled
Scratch allocation fails The sender still needs valid source memory Return null from the allocator Pass. One empty sample table is sent
Boot and normal stock operation with empty slots The replacement sender must deliver an empty sample table MWB1 on the Syntakt Pass, 30 November 2026. I confirmed normal boot and stock operation
Boot and playback with all 64 stock slots at five seconds The stock aggregate used to overwrite the base at this capacity MWB1 on the Syntakt, USB readback and playback check Pass, 30 November 2026. I confirmed boot and correct playback in every slot. USB MIDI confirmed all 64 lengths and full PCM in slots 1, 17 and 64
Boot after switching the unit off and back on A cold boot reinitialises the base and sample transfer MWB1 on the Syntakt Pass, 30 November 2026. I confirmed a successful cold boot
Restore official Syntakt OS 1.42 The normal firmware restore must work after running the base Install official 1.42 and verify normal operation Pass, 30 November 2026. I restored official 1.42 and confirmed normal operation
Memory retention during playback with delay and reverb tails Runtime or DMA writes could affect the resident MAIN window MWT1 compares every word through both DDR views on a Syntakt Pass, 30 November 2026. The contributor reported RUN L0 A0

What the guides lacked or got wrong

The Syntakt guides pointed to the stack-gap experiment as the path to resident MAIN memory. The base and machine guides now describe the 64 KiB reservation, the stock sample collision and how to build and test the new path locally. The machine guide retains file-by-file authorship and licence review before importing Synfact source and the +Drive persistence qualification before enabling writes.

For cumulative base draft #1922.

@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, this is a careful piece of work. Streaming the stock samples page by page so the full 64-slot set can't overwrite the resident window is the right fix, and the emulator cases cover the failure paths well. I read the boot copier, the four sender sites and stock-samples.c, and I found nothing wrong in the logic. Reads stay within 2,560 bytes of scratch, a slot never goes past its 512 KiB, and a failed read or allocation falls back to silence or an empty table.

Three things before it can go into the Syntakt base draft (#1922):

  1. The unit record for MWB1. This change runs on the instrument, so it needs your own run on the exact build (SysEx SHA-256 a4dd78ce…), following the test procedure. The procedure runner only drives the Octatrack, so do the steps by hand and record what you saw:
    • MWB1 boots and stock works normally with empty slots.
    • With all 64 slots full (five seconds each), it boots, every slot plays the right sample, and the reserved window is unchanged afterwards (a readback over the link is enough).
    • A power cycle and a boot after it.
    • Flashing official OS 1.42 again restores the unit.
      Add these as rows in your edge-case table, with a pass or fail for each and the date.
  2. Keep two lines in sdk/machines/syntakt/README.md. The edit removes the sentence about qualifying +Drive persistence before enabling writes, and the one about reviewing authorship and licence file by file before importing Synfact source. This base doesn't write to the drive yet, so both still apply. Please put them back, next to your new line.
  3. Licence. The new files are GPL-3.0-or-later, and the Synfact manifest says GPL-2.0-or-later. If you wrote this code yourself for Modwerk as Synfact's author, please say so in the description, and that settles it.

Then run npm run pr:ready, push, and mark it ready. Your checks are waiting for a maintainer to start them, and that will happen separately.

@GSM1980
GSM1980 marked this pull request as ready for review November 30, 2026 12:51

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