Repository navigation
Description
Motivation
The on-device crash detection traps being added across FastLED/fbuild/Arduino-core (FastLED/framework-arduino-lpc8xx#30 HardFault override; #3301 OOM-allocator emit; #3300 Step F watchdog wiring) are diagnostic safety nets -- when they fire, the user sees a useful error instead of silent infinite-loop. But there's no way to validate that the safety nets actually work without intentionally triggering them.
This issue adds a small bring-up sketch (or AutoResearch RPC method) that deliberately causes a fault and asserts the device emits the expected diagnostic. Two trigger paths:
- Intentional OOM:
new char[16 * 1024 * 1024]-- allocate 16 MB. On any embedded target with <= 1 MB RAM this is guaranteed to fail. - Stack blow: infinite recursive function. On a 4 KB stack (LPC845 default), this hits the stack-limit within microseconds and triggers a HardFault.
Either trigger should produce the expected emit:
- OOM trap path:
FAULT: OOM size=0x1000000 at <caller-PC>(from FastLED [LOW] In-FastLED OOM allocator wrapper — diagnostic emit at allocation site (complement to LPC8xx#30) #3301). - HardFault path:
FAULT: HardFault PC=0x... LR=0x... xPSR=0x...(from HardFault_Handler silently spins forever — emit useful diagnostic + reboot instead framework-arduino-lpc8xx#30, mirrored in FastLED [BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300 Step F).
If neither emits, the safety nets are broken; the test fails and that's a real bug.
Why this is bring-up-critical
When the user (or a future agent) runs bash autoresearch lpc845brk and sees an empty RX: b'' response, the immediate question is: "did the firmware crash, or is something else wrong?". If the crash-detection traps work, we get an immediate FAULT: ... line and can decode the cause in seconds. If they DON'T work (e.g. a future change accidentally regresses the HardFault override back to weak alias), the user is back to "silent failure = ambiguous root cause" and may waste hours debugging the wrong layer.
The test catches regressions in the safety nets. Without it, the safety nets are write-only code -- we trust them until they silently break.
Proposed design
Test as an autoresearch RPC method
Add two new methods to examples/AutoResearch/AutoResearchLowMemory.h -- only registered when FASTLED_AUTORESEARCH_FAULT_TEST=1:
#if defined(FASTLED_AUTORESEARCH_FAULT_TEST)
remote.bind("trigger_oom", [](void) -> bool {
// 16 MB -- guaranteed to fail on any embedded target. Use `new char[]`
// rather than the fl-allocator chokepoint so the test exercises the
// platform allocator path too (catches breakage in Arduino-core OOM
// trap separately from FastLED's allocator wrapper).
volatile char* p = new char[16 * 1024 * 1024];
// If this returns, the trap is broken -- p will be nullptr.
// The expected behavior: emit_oom fires before this lambda returns,
// followed by AIRCR.SYSRESETREQ. The caller never sees the return.
return p != nullptr;
});
remote.bind("trigger_stackblow", [](void) -> bool {
return recurse_forever(0); // see helper
});
static bool recurse_forever(int depth) FL_NO_INLINE {
volatile uint8_t pad[64]; // 64 B per frame to burn stack quickly
pad[0] = static_cast<uint8_t>(depth);
return recurse_forever(depth + 1) && pad[0] != 0;
}
#endifThe FL_NO_INLINE is load-bearing -- without it the compiler elides the recursion and the test does nothing.
Host-side assertion
bash autoresearch lpc845brk --fault-emit-test (or a new top-level harness flag) does:
- Build with
-DFASTLED_AUTORESEARCH_FAULT_TEST=1. - Flash, reset, wait for ready.
- Send
{"method":"trigger_oom","id":1}. - Wait up to 5 s for serial output.
- Assert the output contains a line matching
^FAULT: (OOM size=0x[0-9A-F]+|HardFault PC=0x[0-9A-F]+). - Re-flash + reset (fresh firmware).
- Send
{"method":"trigger_stackblow","id":2}. - Assert similar emit line.
If both pass, the safety nets work. If either fails, the harness emits a P0 alert -- crash detection is broken, future bring-up debugging will be back to "silent hang = no information".
Optional: also test fault-during-fault recursion
Stretch goal -- not required for the initial test. If we want to validate the fault-during-emit fallback (chip should lock-up reset rather than infinite-loop), add a trigger_double_fault that causes a fault inside the fault handler's emit path. Assertion: the chip reboots within ~50 ms (lock-up reset behavior) and the next boot's Watchdog::lastResetCause() reports SOFTWARE.
Acceptance criteria
-
FASTLED_AUTORESEARCH_FAULT_TESTbuild flag adds the two trigger methods to AutoResearch's RPC table. - Autoresearch harness has a
--fault-emit-testmode that flashes the test build, triggers each fault, and asserts the expected emit pattern. - Test passes on LPC845-BRK (the immediate validation target). Test passes on at least one other low-memory platform once [LOW] In-FastLED OOM allocator wrapper — diagnostic emit at allocation site (complement to LPC8xx#30) #3301 ships for it (proves the FastLED-side emit hook works cross-platform).
- Test runs in CI on the LPC845 canary (or whatever CI surface exists for it -- if none today, file a follow-on for that).
- Documentation in
agents/docs/hardware-autoresearch.mdexplains the fault-emit test and what to do if it fails (the safety nets are broken; consult the linked issues to figure out which layer regressed).
Priority
Medium. Not blocking #3102 / #3300, but should land soon after the safety nets do -- there's a 2-week window between "trap shipped" and "trap silently regressed" where this test catches the regression cheaply. Without the test, regression is caught only when the next bring-up gets a silent hang and the user has to re-investigate from scratch.
Out of scope
- Fault types beyond OOM and stack blow (e.g. unaligned access, divide-by-zero on M4/M7, MPU violation). The two chosen triggers exercise the two highest-leverage emit paths (OOM trap + HardFault override). Other fault types share the HardFault path and don't add new coverage.
- Testing the watchdog-fired emit (Step F.2 in [BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300). That requires staging a known infinite-loop and waiting 3 s for WWDT to fire -- doable but a separate harness shape; file as a follow-up.
- Crash-log persistence verification (not yet implemented on LPC; will be its own issue if we add retention-RAM-backed crash dumps).
Refs
- [BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300 -- bring-up echo silence; safety nets land in Step F.
- [LOW] In-FastLED OOM allocator wrapper — diagnostic emit at allocation site (complement to LPC8xx#30) #3301 -- FastLED-side OOM allocator wrapper.
- HardFault_Handler silently spins forever — emit useful diagnostic + reboot instead framework-arduino-lpc8xx#30 -- LPC8xx HardFault override.
- meta(lpc845-brk): bench-validate the three on-hand-hardware checklists (deploy + #565-sidestep + SCT-RX phases) #3102 -- LPC845-BRK bench-validation meta (blocks until these safety nets ship + this test asserts they work).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 23, 2026
Tracking this under the new LPC845-BRK / LPC8xx AutoResearch coordination meta: #3348.
Keeping this issue open for now as optional LPC8xx validation safety-net work. If fault-emit validation is deferred, close this separately with rationale from #3348 rather than folding it silently into the meta.
zackees commentedon Jul 6, 2026
Rolled up under the active LPC845-BRK meta #3348 and attached there as a GitHub sub-issue.
Next agent: implement or verify this locally on the attached LPC845-BRK. Capture the exact command, serial port, and observed
FAULT:diagnostic/recovery output before closing this issue.zackees commentedon Jul 6, 2026
Completed via #3615 and verified again after merge on
master(298830fed2).Post-merge local validation on attached LPC845-BRK / COM10:
Evidence: build/deploy succeeded, the harness re-flashed between triggers, and both intentional fault RPCs emitted diagnostics:
trigger_oom: FAULT: HardFault PC=0x10001E70 LR=0xFFFFFFF9 xPSR=0x10000020trigger_stackblow: FAULT: HardFault PC=0x10002FC0 LR=0xFFFFFFF9 xPSR=0x00000000Harness verdict:
PASS - #3302 fault emit validation confirmed.