code wiki / (root) / nx_mcu_fit.nx

nx_mcu_fit.nx

buildroot/runtime/nx_mcu_fit.nx

3913 B64 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind librarytopic mcu
docsdependenciesstructsconstsfunctions

about

nx_mcu_fit.nx -- does a model config fit a specific MCU's memory hierarchy? Pure decision logic. THE ONE RULE THAT MAKES THIS HONEST: an UNMEASURED resource is REFUSED, never assumed. mcu_targets.conf carries -1 for every field we have not put on a bench, and a -1 must never be silently treated as 0 (infinite room) or as a datasheet guess. If we cannot decide, we say so and name the field to go measure. That is what makes this organ useful for hardware bring-up rather than merely decorative: pointing it at an unmeasured board returns a WORK ORDER, not a verdict. The second rule, inherited from the memfloor incident: REFUSE, NEVER SILENTLY SHRINK. An allocator that quietly reduces a grid to make it fit froze every seat's builds for minutes. So there is no "nearest fitting config" return path here -- the caller is told which wall it hit and decides. Resource model, matching how a PLE-style model actually lands on an ESP32-S3: dense core -> internal SRAM (fast, tiny, the real constraint that sizes the model) weights+table-> SPI flash (large, slow, XIP / memory-mapped) KV + scratch -> PSRAM (medium, bandwidth-bound) Checks run in that order so the BINDING constraint reported is the tightest real one, deterministically. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_mcu_fit.nx nx_eqprobe.nx nx_mcu_fit_gate.nx nx_mcu_ready.nx

imports: nx_syscalls.nx

imported by: nx_eqprobe.nxnx_mcu_fit_gate.nxnx_mcu_ready.nx

structs

none

consts

21const MF_FIT: i64 = 0
22const MF_REFUSE_SRAM: i64 = 1
23const MF_REFUSE_FLASH: i64 = 2
24const MF_REFUSE_PSRAM: i64 = 3
25const MF_REFUSE_UNMEASURED: i64 = 4
26const MF_UNMEASURED: i64 = 0 - 1
27const MF_KB: i64 = 1024
28const MF_MB: i64 = 1048576

functions

30func mf_reason(v: i64) -> *u8
called by 2: mainmain
39func mf_core_bytes(params: i64, bits: i64) -> i64
called by 1: main
47func mf_admit(sram_kb: i64, psram_mb: i64, flash_mb: i64,
called by 2: mainrdy_check