sprint_event: avoid %hu format (unsupported by MicroPython internal printf) - #888
Conversation
PRIu16 expands to "%hu", which MicroPython's internal printf (mp_vprintf, used when MICROPY_USE_INTERNAL_PRINTF=1 overrides snprintf) does not support: it hits assert(*fmt == '%' || !"unsupported fmt char") in py/mpprint.c and aborts on debug builds. This fires in any MicroPython port that links AMY and binds snprintf to the internal implementation (e.g. Tulip Linux desktop, or the AMYboard VCV Rack plugin build) whenever sprint_event runs — amy_dump_state(), update_sketch_knobs(), etc. Print the osc field with %u and an unsigned cast instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🎛️ AMY HW CI (AMYboard bench)Flashed this PR's AMY (LoadTestChord: 6-voice Juno ✅ PASS — the bench ran the test to completion.
Full chord settled render μs: 3189 (was 3192, Δ -0.1%) (peak 3197, 39 samples) ⬇️ Artifacts: serial log · load trace · report Self-hosted bench (amyboardci). FAIL means only that the test could not run — the load values are informational, with no threshold and no audio compare. See |
⛓️ tulipcc integration PR openedThis merge was pinned into tulipcc for full-system CI: shorepine/tulipcc#1245 Test it there and merge that PR to move tulipcc onto this AMY. |
Problem
sprint_eventinsrc/patches.cprinted theoscfield withPRIu16, which expands to%hu. MicroPython's internal printf (mp_vprintf) has nohlength-modifier support, so in any MicroPython port whereMICROPY_USE_INTERNAL_PRINTF=1overridessnprintf(the default;micropython/shared/libc/printf.croutes it intomp_vprintf), formatting reachesassert(*fmt == '%' || !"unsupported fmt char")inpy/mpprint.cand aborts on debug builds — triggered by anything that serializes events:tulip.amy_dump_state(),amyboard.update_sketch_knobs(), etc.Affected in practice: Tulip Linux desktop builds and the AMYboard VCV Rack plugin build. Tulip macOS desktop happens to be immune: Darwin's fortify headers rewrite
snprintfcalls to___snprintf_chk(system libc) regardless of-U _FORTIFY_SOURCE, bypassing the MicroPython override — verified live at the desktop REPL.Fix
Print the osc field with
%uand an(unsigned)cast (varargs promoteuint16_ttointanyway, so this is value-identical). These were the only two%husites reachable throughsnprintfin AMY; all other formats used (%d/%uvia 32-bit PRI macros,%.3f,%s) are supported bymp_vprintf.Testing
make test: 109 tests pass.🤖 Generated with Claude Code