p1: event-rate interrupt code built for size (main 0.9.14/0.9.15's policy), the sound's layout re-pinned

tools/size_fns.py: of what an interrupt reaches, the code that runs once an event (a USB control transfer, a MIDI
message, a step, a note, a recorded key) gets minsize, as main's EVENT_PFX / EVENT_KEEP, plus seq-v2's own once a
step (comp_run, comp_lane, comp_cond, comp_count, gl_eval, gl_take, gl_cond, gl_step_at, fl_once); one an
interrupt's -Os code calls stays a call. -3604 B of flash, -1952 B of RAM code.

FELUCCA_REPIN=1 (tools/audio_layout.txt recorded anew: the event code changed size): its intermediate link, the UI's
tables not yet in the holes, now goes in the probe's larger region (it overflowed XIP by 21.8 KB). Needs a check on
the device (load, crackle), as every repin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-10-25 13:18:37 +00:00
1 parent ad76a14901
commit 5de8805ffa
3 files changed
+1877 -1803

No files matched your search

+1832 -1797
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -451,7 +451,7 @@ def build_app():
rows = layout_read() # (the merged constants' place once the UI's tables have left .rodata)
compile_hot(rows)
layout_ld(rows)
symt = sym_table(link()[1])
symt = sym_table(link(probe=True)[1]) # (p1) the UI's tables not yet in the holes: in the larger region
layout_write([f"{(symt[n] - APP_XIP) if f == 'c' else o:06x} {f} {n}" for o, f, n in rows])
rows = layout_read()
aligns = compile_hot(rows)
+44 -5
View File
@@ -31,7 +31,40 @@ SIZE_FILES = ["ui.c", "favorites.c", "menu_items.c", "icons.c", "ui_graph.c", "u
"ui_tools.c", "fm6_vbank.c", "sing.c",
# (0.9.7) the main-loop functions of the sound files (what the interrupts reach stays -Os, as above): the
# MASTER pot's boot and poll, FM6's patch store, the kit's names and grids, MOD's names, the PUNCH lane
"pfx.c", "master.c", "audio.c", "mod.c", "fx.c", "drumx_voice.c", "eng_drum.c", "eng_fm6.c"]
"pfx.c", "master.c", "audio.c", "mod.c", "fx.c", "drumx_voice.c", "eng_drum.c", "eng_fm6.c",
# (p1, main 0.9.15) for their event code below (what runs every sample or block there stays -Os)
"perform.c", "voice.c", "song_play.c", "eng_wheel.c", "eng_formant.c", "eng_animal.c", "slicer.c",
"eng_analog.c", "eng_lofi.c", "eng_noise.c", "eng_phase.c", "fugue.c", "../hal/fm1_input.h"]
# (p1, main 0.9.14) of what an interrupt reaches, the code that runs once an event (a USB control transfer, a MIDI
# message, a step, a note, a recorded key), not once a sample or a block: built for size as the main loop is. By
# prefix; EVENT_KEEP the ones among them that do run every block
EVENT_PFX = ("ep0_", "e0_", "ep1_", "ep3_", "sysex_", "midi_", "um_", "uart_midi_", "ml_", "mn_", "mo_", "seq_step",
"seq_start", "seq_stop", "seq_note", "seq_release", "seq_ratchet", "arp_", "chord_", "cp_", "rec_",
"motion_", "cin_", "latch_", "key_", "kb_", "keys_", "fm6_note_on", "drum_note_on", "dxo_on", "dxo_off",
"dxo_rec_hold", "pfx_fire", "seq_lane_rat", "sy_word", "sy_gen_word", "sy_enter", "live_",
"mod_key", "mod_note", "sing_note", "ly_", "step_parts", "step_rolls", "tie_span", "every_on", "scale_snap",
# (0.9.15) a note (its voice found, started, ended), a key, a section or song row in, the FX layer's buffer
# effect started or switched (a 1/16 at most), a fault: not a sample's or a block's work
"trk_note_on", "trk_note_off", "voice_start", "voice_victim", "voice_room", "mono_play", "input_on",
"input_off", "wheel_note_on", "formant_note_on", "animal_init", "drum_oct_note", "sec_apply", "chain_apply",
"srec_finish", "scene_capture", "fx_trip", "rev_state_clear", "sl_enter", "perf_buf_start", "perf_buf_select",
"perf_buf_done", "perf_glt_step", "perf_switch", "perf_press", "perf_hush_end", "pfx_resync", "pfx_note",
"pfx_hush", "pfx_lane_", "strn_note", "scale_steps", "cg_near", "dxo_part", "trk_nvoice", "lofi_note_on",
"noise_note_on", "animal_note_on", "analog_note_on", "phase_note_on", "fm6_note_of", "glide_set", "glide_from",
"mono_pick", "mono_remove", "lowest_held", "srec_", "trk_fade_out", "voice_kill", "trk_all_off", "fg_reset",
"fg_release", "step_set_lmode", "st_micro_set", "lofi_desc", "noise_desc", "animal_desc", "formant_desc",
"param_desc_of", "param_fit", "uac_rate_set", "uac_ep4_reset", "fl_reset", "rev_line_clear", "dly_line_clear",
"rev_clear", "dly_lo_reset", "slicer_start", "slicer_drop", "perf_drop_slicer", "dx_mute_set", "mc_lost",
"uin_ep_config", "fm1__anim_frame", "sy_tok", "trk_chance", "drum_oct_of", "perf_key",
"perf_len", "mod_midi", "sy_norm", "fl_ok", "get_desc", "drum_muted", "drum_lane", "trk_kit", "drum_kit_of",
"name_of",
# (0.9.17) the glitcher's once a slice, segment, chunk, grain or block: GLITCH's segments, SHUFFLE's 1/16s
# and chunks, FREEZE's grains, the scratch's hand, the knobs' focus
"perf_glt_seg", "perf_shuf_step", "perf_shuf_go", "perf_frz_grain", "perf_scratch", "perf_gfocus",
"perf_gx", "perf_pick", "pf_hash",
# (p1) seq-v2's own once a step: the components (seq2d) and the global lane (seq2f) on the step played
"comp_run", "comp_lane", "comp_cond", "comp_count", "gl_eval", "gl_take", "gl_cond", "gl_step_at", "fl_once")
EVENT_KEEP = {"mo_block", "ep1_tx", "key_latch", "midi_clock_advance", "cin_block", "kb_lat", "live_q", "live_adv"}
ISR_ROOTS = ("fm1_alnk0_irq", "fm1_timer5_irq") # hal/fm1_isr.S: the audio ISR, the key / LED scan (+ USB poll)
DEF = re.compile(r"^(?:static|void|int|uint\w*|int\w*|const)\b[^;=(]*?\b([A-Za-z_]\w*)\s*\(", re.M)
IR_DEF = re.compile(r"^(define [^\n]*?@\"?([\w.]+)\"?\([^\n]*\)(?: unnamed_addr| local_unnamed_addr)?)( #\d+[^\n]*\{)$",
@@ -91,16 +124,22 @@ def isr_reach(ir, with_globals=False):
def main(src, dst):
ir = Path(src).read_text()
isr = isr_reach(ir)
names, hit = size_names() - isr, set()
names, hit = {n for n in size_names() if n not in isr or (n.startswith(EVENT_PFX) and n not in EVENT_KEEP)}, set()
# (0.9.15) an event function of some size that an interrupt's -Os code calls stays a call (noinline): inlined there
# it would be built -Os in its caller and its minsize lost (ep0_service into TIMER5, chord_glide, the arp's notes)
body = {m.group(1): m.group(2) for m in IR_BODY.finditer(ir)}
fast = {f for f in isr if f not in names}
called = {g for f in fast for g in IR_REF.findall(body.get(f, ""))}
out = {n for n in names & isr & called if body.get(n, "").count("\n") >= 0}
def mark(m):
if m.group(2) not in names:
return m.group(0)
hit.add(m.group(2))
return m.group(1) + " minsize" + m.group(3)
return m.group(1) + (" minsize noinline" if m.group(2) in out else " minsize") + m.group(3)
Path(dst).write_text(IR_DEF.sub(mark, ir))
print(f"size: {len(hit)} main-loop functions built for size ({len(names) - len(hit)} not in this build; "
f"{len(size_names() & isr)} reached from an interrupt kept -Os)")
print(f"size: {len(hit)} main-loop and event functions built for size ({len(names) - len(hit)} not in this build; "
f"{len((size_names() & isr) - names)} reached from an interrupt kept -Os)")
return 0