Skip to content

feat(lpc845): WWDT watchdog driver + FL_WARN_LIT enabled on Low-memory - #3014

Merged
zackees merged 3 commits into
masterfrom
feat/lpc845-watchdog-and-fl-warn-lit
Jun 14, 2026
Merged

zackees merged 3 commits into
masterfrom
feat/lpc845-watchdog-and-fl-warn-lit

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Two follow-ups to #3012 / #3013 that complete the LPC845-BRK bring-up goal (FastLED #3002 + #3004):

1. LPC8xx WWDT watchdog driver

src/platforms/arm/lpc/watchdog_lpc.impl.hpp implements the FastLED fl::Watchdog interface against the LPC84x Windowed Watchdog Timer. Routes through the SYSCON-clocked WDOSC (~125 kHz tick after the WWDT-internal /4 prescaler). Self-contained — no dependency on the LPC8xx Arduino core's CMSIS header (which only exposes the IRQ vector list).

  • begin(timeout_ms), feed(), disable()
  • lastResetCause() from SYSRSTSTAT (sticky bits, write-1-to-clear)
  • reboot() via Cortex-M AIRCR SYSRESETREQ
  • Dispatcher routing added under FL_IS_ARM_LPC in platforms/watchdog.impl.cpp.hpp
  • The bring-up sketch arms it in setup() with a 3-second window so a hung firmware unbricks itself on crash

2. FL_WARN_LIT enabled on Low-memory targets

FL_WARN_LIT(literal) was documented as the "minimal-overhead variant for literal-only messages" that bypasses the sstream + operator<< chain the full FL_WARN uses — but the gate at log.h:102 made it a no-op on any target without SKETCH_HAS_LARGE_MEMORY. The very platforms the lite macro was supposed to serve got a no-op.

Fix: new FASTLED_LOG_LITE_ENABLED gate (= FASTLED_LOG_VERBOSITY >= 1, no memory check). FL_WARN_LIT / FL_LOG_LIT move under this gate and stay alive on LPC845 / AVR / ATtiny.

The autoresearch bring-up harness now verifies the FL_WARN_LIT(\"FL_WARN: LPC845 bring-up OK\") line reaches the host — third leg of the bring-up contract alongside Serial.println and JSON-RPC echo.

Build impact

Step Text bytes
Before #3012/#3013 overflow +3424
After #3012 (libm-free fl::math) overflow +760
After #3013 (visitor double-cast cleanup) 63088 (fits)
+ WWDT driver armed in sketch 63212
+ FL_WARN_LIT in sketch 63260
LPC845-BRK flash budget 65536
Headroom ~2.2 KB

Test plan

  • bash test fl/math/math.cpp --cpp — host math tests pass
  • bash test json --cpp — host JSON tests pass
  • bash test log --cpp — host log tests pass
  • bash test power --cpp — host power_mgt tests pass
  • bash autoresearch lpc845brk — firmware builds and links (text=63260, data=372 on 64 KB-flash part)
  • Verify on physical LPC845-BRK hardware (no board attached in this session — see AutoResearch: wire LPC845-BRK into bash autoresearch harness #3004 for the autoresearch wire-up that gates this)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added watchdog timer support for LPC8xx (including LPC845) to detect and recover from sketch hangs.
    • Enabled “lite-mode” literal-only logging on memory-constrained platforms based on log verbosity.
    • Enhanced LPC bring-up and validation signals used by automated bring-up checks.
  • Bug Fixes

    • Updated bring-up automation to avoid blocking pin-discovery and to use stricter success gates for echo/serial warning markers.
  • Documentation

    • Updated platform watchdog coverage notes to reflect LPC8xx support.

zackees and others added 2 commits June 13, 2026 20:10
…sketch

Adds `platforms/arm/lpc/watchdog_lpc.impl.hpp` implementing the
FastLED `fl::Watchdog` interface against LPC84x WWDT (Windowed
Watchdog Timer). Routes through SYSCON-clocked WDOSC (~125 kHz tick
after the WWDT-internal /4 prescaler), with begin/feed/disable,
reset-cause readback from `SYSRSTSTAT`, and `NVIC_SystemReset`-style
`reboot()` via AIRCR. Persist storage is in-RAM (LPC845 has no
battery-backed retention RAM).

The driver does NOT depend on the LPC8xx Arduino core's CMSIS header
(which only exposes the IRQ vector list, no WWDT register struct) —
register addresses are inline `volatile fl::u32*` casts per UM11029
§3, §4, §14, with `// ok reinterpret cast` suppression markers
matching the convention in `platforms/arm/nrf52/fastpin_arm_nrf52.h`.

Dispatcher routing added to `platforms/watchdog.impl.cpp.hpp` under
`FL_IS_ARM_LPC` (between the AVR branch and the noop fallback). No
`FL_HAS_INCLUDE` guard — the impl is self-contained.

`examples/AutoResearchLpc/AutoResearchLpc.ino` now arms the watchdog
in `setup()` with a 3-second window and feeds it from `loop()`, so a
hung bring-up sketch unbricks itself on crash. Firmware grows ~140 B
(text 63088 → 63212), well within the LPC845-BRK 64 KB budget.

Refs: #3002, #3004 (autoresearch wire-up).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
`FL_WARN_LIT(literal)` was documented as the "minimal-overhead variant
for literal-only messages" that bypasses the sstream + operator<< chain
the full FL_WARN uses, but the gate at log.h:102 made it a no-op on any
target without `SKETCH_HAS_LARGE_MEMORY` — the very platforms the lite
macro was supposed to serve. This commit fixes that:

  - New `FASTLED_LOG_LITE_ENABLED` gate (= `FASTLED_LOG_VERBOSITY >= 1`,
    no memory check). `FL_WARN_LIT` / `FL_LOG_LIT` move under this gate
    and stay alive on LPC845/AVR/ATtiny.
  - The full FL_WARN / FL_DBG / FL_INFO / FL_ERROR machinery remains
    gated on `FASTLED_LOG_RUNTIME_ENABLED` — no change to existing
    behavior on either Large- or Low-memory targets.
  - Single point of definition for FL_WARN_LIT (the runtime block now
    forwards through a comment to the lite block instead of redefining).

The LPC845 bring-up sketch now emits `FL_WARN_LIT("FL_WARN: LPC845
bring-up OK")` in `setup()`, and the autoresearch bring-up harness
verifies that token reaches the host. The bring-up PASS gate is now
`echo && remote && warn` (was `echo && remote` with FL_DBG advisory),
which proves the FL_WARN pipeline works end-to-end on a 64 KB-flash
no-FPU MCU — completing the third leg of FastLED #3002's bring-up
goal alongside `Serial.println` and JSON-RPC echo.

Firmware grows ~50 B (text 63212 → 63260) for the literal + one extra
`fl::println` call site. Still ~1.9 KB flash headroom.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a complete LPC845 WWDT watchdog implementation (watchdog_lpc.impl.hpp) with reset-cause tracking and crash counters, wires it into the platform dispatcher, and reworks FL_WARN_LIT/FL_LOG_LIT in log.h to be gated by FASTLED_LOG_LITE_ENABLED independent of large-memory requirements. Arms the watchdog in the AutoResearchLpc sketch with literal-only bring-up markers and extends the CI phase to validate the markers while skipping LPC-specific pin discovery tests.

Changes

LPC845 Watchdog and Bring-up Verification

Layer / File(s) Summary
FL_WARN_LIT gating via FASTLED_LOG_LITE_ENABLED
src/fl/log/log.h
Introduces FASTLED_LOG_LITE_ENABLED computed from FASTLED_LOG_VERBOSITY >= 1, removes the prior in-block FL_WARN_LIT/FL_LOG_LIT definitions, and redefines them in a dedicated lite-variant section gated by the new macro, independent of SKETCH_HAS_LARGE_MEMORY.
LPC8xx WWDT watchdog implementation
src/platforms/arm/lpc/watchdog_lpc.impl.hpp
Adds the complete LPC845 WWDT backend: MMIO register helpers, singleton in-RAM state (armed flag, crash counter, reset-cause caching), IRQ-safe feed sequence, begin/feed/disable core APIs, lastResetCause detection with SYSRSTSTAT write-1-to-clear and crash counter increment, persistence read/write, safe-mode threshold, Cortex-M reboot() via AIRCR, and stub no-ops for unsupported APIs.
Platform dispatcher: FL_IS_ARM_LPC route
src/platforms/watchdog.impl.cpp.hpp
Adds an #elif FL_IS_ARM_LPC branch in the watchdog platform dispatcher and updates the coverage comment to document LPC8xx (LPC84x).
AutoResearch sketch: arm watchdog and emit bring-up markers
examples/AutoResearchLpc/AutoResearchLpc.ino
Adds watchdog and logging includes, calls Watchdog::begin(3000) with literal bring-up marker FL_WARN_LIT("FL_WARN: LPC845 bring-up OK") in setup(), updates the echo JSON-RPC handler to emit FL_WARN_LIT("FL_WARN: echo invoked") on each invocation, and feeds the watchdog each loop() iteration.
CI bring-up harness: skip LPC pin tests and extend success criteria
ci/autoresearch/phases.py
Updates _run_schema_and_pin_setup to skip pin discovery and GPIO connectivity pre-test for LPC bring-up environments. Extends _run_bring_up_tests to detect FL_WARN: echo invoked as a required pass gate (warn_ok) alongside echo_ok and remote_ok; keeps Stored request ID for echo as a bonus diagnostic (log_ok). Updates bring-up reporting to print FL_WARN_LIT status on success and expanded diagnostics on failure.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI Phase<br/>_run_bring_up_tests
  participant Sketch as AutoResearchLpc.ino<br/>LPC845
  participant Watchdog as fl::Watchdog<br/>(LPC845 WWDT)
  participant Serial as Serial Output

  CI->>Sketch: flash and boot
  Sketch->>Watchdog: Watchdog::begin(3000)
  Watchdog-->>Sketch: armed, WWDT enabled
  Sketch->>Serial: FL_WARN_LIT("FL_WARN: LPC845 bring-up OK")

  rect rgba(100, 200, 100, 0.5)
    Note over Sketch,Serial: Main loop operation
    loop Each iteration
      Sketch->>Watchdog: feed()
      Sketch->>Serial: JSON-RPC echo result
      Sketch->>Serial: REMOTE: marker
      Sketch->>Serial: FL_WARN_LIT("FL_WARN: echo invoked")
    end
  end

  Serial-->>CI: collect serial output
  CI->>CI: echo_ok = detect echo result?
  CI->>CI: remote_ok = detect REMOTE: marker?
  CI->>CI: warn_ok = detect FL_WARN: echo invoked?
  CI->>CI: log_ok = detect Stored request ID? [bonus]
  CI->>CI: passed = echo_ok AND remote_ok AND warn_ok
  
  alt Bring-up succeeded
    CI-->>CI: Report FL_WARN_LIT (required gate)
  else Bring-up failed
    CI-->>CI: Report echo_ok, remote_ok, warn_ok, log_ok
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2745: Both PRs modify the watchdog platform dispatcher in src/platforms/watchdog.impl.cpp.hpp to add per-platform Watchdog hardware backends.
  • FastLED/FastLED#3009: Both PRs extend the LPC bring-up validation logic in ci/autoresearch/phases.py's _run_bring_up_tests to detect FastLED logging markers.
  • FastLED/FastLED#2791: Both PRs update src/fl/log/log.h to gate FL_WARN_LIT/FL_LOG_LIT based on FASTLED_LOG_VERBOSITY, controlling the same compile-time logging-macro conditions.

Poem

🐇 Hop, hop, the watchdog wakes at last,
On LPC8xx, the timer is cast.
FL_WARN_LIT barks "bring-up OK!"—
No hung sketch shall ruin the day.
Feed and reset with each heartbeat fine,
CI checks echo, remote, warn—all align! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the two main features: LPC845 watchdog driver (WWDT) and FL_WARN_LIT macro enablement for low-memory targets, matching the core changes across the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lpc845-watchdog-and-fl-warn-lit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/autoresearch/phases.py`:
- Around line 1535-1542: Remove the f-string prefixes from the four strings in
the print statements (the strings containing "FL_WARN_LIT" and "FL_DBG") since
they contain no placeholder expressions. Convert each f-string to a regular
string by removing the f prefix, as these are static strings with no variable
interpolation and the f prefix is flagged as a Ruff F541 lint error.
- Around line 1512-1522: The FL_WARN: LPC845 bring-up OK marker emitted during
sketch setup() is being cleared from the accumulated serial data before the
warn_ok check is evaluated, causing the passed check to fail incorrectly.
Capture the warn_ok status by checking for the FL_WARN: LPC845 bring-up OK token
in accumulated data before any serial input clearing occurs in this flow, or
move the warn_ok evaluation point to happen earlier before the accumulated data
is cleared. Ensure the warn_ok variable retains its value from before the
clearing and is used correctly in the final passed check that combines echo_ok,
remote_ok, and warn_ok.

In `@src/fl/log/log.h`:
- Around line 108-113: Replace all Unicode em-dashes (—) with ASCII-only
alternatives (use hyphen - or double hyphen --) in the comments at both
locations in src/fl/log/log.h: at the anchor site (lines 108-113) in the comment
block describing the lite gate for FL_WARN_LIT / FL_LOG_LIT, and at the sibling
site (lines 285-288). Ensure all punctuation in header file comments uses only
7-bit ASCII characters to comply with the repository's coding guidelines.

In `@src/platforms/arm/lpc/watchdog_lpc.impl.hpp`:
- Around line 163-166: The calculation of ticks on line 163 multiplies two
32-bit values (timeout_ms and kTickHz) which can overflow before the division by
1000u is applied, causing incorrect WWDT TC programming for large timeout
values. Fix this by casting one of the operands to a 64-bit type (such as
fl::u64) before the multiplication so that the arithmetic is performed in 64-bit
space to prevent overflow, then the result will be divided correctly and
truncated back to 32-bit for the ticks assignment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45f36696-77d4-4ee1-93f1-485d1740d5c1

📥 Commits

Reviewing files that changed from the base of the PR and between 313ae0b and e76141c.

📒 Files selected for processing (5)
  • ci/autoresearch/phases.py
  • examples/AutoResearchLpc/AutoResearchLpc.ino
  • src/fl/log/log.h
  • src/platforms/arm/lpc/watchdog_lpc.impl.hpp
  • src/platforms/watchdog.impl.cpp.hpp

Comment thread ci/autoresearch/phases.py Resolved
Comment thread ci/autoresearch/phases.py
Comment on lines +1535 to +1542
f" ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
if warn_ok
else f" ❌ FL_WARN_LIT — warning literal not observed"
)
print(
f" ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
if log_ok
else f" ⚠️ FastLED log pipeline — FL_DBG line not observed"
" (may be optimized out in release builds without FASTLED_FORCE_DBG)"
else f" ⚠️ FL_DBG — full pipeline not active"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove extraneous f prefixes on static strings (Ruff F541).

These four prints are f-strings without placeholders and are currently lint errors.

Proposed fix
-                f"   ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
+                "   ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
                 if warn_ok
-                else f"   ❌ FL_WARN_LIT — warning literal not observed"
+                else "   ❌ FL_WARN_LIT — warning literal not observed"
             )
             print(
-                f"   ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
+                "   ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
                 if log_ok
-                else f"   ⚠️  FL_DBG — full pipeline not active"
+                else "   ⚠️  FL_DBG — full pipeline not active"
                 "  (expected on Low-memory targets — FL_WARN_LIT is the gate)"
             )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
f" ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
if warn_ok
else f" ❌ FL_WARN_LIT — warning literal not observed"
)
print(
f" ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
if log_ok
else f" ⚠️ FastLED log pipeline — FL_DBG line not observed"
" (may be optimized out in release builds without FASTLED_FORCE_DBG)"
else f" ⚠️ FL_DBG — full pipeline not active"
" ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
if warn_ok
else " ❌ FL_WARN_LIT — warning literal not observed"
)
print(
" ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
if log_ok
else " ⚠️ FL_DBG — full pipeline not active"
" (expected on Low-memory targets — FL_WARN_LIT is the gate)"
)
🧰 Tools
🪛 Ruff (0.15.15)

[error] 1535-1535: f-string without any placeholders

Remove extraneous f prefix

(F541)


[error] 1537-1537: f-string without any placeholders

Remove extraneous f prefix

(F541)


[error] 1540-1540: f-string without any placeholders

Remove extraneous f prefix

(F541)


[error] 1542-1542: f-string without any placeholders

Remove extraneous f prefix

(F541)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/autoresearch/phases.py` around lines 1535 - 1542, Remove the f-string
prefixes from the four strings in the print statements (the strings containing
"FL_WARN_LIT" and "FL_DBG") since they contain no placeholder expressions.
Convert each f-string to a regular string by removing the f prefix, as these are
static strings with no variable interpolation and the f prefix is flagged as a
Ruff F541 lint error.

Source: Linters/SAST tools

Comment thread src/fl/log/log.h
Comment on lines +108 to +113
// Lite gate for FL_WARN_LIT / FL_LOG_LIT — string-literal-only macros that
// route through fl::println without the sstream / operator<< / log_emit
// chain. These are intentionally usable on Low-memory targets (LPC845,
// AVR, ATtiny) where the full FL_WARN pipeline is too expensive — the
// caller pays for one `fl::println(const char*)` symbol and the literal
// bytes, nothing more. See FastLED #3002 (LPC845 bring-up).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use ASCII-only punctuation in new .h comments.

These newly added comments include Unicode em-dashes (—), which violates the repository’s ASCII-only rule for C/C++ headers.

As per coding guidelines, "ASCII-only in source files: no Unicode glyphs/em-dashes in .h/.hpp code or comments (only 7-bit ASCII)."

Also applies to: 285-288

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fl/log/log.h` around lines 108 - 113, Replace all Unicode em-dashes (—)
with ASCII-only alternatives (use hyphen - or double hyphen --) in the comments
at both locations in src/fl/log/log.h: at the anchor site (lines 108-113) in the
comment block describing the lite gate for FL_WARN_LIT / FL_LOG_LIT, and at the
sibling site (lines 285-288). Ensure all punctuation in header file comments
uses only 7-bit ASCII characters to comply with the repository's coding
guidelines.

Source: Coding guidelines

Comment on lines +163 to +166
fl::u32 ticks = (timeout_ms * kTickHz + 999u) / 1000u;
if (ticks < 0x100u) ticks = 0x100u; // hardware minimum
if (ticks > 0x00FFFFFFu) ticks = 0x00FFFFFFu; // 24-bit ceiling
TC() = ticks;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix 32-bit overflow in timeout-to-ticks conversion.

Line 163 multiplies two 32-bit values that can overflow before division, so large timeout values program the wrong WWDT TC.

Proposed fix
-    fl::u32 ticks = (timeout_ms * kTickHz + 999u) / 1000u;
-    if (ticks < 0x100u)      ticks = 0x100u;       // hardware minimum
-    if (ticks > 0x00FFFFFFu) ticks = 0x00FFFFFFu;  // 24-bit ceiling
-    TC() = ticks;
+    fl::u64 ticks = (static_cast<fl::u64>(timeout_ms) * kTickHz + 999u) / 1000u;
+    if (ticks < 0x100u)      ticks = 0x100u;       // hardware minimum
+    if (ticks > 0x00FFFFFFu) ticks = 0x00FFFFFFu;  // 24-bit ceiling
+    TC() = static_cast<fl::u32>(ticks);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fl::u32 ticks = (timeout_ms * kTickHz + 999u) / 1000u;
if (ticks < 0x100u) ticks = 0x100u; // hardware minimum
if (ticks > 0x00FFFFFFu) ticks = 0x00FFFFFFu; // 24-bit ceiling
TC() = ticks;
fl::u64 ticks = (static_cast<fl::u64>(timeout_ms) * kTickHz + 999u) / 1000u;
if (ticks < 0x100u) ticks = 0x100u; // hardware minimum
if (ticks > 0x00FFFFFFu) ticks = 0x00FFFFFFu; // 24-bit ceiling
TC() = static_cast<fl::u32>(ticks);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platforms/arm/lpc/watchdog_lpc.impl.hpp` around lines 163 - 166, The
calculation of ticks on line 163 multiplies two 32-bit values (timeout_ms and
kTickHz) which can overflow before the division by 1000u is applied, causing
incorrect WWDT TC programming for large timeout values. Fix this by casting one
of the operands to a 64-bit type (such as fl::u64) before the multiplication so
that the arithmetic is performed in 64-bit space to prevent overflow, then the
result will be divided correctly and truncated back to 32-bit for the ticks
assignment.

Two bugs the prior commit missed once the firmware actually reached a
physical LPC845-BRK:

1. **Pin discovery hung on LPC.** `_run_schema_and_pin_setup` was
   running `run_pin_discovery` against the bring-up sketch, but that
   sketch only binds `echo` — no `findConnectedPins` RPC. Result was
   a 30-second hang followed by an executor-shutdown crash.

   Skip pin discovery AND the GPIO connectivity pre-test when the
   target board is one of `{lpc845brk, lpcxpresso845max, lpcxpresso804}`.
   The bring-up short-circuit later in the pipeline runs the RPC echo
   test directly against the configured upload port — no jumper wire
   required, no `findConnectedPins` binding required.

2. **FL_WARN_LIT marker fired during setup() but was drained by the
   test scaffolding.** `_run_bring_up_tests` does `reset_input_buffer`
   → sleep(2s) → `reset_input_buffer` before sending the first request,
   which discards the boot banner along with the setup-time
   `FL_WARN_LIT("FL_WARN: LPC845 bring-up OK")` line. The harness then
   reported `warn_ok=False`.

   Move the FL_WARN_LIT emit into the `echo` lambda (`FL_WARN_LIT(
   "FL_WARN: echo invoked")`) so it fires per-request and lands in the
   accumulator alongside the RPC response. Update the harness's
   `warn_token` to match.

Verified on real LPC845-BRK on COM10:
  TX: {"jsonrpc":"2.0","method":"echo","params":[4242],"id":1}
  RX: b'FL_WARN: echo invoked\r\nREMOTE: {"id":1,"result":4242,"jsonrpc":"2.0"}\r\n'
  ✅ Serial.println — REMOTE: response received
  ✅ JSON-RPC echo — sentinel 4242 round-trip verified
  ✅ FL_WARN_LIT — FastLED warn pipeline reached host

This closes the original /goal: "Serial.println, FL_WARN and JSON RPC
all work with the auto research tool" on LPC845-BRK.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
ci/autoresearch/phases.py (1)

1551-1560: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix f-string prefix lint errors and string concatenation syntax bug.

Lines 1551, 1553, 1556, and 1558 use f-string prefixes on static strings without placeholders (Ruff F541 violation, flagged in past review). Additionally, lines 1558-1559 have a syntax bug: the second string literal on line 1559 is orphaned and will be discarded at runtime because there's no concatenation operator.

🐛 Proposed fix
             print(
-                f"   ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
+                "   ✅ FL_WARN_LIT — FastLED warn pipeline reached host"
                 if warn_ok
-                else f"   ❌ FL_WARN_LIT — warning literal not observed"
+                else "   ❌ FL_WARN_LIT — warning literal not observed"
             )
             print(
-                f"   ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
+                "   ✅ FL_DBG — full log pipeline (bonus, LARGE_MEMORY only)"
                 if log_ok
-                else f"   ⚠️  FL_DBG — full pipeline not active"
-                "  (expected on Low-memory targets — FL_WARN_LIT is the gate)"
+                else "   ⚠️  FL_DBG — full pipeline not active"
+                "  (expected on Low-memory targets — FL_WARN_LIT is the gate)"
             )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/autoresearch/phases.py` around lines 1551 - 1560, Remove the f-string
prefix (f"") from all four print statement strings on lines 1551, 1553, 1556,
and 1558 since they contain no placeholder expressions and violate Ruff F541.
Additionally, fix the string concatenation bug on lines 1558-1559 by adding a
concatenation operator (+) between the two string literals so the second string
on line 1559 is not discarded at runtime.
🧹 Nitpick comments (1)
ci/autoresearch/phases.py (1)

614-614: ⚡ Quick win

Extract duplicated bring_up_envs to a module-level constant.

The bring_up_envs set is defined identically in four different functions (lines 614, 852, 1042, 1178). Extract this to a module-level constant to eliminate duplication and prevent inconsistencies.

♻️ Proposed refactor

Add near the top of the file (after imports, around line 58):

 MAX_AUTORESEARCH_LANES = 16
+
+# LPC bring-up boards that use the minimal AutoResearchLpc sketch
+# (JSON-RPC echo only, no pin discovery or LED-protocol matrix).
+LPC_BRING_UP_ENVS = {"lpc845brk", "lpcxpresso845max", "lpcxpresso804"}

Then replace all four instances:

-    bring_up_envs = {"lpc845brk", "lpcxpresso845max", "lpcxpresso804"}
-    if env_for_sketch in bring_up_envs:
+    if env_for_sketch in LPC_BRING_UP_ENVS:
-    bring_up_envs = {"lpc845brk", "lpcxpresso845max", "lpcxpresso804"}
-    if final_environment in bring_up_envs:
+    if final_environment in LPC_BRING_UP_ENVS:
-    bring_up_envs = {"lpc845brk", "lpcxpresso845max", "lpcxpresso804"}
-    if ctx.final_environment in bring_up_envs:
+    if ctx.final_environment in LPC_BRING_UP_ENVS:
-    bring_up_envs = {"lpc845brk", "lpcxpresso845max", "lpcxpresso804"}
-    if ctx.final_environment in bring_up_envs:
+    if ctx.final_environment in LPC_BRING_UP_ENVS:

Also applies to: 852-852, 1042-1042, 1178-1178

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/autoresearch/phases.py` at line 614, The set constant `bring_up_envs` is
defined identically in four separate locations within the file (at lines 614,
852, 1042, and 1178). Extract this duplicated definition to a single
module-level constant near the top of the file after the import statements
(around line 58) to eliminate duplication and ensure consistency. Then replace
all four instances of the local `bring_up_envs` definitions with a reference to
the newly created module-level constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@ci/autoresearch/phases.py`:
- Around line 1551-1560: Remove the f-string prefix (f"") from all four print
statement strings on lines 1551, 1553, 1556, and 1558 since they contain no
placeholder expressions and violate Ruff F541. Additionally, fix the string
concatenation bug on lines 1558-1559 by adding a concatenation operator (+)
between the two string literals so the second string on line 1559 is not
discarded at runtime.

---

Nitpick comments:
In `@ci/autoresearch/phases.py`:
- Line 614: The set constant `bring_up_envs` is defined identically in four
separate locations within the file (at lines 614, 852, 1042, and 1178). Extract
this duplicated definition to a single module-level constant near the top of the
file after the import statements (around line 58) to eliminate duplication and
ensure consistency. Then replace all four instances of the local `bring_up_envs`
definitions with a reference to the newly created module-level constant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bbff2e37-9ad0-40e9-9fa4-0c78a5c70631

📥 Commits

Reviewing files that changed from the base of the PR and between e76141c and b468ed7.

📒 Files selected for processing (2)
  • ci/autoresearch/phases.py
  • examples/AutoResearchLpc/AutoResearchLpc.ino
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/AutoResearchLpc/AutoResearchLpc.ino

@zackees
zackees merged commit a13f4f8 into master Jun 14, 2026
7 of 8 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 14, 2026
zackees added a commit that referenced this pull request Jun 14, 2026
Adds `probePair(packed)` RPC to the LPC bring-up sketch — single-int
encoding `(out_pin << 8) | in_pin` reuses the `JsonToType<int>`
instantiation `echo` already pulled in (a 2-int binding would
re-instantiate the tuple/arg-converter chain and blow ~1.6 KB of
flash budget — confirmed in this session).

Probe sequence:
  1. Pre-charge: both pins OUTPUT HIGH for 200 µs to flush residual
     capacitance left by the previous probe (without this the scan
     gave "succeeds both ways" false positives for adjacent pins on
     the breakout header).
  2. Drive `out` LOW, switch `in` to INPUT_PULLUP, sleep 2 ms — the
     ~50 kΩ internal pull-up needs the full settle to win against
     stray breadboard capacitance. A real jumper wire pulls the line
     LOW in nanoseconds; parasitic coupling doesn't survive the fight.
  3. Read `in`, restore both pins to plain INPUT (high-Z).

Verified on real LPC845-BRK on COM10:
  Bidirectional hits: 1
    P0_10  <->  P0_11

P0_10 and P0_11 are the LPC845's only two true open-drain pins (no
internal pull-up resistors — the dedicated I2C SDA/SCL pads). That
asymmetry shows up in the scan as a stripe of unidirectional hits
when EITHER pin is used as the `in` side (its absent pull-up always
reads LOW), but as the `out` side they drive push-pull normally, so
the lone bidirectional hit cleanly identifies the bridge.

Flash impact: 63 060 / 65 536 B text (~940 B headroom remaining).

Refs: #3014, #3015.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant