Repository navigation
More RAM for the mods: 0026 / 0029's large buffers in DDR claims outside elekloader's area (big-ram) - #34
More RAM for the mods: 0026 / 0029's large buffers in DDR claims outside elekloader's area (big-ram)#34twwwy wants to merge 4 commits into
Conversation
A mod may keep a large zero-initialised buffer outside elekloader's 128 KB area, at a fixed DDR address the OS never uses. elekloader's boot copier only copies and zeroes its own area, and an absolute address is never checked by it, so this needs nothing from core 0.1 or the web page. It fits the registry's pool scheme, as the caves do: a [[pool]] with its evidence in its note, and claims in it. - registry: pool ddr_mods 0x47C00000-0x47C40000 (256 KB, just above elekloader's area), os = "1.74", status verified. Its note gives the free ranges (0x47B48000-0x47BE0000, 0x47C00000-0x47FF0000; the top 64 KB is left to the stack) and the evidence: no instruction operand of 1.74 names 0x47B48000-0x47FFF000 in either alias, Modwerk's and elekloader's DDR canaries, rytm-emu runs, and one MKII's hardware run. 1.73 has no DDR pool yet. - layout.py: [[ddr]] claims are checked like caves (inside a pool, no overlaps: POOL_OF["ddr"]), plus their own rules: named, 16-aligned, at least 32 B; a DDR pool names its OS and lies outside the image and outside elekloader's area. A pool with an `os` holds claims for that OS only: on another OS they are inactive. - build.py: each enabled mod gets RAM_<NAME> and RAM_<NAME>_SIZE for its claims in this OS's pool as assembler symbols (defsym / .set, as its params), and the manifest records them. A mod whose claims are in another OS's pool gets none (its stub then keeps the buffers in elekloader's area). - verify.py: the manifest's claims are the registry's for this OS, each outside the area, inside this OS's DDR pool, and disjoint. - ostarget.py: a DDR pool is not an image address: the port passes it through unmapped. - tests: test_layout.py Ddr (9 cases), test_ostarget.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a (big-ram)
On OS 1.74 the remote page's frame buffers, the source-list names and
the param modulation (0026), and 0029's labels and lists, move out of
elekloader's 128 KB area into four claims in the registry's ddr_mods
pool: rui_frame 0x47C00000 (0x3200), rui_names 0x47C03200 (0x1000),
rui_pmo 0x47C04200 (0x2800), sfu_x 0x47C06A00 (0x2000): 35,328 B of the
pool's 256 KB.
Cost, the Makefile's release set on 1.74: code +3,352 B (0026 +2,118,
0029 +1,234), area .bss -33,178 B (0026 30,564 -> 4,064, 0029 6,706 ->
28). The area's spare goes from 13,432 to 43,264 B.
- Nothing zeroes that RAM. In 0026's first three ticks (a claim a tick)
and in 0029's first tick, before anything that reads them is
published, each claim is zeroed and gets 8-byte sentinels at both
ends ('RAMS' ^ address). A bit a claim (ram_ok / x_ok) says it's good;
until then nothing reads it.
- Every tick the sentinels are checked. A changed one turns that claim
off for the rest of the boot, and the mod falls back to what is safe
without it: no param modulation (the sound is stock's), no frame (the
remote page leaves with reason 4), the source names as numbers, our
SEND FX records read-only (never stock's own write of FX 38..41), the
value texts as numbers, the host's messages for it dropped.
- The Rytm reports it to the host once and again with each hello,
55 01 00 <claims> <address 5x7> <word 5x7>, and shows MOD RAM ERROR
over the stock screen for 5 s (and on TRK + YES). An older host
ignores 0x55.
- pmo's guard is in its two detours (and.l ram_ok), not in the C
functions, so the audio interrupt's hot path keeps gcc's code.
- ddrdiag=1 (a param, off in releases): the diagnostic image fills the
rest of 1.74's free DDR with address ^ 0xC0DEF00D, checks 512 B of it
a tick (a pass in ~7.5 min), reports it every 10 s (55 01 01) and
shows "DDR <passes> BAD <n>" while FUNC is held.
- On an OS without a DDR pool (1.73) each stub keeps the same block in
its own .bss (.ifndef RAM_<NAME>), set up and checked the same way;
ddrdiag refuses to assemble there. That build costs 3,544 B of the
area (the code and the sentinels) and frees nothing: 9,888 B spare
with the release set, measured on a 1.74 tree with the pool marked
for another OS.
Each stub refuses to assemble when its claim is smaller than its struct
+ 16. Design notes: 0026 design.md "big-ram", 0029 section 12.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ram_emu.py TAG sealed | frame | pmo | names | sfux | diag:
- sealed: the build keeps 0026 / 0029's buffers in the four DDR
claims outside elekloader's area (fails on a build without them),
each zeroed and sealed after boot (ram_ok 7, x_ok 1);
- one sentinel changed per test: only that claim turns off, the
report goes out, the mod falls back (the page leaves with reason 4
and won't reopen, the modulation's interrupt entries stop, the
source names stop, SEND FX turns are refused with FX 38..41
unchanged), no fault and no strict access;
- diag, on a ddrdiag=1 build: a changed canary word is found, written
back and reported.
- suites.py: the ram suite.
- pm_emu cost: the worst-case bound 105 us, not 100. Its 96-route-amount
case reads 94.2 or 103.6 us depending only on the boot's phase (which
block a burst of records lands in), with the code before big-ram as
well (0026 design.md, big-ram "pm's worst case"). The other bounds
stay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vention
A provenance check of the big-ram series: its first DDR prototype was
written after another project's linker change had been looked at (a
different approach, which this series does not take: no linker or
loader change). The cap words ('RAMS' ^ address) and the clearing loops
date from after that, so they are rewritten from this tree's own design:
- caps: the two first and two last words of a claim are each their own
address ^ 0xC0DEF00D, 0003's canary convention (this registry's cave
canary since 2026-09, and the diagnostic image's fill);
- 0026: claim_open (clear with an end pointer, then the four caps) and
claim_cap_bad (the first cap that does not hold); 0029: x_init /
x_cap_bad, the same.
Same claims, addresses and sizes; the same checks, reports and
fallbacks. ram_emu sealed expects the new caps; ram 24 / 0, and 28 / 0
on a ddrdiag=1 build (diag included). Code -66 B (0026 -52, 0029 -14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Licence check: I traced this series' history for anything taken from Modwerk (GPL-3.0 / Elastic-2.0). Modwerk appears only as a source of facts about the Rytm: its README reports the same DDR ranges intact on one RAM-booted MKII, and that is cited in the pool's note next to our own evidence (an operand scan of the 1.74 image, emulator canaries, and a flashed hardware run). No Modwerk code is used. Our design is fixed registry claims with no linker or loader change, the opposite of Modwerk's approach. One part, the claims' boundary words and clearing loops, was first written after Modwerk's linker change had been looked at. To be safe I rewrote it from this repo's own canary convention (address ^ 0xC0DEF00D, as the cave canary 0003 uses), in 2c25894; the claims, addresses and behaviour are unchanged, and the ram suite passes. The full suites and the lag gate are rerunning on 2c25894; I'll post them here. The lag result is likely found: the pmo guard's load of 🤖 Generated with Claude Code |
|
Thanks a lot for this, @twwwy. The measurements and the static operand scan are careful work, and the placement itself holds up: the pool at 0x47C00000 is clear of the sample memory, the block the OS clears at boot, the stack and every OS operand we could find on 1.74. We found no copied third-party code. We can't merge it as it is, for four reasons:
Smaller points:
What we did with it: we need this room for the next mods build, so we built a reshaped version on our side, credited "based on twwwy's #34":
That frees about 23 KB of the area. It will be in the next mods release. So please don't spend more time on this branch; we'll close it when that release is out. Your notes made it possible, thank you. Before we close it, one check, as AGENTS.md asks: did you use only Modwerk's README (the canary ranges and timings), and not its code? |
|
Yes for the code: no Modwerk code is in #34. From Modwerk I used only facts from its README: the free ranges, and the RAM-booted run's outcome. To be complete: on 2026-11-20, while investigating, our agents also looked at Modwerk's linker change and a few of its source files. That was before this branch existed, in a separate comparison. We took a different approach, fixed registry claims with no linker change. The two parts first written after that look, the claims' boundary words and their clearing loops, I rewrote from this repo's own canary convention in 2c25894 to be safe. That is the audit I described in my comment above. From now on our agents don't read Modwerk's source at all. Thanks for building the reshaped version. Your four points make sense, and keeping pmo in 🤖 Generated with Claude Code |
Closes #32. The host half is trigcondition/sidecar-firmware#73. Apply #33 first.
Why
With the full mod set, elekloader's 128 KiB area is nearly full, and MORPH, the re-hello and the later topics need room. This moves 0026's and 0029's large buffers out of it, into free DDR, claimed in the registry.
The method
Free DDR on stock 1.74.
0x47C00000-0x47C40000:0x47B47480.bigarea canary agree.Registry (
registry/allocations.toml).[[pool]],ddr_mods, at0x47C00000-0x47C40000(256 KB). It names its OS (os = "1.74"), and the evidence is in its note, in the cave pools' style.[[ddr]]tables, a claim kind beside cave / ram.layout.pychecks them as it checks caves (inside a pool, no overlaps), plus: named, 16-aligned, at least 32 B. A DDR pool must lie outside the image and elekloader's area, and holds claims for its own OS only.build.pygives each enabled modRAM_<NAME>/RAM_<NAME>_SIZE.verify.pychecks the manifest's claims again.Nobody zeroes DDR, so each mod does.
rui_emu cost's bound. 0029 zeroes its claim in its first tick.Checked every tick.
55 01 00 <bad bits> <address 5x7> <word 5x7>, sent again with each hello.0x55.The diagnostic (
--param 0026-remote-ui:ddrdiag=1): fills the free DDR around the pool with an address-keyed pattern, checks 128 words a tick (DG_STEP), and reports55 01 01every 10 s. FUNC held showsDDR <passes> BAD <n>.OS 1.73. I have no 1.73 image, so there's no static check and no build. 1.73 has no DDR pool, so
build.pygives noRAM_symbols. Each stub then keeps the same block in its own.bss(.ifndef RAM_<NAME>), set up and checked by the same code, andddrdiag=1refuses to assemble. I checked this on a 1.74 tree with the pool marked for another OS: it builds, verify passes, and the build notes "buffers stay in elekloader's area". Adding 1.73 later is a pool withos = "1.73", its evidence and the claims.Cost (
tools/build_rui.sh, OS 1.74; baseline tagr9b=dev292ab6c, fix tagr9f= this branch).bss: 0026 30,564 -> 4,064 B, 0029 6,706 -> 28 B.r9fsha256248965cea725c7ce18a37da39ce1b799b4995a55b605226eb4b172cacbc8eb08.hash_expect:--image build/stock_mainos.binconverted nothing, and--checkpasses.What I ran
In
build/os/1.74aftertools/ostarget.py port 1.74, rytm-emu,DTEMU_STRICT=1:devin every suite except these two:ram(new,tools/emu/ram_emu.py): 24 / 0, and it fails ondev. It covers sealed claims, a damaged frame / pmo / names / sfu_x claim (fallback, report, message), and the diagnostic. On addrdiag=1build: 28 / 0.sq: 399 / 8 against 403 / 7. The new failure isfillqueue, the 0021 race fixed in 0021: ext_ui_lock waits while a stock SysEx goes out (no message inside a dump) #33. The other seven fail ondevtoo.pm's bound: raised from 100 to 105 us. One of five cases (128 entries, 96 route amounts) reads 103.6 us at most boot phases ondev's own code too. Which block a burst lands in decides it, and this branch's start-up timing makes that phase common. 105 us is about 1.5 % of a block above the old bound. The other bounds are unchanged.--fullrun on the Makefile's release set agreed with the--changedrun above.Hardware: one MKII, OS 1.74, with a larger mod set than
dev's, using the same claims and addresses. This was before the licence rewrite of the caps (see the comment below)..syxsent outside the upgrade menu. 0 bad words.Knob latency (emulator)
12 tracks of 16ths, knobs turning, mean / max ms.
On plain
dev: a small cost, consistent at every budget that isn't saturated.devscenedevno sceneand.l ram_okthat keeps pmo off its claim until the claim is cleared. With the guard replaced by same-size no-ops, or removed, the numbers go back todev's. Ruled out: code layout (dev+ 3,286 B of dead code), the per-tick checks, 0029, and the buffers' placement.ram_okonto a cache line the interrupt already writes didn't change anything.On top of the performance PR (#25): no cost. The run is this branch + #33 on #25's head, against #25 alone:
The means are equal or better. The max at 122 M is 12 to 14 ms higher.
🤖 Generated with Claude Code