Skip to content

META: LPC845 flash-budget Phase 2 — grow headroom from 1.4 KB to ~6-10 KB for feature capacity #3224

Description

@zackees

Context

Predecessor: meta #3079 (closed 2026-06-15) shipped a 6-PR arc that cleared an 11,112-byte FLASH overage on LPC845-BRK and turned -DFASTLED_LPC_RX_SCT_WS2812=1 default-on. Today's LPC845 state with that flag enabled:

Flash: 62.61 KB / 64.00 KB (97.8%)   — 1,420 B headroom
RAM:   10.50 KB / 16.00 KB (65.6%)   — 5.5 KB free

The 1,420 B headroom is enough to ship the WS2812 SCT-RX loopback RPC binding by default, but it's too narrow to absorb any meaningful new feature work on the LPC8xx surface (debug logging, additional RPC methods, expanded JSON-RPC contracts). This meta tracks the Phase 2 reductions that would grow that headroom toward ~6-10 KB so the LowMemory build can carry comfortable feature-add capacity again.

This is not a regression hunt — the budget is technically met. It's a deliberate margin-expansion effort.

Headroom growth target

Stage Headroom
Today (post-#3079) 1,420 B
After Tier 1 (#3092 single-prec soft-FP elim) ~5,500 B
After Tier 1 + Tier 2 (RPC/JSON outlining) ~9,000 B
Aspirational ceiling (all 8 sub-issues) ~13,000 B

Sub-issues to file (in priority order)

Each row below should be filed as its own sub-issue once this meta lands. Numbers are based on arm-none-eabi-nm --print-size --size-sort on the LPC845 ELF as of 2026-06-15, after meta #3079 closed.

Tier 1 — cleanest wins (file first)

# Target Current Potential Effort Notes
A Single-precision soft-FP cascade (__aeabi_fsub 1,172 + __aeabi_fadd 1,110 + __aeabi_fmul 660 + __aeabi_fdiv ~550 + __clzdi2 828) ~4,500 B -3 to -4 KB medium Drop the float alternative from json_value::variant_t on Low-memory. All reachable operator()(const float&) visitor overloads become unreachable → DCE. Same pattern as #3076 / #3082. Semantic change: json(3.14f) either fails to compile or silently stores 0; LPC8xx integer-only RPC contract never sends floats so this is unobservable.
B fl::Remote::processRpc 5,808 B -1 to -2 KB medium Outline ACK + error-emit paths. Today after merge with Rpc::handle the function is monolithic; the JSON-RPC envelope validation + async-ACK emit + error-formatting cluster outlines cleanly.
C autoResearchLowMemorySetup + lambdas 4,626 B -1 to -2 KB low Sketch-side. Reduce captured state in the 2 large lambdas (1,080 + 812 B); they currently capture the entire RPC context by value.

Tier 2 — bigger structural changes

# Target Current Potential Effort Notes
D fl::(anonymous).JsonBuilder::on_token 2,328 B -800 B medium Outline the variant emplace paths. The SAX visitor's branch bodies are small; the multiplier is inlined variant<>::emplace<T> per alternative. Replace with a single non-template emit_value(json_value& dst, TokenType tag, span<char> raw).
E fl::(anonymous).JsonTokenizer::parse 1,258 B -1 KB medium Hand-write a minimal RFC-7159 subset tokenizer for the LowMemory integer-only RPC contract. Accepts only {"jsonrpc":"2.0","id":N,"method":"foo","params":[1,2,3,4]}. The full general tokenizer is overkill on a 3-method RPC surface.
F 3× unordered_map<string, T>::rehash_inline_no_resize instantiations ~1,800 B -1 KB medium Collapse RpcEntry / AsyncRequest / shared_ptr<StringHolder> variants into a single non-template rehash that takes a per-entry-stride parameter.

Tier 3 — small wins (file last)

# Target Current Potential Effort Notes
G fl::basic_string::write 762 B -300 B small Outline format-string handling.
H fl::TypedRpcBinding<Sig>::invokeWithReturn 2,140 B/sig -1 KB/sig invasive De-template the heavy Converter::convert + make_tuple + TypeToJson lifting. Affects every registered RPC signature across ESP32 / Teensy / WASM. Was deferred during meta #3079 because it's a multi-PR architectural change. File this last; only pursue if Tier 1+2 don't grow the budget enough.

Tooling dependency: FastLED/fbuild#594

The companion tooling-gap issue (bash bloat / fbuild symbols: no arm-none-eabi path) is still open and is the single biggest velocity multiplier for this meta. Three independent gaps cataloged there:

  1. ci/bloat.py's BOARD_CHIP_MAP has no arm-none-eabi entry (Xtensa + RISC-V ESP32 only).
  2. fbuild build has no "emit ELF on region overflow" mode — when measuring degenerate over-budget configs, the link errors fatally and no ELF / .lto-tmp/*.ltrans*.o is preserved.
  3. bash bloat doesn't look at .fbuild/build/<env>/release/firmware.elf even on green builds.

Every PR in meta #3079 had to repeat the LD-script-patch + manual nm dance (12+ build-and-measure cycles). It also produced a real correctness bug: a one-off Python firmware.map parser misattributed byte gaps and overstated 4 phantom issues by 18-176× (the #3075 / #3078 retraction story in #3079). bash bloat lpc845brk would have caught that immediately.

This meta does not block on fbuild#594 — sub-issues can still be measured the manual way — but landing #594 first would compress per-PR iteration from ~10 minutes to seconds and remove the methodology-error footgun.

How to measure progress (until fbuild#594 lands)

# 1. Apply the proposed reduction on a feature branch
# 2. Temporarily bump FLASH 64K -> 128K in fbuild's cached LD script:
#    ~/.fbuild/prod/cache/platforms/zackees-ArduinoCore-LPC8xx/.../lpc845_flash.ld
# 3. Build:
#    PLATFORMIO_SRC_DIR=examples/AutoResearch fbuild build -e lpc845brk
# 4. CANONICAL bloat measurement (NOT linker map address-delta):
#    NM=~/.fbuild/prod/cache/toolchains/developer-gnu/.../arm-none-eabi-nm.exe
#    "$NM" --print-size --size-sort --demangle .fbuild/build/lpc845brk/release/firmware.elf | \
#      awk '$3=="t" || $3=="T"' | tail -25
# 5. Revert the LD script

Once fbuild#594 lands this collapses to:

bash bloat lpc845brk --example AutoResearch

Acceptance for closing this meta

  • LPC845 LowMemory + RX_SCT_WS2812=1 build flash headroom is ≥6 KB (today: 1,420 B)
  • At least Tier 1 sub-issues (A, B, C) closed via merged PRs
  • Tier 2 sub-issues (D, E, F) either closed or explicitly deferred with rationale
  • Tier 3 sub-issues (G, H) filed as separate trackers (H may stay deferred indefinitely)

Out of scope

  • New LED-protocol matrix support on LPC8xx (Low-memory targets stay RX-only + bit-bang/SCT-DMA TX)
  • LPC11Uxx / LPC15xx hardware bring-up (tracked under fbuild#456)
  • RAM reductions — 5.5 KB free, not constrained
  • ESP32 / Teensy / WASM bloat hunts (different cost model; full-fat targets have huge flash budgets)

Related work

Activity

  1. added 20 commits that reference this issue on Jun 18, 2026
  2. moved this from Triage to Done in FastLED Trackeron Jun 18, 2026
  3. zackees commented on Jun 18, 2026

    @zackees
    MemberAuthor

    Forward link: ongoing memory/flash reduction tracked at Phase 3 meta #3244 (which carries the Tier 3H RuntimeRpcBinding thread from this meta forward).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions