Kleidos API Search

In development. It changes without notice.

MISRA C++:2023 — what the firmware holds, and its deviations

The owner wants the firmware held to as much of MISRA C++:2023 as the project can reach, step by step. This page is the register: what is claimed, which gate holds each claim, and every known departure with its reason. It is not a compliance statement. No certified MISRA C++:2023 checker runs on this tree (they are all commercial: Cppcheck Premium, Helix QAC, Parasoft, Polyspace, PVS-Studio, LDRA), so a rule is listed as held only where a free gate checks it or where the code was read against the rule and the reading is written here.

Scope

  • Own code: everything under firmware/src. The rules apply to it.
  • Adopted code (MISRA Compliance:2020's term): ESP-IDF, FreeRTOS, the C and C++ libraries, and the fake ESP-IDF of the host tests (firmware/test/native/harness). They are not required to comply; where they affect a claim about our code, this page says how.
  • Tests and host tools (firmware/test/native, host/, scripts/) are outside the scope.

Rule numbers

The rule numbers and headlines below are confirmed against MathWorks' public index of MISRA C++:2023 (Polyspace Bug Finder documentation, "MISRA C++:2023 Rules and Directives", read 2026-11-20; the pages of 0.2.4, 4.1.1, 6.7.1, 7.11.2 and 11.6.2 read 2026-11-23, those of 0.0.2, 5.13.4, 7.0.4, 8.0.1, 8.1.2, 8.2.2, 8.14.1, 8.19.1, 9.4.1, 9.5.1 and 19.6.1 read the same day for FW-21, and those of 6.9.2 and 7.0.5 the same day for FW-23; 8.2.6's headline and category from MathWorks' page, read 2026-11-24 for the review that found its sites), not against the standard itself, which is not in either repository: confirm each against the owner's copy before it goes into a formal deviation record. Categories are given only where a public source states them (SonarSource's rule pages, SciTools' CodeCheck list, MathWorks' rule pages); the others are marked unconfirmed. A rule headline written with "shall" is usually Required and one with "should" Advisory, but that is an inference, not a source.

Rule Headline (MathWorks' index) Category
0.1.2 The value returned by a function shall be used Required (MathWorks)
0.2.2 A named function parameter shall be used at least once Required (MathWorks)
0.0.2 Controlling expressions should not be invariant unconfirmed
0.2.4 Functions with limited visibility should be used at least once Advisory (MathWorks)
4.1.1 A program shall conform to ISO/IEC 14882:2017 (C++17) Required (MathWorks)
5.13.4 Unsigned integer literals shall be appropriately suffixed Required (MathWorks)
5.13.5 The lowercase form of L shall not be used as the first character in a literal suffix Required (MathWorks)
6.4.1 A variable declared in an inner scope shall not hide a variable declared in an outer scope unconfirmed
6.7.1 Local variables shall not have static storage duration Required (MathWorks)
6.7.2 Global variables shall not be used Required (SciTools)
6.9.2 The names of the standard signed integer types and standard unsigned integer types should not be used Advisory (MathWorks)
7.0.1 There shall be no conversion from type bool Required (MathWorks)
7.0.2 There shall be no conversion to type bool Required (MathWorks)
7.0.3 The numerical value of a character shall not be used Required (MathWorks)
7.0.4 The operands of bitwise operators and shift operators shall be appropriate Required (MathWorks)
7.0.5 Integral promotion and the usual arithmetic conversions shall not change the signedness or the type category of an operand Required (MathWorks)
7.11.2 An array passed as a function argument shall not decay to a pointer Required (MathWorks)
8.0.1 Parentheses should be used to make the meaning of an expression appropriately explicit Advisory (MathWorks)
8.1.2 Variables should be captured explicitly in a non-transient lambda Advisory (MathWorks)
8.2.2 C-style casts and functional notation casts shall not be used Required (MathWorks)
8.2.5 reinterpret_cast shall not be used Required (MathWorks)
8.2.6 An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type Required (MathWorks)
8.2.10 Functions shall not call themselves, either directly or indirectly Required (SciTools)
8.14.1 The right-hand operand of a logical && or \|\| operator should not contain persistent side effects Advisory (MathWorks)
8.19.1 The comma operator should not be used Advisory (MathWorks)
9.4.1 All if ... else if constructs shall be terminated with an else statement Required (MathWorks)
9.4.2 The structure of a switch statement shall be appropriate Required (MathWorks)
9.5.1 Legacy for statements should be simple Advisory (MathWorks)
10.0.1 A declaration should not declare more than one variable or member variable Advisory (MathWorks)
11.3.1 Variables of array type should not be declared unconfirmed
11.6.2 The value of an object must not be read before it has been set Mandatory (MathWorks)
13.3.3 The parameters in all declarations or overrides of a function shall either be unnamed or have identical names Required (MathWorks)
15.0.1 Special member functions shall be provided appropriately Required (MathWorks)
15.1.3 Conversion operators and constructors that are callable with a single argument shall be explicit Required (MathWorks)
15.1.4 All direct, non-static data members of a class should be initialized before the class object is accessible Advisory (MathWorks)
19.0.2 Function-like macros shall not be defined Required (MathWorks)
19.6.1 The #pragma directive and the _Pragma operator should not be used Advisory (MathWorks)
21.2.2 The string handling functions from <cstring>, <cstdlib>, <cwchar> and <cinttypes> shall not be used Required (MathWorks)
21.6.1 Dynamic memory should not be used Advisory (SonarSource)
21.6.2 Dynamic memory shall be managed automatically unconfirmed
21.6.3 Advanced memory management shall not be used unconfirmed
21.10.1 The features of <cstdarg> shall not be used unconfirmed
30.0.1 The C Library input/output functions shall not be used unconfirmed

The gates

Gate Where What it holds
GCC and clang, every warning an error firmware/platformio.ini build_src_flags, the same set in the host tests' Makefile; -Wl,--fatal-warnings on the device link (firmware/CMakeLists.txt) and its Apple spelling on the host's; tests/firmware/test_effective_compile_flags.py over the compile database of each of the 23 sources (src.sources under "The counts"), in CI's Device image job Every warning an error as the compiler is actually told: ESP-IDF's own -Wno-error=unused-function, -Wno-error=unused-variable, -Wno-error=unused-but-set-variable, -Wno-error=deprecated-declarations, -Wno-error=extra, -Wno-unused-parameter, -Wno-sign-compare and -Wno-enum-conversion, which a later -Werror does not undo, are each answered by name after them (FW-01, 2026-11-22), and a linker warning is an error too. -Wold-style-cast, -Wconversion, -Wsign-conversion, -Wdouble-promotion, -Wcast-qual, -Wcast-align (the cast and conversion rules, in part); -Wshadow (6.4.1 for variables); -Wswitch-enum, -Wundef, -Wredundant-decls, -Wvla, -Walloca, -Wnull-dereference, and GCC's -Wduplicated-cond, -Wduplicated-branches, -Wlogical-op. Exceptions and RTTI are off in the image (CONFIG_COMPILER_CXX_EXCEPTIONS, CONFIG_COMPILER_CXX_RTTI unset).
clang-tidy, two legs .clang-tidy, scripts/run_static_analysis.sh tidy through scripts/clang_tidy_gate.py, CI's Static analysis after the device image; LLVM major pinned in scripts/analysis_toolchain.sh Each of the 23 sources of firmware/src/CMakeLists.txt twice (FW-02, 2026-11-22): as the device compiles it, from its entry in firmware/compile_commands.json for --target=xtensa-esp-elf against the real ESP-IDF, libstdc++ and picolibc headers, and as the host tests compile it, against the fake ESP-IDF; both with -fno-exceptions -fno-rtti and without C++ modules (-fno-cxx-modules, from ESP-IDF 6.1.1, whose soc/regdma.h starts a line with a bit-field named module, which clang's C++20 mode otherwise reads as a module directive). The firmware repository's guards: another LLVM major, a configuration --verify-config refuses, a unit not analyzed or a stale compile database, and any parse diagnostic each fail the run (exit 2), and scripts/run_static_analysis.sh selftest proves them. The checks: misc-no-recursion (8.2.10, with no suppression since FW-21), cppcoreguidelines-avoid-non-const-global-variables (6.7.2), bugprone-unused-return-value taught every function with the cast to void as the only way out (0.1.2) and cert-err33-c, bugprone-switch-missing-default-case (9.4.2, in part), cppcoreguidelines-no-malloc taught the heap_caps_* names and cppcoreguidelines-owning-memory (21.6.1, 21.6.2), bugprone-*, cert-*, performance-*, the naming rules; and, beyond the firmware repository's set, the ten adopted in FW-02: misc-unused-parameters (0.2.2), readability-uppercase-literal-suffix (5.13.5), readability-implicit-bool-conversion (7.0.1, 7.0.2), cppcoreguidelines-pro-type-reinterpret-cast (8.2.5), readability-isolate-declaration (10.0.1), readability-inconsistent-declaration-parameter-name (13.3.3), cppcoreguidelines-special-member-functions (15.0.1: the four unmovable classes, Console, Ina228Driver, relay::Bank and Sampler, delete their copies and moves and default their destructors), google-explicit-constructor (15.1.3), cppcoreguidelines-pro-type-member-init (15.1.4) and cppcoreguidelines-macro-usage (19.0.2). Nine of them found nothing when they were adopted; the tenth found the four classes. From FW-26 (2026-11-23), three the firmware repository leaves off for its own printf-style output: cppcoreguidelines-pro-type-vararg and cert-dcl50-cpp (21.10.1: no C variadic call and no function with an ellipsis), and cppcoreguidelines-pro-bounds-array-to-pointer-decay (7.11.2: no array decays to a pointer, a string literal apart), each with no finding and no suppression in either leg. Each check holds its rule only as far as the check reads it
Include report (advisory) scripts/run_static_analysis.sh includes, the job summary misc-include-cleaner over the device leg's flags; it reports and fails nothing, because most of what it lists is ESP-IDF's umbrella headers (freertos/FreeRTOS.h must be included first and provides nothing directly)
cppcheck .cppcheck-suppress, the same script and job; release pinned in scripts/analysis_toolchain.sh (2.22.0, built in CI from its checked source archive) the firmware repository's flags (warning,style,performance,portability, exhaustive) over the CMake source list; another release is refused (exit 2). unusedFunction is no longer suppressed (FW-20): those flags do not enable it, and the AST census below reads it over the whole image, which cppcheck, one file at a time and blind to the console's table of member-function pointers, could not; every entry the list keeps has its row in "Tool suppressions"
The register's inventories (FW-20) scripts/misra_register.py, tests/firmware/test_misra_register.py, every test run the tables of this page that the sources can be read for, each compared row by row with what firmware/src holds (comments and literals removed): D9's static locals (6.7.1), D10's constructs that C++17 does not have (4.1.1), every NOLINT, NOLINTNEXTLINE, NOLINTBEGIN and cppcheck-suppress under firmware/ and every entry of .cppcheck-suppress ("Tool suppressions"), D5's table of discarded results by the function called ("The counts"), and every name of a standard integer type outside an alias declaration (6.9.2, FW-23), each of which fails (the few printf's formats needed went with D2 in FW-26); a construct, a suppression or a cast with no row, a row nothing matches any more, a changed count and a row with no reason each fail, and a planted case of each proves it
AST census (FW-20) scripts/ast_census.py (clang, over the harness leg's flags; --leg device reads the image's compile commands and gives the same counts), tests/firmware/test_ast_census.py, every test run the image's translation units read together from clang's AST: no function of the firmware's own that no unit of the image references (0.2.4 and further: every own function, not only those of limited visibility), but the five test seams it names with their reasons (one of them a single overload, named with its parameter types), each of which the image must not reference and a host test must call; the array-to-pointer decays of call arguments (7.11.2) and the C arrays declared (11.3.1), counted and held to "The counts", the decays to a count that only falls over this page's history (0 since FW-26)
MISRA rules (FW-21) scripts/misra_rules.py (clang, over the harness leg's flags; --leg device reads the image's compile commands), tests/firmware/test_misra_rules.py, every test run the image's translation units read from clang's AST, each declaration of kleidos::meter and each C-linkage function the firmware defines (a C-linkage definition no dump filter reads fails the run): 5.13.4, 7.0.3, 7.0.5 (FW-23), 8.0.1 for the conditional operator, 8.1.2, 8.2.6 (a cast from void* counted for D13), 8.14.1, 8.19.1, 9.4.1 and 9.5.1; and the sources' text: 19.6.1, 8.2.2's FreeRTOS tick macros, 21.2.2 (FW-22), and 21.10.1 and 30.0.1 (FW-26). Every finding fails the test, a planted case of each rule and its compliant twin prove the reading, and an entry of the side-effect-free calls the image no longer needs fails as stale. Its blind spots are in the script: a call is judged by its callee's declaration, not its body, a counter passed by non-const reference is not seen as modified, and a side-effect-free free function is known by its name alone, though only when no own declaration is the callee (a member function or an operator is known by its class too)
Source gate tests/firmware/test_no_dynamic_memory.py, every test run no allocation construct in firmware/src (21.6.1 to 21.6.3), and no C stream function (printf, puts, fwrite, fopen and their kin, FW-18); no call of an allocating ESP-IDF entry point outside the allow-list of D1 (empty since FW-16) and the made-safe list (FW-16: the flash log's write and erase, whose allocation the image's configuration takes out), and no entry of either its source no longer calls (FW-08)
Object gate scripts/check_heap_objects.py, CI's Device images no allocator referenced by a compiled object of the firmware (21.6.1 to 21.6.3); no reference to an allocating ESP-IDF entry point outside the allow-list of D1 and the made-safe list, and no entry of either its object no longer references (FW-08, FW-16); and, with --elf, no operator new or operator delete, no __cxa_* function but ESP-IDF's empty __cxa_guard_dummy, no eh_globals and no symbol of NVS anywhere in the linked image (FW-16), and no psa_ or mbedtls_ function but mbedTLS's empty mbedtls_psa_crypto_init_include_impl (FW-18)
Host ledger (FW-08) firmware/test/native/harness/idf_ledger.h, every Bench and Scope of the host tests; tests/firmware/test_idf_allocation_lists.py every fake of an ESP-IDF entry point that allocates or frees on the device records its call, and a case whose code called one on neither the allow-list nor the made-safe list fails; the harness's, the source gate's and the object gate's lists are held equal, each allowed call to its source and to the deviation below that names it, each made-safe call to its mechanism in the tree, and their history to an allow-list that only shrinks and a deny list that only grows
The counts since app_main() (FW-17, FW-19) heap_monitor.cpp, DIAGnostic:HEAP?; on the host firmware/test/native/test_heap.cpp's every-command session, held to the command table by tests/firmware/test_heap_session_covers_the_table.py allocs_since_main=0 frees_since_main=0 (and the 0.7.0 keys allocs_after_init and frees_after_init, the same window from FW-17) after every operation the SCPI table offers: on the host after each message of a session that gives every header of kCommands at least once, the saves, the lead cycle, the charge reset, the STATus subsystem and the watchdog's forced reset included; on the meter after the boot and after each command family (the bench sweep, next row). No operation is exempt: the maintenance deviation went with the last maintenance operation in FW-16, and the settling window with FW-17
Reachability gate (FW-19) scripts/check_heap_reachability.py (pyelftools 0.33), CI's Device image; its --selftest and tests/firmware/test_heap_reachability_gate.py no allocator (the C library's, heap_caps_*, the multi-heap layer, TLSF, FreeRTOS's, the C++ operators) reachable from any function of the firmware's own code, called or not, in the call graph of the linked image, read from the relocation records the link keeps (-Wl,--emit-relocs): every direct call and jump decoded at its relocated site, every long call the linker relaxed to a direct one decoded at its R_XTENSA_ASM_SIMPLIFY (since the review of 2026-11-24, HM2-01: until then 57 such sites, all in picolibc's stdio and dtoa, were missing, among them printf()'s call of vfprintf()), every literal load resolved to the address the literal holds, every address in data. A ROM function the walk reaches is named with the reason it allocates nothing, and an edge that never runs is cut only with its reason and the calls that would make it run, which fail the gate once reachable; a stale entry of either fails it too. On the built image every allocating ESP-IDF entry point of the deny list that the image links reaches an allocator, and no made-safe call does: every write, read and erase is walked through the three run-time tables ESP-IDF's startup installs, the os functions to the wrapped region check, the chip drivers and the host driver to the flash's command layer (HM2-02), and a read reaches the heap only through the bounce buffer's cut edges
Counts by phase and the bench sweep (FW-07) heap_monitor.cpp (pre_main_, _since_main), tests/bench/test_heap_sweep.py against tests/bench/heap_expectations.toml (--run-bench, on the meter) what ESP-IDF allocates before app_main() and everything allocated since, after the boot and after each command family, equal to a tracked file that only falls (tests/bench/test_bench_support.py reads its history); the census build names each site (below)
Stack bound (0.14.0) -Wstack-usage=1024 in firmware/platformio.ini, the device build only (tests/firmware/test_host_build_matches_device.py) no function of the firmware's own takes more than 1 KiB of stack (the largest, 944 bytes at -O2); with the end-of-stack watchpoint and the stack high-water marks of SYSTem:HEALth? and *TST?, the run-time half

Held, by the gates and by reading

  • 6.7.2, global variables. One, and it is not a program variable: RMTMEM (firmware/src/status_led.cpp), the RMT's symbol RAM, declared extern "C" volatile for the address the ESP32-S3's linker script gives it (esp32s3.peripherals.ld, PROVIDE ( RMTMEM = 0x60016800 )), a peripheral's memory the LED's blanker writes word by word (D7 for its name). clang-tidy's cppcoreguidelines-avoid-non-const-global-variables does not report it, an extern "C" declaration, so this sentence is what records it. Every object of the firmware's own has static storage inside a function, which keeps it out of 6.7.2 and puts it under 6.7.1 instead, a deviation of its own (D9): the five objects of the instrument are constinit statics of app_main() (firmware/src/main.cpp), and the TRACE ring a static of it that is not constinit (D9: no compiler evaluates its million elements as a constant expression, and an array of integers needs no guard), all reached only through the references app_main() hands out; the state of six modules (Record logs, Heap monitor, I2C master, Startup memory, uart0, watchdog) is a constinit static of each module's state() function, reached only through it; and the relay bank's reset record is a static of relay::detail::resetRecord() (D11). Constants at namespace scope are constexpr, or const objects (kChannelNames, an array of constant pointers to constant strings).
  • 0.1.2, the value a function returns. Every call's result is used or cast to void (FW-02, 2026-11-22): bugprone-unused-return-value with CheckedFunctions .* and AllowCastToVoid finds none left, in either leg. The 24 it found were the 11 memcpy and memmove calls below, 12 atomic read-modify-writes (fetch_add, fetch_sub, fetch_or) whose previous value no counter or flag set needs, and the ROM's esp_rom_printf() in app_main()'s fallback (gone in FW-26: the fallback writes through the ROM's esp_rom_output_putc(), which returns nothing); the casts are listed under D5.
  • 21.2.2, the string handling functions of <cstring>. No memcpy and no memmove (FW-02): of the eleven calls, eight became std::copy_n and std::copy (each a forward copy, the destination before the source where they overlap, which std::copy allows), and the other three, the calibration blob's reinterpretations of the bytes NVS returned, std::bit_cast, so no raw byte copy is left; from FW-16 the blob is a record of the flash log, read and written through std::bit_cast both ways and judged after a std::copy_n of its 80 bytes (calibration.cpp), and NVS's older layout is no longer read. tests/firmware/test_static_analysis_gate.py holds the sources to it. No str* function either (FW-22, 2026-11-23): names and patterns are carried as std::string_view (the command table's patterns, the profiles', the relays' and the error queue's names, every keyword list a handler matches), compared with ==, starts_with() and ends_with(), their lengths from size(); numbers are read with std::from_chars; the 13 strlen(), the four strncmp() and the two strcmp() are gone, and no source includes <cstring>. scripts/misra_rules.py fails a call of any string handling function of <cstring>, <cstdlib>, <cwchar> and <cinttypes> by name, and an #include of <cstring>, <string.h>, <cwchar> or <wchar.h>, in any source of firmware/src ("Held by `scripts/misra_rules.py`" below; a planted call of each kind fails it). The headline also names <cinttypes>, which no source includes since FW-26: its PRI* format macros went with the formats (21.10.1 and 30.0.1 below).
  • 0.2.4, functions with limited visibility used (FW-20), and further: no function of the firmware's own, whatever its visibility, that no translation unit of the image references (the AST census, "The gates"), but the six test seams scripts/ast_census.py names, public functions the host tests call (heap::disarm() and heap::attachCensus(), which reset and re-ring the heap monitor between cases, i2c_bus::clockHz() and i2c_bus::clearBus(), which read back the bus's clock and run its recovery without a staged fault, from FW-22 the overload of scpi::Parameters::choice() over an array of C strings, which the parser's host tests were written against while the image's handlers keep their keywords as views and call the std::span overload, and, while 0.18.0 is built, pinmap_store::save(), which FW-03 lands with its record log and FW-05 calls from SYSTem:PINS:APPLy, taking its entry out, as FW-04 took out load()'s when the boot called it). Its first run reported eight (FW-20): five dead functions, deleted (Sampler::pace(); channelFromName() and profileFromName(), names the console resolves through its own tables; the one-argument flash_log::mount(), whose second argument the tests now give; and calmath::pointsAgree() with the two-point combination only it used, agreementPpm(), combinedMicroOhm() and kRangeAgreementPpm, which the host judges, kleidos-meter calibrate and the configuration's range_split_max_ppm, never the instrument), the two I2C functions now named as seams, and a function template, which the census now reads with its specializations.
  • 6.9.2, no standard integer type's name (FW-23, 2026-11-23). Members, constants, parameters and loop counters are std::int32_t, std::uint32_t, std::uint64_t or std::size_t: the 69 names the firmware's own code spelled outside a format (the interrupt router's cores and lines, the I2C master's port, core and command index, the parser's base, exponent and decimals, SHA-256's and the CRC's counters, the 128-bit division's bit, the console's self-test word and report fields, the relay bank's reserved pins and pad level) are gone. Where an ESP-IDF function takes or returns int (esp_cpu_get_core_id(), gpio_get_level(), esp_cpu_intr_get_desc(), the I2C and timer groups' low-level calls, std::from_chars's base), the fixed-width value meets it by an implicit conversion between two 32-bit types of one signedness, which -Wconversion passes on both legs; no cast names int for it. The 49 that printf's formats needed (a d, u, %* or llu reads int, unsigned or unsigned long long and no fixed-width type, so the casts in a printf-family call's arguments and the int count a snprintf returned kept them; D2's d2.integer_names, a count that only fell) went with the formats in FW-26, and none is left. scripts/misra_register.py reads every name from the sources (comments and literals removed, an alias declaration exempt as the rule exempts it) and fails any (tests/firmware/test_misra_register.py, with a planted name of each kind, a cast in a call's arguments among them).
  • 7.11.2, no array decays to a pointer (FW-26, 2026-11-23). No array of the firmware's own reaches a function or a constructor as a pointer: clang-tidy's cppcoreguidelines-pro-bounds-array-to-pointer-decay finds none in either leg and is suppressed nowhere, and the AST census counts d3.decays at 0, a ratchet ("The counts"). How the 132 that were left after FW-25 went, and the string literals counted apart, is D3's text.
  • Held by scripts/misra_rules.py (FW-21, "The gates"): each rule below finds nothing in the image, a planted case of each fails it and its compliant twin passes (tests/firmware/test_misra_rules.py).
    • 5.13.4, unsigned literals suffixed. No integer literal of an unsigned type without its U. The 34 that had none were all in sha256.h, round constants and words of the initial hash value unsigned by their value alone; every one of that file's 73 hex constants now carries it.
    • 7.0.3, no character's numerical value. No conversion between a character type (char and the wide character types) and any other type, written or implicit, and so no arithmetic or ordering on a character (c - '0', c >= 'A'), no character as a condition, no static_cast<unsigned char>( c ) and no static_cast<char>( byte ) (FW-22). What the firmware needs of a character comes from firmware/src/chars.h: its class (white space, digit, letter, printable, graphic) and its value as a digit from a constexpr table of 128 entries built at compile time from strings that spell each class, indexed by std::char_traits<char>::to_int_type() after a check against the table's size; its upper case as kDigits at its value; and the byte it stands for on the wire, both ways, through std::char_traits<char>, the conversions MathWorks' page for the rule names as compliant. The gate reads every cast clang writes or the source does, and passes one: the promotions of two characters compared with == or !=, which compare for identity and use no value; that the rule's text allows them is MathWorks' and Polyspace's reading as far as their pages go, to confirm against the owner's copy. The 27 findings the gate made in FW-21's tree were in the parser (scpi.cpp: the character classes, the case folding, the digit values), the scale's digit emission (scale.h), the console's byte checks, the CRC and serial bytes (crc32.h, identity.h) and UART0's ring (uart0.cpp).
    • 7.0.5, no operand whose signedness promotion or the usual arithmetic conversions change (FW-23, 2026-11-23). The operands of every arithmetic, bitwise, shift and relational operator, of ~, unary - and +, of a compound assignment and of the conditional operator's two arms are read for a conversion clang inserted between two integer types of different signedness, and a compound assignment for a left operand computed in a type of the other signedness. The first reading found more than 450 operands, of three kinds, all gone: 318 literals of type int meeting an unsigned operand (size == 0), each now suffixed U (size == 0U); about 150 narrow unsigned operands (std::uint8_t, std::uint16_t) promoted to int against another narrow one, in flag tests, register fields, the status registers and the command table's flags; and a dozen unsigned operands meeting a signed 64-bit one (a shunt bound against a parameter, a sample count dividing a sum), now cast. Masks and bit positions are std::uint32_t (the INA228's fields and DIAG_ALRT bits, the status bytes, the command flags, the channel and relay masks), so a narrow register value that meets one is converted to std::uint32_t without passing through int; the SCPI status registers, the command flags, the channel masks and relay::Mask are held in std::uint32_t themselves; flag tests and field extractions go through bits::hasBit() and bits::field() on std::uint32_t (firmware/src/bits.h), so the conversion is the call's, to its parameter's type. What this reading passes and the rule's text might not is D12.
    • 8.0.1, for the conditional operator. Every operand of ?: that is itself a binary or a conditional expression of higher rank in the rule's table is parenthesized (( a == b ) ? x : ( y - z )), as 101 conditional expressions of FW-20's tree were not, most of them by their condition. An overloaded operator ranks as the built-in one it is spelled as (an iterator's ==, a rewritten != or a < answered by <=>), because the rule is about the expression as written; the gate read only built-in operators until the review of 2026-11-24 found findCommand()'s found == table.end() ? ... passed unparenthesized. The rule's other half, the operands of a binary operator (a + b * c), is not read by the gate and not claimed.
    • 8.1.2, captures named. The six lambdas of firmware/src (src.lambdas under "The counts") name what they capture or capture nothing: Console::findCommand()'s match [header, &suffix], samplerRefusalCode()'s match [error], Console::printSample()'s line writer [this, &sample], the anchor record of TRACe:DATA? (console_commands.cpp) [this], and two that capture nothing: the status update's edge rule in console.cpp and bufferErased()'s byte test in flash_log.cpp. The gate is stricter than the rule: it fails a default capture in a transient lambda too.
    • 8.2.2, for FreeRTOS's tick macros. pdMS_TO_TICKS() and portMAX_DELAY, which expand to C-style casts where they are used, are gone from the sources: rtos::ticksFromMs() converts in 64 bits with one static_cast and rtos::kWaitForever is the largest tick count (firmware/src/rtos_ticks.h). FreeRTOS's other macros the sources use may still expand to C-style casts of its own headers, whichever they are (among them pdTRUE, pdFALSE, pdPASS, configMINIMAL_STACK_SIZE, queueQUEUE_TYPE_RECURSIVE_MUTEX, portYIELD_FROM_ISR(), xSemaphoreGive(), xSemaphoreGiveFromISR(), xSemaphoreCreateBinaryStatic(), xQueueCreateStatic(), xQueueSend()); they are adopted code's spelling, not counted here and not claimed, and the gate's list (BANNED_MACROS) is where one is added.
    • 8.2.6, no cast to a pointer from an integer or an enumeration. No explicit cast in firmware/src converts an integer or an enumeration to a pointer type; a register is reached through ESP-IDF's low-level layer, whose casts are adopted code. A null pointer constant and a cast from void* to a function pointer are the rule's own exceptions. The four casts from void* to an object pointer are D13, counted by the gate (d13.void_pointer_casts) and held to D13's rows. The gate sees an enumeration only where clang spells its type enum ..., as 7.0.5's reading does.
    • 8.14.1, no side effect on the right of && and ||. The right operand assigns nothing, steps nothing, and calls only functions that are constexpr or const members, or one of the gate's side-effect-free calls (PURE_CALLS: std::atomic's load(), std::array's size(), cbegin() and operator[], std::span's size(), std::string_view's size(), operator[], starts_with(), empty(), front(), back() and operator==, std::equal(), esp_timer_get_time() and xPortGetCoreID(), each with its reason; a member function or an operator is matched by the class of its object as well as its name, so an own load() or empty() is judged by its declaration like any own function, since the review of 2026-11-24 (HM2-05); one the image no longer calls fails as stale, which took std::strlen() and std::strcmp() off it with FW-22). Of the 33 right operands the gate found in FW-20's tree (two more went with the recursion), the calls that write state or whose declaration does not say they do not (the bus reads and writes of the bring-up, the self-test, the clip and alert set-up and the charge read, the flash log's scan, erase check and acceptor, the I2C recovery, the parameter decodes, the ABORt match, the census query and the profile lookup) are made in statements of their own, each only while the ones before it succeeded, as the short circuit made them; the character classes, the I2C argument checks and the flash log's word read, which change nothing, are constexpr.
    • 8.19.1, no comma operator. The dump's column loop and equalsIgnoreCase() step their two cursors in statements of their own.
    • 9.4.1, every if ... else if chain ends in an else. The 13 chains of FW-20's tree end in an else whose comment says why nothing is left to do.
    • 9.5.1, every legacy for simple. A for declares one integer counter, compares it alone with a bound the body does not change, and steps it alone by a constant; the 28 that did not are while loops (a pointer or a cursor walking a string, a loop with a second condition, a counter the body steps itself), and the infinite loops are while ( true ). Whether 0.0.2's ban on an invariant controlling expression spares an infinite loop is not in MathWorks' page: to confirm against the owner's copy.
    • 19.6.1, no #pragma. Every header of firmware/src is guarded by #ifndef KLEIDOS_METER_<FILE>_H, #define of the same name as its first directives and #endif // KLEIDOS_METER_<FILE>_H as its last line (ina228_regs.h: KLEIDOS_METER_INA228_REGS_H), in place of #pragma once: a departure from the Kleidos firmware repository's house style, taken on the owner's "MISRA max" ruling of 2026-11-20. No source holds a #pragma or a _Pragma.
    • 21.10.1, no <cstdarg> (FW-26, 2026-11-23). No source includes <cstdarg> or <stdarg.h>, names va_list or one of its macros, or declares a function with a C ellipsis; clang-tidy's cppcoreguidelines-pro-type-vararg and cert-dcl50-cpp hold it too ("The gates"). The console's four printf-style members (printLine, respond, respondMore, fail, C variadic functions reading a std::va_list) were the last, and went with the formatted output they served (30.0.1, next).
    • 30.0.1, no formatted output of the C library (FW-26, 2026-11-23). No source includes <cstdio> or <stdio.h>, or calls a formatted input or output function of the C library (snprintf, vsnprintf and their kin) or the ROM's esp_rom_printf(). Every response, error, stream record and dump row is composed with the bounded writer of text.h, typed appends on std::to_chars into a caller's buffer, with no format string, no variadic call and nothing allocated, through the console's typed members (openUnit(), respondText(), respondNumber(), respondScaled(), respondMoreText(), openRecord(), endRecord(), openError(), failText(), failI2c()): FW-24 moved the relay bank's reports, the LED's, the parser's errors and the sampler's refusals, FW-25 console.cpp, and FW-26 console_commands.cpp, whose 24 snprintf calls and four printf-style members were the last; app_main()'s fallback, where UART0 could not be set up, writes its line through the ROM's esp_rom_output_putc(). The golden transcript (firmware/test/native/golden/console.transcript, docs/testing.md) held every byte on the wire the same through the three steps. The deviation that recorded the formatter (D2) went with it, and so did the dead conversions it left (scpi::formatScaled(), scale::formatThousandths(), chars::decimalDigit()).
  • 8.2.10, no recursion (FW-21). clang-tidy's misc-no-recursion finds none and suppresses none (tests/firmware/test_misra_rules.py fails a NOLINT naming it anywhere under firmware/). The one recursive function, matchFrom() (firmware/src/scpi.cpp), the header matcher that tries each optional node of a pattern present and then absent, is an iterative backtracking search over a fixed stack of kMaxSegments + 1 levels, one per pattern node, in the order the recursion tried them, so every match and its suffix are what they were (the parser's tests unchanged); the deviation that recorded it (D4) went with it.
  • 7.0.4, in the sign extension (FW-21, by reading). scale::decode20() and scale::decode40() extend the sign of a register's 20 and 40 bits in unsigned arithmetic, by flipping the sign bit and subtracting its weight, where they shifted a signed value right; the scale tests are unchanged, and two more hold the bits above the field ignored. The rest of the tree is not claimed under 7.0.4, whose list of appropriate operands is not on MathWorks' page; the narrow unsigned operands its bitwise and shift operators promoted to int are gone with 7.0.5 (FW-23, above).
  • 21.6.1, 21.6.2 and 21.6.3: no dynamic memory, allocs_since_main=0 frees_since_main=0 for every operation (0.7.0 for the firmware's own code; FW-17 for everything that runs from app_main()'s first line, ESP-IDF included, the boot too; FW-19 for every operation the SCPI table offers, on the host and through the call graph). What ESP-IDF allocates before that line is D1, row by row. No new, delete, smart pointer, allocating container (std::vector, std::deque, the lists, maps and sets), std::string, std::function, C or heap_caps allocator, or dynamic FreeRTOS create anywhere in firmware/src; std::array and std::span, which allocate nothing, are used. The sampler's queue and four semaphores are xQueueCreateStatic / xSemaphoreCreateBinaryStatic over storage the Sampler holds; the one task the firmware creates, the sampler's, is xTaskCreateStaticPinnedToCore over a stack and control block the Sampler holds, and ESP-IDF's startup tasks are made by the same call in startup_memory.cpp's wrap (src.static_tasks under "The counts"), and the console runs on ESP-IDF's main task, which app_main() never leaves, whose stack and control block are static slots its creation is linked wrapped onto (startup_memory.h, D1's review of 2026-11-24); the TRACE ring is a static 4 MiB array in PSRAM (EXT_RAM_BSS_ATTR, app_main()) handed to Sampler::begin(); the five objects are constinit statics. No deviation for the firmware's own code. Three gates hold it, cheapest first, a fourth holds what ESP-IDF allocates for it, and a fifth what any of it can reach:
    1. Source gate (tests/firmware/test_no_dynamic_memory.py, every run): the sources with comments and strings removed hold none of those constructs; the allow-list is empty and a planted case of each proves the gate sees it. It also holds the ring's declaration to no initializer, which .ext_ram.bss (a NOLOAD section) would drop without a word.
    2. Object gate (scripts/check_heap_objects.py, CI's firmware job): nm --undefined-only over every object of the firmware's component finds no reference to malloc, calloc, realloc, free, the heap_caps_* allocators, pvPortMalloc, vPortFree, a dynamic FreeRTOS create or any operator new / operator delete, so nothing a header or the compiler inserted allocates either; the count per image is in the job summary.
    3. The counts since app_main() (heap_monitor.cpp, DIAGnostic:HEAP?): with CONFIG_HEAP_USE_HOOKS, ESP-IDF calls esp_heap_trace_alloc_hook and esp_heap_trace_free_hook from every allocation and free in the image, whatever task or interrupt makes it; the firmware counts them from the first hook call, split at app_main()'s first line, whose first statement arms the monitor (pre_main_allocs, pre_main_frees, allocs_since_main, frees_since_main; FW-07, FW-17), and the claim is both since-main counts at 0 after every operation. On the host, firmware/test/native/test_heap.cpp runs the every-command session (kEveryCommand, then kLastWord: every header of the console's kCommands at least once, tests/firmware/test_heap_session_covers_the_table.py failing a header left out and a unit the table does not have; the saves of the tag, the date, the VBUS side, the shunt on each range and a null; *RST, *TST?, the watchdog's query, a scan, register reads, the lead cycle, the charge reset, the STATus subsystem, every capture profile with a ring dump, and the watchdog's forced reset as the last word) and requires both counts at 0 after each message, with another session of each profile, a full ring, a null and 500 queries; the fakes of the ESP-IDF drivers do not allocate as the real ones do, so those counts cover the firmware's own code, what the drivers would allocate is the ledger's (item 4) and the call graph's (item 5), and the device's evidence is the bench session (below).
    4. What ESP-IDF allocates on the firmware's behalf (FW-08): the deny list of the ESP-IDF entry points that allocate or free on the device (a driver's install and delete, NVS's init, open and writes, the task watchdog's subscriptions, the interrupt allocator, the partition and flash calls whose region check takes an iterator, and the rest the lists name with their reasons), the allow-list of the calls the firmware still makes, each tied to D1 below (empty since FW-16), and the made-safe list (FW-16: esp_flash_write() and esp_flash_erase_region() from flash_port.cpp, which stay on the deny list because they allocate in ESP-IDF's default configuration, and allocate nothing in this image: their region check is linked wrapped onto a static table and CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED leaves out the other; and, from the review of 2026-11-24, esp_flash_read(), which reads into a destination outside internal RAM through a bounce buffer it takes from the heap (get_temp_buffer), and which flash_log::port::read() never hands one: it refuses a destination esp_ptr_in_dram() rejects before the call, and a host test plants one), are held by the source gate (by source file), the object gate (by object) and the host tests' ledger (firmware/test/native/harness/idf_ledger.h: every fake of a listed entry point records its call, and every Bench and Scope fails a case that called one outside the allow-list), each of which fails a planted call in its self-test. tests/firmware/test_idf_allocation_lists.py holds the three equal, every allowed call to the deviation that names it, and their history to an allow-list that only shrinks; the zero-allocation work packages take entries off it as they replace the drivers behind them.
    5. What any of it can reach (FW-19, scripts/check_heap_reachability.py, CI's firmware job): the linked image's call graph, built from the relocation records the device link keeps (-Wl,--emit-relocs, firmware/CMakeLists.txt; the loaded bytes are the same), with every function of the firmware's own objects as a root, whether anything calls it or not, must reach no allocator. It sees what the other gates cannot: an allocation two calls deep in ESP-IDF behind a call the firmware makes, through a callback or a table, or through a link-time wrap. On 2026-11-23's image it walked 359 own functions to 661 functions and objects and 17 ROM functions, and met four cuts, each an edge from picolibc's stdin and stdout FILE objects (which every task's TLS template points to) to their close and setvbuf operations, which run only from a C stream function that nothing the walk reaches calls (the gate fails once one is reachable). Since the review of 2026-11-24 it reads the long calls the linker relaxed (HM2-01), which it had missed: then the FILE objects' put and get operations, which allocate their buffer on first use through calloc(), are cut the same way (eight cuts in all, their guards the C library's formatted and character input and output as well as its stream functions), and so is TLSF's default walker, which prints each block and which tlsf_walk_pool() takes only for a null walker, its one caller in the image, multi_heap_get_info_impl(), passing its own; on the image of that review it walked 387 own functions to 891 functions and objects and 24 ROM functions. Since the review of 2026-11-24 it also walks the flash calls through the three tables ESP-IDF's startup installs on the default chip before app_main(): its os functions (esp_flash_spi1_default_os_functions, set by esp_flash_app_enable_os_functions()), its chip driver (one of default_registered_chips, picked by detect_spi_flash_chip()) and its host's driver (esp_flash_default_host, set by memspi_host_init_pointers(), HM2-02). Each esp_flash_* call the firmware makes gets an edge to each by name (RUNTIME_EDGES, stale when the image lacks a name), so the made-safe calls are walked to the flash's command layer (spi_flash_chip_generic_*, memspi_host_*, spi_flash_hal_*, and the ROM's Cache_Invalidate_Addr, listed as a leaf), to their region check (the wrapped one) and to their bounce buffer, whose allocation and free are cut with the reason (a read into internal RAM only) and fail the gate once one of ESP-IDF's other flash readers is reachable. Before, the table was installed by startup code, which is not a root, and the made-safe test held only because the walk could not see the path. Its blind spots are stated in the script: the ROM's code is not read (each ROM function reached is listed with why it allocates nothing), an address made at run time from something other than a relocated value, or a table installed by code that is not a root and not named in RUNTIME_EDGES, is not an edge, and what runs with no own caller (ESP-IDF's startup, its IPC and idle tasks, its tick and cross-core interrupts) is not a root, which is what the device's counts are for.

Deviations

Each is a known departure, kept on purpose. A deviation is removed from this list by the change that removes it from the code. D2, the formatted output of console_commands.cpp (21.10.1, 30.0.1), went in FW-26 with the formatter rewrite ("Held"); its number is not reused, as D4's and the maintenance operations' were not.

D1. Allocation by adopted code: ESP-IDF before app_main() (21.6.1, adopted code)

The firmware's own code allocates nothing, and from app_main()'s first line nothing allocates or frees at all, the boot included (FW-17). Nor does ESP-IDF's startup before that line, which the firmware does not run: no allocation and no free since the review of 2026-11-24 (DIAGnostic:HEAP?'s pre_main_allocs=0 pre_main_frees=0 on its plain image). FW-18 left 16 allocations and 4 frees, 17,380 bytes; three link-time wraps took fifteen and every free, and a fourth, of malloc(), the last, the C library's 4-byte environ ("How the allocations left", "What the review of 2026-11-24 took off"). JSF AV C++ (Rule 206 as commonly quoted: no allocation or deallocation after initialization; the wording is from memory and unconfirmed) states the model; MISRA C++:2023's rule has no initialization exemption in its text, so the residue is recorded here, one row per allocation, with why neither a configuration option, a link-time wrap nor an own driver on ESP-IDF's low-level layer removes it. tests/bench/heap_expectations.toml holds the device to exactly these counts ([boot], read by every bench session: an ESP-IDF bump that changes one fails it), and tests/bench/test_bench_support.py holds that file to this table (its rows and its freed rows). D1 holds these rows and nothing else: every allocation from app_main()'s first line on left the register with the work package that removed it (FW-09 to FW-17), and the count before that line fell from 39 and 4 at FW-07's census to 35 at FW-11's, 31 at FW-16's, 16 at FW-18's, 1 at the review of 2026-11-24's wraps of the startup and 0 at its wrap of malloc() (HM2-04), where the move to ESP-IDF 6.1.1 keeps it: that release's startup creates four more objects, which the image links wrapped onto static slots as the others ("What the move to ESP-IDF 6.1.1 added"); "How the allocations left" (below the census) says what each work package took off.

The residue

No row. The last one, R1, was esp_libc_init()'s environ = malloc(sizeof(char*)) (esp_libc/src/picolibc/picolibc_init.c:119), 4 bytes, the census's only event of the review's first commit. Its reason ("a wrap of `malloc` would serve every allocator call in the image rather than this one") did not hold: the image's only caller of malloc() with a relocation left is esp_libc_init() (ESP-IDF's heap.c makes its calloc() and heap_caps_malloc() from the heap directly, and ESP-IDF's __wrap___bufio_setvbuf() is never called, a cut of the reachability gate), and the wrap answers that one request alone, as the startup's other wraps do: -Wl,--wrap=malloc sends it to __wrap_malloc() (firmware/src/startup_memory.h), which serves one pointer from a static word, once, and refuses any other request with null. The C library's malloc() then leaves the image (the reachability gate's CORE_SINKS name calloc() in its place). A table row would be added back here, with its reason, by an ESP-IDF bump that allocates before app_main() again; tests/bench/heap_expectations.toml's [boot] would fail first.

D3. C arrays (11.3.1, advisory)

Buffers, tables and the anchor and mark arrays are C arrays of fixed size: 48 of them (d3.arrays in "The counts": variables, members and parameters of array type), from 137 before the formatter rewrite (FW-22 to FW-26) and 71 before the review of 2026-11-24, which made the command handlers' keyword tables, the reset reasons, the powers of ten, the INA228's conversion-time and averaging tables, the month lengths, a channel name's buffer and the MAC std::arrays, and formatSerial()'s MAC a fixed-extent std::span. The count is a ratchet since then (tests/firmware/test_ast_census.py, as d3.decays is): a change may lower it, never raise it. The 48 left are kept, not needed: the rule is advisory, and a std::array would take each place with no change to what the code does. Each class has its own obstacle to a mechanical change: the command table (kCommands, kCensusCommands) is read as written by scripts/scpi_table.py; the calibration record's members are its stored layout, held by static_asserts on their offsets; the console's, the sampler's and the error queue's character buffers are read through chars::untilNul() and its array-reference overload, which the buffers and heldOrAbsent() take by reference; the profile table is DRAM_ATTR and read on the IRAM hot path, which scripts/check_iram_hot_path.py holds to no call into flash; and SHA-256's state and schedule, and the serial's text, are fixed-size parameters of their own functions. Each class goes with its own change, and the ratchet holds what is gone. modernize-avoid-c-arrays, cppcoreguidelines-pro-bounds-pointer-arithmetic and cppcoreguidelines-pro-bounds-constant-array-index are off (.clang-tidy). Every index is checked against the array's size or a static_asserted bound where it is computed. None of them decays to a pointer any more (7.11.2, held since FW-26): a buffer reaches the bounded writer of text.h or write() as a std::span, a character array a view as chars::untilNul(), a table a search as a std::span, and an ESP-IDF or driver call that takes a pointer and a length (uart0::read(), esp_efuse_mac_get_default(), the I2C transfers) gets a std::array's data() and size() or a span's; clang-tidy's cppcoreguidelines-pro-bounds-array-to-pointer-decay runs with no finding in either leg. scripts/ast_census.py counts both from clang's AST over the image's translation units, each place once however many units include it: the C arrays and the array-to-pointer decays of a call's or a construction's argument (d3.decays, 0, a ratchet: tests/firmware/test_ast_census.py fails when the sources hold another number than "The counts" and when the number written there rises over this page's history; it fell from 211 at FW-21 to 196 with the parser's views, 194 with FW-24's four modules, 132 with console.cpp and 0 with FW-26). String literals passed the same way are counted apart (d3.literal_decays), because MathWorks' reading of 7.11.2 exempts a string literal passed to a char pointer, and clang-tidy's check does too; to confirm against the owner's copy. From FW-22 a string literal that initializes a std::string_view (the command table's patterns, the keyword lists, the profiles', relays' and errors' names) is counted there too, as the view's constructor takes it as a pointer, and every piece of constant text the writer appends is one (w.text( " (" ), w.field( "samples", n )): 325 at FW-21, 618 after FW-25, 772 after FW-26, 768 after FW-27, which took the stream's unreachable byte-rate refusal and its four pieces of text away, and 763 after FW-29, whose five range refusals (*ESE, *SRE, the two status enables and DIAGnostic:REGister?) name their usage once, in a constant, for both their refusals; 764 at 0.17.0, 779 after 0.18.0's FW-01, whose pin table (pin_table.h) names its five roles and whose pin map (pinmap.h) names its eight problems and the address's and the clock's keys as views, and 855 after FW-02, whose pin map commands name their keys, keyword lists, usages and the words of a map's report, and whose averaging settings name their usages. A std::va_list, an array on the host and a struct on the Xtensa target, was not counted while one was left. Kept because std::array and std::span would take the remaining arrays' places one by one with no change to what the code does; the advisory rule is recorded rather than chased.

D5. Return values discarded on purpose (0.1.2)

A call whose result the code has no use for is cast to void, never left bare (FW-02: bugprone-unused-return-value with every function checked and the cast as the only way out). Every such call, d5.void_casts in all ("The counts"), is counted below by the function it calls, each with why its result is not needed; tests/firmware/test_misra_register.py fails a function with no row, a row nothing casts any more and a count that moved. A function called on an object is written with a leading dot, whatever the object.

The discarded results, by the function called

Function Count Why
.begin() 1 gRelays.begin() in app_main(): a bank that did not come up is read back from the bank (relay::Bank::ready()), which the console reports and which refuses every relay order
.fetch_add() 7 an atomic counter's increment (the sampler's edge, read-failure and stale-edge counts, the heap hooks' counts): the value before the change is of no use to a counter
.fetch_or() 3 an atomic flag set (the sampler's diagnostic flags, the watchdog's subscriptions): the flags before the change are of no use
.finishZero() 1 *RST closing a null window it abandons: the result is discarded on purpose, as the window is
.load() 1 gCalibration.load() in app_main(): a log with no record it takes keeps the defaults, which report q=uncal
.readDiagAlrt() 5 a DIAG_ALRT read made for its side effect, releasing the ALERT pin and clearing the conversion-ready flag; its value is not used, and a bus that failed it fails the reads that follow, which report it
.setBusSpeed() 2 *RST restoring the reset clock, and a reverted apply restoring the running one: a refusal leaves the clock the console reports (Ina228Driver::busSpeedHz())
.setProfile() 3 *RST, SENSe:PROFile and Console::selectBusProfile() choosing a profile when no capture is open, which is the only refusal (the command table's R flag has raised it already)
.setRange() 1 an apply putting back the range the INA228's reset cleared: a refusal leaves the range the console reports (Ina228Driver::range()), and the self-test that follows reads the part
.setThreshold() 3 the threshold commands, whose one refusal for a level (a capture open) the table's R flag has raised, and whose other (a negative hysteresis) the command's own bound has
.setThresholdMarks() 2 as .setThreshold()
applyRangeParameter() 1 the command it serves reports its own refusals inside the call
gpio_config() 1 parking an unused pin: one that does not park stays as reset left it, and the others are parked by their own calls
gpio_set_level() 3 the relay outputs' latch, written before and after the pad is configured; the pad's real level is read back (padMismatches())
identity::readSerial() 1 an eFuse MAC that cannot be read leaves the serial 0, which the console reports as it is
maskParameter() 4 the STATus mask setters, which report a refused parameter inside the call
mountLog() 2 a log that does not mount is mounted again at the store's next call, and reported as q=uncal meanwhile (the calibration's); the pin map's save reads the sectors again itself, and fails if that read fails too
push() 1 the I2C command list's last entry, whose index the list's length bounds by construction
recover() 3 the I2C master's recovery after a time-out, a fault or a held bus: the transaction reports the time-out either way, and the next one finds the bus as the recovery left it
readShuntPicovolts() 2 an apply's rest check reading the shunt before and after a relay move: a reading that fails leaves the stored null in its place, a share of nothing, which is not judged before the move and puts the map back after it
reportFunction() 8 the measurement queries, which answer or fail inside the call
selectRange() 2 *RST and the range command, which report a refusal inside the call
parseNumber() 2 the whole and the fractional digits of a decimal parameter (scpi::Parameters::scaled()), each a run of digits whose significant ones the call before has bounded to 18, which fit 64 bits; an empty run leaves its 0
std::copy() 2 the end iterator of a copy whose length each site already holds
std::copy_n() 12 as std::copy()
uart0::takeOverrun() 1 the console's start empties the receive ring and takes its overrun with it: what came before the announcement is discarded, a loss in it included
waitUntil() 2 the sampler's settling waits before a capture and a pace probe: the time the wait was entered, which it returns, matters only to the paced loop that reads it
watchdog::begin() 1 a watchdog that did not start is read back by watchdog::subscribed(), which DIAGnostic:WATChdog? reports
watchdog::subscribe() 2 as watchdog::begin()
xSemaphoreGive() 4 a give to a binary semaphore that may already be given, which a waiter takes once either way
xSemaphoreGiveFromISR() 2 as xSemaphoreGive(), from the ALERT and UART0 interrupts
xSemaphoreTake() 6 a take with no wait that forgets a stale give, or a bounded wait whose end the code reads from the data, not from the result

D6. ESP-IDF configuration structs zero-initialized (withdrawn in FW-14; no rule; adopted headers)

No site is left, and the number is kept so that D7 keeps its own; D4, the one recursive function (8.2.10), went in FW-21 with the recursion, and its number is not reused either. The number after D7 was the maintenance operations' deviation, removed in FW-16 with the last of them; it is not reused, so the deviations FW-20 added start at D9. An ESP-IDF driver's configuration struct was value-initialized with = {} and then every field the firmware needed was assigned; its enums have no zero enumerator, which bugprone-invalid-enum-default-initialization reports, and each site carried a NOLINT. FW-10 removed rmt_tx_channel_config_t with the RMT driver, FW-12 uart_config_t with the UART driver and FW-14 the last, i2c_master_bus_config_t, with the I2C master: the own drivers set their peripherals on the registers and fill no ESP-IDF configuration struct.

D7. Names fixed by others (no rule; naming)

app_main is the name ESP-IDF calls, RMTMEM (status_led.cpp, FW-10) the symbol ESP-IDF's ESP32-S3 linker script gives the RMT's RAM (esp32s3.peripherals.ld), which only its RMT driver's private header declares, the __wrap_* functions (__wrap_esp_partition_is_flash_region_writable() in flash_port.cpp; __wrap_psa_crypto_init(), __wrap_vApplicationGetIdleTaskMemory(), __wrap_xTaskCreatePinnedToCore(), __wrap_xQueueCreateMutex(), __wrap_xQueueGenericCreate(), __wrap_esp_intr_alloc() and __wrap_malloc() in startup_memory.cpp; scripts/misra_register.py holds this list to the functions the sources define) carry the names the linker's --wrap option gives a replacement, reserved identifiers by the language's rules, and the one-letter flag aliases D, R, C, N in Console::execute() are the letters of docs/scpi.md's Flags column, so the command table reads as that page does. Each carries its NOLINT ("Tool suppressions").

D9. Static locals (6.7.1)

The firmware's objects have static storage, so that nothing is allocated and nothing needs a constructor order across files, and each lives inside the one function that hands out references to it, so that none is a global (6.7.2, "Held"). That is exactly what 6.7.1 forbids: a local variable of static storage, const and constexpr objects excepted (MathWorks' reading). The table is every one of them; scripts/misra_register.py reads them from the sources (a static in a function body, const and constexpr objects excepted) and tests/firmware/test_misra_register.py fails one the table does not list and a row the sources no longer hold. Each is constinit but the reset record and the TRACE ring, which are placed in sections the startup does not zero or fill (D11, EXT_RAM_BSS_ATTR), so none has a guard or a constructor that runs at first use. Kept because the alternative the rule leaves, an object at namespace scope, is what 6.7.2 forbids, and a heap object is what 21.6 does.

The static locals

File Function Object Why
flash_log.cpp state instance each record log's state, one per flash_log::Log (the calibration's and, from FW-03, the pin map's): the base address, the newest record, the Acceptor and the static buffer its reads and writes use
heap_monitor.cpp state instance the heap hooks' counts and the census ring, written from any task or interrupt that allocates, so they exist before the first hook call (before app_main())
i2c_bus.cpp state instance the own I2C master's state: the clock, the core it runs on and the transaction in flight
main.cpp app_main gCalibration one of the six objects of the instrument (docs/architecture.md §5.1): the calibration store
main.cpp app_main gConsole the console, which runs on the main task app_main() never leaves
main.cpp app_main gDevice the INA228 driver
main.cpp app_main gPins the pin map the boot runs, read before a pin is driven (FW-04)
main.cpp app_main gRelays the relay bank
main.cpp app_main gRing the TRACE ring, 4 MiB in PSRAM (EXT_RAM_BSS_ATTR), handed to Sampler::begin()
main.cpp app_main gSampler the sampler, its tasks' stacks and control blocks inside it
relay.cpp detail::resetRecord kept the relays energized when the last reset came, kept across it in RTC memory (D11)
startup_memory.cpp state instance what ESP-IDF's startup is served before app_main() (D1, "What the review of 2026-11-24 took off"): the idle tasks' stacks and control blocks, handed out by the wrapped vApplicationGetIdleTaskMemory(); the IPC tasks' and the main task's static slots, created by the wrapped xTaskCreatePinnedToCore(); the flash lock's StaticQueue_t and, from ESP-IDF 6.1.1, the SPI1 flash API's two plain mutexes', made by the wrapped xQueueCreateMutex(); the mmap lock's two binary semaphores' StaticSemaphore_t, made by the wrapped xQueueGenericCreate(); and the records of what each has handed out, the startup interrupts the wrapped esp_intr_alloc() routed included
uart0.cpp state instance the console's UART: its receive ring, its flags and its semaphore, written by its interrupt
watchdog.cpp state instance the own watchdog's check-in mask, written by the console, the sampler and Core 0's idle hook

D10. What C++17 does not have (4.1.1)

MISRA C++:2023 is written against C++17 and 4.1.1 asks a program to conform to it. The firmware is built as -std=gnu++26 (firmware/CMakeLists.txt; the host tests as -std=gnu++2c, the same language), GCC's dialect of C++26, and uses the constructs below that C++17 does not have: C++20 keywords and library names, GCC's attributes, and ESP-IDF's attribute macros, which expand to GCC's section attribute. Each is used for a reason the image cannot do without at the same cost: constinit proves at compile time that a static has no dynamic initialization (D9), consteval that an RMT word, the character table of chars.h (7.0.3), the CRC-32 table and the command table's parameter counts are computed at compile time, std::bit_cast replaced the byte copies of 21.2.2, starts_with() and ends_with() compare a view's ends where strncmp() did (21.2.2), std::span carries a buffer with its length, [[gnu::noinline]] and noinline keep a frame where the stack bound and the census need it, and the section macros place code and data where the hardware needs them (IRAM_ATTR for code that runs while the flash cache is off, DRAM_ATTR for a table an IRAM path reads, EXT_RAM_BSS_ATTR for the ring in PSRAM, RTC_NOINIT_ATTR for D11's record). scripts/misra_register.py lists every construct of firmware/src that C++17 does not have, with the sources it is in, and tests/firmware/test_misra_register.py fails a construct the table does not list (an attribute, a keyword, a header or a library name), a row no source uses any more, and a row whose files moved; the script's lists of what to look for are its blind spot, and a construct it does not know is not seen.

What C++17 does not have

D11. The relay bank's reset record (4.1.1; 6.7.1 as D9)

relay::detail::resetRecord() (firmware/src/relay.cpp) returns a static ResetRecord placed with RTC_NOINIT_ATTR in RTC slow memory, which ESP-IDF's startup neither zeroes nor initializes, so that the coils energized when a reset came survive it and ROUTe:STATe? can say which relays the reset released (released_by_reset=, 0.16.0). The language zero-initializes every object of static storage before anything else runs; the attribute suspends that, which is a departure from the standard (4.1.1) and the reason the object has no initializer (one would be dropped without a word). The program reads, at every boot, a value it did not write in this run: on a power-on the memory holds noise, after any other reset what the previous run left. It is judged before it is used: Bank::begin() reads it only after a reset other than a power-on (esp_reset_reason()), takes it only when recordWhole() finds the magic word and the energized mask's complement beside it, and otherwise reports that no relay was released; it then overwrites the record whole before any relay is driven. In the abstract machine the object is zero-initialized and is set before it is read, so whether a checker would report the read under 11.6.2 (Mandatory, which MISRA Compliance:2020 lets no deviation cover) is to confirm against the owner's copy; what this page records is the attribute and the judged read. The record is also one of D9's static locals.

D12. What 7.0.5's reading passes, to confirm against the owner's copy (7.0.5)

The gate ("Held") reads 7.0.5 as clang writes the conversions, and finds nothing in the image. Two things it passes, and one it does not read, are recorded here, because MathWorks' page lists no exception and does not say how its checker reads them; each is to confirm against the owner's copy of the standard:

  • A narrow unsigned operand that meets a wider unsigned one (flags & kMask with flags a std::uint8_t and kMask a std::uint32_t). The language promotes the narrow operand to int first and then converts it to the unsigned type; clang writes the two steps as one conversion, unsigned to unsigned, and the gate reads no change of signedness. The value never passes through a negative int. This is the shape FW-23's std::uint32_t masks give every flag test and field read on a register value, d12.widened_operands in "The counts" (held by tests/firmware/test_misra_rules.py); a reading that counts the intermediate promotion would report each, and the remedy would be an explicit static_cast<std::uint32_t> on each narrow operand, or the narrow members widened at their declaration.
  • An integer literal is an operand like any other. A literal of type int that meets an unsigned operand is reported and was suffixed (318 of them), although its value is never negative; if the rule's text exempts a non-negative constant expression, those suffixes are harmless and stay.
  • Not read: an enumeration's promotion (its underlying type is not looked up), and a conversion inside a macro's expansion, which for ESP-IDF's and FreeRTOS's macros is adopted code (RMT_LL_MAX_LOOP_COUNT_PER_BATCH, U0TXD_GPIO_NUM and the other macros the sources compare are cast where they are used).

D13. A callback's context cast from void* (8.2.6, required)

ESP-IDF's IPC call (esp_ipc_call_blocking()), its interrupt handlers (intr_handler_t, which the firmware's own router keeps for its table, interrupt.h) and FreeRTOS's task entry (TaskFunction_t) each take a function of void ( void* ) and hand it back the pointer the caller registered with it. The callee casts that pointer back to the object it was given, which 8.2.6 forbids: a void* cast to a pointer type. The signatures are ESP-IDF's and FreeRTOS's, not ours to choose (as D7's names are not), and each callback is registered with exactly one type of object, in the same file, so the cast restores the type the pointer had. Replacing the pointer with a static accessor would not fit every site: Ina228Driver::makeCall() serves a request on the caller's stack, a different one each call, and the host tests build more than one Sampler. scripts/misra_rules.py counts every such cast (d13.void_pointer_casts under "The counts") and tests/firmware/test_misra_rules.py holds the casts it finds to these rows, file for file; a cast from an integer or an enumeration is a finding ("Held").

File Function Registered with What the context is
ina228.cpp Ina228Driver::makeCall() esp_ipc_call_blocking() the BusRequest on Ina228Driver::onBusCore()'s stack
main.cpp bootOnSamplerCore() esp_ipc_call_blocking() app_main()'s SamplerCoreBoot
pin_apply.cpp onBusCore() esp_ipc_call_blocking() the move's half pin_apply::moveTo() keeps on its stack
sampler.cpp Sampler::alertIsr() interrupt::routeHere() the Sampler whose ALERT line it is
sampler.cpp Sampler::taskEntry() xTaskCreateStaticPinnedToCore() the Sampler whose task it is

Tool suppressions

Every place a static analyzer is told not to report, under firmware/ and in .cppcheck-suppress. scripts/misra_register.py reads them (a NOLINT, NOLINTNEXTLINE or NOLINTBEGIN comment with the checks it names, * for none; a cppcheck-suppress comment; an entry of the list) and tests/firmware/test_misra_register.py fails one with no row, a row nothing matches any more, a count that moved and a row with no reason. cppcheck's --inline-suppr honors the comments, and its unmatchedSuppression would report one that matches nothing if the run enabled the information severity, which the firmware repository's flags do not; a stale comment is found here instead.

File Marker Checks Count Why
.cppcheck-suppress list missingIncludeSystem 1 the standard and ESP-IDF headers are not given to cppcheck, which reads the host harness's fake ESP-IDF for the project's own includes only; an information check the run does not enable, kept as the firmware repository keeps it
.cppcheck-suppress list shadowFunction 1 a parameter named after the accessor of the value it carries (setProfile( Profile profile ) beside profile()) hides no variable: -Wshadow, which the compiler gates, and 6.4.1 are about variables
.cppcheck-suppress list unmatchedSuppression 1 an inline suppression that a later fix made unnecessary is not cppcheck's error; it is this table's, which fails a stale row
.cppcheck-suppress list useStlAlgorithm 1 a raw loop over a fixed table is kept where an algorithm would hide a bound or an early exit the code relies on
firmware/src/console.cpp NOLINTBEGIN readability-identifier-naming 1 the one-letter flag aliases D, R, C, N of Console::commands(), the letters of docs/scpi.md's Flags column (D7)
firmware/src/console.h NOLINT clang-analyzer-optin.performance.Padding 1 Console's members stay grouped by role, as the reference documents them, not sorted by alignment; the one static instance spends the padding (the quality kit's analyzer, from the kit 3 switch)
firmware/src/console_commands.cpp cppcheck-suppress constParameterReference 1 a command handler that does not write its Call still has the table's Handler type
firmware/src/flash_port.cpp NOLINTNEXTLINE bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming 1 __wrap_esp_partition_is_flash_region_writable(), the name the linker's --wrap gives the replacement (D7)
firmware/src/flash_port.h NOLINTNEXTLINE bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming 1 its declaration
firmware/src/heap_monitor.cpp cppcheck-suppress constParameterPointer 2 the heap hooks' parameters, whose signatures are ESP-IDF's
firmware/src/main.cpp NOLINT readability-identifier-naming 1 app_main, the name ESP-IDF calls (D7)
firmware/src/sampler.h NOLINT clang-analyzer-optin.performance.Padding 2 CaptureStats in the order FETCh:STATistics? reports it and Sampler's members grouped by role, not sorted by alignment, for a few bytes of static RAM
firmware/src/scpi.cpp NOLINT bugprone-branch-clone 1 two ways to a zero magnitude kept apart on purpose: a zero mantissa, at any exponent, and a value below the unit's resolution
firmware/src/startup_memory.cpp NOLINTNEXTLINE bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming 7 __wrap_psa_crypto_init(), __wrap_vApplicationGetIdleTaskMemory(), __wrap_xTaskCreatePinnedToCore(), __wrap_xQueueCreateMutex(), __wrap_xQueueGenericCreate(), __wrap_esp_intr_alloc() and __wrap_malloc(), the names the linker's --wrap gives the replacements (D1, D7)
firmware/src/startup_memory.h NOLINTNEXTLINE bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming 7 their declarations
firmware/src/status_led.cpp NOLINTNEXTLINE readability-identifier-naming 1 RMTMEM, the linker script's name for the RMT's RAM (D7)
firmware/test/native/harness/sim.cpp NOLINTNEXTLINE readability-identifier-naming 1 the host harness's definition of RMTMEM, the same name

The counts

Every count this page states about the sources, read by a script and compared by a test: scripts/misra_register.py and tests/firmware/test_misra_register.py for the textual ones, scripts/ast_census.py and tests/firmware/test_ast_census.py for those of clang's AST. A change that moves one updates it here in the same commit; d3.decays may only fall.

Key What Count
d3.arrays C arrays declared: variables, members and parameters of array type (D3, 11.3.1), a ratchet 48
d3.decays arrays that decay to a pointer as a call's or a construction's argument (7.11.2), the ratchet 0
d3.literal_decays string literals passed the same way, counted apart (D3) 887
d5.void_casts calls whose result is cast to void (D5) 91
d12.widened_operands narrow unsigned operands converted in one step to a wider unsigned type (D12, scripts/misra_rules.py) 65
d13.void_pointer_casts casts of a callback's void* context to an object pointer (D13, 8.2.6, scripts/misra_rules.py) 5
src.sources translation units of firmware/src/CMakeLists.txt, each read by the compile-flag test and both clang-tidy legs 23
src.static_tasks calls of xTaskCreateStaticPinnedToCore in firmware/src, each over static memory (21.6.1): the sampler's task, and the wrap that makes ESP-IDF's IPC and main tasks 2
src.lambdas lambda expressions written in firmware/src, each naming what it captures (8.1.2, scripts/ast_census.py) 6

The claim on the device: the bench session

The host session proves the firmware's own code against the harness's fakes, and the reachability gate what the image can call; the claim itself, allocs_since_main=0 frees_since_main=0 for every operation, is proven on the instrument. Its run of record is the release's ("The run of record", below); a change that can move a count runs it on its own image before it is merged. The procedure, on the meter with a DUT drawing through the shunt, with the bench lock held (docs/testing.md):

  1. host/.venv/bin/python -m pytest -q -W error tests/bench --run-bench --meter-port "$KLEIDOS_METER_PORT" --bench-lock <lock> --bench-long --bench-record <file> --bench-session-record <file>. The heap sweep (tests/bench/test_heap_sweep.py) reboots the meter through the carrier's auto-reset, waits for the power-on bit and reads DIAGnostic:HEAP?: armed=1, pre_main_allocs and pre_main_frees equal to D1's rows and its freed rows ([boot] of tests/bench/heap_expectations.toml, which tests/bench/test_bench_support.py holds to the table), and allocs_since_main, frees_since_main, allocs_after_init and frees_after_init at 0.
  2. Every command family of docs/scpi.md (SWEEP of tests/bench/bench_support.py: the common commands with *TST?, SYSTem, STATus, SENSe with the charge reset, the ranges, SAMPle, FORMat and TRIGger, CONFigure, MEASure, READ and FETCh, a capture of each profile with a mark, the ring's RAW and SCALed dumps, two clock changes, the calibration reads, a calibration save that changes the record and writes it back, a null with its save, DIAGnostic with a scan and register reads, the relay orders, 500 SYSTem:STATus? and *RST), each followed by a DIAGnostic:HEAP? that must read the four since-main keys at 0 and the pre-main counts unchanged; the console's stack must keep 0.16.6's margin after it.
  3. The rest of the suite on the same image: 20 calibration saves that change the record and a reboot (test_calibration_bench.py), three clock changes and every profile at its clock (test_i2c_bench.py), the watchdog's forced reset, a 600 s idle and a full TRACE ring with its dump (test_watchdog_bench.py), the console's line under load and a provoked overrun (test_uart_bench.py), the pin map applied, put back, moved and defaulted (test_pins_bench.py, 0.18.0) and the averaging override on and off (test_averaging_bench.py, 0.18.0), each reading the heap counts where it moves a state.
  4. The session on one boot (test_heap_session.py, --bench-long): step 2's families again and a full TRACE ring with its whole RAW and SCALed dumps, with no reset in between; DIAGnostic:HEAP? at its end reads both since-main counts at 0 and the pre-main counts D1's.
  5. The panel's bench test (host/tests/test_panel_bench.py --run-bench, host/README.md): the same counts unmoved under kleidos-meter serve, a 10 s STATE capture whose every sample reached the live events (the rows the Server-Sent Events carried equal FETCh:STATistics?'s samples, with dropped=0), a null on the relay path and a TRACE ring decoded on the host; then, from 0.18.0, the same serve from its page in a headless Chromium (run_page_scenario): the Pins view drawing the live map, SDA moved to an unwired pin applied from the page and put back by the instrument with its sentence and 117, the live chart at 100 ms of smoothing on the meter's STATE samples, its readout's mean in view the capture's FETCh:STATistics? mean_na to the page's four digits, and a run recorded with the INA228's averaging on (AVG 16) named in its meta.json, the averaging off again.
  6. The record (--bench-record, --bench-session-record): fw, elf, serial, the boot's four counts, each family's change in the since-main counts (every one 0), and anything unexpected.

The run of record: 0.18.0

Status: passed on 2026-11-26 but for one case, that case passing alone four times on the same image. Firmware 0.18.0, image meter, built through the Kleidos firmware repository's scripts/pio-job in a clean clone of commit 90fafb7 (meter-next/integration, the tree tagged v0.18.0 but for the documents this run wrote), whose firmware/src is git tree ca4ba6e5b7c5063b, ELF SHA-256 80a257970e934ff61faca739d5b439cc08cf02d4f31faf980dda2e961a430293 (SYSTem:INFormation? elf=80a257970e934ff6), instrument KM-0000000000, the rig's wiring of hardware/rig.kicad_sch rev D with the T-Deck asleep drawing about 43 µA through the shunt. The upload built the tree again (the build stamps its date and time, so the clone's gate build had another digest, 7702094ee167ab23); the image gates (radio, retired drivers, heap objects, heap reachability, IRAM hot path, the version in firmware.bin) were run on both and passed on both.

  • The flash. Uploaded over the integration's image, the calibration partition kept: the first boot read q=cal, src=default, *TST? 0, DIAGnostic:HEAP? all four counts 0, and kleidos-meter calibration verify answered applied before the run and at its end, so no restore was needed.
  • The pin map first (test_pins_bench.py alone, before the suite): 9 of 9 in 96 s.
  • The suite (tests/bench --run-bench --bench-long): 71 cases; 70 passed in 37 min 51 s, among them the heap sweep (the boot's four counts 0, 0, 0 and 0, each of its 20 steps 0 allocations and 0 frees, no unexpected error), the pin map's (four wrong maps each put back with one 117 in 0.05 to 0.06 s; the DUT's current with GPIO7 driven high 42.47 µA, parked high 42.19 µA and parked low after a reboot 42.51 µA), the averaging override's (the null path's standard deviation 18.78, 4.89 and 2.59 µA at AVG 1, 16 and 64, pace_err_ppm 98 to 100, nothing dropped), the I2C bus at its three clocks, the line, the calibration saves, the watchdog's forced reset, the 600 s idle and the session on one boot (a full TRACE ring of 1,048,576 samples in 293.6 s, dropped=0 read_err=0 stale_edges=0, its RAW and SCALed dumps, 3,760,443 and 36,583,759 bytes, each whole at the first request, every count of the end 0 and every free figure as at the boot, stack_console=5792). The one failure was test_a_relay_moved_off_its_wire_fails_its_null_path_check_and_comes_back[relay1]: with Relay 1 stored on GPIO16, after the meter's reboot, the DUT's current read 21.83 µA against 43.02 µA before the move, 43.15 µA moved and 42.45 µA back, outside the 10 µA the test allows. The same test passed in the pin map's run before the suite (39.49 µA after the reboot) and in three runs of that file after it (43.69, 43.58 and 43.33 µA), and the suite's own case for GPIO7 parked low after a reboot read 42.51 µA, so Relay 1's input held released under GPIO7's pull-down there; why one 8 s capture read half the DUT's current was not found (the DUT's own draw, or Relay 1 under the pull-down at that boot, are the candidates), and nothing in the firmware's answers differed.
  • The panel (host/tests/test_panel_bench.py --run-bench --bench-shots, kleidos-meter serve on the same image, 9 of 9 in 60 s): HEALTH and NULL_RELAY done; a 10 s STATE capture of 8,732 samples, all 8,732 as rows over Server-Sent Events; a TRACE ring of 11,063 samples decoded on the host and equal to the instrument's SCALed dump; then the page in a headless Chromium: the Pins view drew the default map the instrument reported; SDA moved to GPIO18 was applied from the page and put back by the instrument ("Reverted: the INA228 did not answer on the map's SDA, SCL and address. The last good map is back.", 117); the live chart at 100 ms of smoothing on an 8 s STATE capture gave in its readout a mean in view of 43.24 µA against FETCh:STATistics?'s mean_na=43242.86; a run recorded with the INA228's averaging on named it in its meta.json (state=on count=16 conversion_us=1052 period_us=18432), and the averaging was off again after it; the page's self-test read "0: every part passes."; the six heap counts 0 at the start and at the end; the verdict applied at both. Its images of the Live, Pins and Calibration and health views are the bench images of “On the bench” in the panel's guide.
  • The state it was left in. *TST? 0 and SYSTem:ERRor:ALL? 0,"No error"; SYSTem:PINS? the default map (src=default verified=1) with nothing staged, SENSe:AVERage? 0, FORMat? TEXT, ROUTe:STATe? path=shunt, DIAGnostic:HEAP? allocs_since_main=0 frees_since_main=0, the calibration applied.

The candidate's run: 0.18.0 (FW-09)

Status: passed on 2026-11-26, the heap session on its second run, on FW-09's candidate image, before the review of that day changed the firmware. Firmware 0.18.0, image meter, built through the Kleidos firmware repository's scripts/pio-job in a clean clone of commit 3f49120 (meter-next/fw-09), whose firmware/src is git tree 9f9fcaa59c16, ELF SHA-256 9b23c01cda4eb3e900bf8e64cb219b4c0fe232e84209c5b6546d6ef0da5646dd (SYSTem:INFormation? elf=9b23c01cda4eb3e9), instrument KM-0000000000, the rig's wiring of hardware/rig.kicad_sch rev D with the T-Deck asleep drawing about 43 µA through the shunt. The upload built the tree again (the build stamps its date and time, so the first build of the clone had another digest, ee075f28c9e6551c); the image gates (radio, retired drivers, heap objects, heap reachability, IRAM hot path, the version in firmware.bin) were run on both and passed on both.

  • The flash. Uploaded over FW-08's image, the calibration partition kept: the first boot read q=cal, src=default, *TST? 0, DIAGnostic:HEAP? all four counts 0, and kleidos-meter calibration verify answered applied before the run and at its end, so no restore was needed.
  • The suite (tests/bench --run-bench --bench-long): 69 cases; 68 passed in 46 min 50 s, among them the heap sweep (the boot's four counts 0, 0, 0 and 0, and each of its 20 steps 0 allocations and 0 frees, the pin map's family included, with no unexpected error), the pin map's seven (five wrong maps each put back with one 117, a relay moved and back, a stored map and DEFault), the averaging override's fifteen (STATE at AVG 16 and 64 on ALERT, 18,432 and 73,728 µs, pace_err_ppm 108 and 111, nothing dropped; the null path's standard deviation 18.88, 4.67 and 2.44 µA at AVG 1, 16 and 64), the I2C bus, the line, the calibration saves, the watchdog's forced reset, the 600 s idle and the full ring. The heap session failed on its dump: the full ring's SCALed dump (about 36.6 MB) did not arrive whole in three attempts (twice no block within 300 s, once a block whose CRC-32 did not match), while the host ran the repository's test run and its hooks and other builds beside it ("A damaged dump is the line's", docs/testing.md); no heap count had moved.
  • The session (test_heap_session.py, run again alone on the same image with the host otherwise quiet: passed in 7 min 9 s). On one boot: every step of the sweep, a full TRACE ring (1,048,576 samples in 293.6 s, dropped=0 read_err=0 stale_edges=0) and its RAW (3,758,332 bytes) and SCALed (36,620,260 bytes) dumps, each whole at the first request, 500 SYSTem:STATus? and *RST ended at armed=1 allocs_after_init=0 frees_after_init=0 maint_allocs=0 maint_frees=0 pre_main_allocs=0 pre_main_frees=0 allocs_since_main=0 frees_since_main=0, every free figure as at the boot (free_internal=337700 min_free_internal=337700 largest_internal=270324 free_spiram=0), stack_console=5792 (the floor is 5,160), DIAGnostic:WATChdog? stalls=0 and SYSTem:HEALth? reset=poweron on the same boot.
  • The panel (host/tests/test_panel_bench.py --run-bench --bench-shots, kleidos-meter serve on the same image, 9 of 9 in 60 s): HEALTH and NULL_RELAY done; a 10 s STATE capture of 8,747 samples, all 8,747 as rows over Server-Sent Events; a TRACE ring of 10,981 samples decoded on the host and equal to the instrument's SCALed dump; then the page in a headless Chromium: the Pins view drew the default map the instrument reported (src=default); SDA moved to GPIO18 was applied from the page and put back by the instrument ("Reverted: the INA228 did not answer on the map's SDA, SCL and address. The last good map is back.", 117), the live map and *TST? 0 as before; the live chart at 100 ms of smoothing on an 8 s STATE capture gave in its readout a mean in view of 43.05 µA against FETCh:STATistics?'s mean_na=43051.157; a run recorded with the INA228's averaging on named it in its meta.json (state=on count=16 conversion_us=1052 period_us=18432), and the averaging was off again after it; the page's self-test read "0: every part passes."; the six heap counts 0 at the start and at the end; the verdict applied at both. Its images of the Live, Pins and Calibration and health views were kept for the panel's pages, as bench images of that date and elf=.
  • The state it was left in. *TST? 0 and SYSTem:ERRor:ALL? 0,"No error"; SYSTem:PINS? the default map (src=default verified=1) with nothing staged, SENSe:AVERage? 0, FORMat? TEXT, ROUTe:STATe? path=shunt, DIAGnostic:HEAP? allocs_since_main=0 frees_since_main=0, the calibration applied.

The run of record: 0.17.0

Status: passed on 2026-11-24. Firmware 0.17.0, image meter, a clean build (firmware/.pio/build/meter removed first) of the release's tree after the review of 2026-11-24, whose firmware/src is git tree 1f0f316faaa6 (commit 0f7f75b of meter-finish/integration; nothing under firmware/ changes after it), ELF SHA-256 29424f9c7f95f3218bd206115b4bf3a14c47213cf692afd763106999338e08ea (SYSTem:INFormation? elf=29424f9c7f95f321), instrument KM-0000000000, the rig's wiring of hardware/rig.kicad_sch rev D with the T-Deck drawing about 41 µA through the shunt. The build stamps its date and time, so a rebuild of the same tree has another digest. This image has every wrap of the review, the startup's and malloc()'s (D1, no row), and the ring capture's checked pointer write (HM2-06).

  • The flash. The image was uploaded over the previous one, the calibration partition kept: the first boot read q=cal, kleidos-meter calibration verify answered applied before the run and again at its end, and DIAGnostic:HEAP? read pre_main_allocs=0 pre_main_frees=0 allocs_since_main=0 frees_since_main=0.
  • The suite (tests/bench --run-bench --bench-long, the record in --bench-record and --bench-session-record): 46 of 46 cases passed in 42 min 39 s, no case skipped: the suite's own support, the calibration saves and the reboot, the heap sweep (the boot's four counts 0, 0, 0 and 0, every one of its 19 steps 0 allocations and 0 frees, the end's four counts 0, and no unexpected error), the I2C bus, the line, the watchdog's forced reset, the 600 s idle, the full ring and the session below.
  • The session (test_heap_session.py, in the same run). On one boot: every step of the sweep, a full TRACE ring (1,048,576 samples in 293.6 s, dropped=0 read_err=0 stale_edges=0) and its RAW (3,773,552 bytes) and SCALed (36,566,991 bytes) dumps, 500 SYSTem:STATus? and *RST ended at armed=1 allocs_after_init=0 frees_after_init=0 maint_allocs=0 maint_frees=0 pre_main_allocs=0 pre_main_frees=0 allocs_since_main=0 frees_since_main=0, with every free figure as at the boot (free_internal=338084 min_free_internal=338084 largest_internal=270324 free_spiram=0), stack_console=5840 (the floor is 5,160), DIAGnostic:WATChdog? stalls=0 and SYSTem:HEALth? reset=poweron on the same boot. pre_main_allocs and pre_main_frees are D1's rows, none. The SCALed dump was asked for three times: twice no block arrived within 300 s, the third came whole (docs/testing.md, "A damaged dump is the line's"); no heap count moved.
  • The panel (host/tests/test_panel_bench.py --run-bench, kleidos-meter serve on the same image, 9 of 9 in 34 s): HEALTH and NULL_RELAY done; a 10 s STATE capture of 8,745 samples, all 8,745 as rows over Server-Sent Events, equal to FETCh:STATistics?'s samples; a TRACE ring of 11,000 samples decoded on the host; the six heap counts 0 at the start and at the end; the verdict applied at both.
  • The state it was left in. *TST? 0 and SYSTem:ERRor:ALL? 0,"No error"; FORMat? TEXT, ROUTe:STATe? path=shunt, the calibration applied.

The bench transcripts of docs/scpi.md, docs/usage.md, docs/panel.md and docs/troubleshooting.md were taken earlier on 2026-11-24 on the image of commit af92a3c (elf=0f2b6ed8b28068a4, firmware/src tree 0af8d14a68c6), before the startup's wraps: its own run of record read the boot's counts 16, 4, 0 and 0. The protocol did not change between the two images, so the transcripts still show what each command answers; only elf= and the heap keys before app_main() read otherwise on the image above.

Earlier sessions of record: the 0.7.0 keys

Until FW-07 the device reported only the steady-state keys, counted from a quarter of a second after the boot, and until FW-16 two operations, a calibration save and (until FW-14) an I²C clock change, were maintenance, counted apart in maint_allocs and maint_frees under a deviation FW-16 retired with the last of them. The claim then read "heap-free from the end of the boot, but for the maintenance operations", and this was its procedure, on a freshly booted meter with a DUT drawing a few milliamps through the shunt:

  1. Wait a second after the power-on bit appears, then DIAGnostic:HEAP?: armed=1 and all four counts 0.
  2. Each profile captured and closed (SENSe:PROFile STATE, SLEEP, TRACE, then BURST at SYSTem:COMMunicate:I2C:FREQuency 1000000, each INITiate, a few seconds, ABORt, FETCh:STATistics?); a full TRACE ring and its whole TRACe:DATA? dump; a MEASure:CURRent?; ROUTe:NULLpath ON, CALibration:ZERO 10, ABORt, CALibration:ZERO:RESult? (stored=1 makes one save), ROUTe:NULLpath OFF; SENSe:CURRent:RANGe:INDex 1 and back to 0; every relay order; 500 SYSTem:STATus?.
  3. DIAGnostic:HEAP? again: allocs_after_init=0 frees_after_init=0. maint_allocs and maint_frees are whatever the save and the clock changes cost, and are recorded beside the result with min_free_internal.

Status: passed on 2026-11-20. Firmware 0.8.0, image meter, built from 5e7b0c0 (tag v0.8.0), ELF SHA-256 7a0defadeefb8b768fc58dfc4a39a7e19d817c545c6dc7c6a2dea3d67bc2d8ee (SYSTem:INFormation? elf=7a0defadeefb8b76), instrument KM-0000000000, its calibration applied by kleidos-meter calibration verify before the session and after it.

  • The boot. The meter was rebooted through the carrier's auto-reset (RTS asserted for 100 ms with DTR released, docs/carrier-board.md §7); the next *ESR? answered 1.08 s later with the power-on bit set, and one second after it DIAGnostic:HEAP? read armed=1 allocs_after_init=0 frees_after_init=0 maint_allocs=0 maint_frees=0.
  • Step 2, as written. STATE, SLEEP, TRACE and BURST (at SYSTem:COMMunicate:I2C:FREQuency 1000000, set back to 400000 after it) each captured for 4 to 5 s and closed with ABORt and FETCh:STATistics?; a STATE capture with ROUTe:RELay3 ON,LIVE, ROUTe:RELay3 OFF,LIVE and a TRACe:MARK in it; a full TRACE ring (1,048,576 samples over 293.6 s) and its whole TRACe:DATA? (SCALed, 36,654,290 bytes in 222 s); MEASure:CURRent?; ROUTe:NULLpath ON, CALibration:ZERO 10, 11 s, ABORt, CALibration:ZERO:RESult? (stored=1), ROUTe:NULLpath OFF; SENSe:CURRent:RANGe:INDex 1 and back to 0; the relay orders ROUTe:BYPass ON and OFF with and without FORCe, ROUTe:LEAD OPEN and CLOSe (the bare OPEN on path=shunt refused with 109, then given with FORCe), ROUTe:NULLpath ON and OFF again, ROUTe:RELay3 and ROUTe:RELay4 ON and OFF, and ROUTe:RELay1 ON (refused, -114); 500 SYSTem:STATus?.
  • The result. The last DIAGnostic:HEAP?: allocs_after_init=0 frees_after_init=0 maint_allocs=15 maint_frees=15, free_internal=338663 min_free_internal=302284 largest_internal=241664 free_spiram=4187740, every byte figure the same as at the first reading (the low-water mark is the boot's). The maintenance count is the two maintenance operations of the time: the two I2C clock changes at two allocations and two frees each (maint_allocs=2 maint_frees=2 after the first, 4 after the second) and the null window's one save at 11 of each. No allocation outside them: the claim holds.
  • One departure from the setting. The DUT, a T-Deck also on its USB supply, drew about 12 to 17 µA through the shunt rather than a few milliamps, so ROUTe:NULLpath ON answered check=unverified (README.md, "The relays: a null without hands"); the null was stored all the same, and every code path of the procedure ran. The range 0 null it stored is session state and is taken again, as calibration/README.md says, before a measurement relies on it.

Again with 0.9.0 (2026-11-20, ELF 9f812041835d2a89, the pacing session of docs/architecture.md §3.4): twelve captures on the shunt (three per profile, six of them alert-paced), eight on the null path, the null path formed and released twice, twelve idle SENSe:CHARge windows and every I²C clock change those needed ended at allocs_after_init=0 frees_after_init=0, maint_allocs=50 maint_frees=50 (the clock changes, then maintenance), with the same free figures as at boot. The per-edge DIAG_ALRT read the pacing adds is a bus transfer on a device handle created at boot and allocates nothing.

What allocates, and where: the census of 2026-11-22

The counts by phase say how much; the census build says where (firmware/src/heap_monitor.h). Built from the commit that added it (FW-07) with PLATFORMIO_BUILD_SRC_FLAGS=-DMETER_HEAP_CENSUS, flashed, rebooted through the carrier's auto-reset and read 1.5 s after it first answered, its ring held all 153 events of the boot, and scripts/heap_census.py --port "$KLEIDOS_METER_PORT" --elf firmware/.pio/build/meter/firmware.elf named each one's site; the plain image of the same commit reports the same counts (DIAGnostic:HEAP?, the sweep's [boot]). By the innermost function of the firmware's own code above each event:

Phase From Allocations Frees Bytes What
before app_main() ESP-IDF 39 4 50,855 the interrupt allocator's records (12, 4 freed), the IPC tasks (4), the main task (2), the idle tasks' stacks and control blocks (4), pthread's and the flash and RSA locks (6), PSRAM's heap registration and its 32 KiB DMA reserve (3), VFS (2), the task watchdog (2), the C library, a pthread key, the RTC interrupt and mbedTLS's PSA init (1 each)
since led::blankAll, blankOne 35 22 1,936 the RMT channel, its transaction queue, encoder, group, interrupt and the C library's lazy locks it takes, created and deleted to write the LED's off frame
since app_main 19 7 2,336 nvs_flash_init(): the partition table's load and mapping, NVS's pages, entry tables and storage
since Console::begin 9 0 2,444 uart_driver_install(): the driver object, its receive ring buffer, event queue and mutexes
since Ina228Driver::openBus, addDeviceHere 11 0 1,344 i2c_new_master_bus() (the bus, its semaphores and queue, its interrupt) and the device handle
since CalibrationStore::openNamespace 2 0 40 nvs_open()'s handle
since Sampler::runCapture 2 0 32 the task watchdog's two subscriptions
since Sampler::begin 1 0 392 gpio_install_isr_service() for the ALERT pin
since ESP-IDF 0 2 0 the idle task freeing the main task's stack and control block once app_main() returned (until FW-17)

The before app_main() row is FW-07's; from FW-18 it was 16 allocations and 4 frees, 17,380 B, one row each in D1's residue table, and the census build of FW-18's commit held 20 events, all of them before app_main(); from the review of 2026-11-24 it is 1 allocation, the C library's environ, and the census holds that one event. FW-09 took the Sampler::begin row off, with two of the interrupt allocator's records the LED's row counted (D1): its census build read 75 allocations and 30 frees since app_main(), one NVS page load (an allocation and its free) fewer than the plain image's first boots, by the state of NVS's pages. FW-10 took the led::blankAll row off: its census build read 52 and 8, the lazy locks and five of the allocator's records now in the app_main and Ina228Driver::openBus rows (D1). FW-11 took the Sampler::runCapture row off, the task watchdog's two subscriptions, and four allocations of the before app_main() row, the task watchdog's two and two of the allocator's records (D1): 35 before app_main() and 50 and 8 since on its image.

The per-site table (75 rows on this image, each with its file and line in ESP-IDF 6.0.3 and the wrapper it went through) is the script's output, reproduced from any census build of a commit; D1 above and "How the allocations left" below are written from it and from the census of the maintenance operations (FW-08). After the boot, until FW-16, the sweep's command families allocated only in the maintenance operations, the deviation FW-16 retired: 21 or 22 allocations and as many frees for two calibration saves that change the stored record, 10 to 12 of each for the null window's save; until FW-14 also 4 and 4 for two I2C clock changes. From FW-16 no family allocates or frees anything (tests/bench/heap_expectations.toml).

How the allocations left: FW-07 to the review of 2026-11-24

The record of what each work package took off, before app_main() and after it, from the census of 2026-11-22 to the residue D1 lists. Nothing here is still allocated.

What the move to ESP-IDF 6.1.1 added

ESP-IDF 6.1 moved the SPI1 flash API's locks into its startup on every target but the ESP32: esp_flash_app_init_os_functions(), a startup hook, now calls _lock_init() on the SPI1 operations' mutex (s_spi1_flash_mutex, spi_flash_os_func_app.c:512) and flash_mmap_lock_init(), which calls it on the mmap lock's outer_mux and creates that lock's two binary semaphores (semphr_freeze and semphr_acq, flash_mmap.c:78 to 89). In 6.0.3 neither existed at startup. The C library's lock layer makes each mutex with xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) and aborts on a null handle, so the image linked as 6.0.3's reboot-looped in _lock_init() on the bench (2026-11-28): the wrap served only the recursive flash lock. With two plain mutexes served it booted and read pre_main_allocs=2, the two semaphores, each xSemaphoreCreateBinary(), a macro for xQueueGenericCreate(). Both now have static homes in firmware/src/startup_memory.h, and the count is 0 again:

Site Objects Now
_lock_init() from esp_flash_app_init_os_functions(): s_spi1_flash_mutex and the mmap lock's outer_mux 2 __wrap_xQueueCreateMutex(): the first two plain mutexes over two static StaticQueue_t; a third refused
flash_mmap_lock_init(): semphr_freeze and semphr_acq 2 __wrap_xQueueGenericCreate() (-Wl,--wrap=xQueueGenericCreate): the first two binary semaphores over static StaticSemaphore_t (xSemaphoreCreateBinaryStatic()); any other queue, or a third, refused

flash_mmap_lock_init() is the image's only caller of xQueueGenericCreate() with a relocation left, so ESP-IDF's own xQueueGenericCreate() leaves the image with it, as xQueueCreateMutex() did.

What the review of 2026-11-24 took off

FW-18 recorded sixteen rows and said the fifteen past R1 had no remedy; two of its reasons were wrong (the flash lock's handle is whatever xQueueCreateMutex() returns, which a wrap of the callee serves, and the system interrupts' handlers and arguments are parameters of esp_intr_alloc(), which a wrap receives), and the others did not weigh a wrap at all. Each was a call from another object, which -Wl,--wrap redirects (firmware/CMakeLists.txt, firmware/src/startup_memory.h), and each wrap refuses what it does not serve rather than pass it on:

Was Census of FW-18 Site Bytes Now
R2 1 spi_flash_init_lock(): the flash operations' recursive mutex 84 __wrap_xQueueCreateMutex(): xQueueCreateMutexStatic() over a static StaticQueue_t, the first recursive mutex only
R3 to R6 2 to 5 esp_ipc_init(): ipc0's and ipc1's stacks and control blocks 8,392 __wrap_xTaskCreatePinnedToCore(): xTaskCreateStaticPinnedToCore() over a static slot of the size ESP-IDF asks for, each name once
R9, R10 9, 10 esp_startup_start_app(): the main task's stack (the console's 8,192 bytes and ESP-IDF's 512) and control block 8,804 the same wrap, its main slot
R7, R8, R11 to R16 6, 7, 11, 12, 14, 15, 17, 18 esp_intr_alloc() from esp_crosscore_int_init() and vSystimerSetup() on each core: four handles (freed at once) and four vector descriptors 96 __wrap_esp_intr_alloc(): the four sources routed with interrupt::routeHere() on the calling core, as the firmware's own interrupts are; no handle and no descriptor is made, and any other request is refused
R1 0 (of the review's first commit) esp_libc_init(): the C library's environ array 4 __wrap_malloc() (HM2-04): one pointer from a static word, once; any other request refused with null

ESP-IDF's own xTaskCreatePinnedToCore(), xQueueCreateMutex() and esp_intr_alloc() then leave the image, having no caller left. The interrupt allocator's descriptor list held the four lines only to mask the non-IRAM ones during a flash operation (esp_intr_noniram_disable()); all four are IRAM interrupts, which it leaves enabled, as the router's lines are left.

What FW-18 took off

Fifteen allocations, 37,868 bytes, by configuration first and by a wrap or an own driver where no option exists (the census build of FW-17's commit, read on the meter on 2026-11-23, against FW-18's):

  • PSRAM in the heap (3: its region record, 36 B, and the 32 KiB internal DMA reserve with its record, 32,768 and 36 B). CONFIG_SPIRAM_USE_MEMMAP maps PSRAM without registering it as a heap; the TRACE ring, PSRAM's one user, is placed at link time in .ext_ram.bss, which ESP-IDF zeroes at boot whatever the access method (esp_psram_bss_init()). On the meter (2026-11-23, against FW-17's image 1103c514a1c75d83): largest_internal 237,556 to 270,324 bytes (+32,768, the reserve), min_free_internal 300,304 to 337,084 (+36,780: the reserve was taken out of the heap and then added back as a region of its own, so the boot's low-water mark sat 32 KiB lower), free_internal 332,323 to 337,108 (+4,785: the reserve was counted as free before, though only internal and DMA requests could have it), and free_spiram 4,192,124 to 0.
  • PSA's initialization (5: two mutexes of 8 and 84 B each and the key slots' 1,408 B). Nothing in the image uses PSA, mbedTLS's startup hook calls psa_crypto_init() regardless, and no option leaves the hook out; the image is linked with -Wl,--wrap=psa_crypto_init onto __wrap_psa_crypto_init() (firmware/src/startup_memory.h), which answers PSA_SUCCESS and initializes nothing, and PSA's code leaves the image with its only caller. scripts/check_heap_objects.py --elf fails an image that links a psa_ or mbedtls_ function.
  • The idle tasks' memory (4: two stacks of 1,596 B and two control blocks of 100 B). ESP-IDF's vApplicationGetIdleTaskMemory() takes them from the heap and has no option; -Wl,--wrap=vApplicationGetIdleTaskMemory hands FreeRTOS two static slots of the same size in internal RAM instead (startup_memory.h).
  • The brownout interrupt (3: rtc_isr_register()'s record, 20 B, and the allocator's handle and descriptor, 8 and 16 B). ESP-IDF armed the detector with an interrupt because the promptless CONFIG_SPI_FLASH_BROWNOUT_RESET selects one, to reset an XMC flash chip; the meter's flash is a BoyaMicro part (manufacturer 0x68). CONFIG_ESP_BROWNOUT_DET=n leaves ESP-IDF's handling out and firmware/src/brownout.h arms the detector as ESP-IDF does without the interrupt, at the same level, right after app_main() releases the relays, with nothing allocated.
  • Not needed: VFS and mbedTLS's hardware options. The VFS's two allocations (esp_vfs_register_fs_common(), 63 B) and mbedTLS's RSA DS lock (esp_rsa_ds_conn_lock(), 84 B) were in FW-07's census and left with FW-16's component list (the vfs component is out of the build, which tests/firmware/test_meter_sdkconfig_reaches_the_build.py holds, and sdkconfig.defaults turns its I/O off should it return); FW-17's census held neither, so no mbedTLS option was changed.

What left D1 before FW-18

Until FW-17 ESP-IDF also allocated on the firmware's behalf after app_main()'s first line, while the instrument booted. The figures are the census of 2026-11-22 (above: 0.16.6's image at FW-07's commit, ESP-IDF 6.0.3): 39 allocations and 4 frees before app_main()'s first line, 79 and 31 from it to the settled boot; from FW-09, which took the GPIO ISR service off (below), 76 and 31, or 75 and 30 when NVS has one page fewer to load in full (the bench, 2026-11-22); from FW-10, which took the RMT driver off (below), 52 and 8 at every boot of 2026-11-22, with one such page load; from FW-11, which took ESP-IDF's task watchdog off (below), 35 and 4 before app_main() and 50 and 8 from it, at every boot and every watchdog reset on the bench of 2026-11-22; from FW-12, which took ESP-IDF's UART driver off (below), 35 and 4 before and 35 and 8 from it; from FW-14, which took ESP-IDF's I2C master off (below), 35 and 4 before and 23 and 8 from it; from FW-16, which took NVS off (below), 31 and 4 before and 0 allocations and 2 frees from it (DIAGnostic:HEAP? on the meter, 2026-11-23, ELF f30fed2a5e870da3, at the first boot, after the registry's restore, through the bench suite's sweep and its 20 saves); and from FW-17, which keeps the main task as the console, 31 and 4 before and 0 allocations and 0 frees from it (DIAGnostic:HEAP? on the meter, 2026-11-23, ELF 41f60a8bc5d49b06: at the boot, after every command family of the bench suite's sweep, after the watchdog's forced reset, and after a full TRACE ring and its whole RAW dump). Since app_main()'s first line nothing allocates and nothing frees, the boot included: the allow-list the source and object gates hold is empty and the host harness has none (tests/firmware/test_idf_allocation_lists.py), and the count starts at that line (heap::arm()), with no settling window.

No longer an event either: the idle task freeing the main task's stack and control block once app_main() returned (2 frees, until FW-17), which is why the steady-state count started a quarter of a second after the boot rather than at app_main()'s first line. app_main() now runs the boot and then the console's loop on the main task and never returns (firmware/src/main.cpp, docs/architecture.md §5.1), so ESP-IDF never deletes it; the console's own static task and its 8 KiB stack went with it, and the main task's stack is the console's: allocated before app_main() until the review of 2026-11-24 (D1's R9 then), a static slot of ESP_TASK_MAIN_STACK bytes (8,704: the 8,192 of CONFIG_ESP_MAIN_TASK_STACK_SIZE and ESP-IDF's 512 extra) since (firmware/src/startup_memory.cpp).

No longer on the list either: nvs_flash_init() and nvs_flash_erase() (main.cpp), nvs_open() and nvs_set_blob() (calibration.cpp, until FW-16), NVS at boot (FW-07's census: 19 allocations, 7 freed, 2,336 B, the partition table's load and mapping, a partition iterator and NVS's pages, entry tables and storage; from FW-10 also the C library's five lazy locks) and its handle (2, 40 B), and every save (one 20-byte partition iterator per flash write of NVS's region check, 10 to 26 allocations and as many frees by the state of its pages, counted as maintenance). The calibration is a record of the firmware's own log on the calib partition (firmware/src/flash_log.cpp, flash_port.cpp, docs/architecture.md §3.7), written through esp_flash_write() and esp_flash_erase_region(), which stay on the deny list and are on the made-safe list: the region check they ask is linked wrapped onto the firmware's static table (-Wl,--wrap=esp_partition_is_flash_region_writable), CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED leaves out the other, and their buffer is the log's, in internal RAM, which needs no bounce buffer. The build also holds only the firmware's component and what it requires (firmware/CMakeLists.txt, COMPONENTS): with NVS in the build, mbedTLS compiled its PSA storage onto it, psa_crypto_init() reached it, and the image kept NVS's code, operator new and delete and the C++ exception runtime with its eh_globals, whose constructor runs before app_main(); scripts/check_heap_objects.py --elf fails an image that holds any of them. The four allocations fewer before app_main() (35 to 31) come with that smaller build; no census build of FW-16's commit was read, so they are not split by site here.

No longer on the list: gpio_install_isr_service() (sampler.cpp, until FW-09), the GPIO's table of 49 handlers (1 allocation, 392 B) and the interrupt allocator's record and vector for its line (2 allocations, 24 B; the census of FW-07 counted them among the records it gave the LED's frame, the innermost frame of ours on their stack). Sampler::begin() routes the ALERT pin's interrupt itself, on the CPU's own tables (firmware/src/interrupt.cpp, docs/architecture.md §5.1), and the census build of FW-09's commit holds neither the table nor the two records: 4 of the allocator's handles (intr_alloc.c:575) and 2 vectors (:173) since app_main() where FW-07's held 5 and 3. esp_intr_alloc() and its variants, and the GPIO ISR service, stay on the deny list; tests/firmware/test_interrupt_routing.py also holds the CPU's lines to interrupt.cpp.

No longer on the list either: rmt_new_tx_channel(), rmt_new_bytes_encoder(), rmt_del_encoder() and rmt_del_channel() (status_led.cpp, until FW-10), the LED's off frame on each of its two lines: the channel, its transaction queue, the RMT group and the encoder (all freed), the interrupt allocator's records for the channel's interrupt, and the first take of the C library's lazily created locks, 33 allocations and 22 frees once FW-09 had taken two of the records off (FW-07's census gave the row 35 and 22, 1,936 B). led::blankAll() writes the frame on the RMT's registers (ESP-IDF's hal/rmt_ll.h, docs/architecture.md §8) and allocates nothing. Ten of the allocations the driver made first are now made by the next caller, and are counted in its entry above: the C library's five lazy locks (420 B) by nvs_flash_init(), and the interrupt allocator's two handles, two vectors and one shared-vector record (intr_alloc.c:575, :173, :612) by i2c_new_master_bus() for the I2C master's interrupt. The census build of FW-10's commit holds 52 allocations and 8 frees since app_main() and the plain images the same at every boot (six, 2026-11-22: two reads after a flash and four bench sweeps): app_main 23 and 6 (NVS, one page loaded in full, and the locks), Ina228Driver::openBus 14, Console::begin 9, CalibrationStore::openNamespace 2, Ina228Driver::addDeviceHere 2, Sampler::runCapture 2, and ESP-IDF's two frees of the main task. The RMT driver's entry points stay on the deny list, and scripts/check_drivers_absent.py (CI's firmware job) fails an image whose link map holds any member of esp_driver_rmt.

No longer on the list either: esp_task_wdt_add() (console.cpp, sampler.cpp, until FW-11), the task watchdog's entry for each of the two tasks, 2 allocations of 16 B. CONFIG_ESP_TASK_WDT_EN is off and the firmware runs its own watchdog on the same timer, Timer Group 0's MWDT, through ESP-IDF's hal/mwdt_ll.h (firmware/src/watchdog.cpp, docs/architecture.md §5.1): a static check-in mask of the console, the sampler and Core 0's idle task, an idle hook in ESP-IDF's static table of eight, and the timer's registers, nothing allocated and no interrupt. With it went the four allocations the task watchdog made before app_main() (its object and Core 0's idle task's entry, and the interrupt allocator's handle and vector for its timer's interrupt): pre_main_allocs reads 35, allocs_since_main 50 (DIAGnostic:HEAP? at every boot and every watchdog reset on the bench, 2026-11-22), and the census build of FW-11's commit holds 35 allocations and 4 frees, 50,799 B, before app_main(), with 10 of the allocator's records (5 handles, intr_alloc.c:575, and 5 vectors, :173) where FW-07's held 12, and no task watchdog entry, and 50 allocations and 8 frees since: app_main 23 and 6, Ina228Driver::openBus 14, Console::begin 9, CalibrationStore::openNamespace 2, Ina228Driver::addDeviceHere 2, and ESP-IDF's two frees of the main task. The task watchdog's entry points stay on the deny list.

No longer on the list either: uart_param_config() and uart_driver_install() (console.cpp, until FW-12), the console's UART driver: its object, its receive ring buffer, its event queue, its mutexes and pattern queue, and the interrupt allocator's records for its line (FW-07's census gave the Console::begin row 9 allocations, 2,444 B, before FW-10 moved the C library's lazy locks and the allocator's records between rows). Console::begin() sets UART0 on its registers through ESP-IDF's hal/uart_ll.h and routes its interrupt with interrupt::routeHere(), its ring, flags and semaphore static (firmware/src/uart0.cpp, docs/architecture.md §4.2), and allocates nothing: allocs_since_main reads 35, 15 fewer, and frees_since_main 8, unchanged (DIAGnostic:HEAP? on the plain image of FW-12's commit, 2026-11-22; no census build of that commit was read, so the 15 are not split by site here). The UART driver's entry points stay on the deny list, and scripts/check_drivers_absent.py fails an image whose link map holds any member of esp_driver_uart.

No longer on the list either: i2c_new_master_bus() and i2c_master_bus_add_device() (ina228.cpp, until FW-14), the INA228's bus: the bus object, its five semaphores and its queue, the port's handle slot and the device object (FW-07's census: 11 allocations, 1,344 B), and the interrupt allocator's records for its line, which FW-10 moved into the Ina228Driver::openBus row (14 allocations with the device object's two in addDeviceHere). Ina228Driver::openBus() sets up the own I2C master on I2C0's registers through ESP-IDF's hal/i2c_ll.h, with static state and no interrupt, semaphore or queue, each transaction polled to its end on Core 1 (firmware/src/i2c_bus.cpp, docs/architecture.md §2.4), and allocates nothing: allocs_since_main reads 23, 12 fewer, and frees_since_main 8, unchanged (DIAGnostic:HEAP? on the plain image of FW-14's commit, 2026-11-22; no census build of that commit was read, so the 12 are not split by site here). The I2C master's entry points stay on the deny list, and scripts/check_drivers_absent.py fails an image whose link map holds any member of esp_driver_i2c.

Before app_main(), until FW-18 (39 allocations, 4 frees, 50,855 B at FW-07's census; 35, 4 and 50,799 B at FW-11's, which took off the task watchdog's two and two of the allocator's records; 31 and 4 from FW-16, unsplit): the interrupt allocator's records (12, 4 freed; 10 from FW-11), the IPC tasks (4, 8,392 B), the main task (2, 4,196 B; from FW-17 its stack is the console's 8,192 B, so about 12,300 B, and the console's static 8 KiB stack is gone), the idle tasks' stacks and control blocks (4, 3,392 B), pthread's mutexes and the flash and RSA locks (6, 352 B), PSRAM's heap registration and its 32 KiB DMA reserve (3, 32,840 B), VFS (2, 63 B), the task watchdog's init and first entry (2, 32 B, until FW-11), the C library (4 B), a pthread key (12 B), the RTC interrupt (20 B) and mbedTLS's PSA init (1,408 B). The census holds no allocation of esp_timer's (this entry named one until FW-08).

Not checkable with the tools at hand

Most of the declaration, lifetime, template and side-effect rules need a whole-program analyzer or a certified checker. They are neither claimed nor denied here; a rule moves into "Held" only with the gate or the reading that holds it.

Back to the top