memlnaut-nisps/firmware/MEMLNaut-NISPS/platformio.ini
monkey-w1n5t0n 68d4cc4017 build(firmware): migrate to PlatformIO and vendor memllib (plan §5)
One cut, no dual path. Closes ALIGNMENT defect 3 ("Arduino-CLI build
machinery is actively hostile") and vision bullet 4.

platformio.ini carries 16 [env:], one per variant, each passing
-DMEMLNAUT_MODE_TYPE; selftest passes -DNISPS_SELFTEST=1 instead. The env list
IS the registry now — the .ino comment-registry and the NISPS_ST_* token-paste
table are deleted rather than migrated. L12 noted that table was already
silently missing the currently-shipped SLPWorkshop variant, which is the whole
argument against having a second list.

Also deleted: the Python/sed machinery that rewrote the COMMITTED .ino on every
build, the sketch symlink forest, the global TFT_eSPI User_Setup.h mutation
(now -D flags — TFT_eSPI's own documented PlatformIO recipe), the UF2
boot-mount detection stack (upload_protocol=picotool talks to the bootloader
directly), and build-firmware-arch.sh entirely. Scripts 683 -> 435 lines.

memllib is vendored at lib/memllib/ from upstream e291192; no submodules
remain. VENDORED.md records provenance and the re-sync procedure.

S9: a firmware-build CI job compiles three representative envs against a cached
toolchain and reports per-variant flash/RAM. Firmware is in an automated gate
for the FIRST time. The old ci.yml comment justified excluding it as "low
verification value" — an assessment that did not survive contact, since the
SelfTest variant sat broken for an unknown period calling a DisplayDriver
method that did not exist at the pinned memllib commit, and nothing noticed
because nothing built it.

Verified: all 16 envs build from an empty cache, each within ~520 bytes of the
arduino-cli binary it replaces, flash and RAM. Measured as .text+.rodata /
.data+.bss+vector+uninitialized — NOT PlatformIO's console line, which
double-counts .data on this board. This does not prove the hardware boots; no
flash+smoke test was possible and that stays an operator chokepoint.

  slpworkshop 248232/145028   pafsynth 256880/149716   selftest 216228/17960
  (all 16 in the CI log format; none exceeds 2% of a 16 MB flash)

Two traps recorded so nobody rediscovers them: vendoring memllib's subdirs
without a src/ wrapper makes PlatformIO's library builder silently compile
NOTHING while still linking; and project build_flags land BEFORE the
framework's own -std=gnu++17 -Os, so build_unflags is required.

CORRECTION carried in this commit: the firmware sizes in c19d846's message and
the first version of the memllib recon doc were wrong — SLPWorkshop 145348,
PAFSynth 145300, SelfTest 141840. They came from building variants in sequence
through a SHARED incremental arduino-cli build directory, which reused stale
objects and under-reported by ~75 KB. Clean-cache rebuilds of the identical
commit give 216736/18492 for SelfTest. The real cost of the memllib upstream
bump is +216 bytes flash, not +316. Never measure firmware size through a
reused build dir.

HISTORY NOTE: this commit and the docs commit before it were rebuilt (force-push,
2026-07-21) so that each contains only what its message describes. The first
versions had the firmware deletions stranded in the docs commit by a shared-index
race between concurrent agents; content is byte-identical to the originals.

Gates: run-all-tests.sh ALL GREEN (nisps/ untouched by this change beyond
include paths); 16/16 pio envs build.
2026-07-21 20:17:58 +02:00

160 lines
6.6 KiB
INI

; firmware/MEMLNaut-NISPS/platformio.ini — MEMLNaut-NISPS firmware, PlatformIO build.
;
; One [env:<alias>] per firmware variant. The variant list here IS the
; registry — there is no separate .ino comment-registry to keep in sync.
; Each normal-mode env sets MEMLNAUT_MODE_TYPE to one of the type aliases
; declared in glue/mode_select.hpp; the `selftest` env sets NISPS_SELFTEST=1
; instead (see src/main.cpp for the fork).
;
; Build one variant: pio run -e pafsynth
; Build a bare `pio run` (no -e): only the hardware's current shipped variant
; (`default_envs` below). Build everything: `pio run -e a -e b -e c ...` (list
; every env; PlatformIO has no "all" shorthand) or scripts/build-firmware.sh
; --all.
;
; NOTE on `pio run`'s own "Flash: NN%" console line: for this board, PlatformIO's
; generic size checker (builder/tools/piosize.py) counts any PROGBITS+ALLOC
; section toward "flash used" — which double-counts .data (it's genuinely
; flash-resident AND ram-resident: its initialiser image lives in flash, its
; runtime copy lives in RAM). Arduino-CLI's own "Sketch uses" line does not
; do this (flash = .text + .rodata only). For modes with large MLP nets
; (.data-heavy), PlatformIO's console number reads far larger than
; arduino-cli's for the identical binary — not a real regression. Compare
; `arm-none-eabi-size -A` section-by-section (text+rodata vs. data+bss) if
; a number here looks alarming.
[platformio]
default_envs = slpworkshop
[env]
; earlephilhower's arduino-pico core via the community PlatformIO platform
; wrapper (the same pattern firmware/useq-celium/main/platformio.ini uses).
; platform_packages pins the EXACT framework + toolchain versions this repo's
; arduino-cli setup uses today (boards.txt v5.5.1 / toolchain 4.1.0-1aec55e,
; gcc 14.3.0) so PlatformIO and arduino-cli produce comparable binaries.
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
platform_packages =
earlephilhower/framework-arduinopico @ https://github.com/earlephilhower/arduino-pico.git#5.5.1
board = solderparty_rp2350_stamp_xl
framework = arduino
board_build.core = earlephilhower
; Matches the board's default 150 MHz menu.freq entry (arduino-cli FQBN
; leaves this at its default too — see boards.txt menu.freq.150).
board_build.f_cpu = 150000000L
; arduino-cli builds this firmware with FQBN
; rp2040:rp2040:solderparty_rp2350_stamp_xl:opt=Optimize3 (-O3) plus
; --build-property compiler.cpp.extra_flags=-std=gnu++20. The arduino-pico
; PlatformIO builder appends its OWN default `-std=gnu++17 -Os` AFTER project
; build_flags (verified via `pio run -v`: project flags land first, then the
; framework's, and GCC honours the LAST -std/-O on the command line) — so
; build_unflags is required to actually remove them; simply listing our own
; flags in build_flags is not enough to win.
build_unflags =
-std=gnu++17
-Os
build_flags =
-std=gnu++20
-O3
; nisps/ stays platform-neutral at the repo root (shared with the WASM
; build) — reached via -I, never copied or symlinked into firmware/.
-I${PROJECT_DIR}/../..
; glue/ headers, reached as "glue/x.hpp" from src/main.cpp.
-I${PROJECT_DIR}
; ---- TFT_eSPI hardware config (was: setup-firmware-toolchain.sh mutating
; the GLOBALLY installed TFT_eSPI library's User_Setup.h). USER_SETUP_LOADED
; makes TFT_eSPI's User_Setup_Select.h skip its own bundled setup files
; entirely (see TFT_eSPI/User_Setup_Select.h: "Lets PlatformIO users define
; settings in platformio.ini") — this is TFT_eSPI's own documented recipe,
; not a repo-invented hack. Values below are the MEMLNaut panel config that
; used to live in
; src/memllib/hardware/memlnaut/Setup9999_MEMLNaut.h.renameme.
-D USER_SETUP_LOADED=1
-D USER_SETUP_ID=60
-D ILI9341_DRIVER=1
-D TFT_MISO=16
-D TFT_MOSI=3
-D TFT_SCLK=2
-D TFT_CS=20
-D TFT_DC=18
-D TFT_RST=22
-D TOUCH_CS=21
-D LOAD_GLCD=1
-D LOAD_FONT2=1
-D LOAD_FONT4=1
-D LOAD_FONT6=1
-D LOAD_FONT7=1
-D LOAD_FONT8=1
-D LOAD_GFXFF=1
-D SMOOTH_FONT=1
-D SPI_FREQUENCY=70000000
-D SPI_READ_FREQUENCY=20000000
-D SPI_TOUCH_FREQUENCY=2500000
; Pinned to the exact versions setup-firmware-toolchain.sh installs via
; arduino-cli today (arduino-cli lib list), for a fair size comparison.
; TFT_eWidget@0.0.5 isn't in the PlatformIO registry (it only carries 0.0.6+),
; so it's pinned straight from upstream's matching git tag instead.
lib_deps =
bodmer/TFT_eSPI@2.5.43
https://github.com/Bodmer/TFT_eWidget.git#v0.0.5
FortySevenEffects/MIDI Library@5.0.2
upload_protocol = picotool
monitor_speed = 115200
; =====================================================================
; Normal-mode variants — one nisps::modes::*Mode each.
; =====================================================================
[env:soundanalysismidi]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeSoundAnalysisMIDI
[env:xiasri]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeXIASRI
[env:verbfx]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeVerbFX
[env:breakor]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeBreakOr
[env:elysiamorfs]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeElysiamorfs
[env:channelstrip]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeChannelStrip
[env:pafsynth]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModePAFSynth
[env:memlcelium]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeMEMLCelium
[env:slpworkshop]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeSLPWorkshop
; ---- External-synth MIDI-CC variants (joystick -> MLP -> MIDI CC) ----
[env:extsynthsub37]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthSub37
[env:extsynthsubphatty]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthSubPhatty
[env:extsynthpro12]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthPro12
[env:extsynthanalogkeys]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthAnalogKeys
[env:extsynthhydrasynth]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthHydrasynth
[env:extsynthjd800]
build_flags = ${env.build_flags} -D MEMLNAUT_MODE_TYPE=MEMLNautModeExtSynthJD800
; =====================================================================
; SelfTest — guided hardware bring-up rig (no engine, no ML).
; =====================================================================
[env:selftest]
build_flags = ${env.build_flags} -D NISPS_SELFTEST=1