Repository navigation
refactor(autoresearch): delegate all deployment to fbuild (removes pyocd from FastLED) - #3550
Conversation
…ocd) `ci/autoresearch/phases.py::_build_and_flash_nxplpc` was invoking `pyocd load` + `pyocd commander reset` directly. On this Windows box with the on-board LPC-Link2 (CMSIS-DAP v1.0.7 firmware, 2013 vintage), `pyocd` wedges on the Windows HID transport indefinitely — `pyocd list` never returns, `pyocd load` never returns, and the LPC845 is left halted with its shared VCOM silenced. An 8-minute wall-clock timeout is required to unstick each invocation. Fix: rip out the direct pyocd path. autoresearch is a bench-orchestration tool; it is not a flasher. Rename the helper to `_build_and_deploy_nxplpc` and route the deploy phase through `fbuild deploy` — the same layer that owns the build. If fbuild lacks a deploy backend for the target (nxplpc as of today), the call fails loudly with a pointer to the tracking issue instead of wedging the probe again. The error message explicitly forbids re-adding a fallback here. Also codify the rule so it doesn't regress: - `CLAUDE.md` — new "Deployment is fbuild's job — ALWAYS" section under Core Rules. - `agents/docs/build-system.md` — full rule + rationale, tools blocklist, and what to do when fbuild is missing a backend. - `agents/docs/hardware-autoresearch.md` — restates the rule at the autoresearch-doc level for agents landing there directly. Deployment wedge-proofing (timeout guards, probe preflight, UART ISP fallback, Windows CMSIS-DAP v1 warning, VCOM unwedge) belongs in one place with proper hardening, not scattered across every FastLED script that wants to flash a board. That work is tracked at FastLED/fbuild#921 (supersedes fbuild#551, extends fbuild#565). Refs: FastLED/fbuild#921, FastLED/fbuild#565, FastLED/fbuild#551 Co-Authored-By: Claude Opus 4.7 <[email protected]>
📝 WalkthroughWalkthroughDocumentation now requires Changesfbuild Deployment Policy and Autoresearch Flow
LPC Watchdog Vendor-Struct Migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ci/autoresearch/phases.py (1)
2147-2179: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRemove the implicit
lpc845brkfallback forenvironment.Lines 2151, 2166, and 2179 silently substitute
lpc845brkwhenenvironmentis missing. That masks caller bugs and can deploy the wrong board instead of surfacing the broken contract;ci/util/fbuild_runner.py:654already treatsenvironmentas mandatory for deploy. Fail fast before launching either subprocess. As per coding guidelines, "Never use silent fallbacks for missing critical resources - always fail fast with descriptive errors".Suggested fix
def _build_and_deploy_nxplpc( build_dir: Path, *, environment: str | None, upload_port: str | None, verbose: bool, ) -> bool: @@ - env = dict(os.environ) + if not environment: + print(f"{Fore.RED}❌ nxplpc deployment requires an explicit environment{Style.RESET_ALL}") + return False + + resolved_environment = environment + env = dict(os.environ) @@ build_cmd = [ "fbuild", "build", "--environment", - environment or "lpc845brk", + resolved_environment, ] @@ build_dir / ".fbuild" / "build" - / (environment or "lpc845brk") + / resolved_environment / "release" / "firmware.bin" ) @@ deploy_cmd = [ "fbuild", "deploy", "--environment", - environment or "lpc845brk", + resolved_environment, ]🤖 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 2147 - 2179, The build-and-deploy flow in phases.py is silently falling back to lpc845brk when environment is missing, which can hide caller bugs and target the wrong board. Update the fbuild build/deploy setup in the relevant helper to require environment explicitly, fail fast with a descriptive error before either subprocess runs, and remove the repeated environment or "lpc845brk" substitutions in the build command, firmware path, and deploy command. Use the existing build/deploy helper symbols in this block to keep the check centralized and consistent with ci/util/fbuild_runner.py’s mandatory environment contract.Source: Coding guidelines
🤖 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 2129-2135: The LPC helper was renamed from _build_and_flash_nxplpc
to _build_and_deploy_nxplpc, so the downstream test mock is still patching the
old symbol and won’t intercept the call. Update the patch target in
ci/tests/test_autoresearch_phases.py to use _build_and_deploy_nxplpc, and make
sure any assertions around the LPC path still reference the renamed helper so
the test continues to stub the subprocess flow correctly.
---
Outside diff comments:
In `@ci/autoresearch/phases.py`:
- Around line 2147-2179: The build-and-deploy flow in phases.py is silently
falling back to lpc845brk when environment is missing, which can hide caller
bugs and target the wrong board. Update the fbuild build/deploy setup in the
relevant helper to require environment explicitly, fail fast with a descriptive
error before either subprocess runs, and remove the repeated environment or
"lpc845brk" substitutions in the build command, firmware path, and deploy
command. Use the existing build/deploy helper symbols in this block to keep the
check centralized and consistent with ci/util/fbuild_runner.py’s mandatory
environment contract.
🪄 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: 454b8fcc-1adf-4b54-890d-c3dccff337d0
📒 Files selected for processing (4)
CLAUDE.mdagents/docs/build-system.mdagents/docs/hardware-autoresearch.mdci/autoresearch/phases.py
Related silicon concern: LPC845 DMA-to-GPIO may not be supportedParking this here because it affects what "deploy works" actually validates — even after fbuild#921 lands. The finding (surfaced from a community observation; awaiting NXP confirmation):
Why this matters for the LPC845 work: The current If DMA-to-GPIO doesn't work on real LPC845 silicon, this data path silently fails or bus-faults — no LED output regardless of how well deploy succeeds. Same class of bug as the reverted LPC804 phantom DMA cascade (#3505 / peripheral-existence guardrail), but subtler: DMA does exist on LPC845, just possibly can't target this specific destination register family. Workaround if NXP confirms the gap — SCT-drives-pin + DMA feeds SCT match:
Immediate implications for #3550:
Suggested follow-up (once NXP answers):
Cross-refs: #3517 (closed meta), #3468 (closed scaffold), #3505 (LPC804 phantom precedent), fbuild#921 (deploy hardening). |
…921 Filed FastLED/fbuild#921 without spotting that fbuild#595 already shipped the exact deployer being requested. #921 is now closed as redundant. Updated references throughout to point at the actual merged work: - **#595** — LpcDeployer Phase 1 (lpc21isp UART ISP path). Wires the `Platform::NxpLpc` arm in fbuild-daemon's deploy dispatch. Sidesteps the CMSIS-DAP HID wedge entirely because lpc21isp uses the CDC/VCOM UART, not the HID interface. - **#923** — path resolver + baud/hex safety nets. - **#928** — `-bin` handling + `\.\COM10` prefix for Windows serial ports. Files: - `ci/autoresearch/phases.py::_build_and_deploy_nxplpc` — docstring + error path reference the shipped PR chain instead of the closed issue. - `CLAUDE.md`, `agents/docs/build-system.md`, `agents/docs/hardware-autoresearch.md` — same substitution in the "Deployment is fbuild's job" rule text. No behavioral change; comments/docs only. Co-Authored-By: Claude Opus 4.7 <[email protected]>
First live run against fbuild 2.3.24 failed with "error: unexpected argument '--upload-port' found" — fbuild's deploy CLI flag is -p/--port. Verified end-to-end on LPC845-BRK hardware: build → fbuild deploy (probe-rs SWD, ~2 s, touchless) → VCOM reopens → freshly-flashed firmware answers JSON-RPC. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ci/autoresearch/phases.py (1)
2158-2158: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winHandle missing
fbuildwith the existing failure path. Bothsubprocess.run(...)calls can raiseFileNotFoundErrorbeforereturncodeis checked, so a missing or non-executablefbuildstill ends in a traceback instead of the descriptive deploy error message.🤖 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 2158, The build invocation in the deploy flow can raise FileNotFoundError before the returncode check, so a missing or non-executable fbuild bypasses the existing error handling. Update the subprocess.run path in phases.py so the build_cmd execution is wrapped by the same failure handling used for other deploy/build failures, and ensure the code that reports the descriptive deploy error message is reached for FileNotFoundError as well. Use the build execution logic around subprocess.run and the existing deploy failure path in this phase as the reference point.Source: Coding guidelines
🤖 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.
Outside diff comments:
In `@ci/autoresearch/phases.py`:
- Line 2158: The build invocation in the deploy flow can raise FileNotFoundError
before the returncode check, so a missing or non-executable fbuild bypasses the
existing error handling. Update the subprocess.run path in phases.py so the
build_cmd execution is wrapped by the same failure handling used for other
deploy/build failures, and ensure the code that reports the descriptive deploy
error message is reached for FileNotFoundError as well. Use the build execution
logic around subprocess.run and the existing deploy failure path in this phase
as the reference point.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e2907de8-87bd-43fc-a194-1a0e16e41bca
📒 Files selected for processing (1)
ci/autoresearch/phases.py
…+ bench defines Three coordinated fixes, all silicon-validated on the LPC845-BRK today: 1. **Watchdog never armed — MOD/TC registers were swapped.** The hand-rolled WWDT map in watchdog_lpc.impl.hpp had TC at offset 0x0 and MOD at 0x4; the vendor CMSIS PAL (and UM11029) say MOD=0x0, TC=0x4. begin() therefore wrote the tick count into MOD (WDEN never set) and the mode bits into TC — the watchdog silently did nothing. Diagnosed on silicon: a deliberately wedged RPC handler ran forever with a 3 s watchdog "armed". Rewrote the file to use vendor WWDT_Type/SYSCON_Type structs per the #3437 no-hand-rolled-maps policy (the file's old "vendor header only has IRQ enums" rationale was stale since framework#33/#34 shipped the full PAL). Also gated the impl selector to LPC845/LPC804 only — the old code poked LPC84x addresses on LPC11xx/15xx, which have different SYSCON layouts; those now take the no-op backend. 2. **Wedge backtrace via WWDT warning → NMI.** begin() programs WARNINT (~8 ms before reset) and routes the WDT interrupt to the Cortex-M0+ NMI via SYSCON->NMISRC. The ACLPC core's NMI_Handler (strong alias of HardFault_Handler) already prints the stacked PC/LR/xPSR of the interrupted context and resets — so a wedge now emits `FAULT: HardFault PC=<wedged addr> ...` live over USART0 and the chip self-recovers. Validated: wedge at t=0 → backtrace line at t=+3.0 s → PC symbolicated against firmware.map to the exact static object (`autoresearch::dma_spi::harnessDriver()::drv`) the SPI+DMA driver had jumped into → boot banner → RPC echo alive again with no physical intervention. Opt out: -DFL_LPC_WDT_NMI_BACKTRACE=0. 3. **autoresearch injects the bench gate defines.** `--dma-spi` now adds FASTLED_LPC_SPI_DMA=1 (and FASTLED_LPC_SPI_DMA_MAX_BYTES=512) to the synthesised build_flags; `--pwm-dma-cl` adds FASTLED_LPC_PWM_DMA=1. Without the gate macro the harness compiles out and every bench RPC reports "no reply" against healthy firmware. The 512-byte cap matters: at the driver default (2048) the u16 encode buffer (4 KB) + u8 harness buffer (2 KB) pushed static RAM to 15.10/16 KB (94%) and the first RPC HardFaulted at PC=0 when heap/stack collided. Capped: 10.60 KB (66%), firmware stable. Known remaining (tracked separately): the SPI+DMA driver itself still wedges on first use — control flow jumps into the driver's static object during lazy init. The new backtrace pinpointed it; fix follows. Refs: #3456, #3453, #3437, #3300 (this explains the suspected-HardFault empty-RX blocker: RAM exhaustion + never-armed watchdog). Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
ci/autoresearch/phases.py (1)
899-917: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFactor the LPC bench define selection into one helper.
The parse-time and deferred-synthesis paths now duplicate the same define list; a small helper avoids future drift where one path compiles the bench handlers and the auto-detected path does not.
Proposed refactor
+def _lpc_bench_defines_from_args(args: Args) -> list[str]: + lpc_bench_defines: list[str] = [] + if getattr(args, "dma_spi", False): + lpc_bench_defines.append("FL_LPC_SPI_DMA=1") + lpc_bench_defines.append("FL_LPC_SPI_DMA_MAX_BYTES=512") + if getattr(args, "pwm_dma_cl", False): + lpc_bench_defines.append("FL_LPC_PWM_DMA=1") + return lpc_bench_definesThen call it from both synthesis paths.
Also applies to: 1193-1208
🤖 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 899 - 917, The LPC bench define selection is duplicated between the parse-time and deferred-synthesis paths, which can drift and cause the wrong bench handlers to be compiled. Extract the shared logic into a single helper near the existing lpc_bench_defines setup in phases.py, use it in both synthesis paths, and ensure the helper preserves the current args checks for dma_spi and pwm_dma_cl along with FASTLED_LPC_SPI_DMA_MAX_BYTES.
🤖 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 899-917: The new LPC compile flags in lpc_bench_defines still use
the запрещён legacy FASTLED_* prefix; rename them to the required FL_LPC_*
equivalents here and in the matching C++ preprocessor checks. Update the flag
strings added under args.dma_spi and args.pwm_dma_cl, including the SPI DMA
max-bytes define, and make sure every corresponding `#if` defined(...) site in the
same PR uses the new identifiers consistently.
In `@ci/autoresearch/staging.py`:
- Around line 46-49: The example in the staging docs uses an outdated FASTLED_*
build flag name; update the `extra_defines` description to use the new `FL_*`
macro vocabulary instead. In the `staging.py` comment/example, replace the
`FASTLED_LPC_SPI_DMA` reference with the matching `FL_LPC_SPI_DMA` define and
keep the wording aligned with what `phases.py` actually emits. Use the
`extra_defines` docstring text and the `--dma-spi` example as the place to fix.
In `@src/platforms/arm/lpc/watchdog_lpc.impl.hpp`:
- Around line 53-55: Rename the new configuration macro in watchdog_lpc.impl.hpp
from FL_LPC_WDT_NMI_BACKTRACE to the spelled-out FL_WATCHDOG_LPC_NMI_BACKTRACE,
and update every related reference consistently. Make sure the documentation
text and all conditional compilation checks in the watchdog implementation use
the same FL_WATCHDOG_* vocabulary, including the places covered by the later
occurrences in the file.
- Around line 175-178: The watchdog tick calculation in watchdog_lpc.impl.hpp
overflows in the timeout_ms * kTickHz multiplication before clamping, so the
computed window can be too short. Update the tick computation in the watchdog
programming path to use 64-bit arithmetic first, then clamp to the hardware
minimum and 24-bit ceiling before assigning to WWDT->TC. Keep the fix localized
around the tick calculation and the watchdog initialization logic in the
relevant function.
---
Nitpick comments:
In `@ci/autoresearch/phases.py`:
- Around line 899-917: The LPC bench define selection is duplicated between the
parse-time and deferred-synthesis paths, which can drift and cause the wrong
bench handlers to be compiled. Extract the shared logic into a single helper
near the existing lpc_bench_defines setup in phases.py, use it in both synthesis
paths, and ensure the helper preserves the current args checks for dma_spi and
pwm_dma_cl along with FASTLED_LPC_SPI_DMA_MAX_BYTES.
🪄 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: 4d222a9c-355c-4cd8-bc04-dfc8ed03140c
📒 Files selected for processing (5)
ci/autoresearch/phases.pyci/autoresearch/staging.pysrc/platforms/arm/lpc/rx_sct_capture.cpp.hppsrc/platforms/arm/lpc/watchdog_lpc.impl.hppsrc/platforms/watchdog.impl.cpp.hpp
✅ Files skipped from review due to trivial changes (1)
- src/platforms/arm/lpc/rx_sct_capture.cpp.hpp
## ISR-refillable drivers (#3453 follow-up) - **`lpc_dma_isr.h`** — shared DMA0 interrupt hub: one strong `DMA0_IRQHandler` (the LPC845 has a single DMA IRQ line for all 25 channels) dispatching `INTA` completion bits to per-channel callbacks registered via `fl::lpc::registerDmaChannelIsr()`. Opt-in via `FASTLED_LPC_DMA_ISR=1`; requires the ACLPC core with named weak IRQ vector slots (framework-arduino-lpc8xx#38, merging alongside). - **SPI streaming** — `ARMHardwareSPIOutputDMA::kickDmaStreamAsync()`: ping-pong halves of the encode buffer; the completion ISR arms the pre-encoded other half (~2 µs wire gap) and refills the freed one, so frames larger than the buffer stream without blocking the main thread. Bench RPC `dmaSpiStreamOverlap` (gated on the ISR build) beacon-toggles across a 1024-byte multi-chunk stream. - **UART async TX** — new `ARMHardwareUARTOutputDMA<TX_PIN, BAUD>` (`uart_arm_lpc_dma.h`): USART1 (or 2) TX paced by its fixed DMA request channel (ch3/ch5 per UM11029 Table 296), chunks chained from the ISR, DMA reading the caller's buffer in place (no staging copy). Owns its full plumbing (clock, reset, FCLKSEL, SWM, OSR/BRG baud search) per the #3580 lesson. USART0 stays free as the console — the "drive a data lane and keep printing" capability. - **Bench**: `bash autoresearch lpc845 --dma-uart` — new harness (`AutoResearchUartDma.h`, `uartDmaStreamOnce`/`Overlap` RPCs, 2048- byte streams = two descriptors so completion REQUIRES the ISR chain), host runner `test_lpc_uart_dma.py`, args/phases wiring, define injection (`FASTLED_LPC_UART_DMA=1` + `FASTLED_LPC_DMA_ISR=1`). ## CodeRabbit review fixes (PR #3550) - `test_autoresearch_phases.py`: mock patches the renamed `_build_and_deploy_nxplpc` (was silently missing the LPC path). - Watchdog tick math: u64 intermediate — `60000 ms * 125 kHz` wraps u32 above ~34.3 s and programmed a much shorter window. - `FL_LPC_WDT_NMI_BACKTRACE` → `FL_LPC_WATCHDOG_NMI_BACKTRACE` (spelled-out vocabulary; macro is new in this PR). Silicon status: SPI sync bench remains green (rebuilt, RAM 11.41 KB); the ISR paths await the ACLPC weak-alias core (framework#38) + fbuild pin bump before on-device validation. Refs #3453, #3580, framework-arduino-lpc8xx#38. Co-Authored-By: Claude Fable 5 <[email protected]>
…n AutoResearch (#3601) * fix(lpc): SPI+DMA driver works on silicon — 6 stacked hardware bugs (closes #3580) `bash autoresearch lpc845 --dma-spi` is now fully green on the LPC845-BRK: build → fbuild deploy (probe-rs SWD) → all four bench RPCs PASS, including the async proof (978 CPU beacon toggles during a 512-byte DMA stream) and a throughput measurement matching the FIFO-less-IP physical model. Six independent silicon bugs, each masking the next, bisected with the WWDT NMI backtrace + breadcrumb prints + bounded-spin register snapshots: 1. **DMA0->SRAMBASE never programmed.** The driver "punted to the SDK conventional address" that nothing ever set — the DMA engine fetched channel descriptors from the FLASH VECTOR TABLE at address 0 and wrote through garbage pointers, corrupting .bss (the original PC=<static object> wedge). New shared `lpc_dma_descriptor_table.h` owns a FL_ALIGNAS(512) 25-channel table; both the SPI driver and the SCT+DMA runtime call `fl::lpc::ensureDmaSramBase()` at init, and `configureChannelDescriptor()` now returns bool so SETVALID can never arm an unwritten descriptor. 2. **SPI peripheral never clocked.** init() assumed "the user's startup enables the SPI clock + SWM routing" — nothing did, and reading an unclocked LPC peripheral stalls the AHB bus forever (no fault; the load never retires). init() now owns SYSAHBCLKCTRL0 (SPI0/1 + SWM), PRESETCTRL0 reset release, and SWM PINASSIGN routing of SCK/MOSI to the template pins. 3. **Wrong DMA channel.** Default was 4, citing a nonexistent "UM11029 Table 80". Ground truth (UM11029 §16.3.3 Table 296): channel 4 is USART2_RX; SPI0_TX is channel 11, SPI1_TX is 13. The armed channel sat waiting for a request line that never fires. 4. **Channel never TRIGGERED.** XFERCFG.SWTRIG was 0 on the belief that "the SPI TXRDY hardware-triggers it" — but PERIPHREQEN requests only PACE transfers; the channel must first be triggered (CTLSTAT.TRIG), and with HWTRIGEN=0 only software can do that. Register snapshot showed CFGVALID=1, TXRDY=1, TRIG=0, XFERCOUNT frozen. SWTRIG=1. 5. **SPI function clock unselected.** SYSCON->FCLKSEL[9] (SPI0) resets to "none": the register bus worked but the shift engine had no clock — first DMA write accepted, then STAT=0 and frozen mid-shift. init() selects main_clk. 6. **Frame never closed after a stream.** DMA writes plain TXDAT (no per-unit EOT), so the master held the frame open and MSTIDLE never re-asserted — every handler call after a completed stream wedged in its entry waitFully() (bench alternated PASS/WEDGE via watchdog reboots). Per-byte sticky EOT fixed it but cost 39% throughput in SSEL gaps (4 MHz → 2.46 MHz effective, measured); final fix closes the frame once in waitFully() via STAT.ENDTRANSFER after the DMA drains. Bench-side changes: - `AutoResearchSpiDma.h`: bounded spin (2M iters) returns a DMA/SPI register snapshot CSV instead of wedging into the watchdog; stale "fbuild SystemInit configures SPI0" comment corrected. - `test_lpc_dma_spi.py`: SCK check remodeled as effective throughput. The LPC845 SPI is FIFO-less — each byte costs 8/SCK shift + ~0.76 us DMA refill (measured), so wire SCK 4 MHz yields ~2.9 MHz effective. The old ±25%-of-wire-SCK band was physically unattainable. - `phases.py`: channel-override hints corrected (SPI1=13, SPI0=11). Acceptance (LPC845-BRK, COM10, 2026-07-02): dmaSpiTransferOnce(32) PASS — 109 us (theoretical 64) dmaSpiTransferOnce(256) PASS — 716 us (theoretical 512) dmaSpiTransferOverlap PASS — 1411 us, 978 CPU toggles during DMA dmaSpiMeasureSck PASS — 2.894 MHz effective vs 2.76 model PASS — #3456 SPI+DMA async bench green. Closes #3580. Refs #3456, #3453 (Phase 1 silicon gate), #3517 (Phase B.1 acceptance — now genuinely met), #3437 (vendor-PAL policy). Co-Authored-By: Claude Fable 5 <[email protected]> * fix(lpc): polled SPI driver owns its LPC845 peripheral plumbing too Port the silicon-validated init block from the DMA sibling (#3580) to ARMHardwareSPIOutput<>: SYSAHBCLKCTRL0 (SPI0/1 + SWM), PRESETCTRL0 reset release, FCLKSEL function-clock select, and SWM SCK/MOSI routing. Without it the first spi->STAT read stalls the AHB bus forever — the polled driver had the identical "user's startup does the plumbing" contract that nothing honors. LPC845-gated; LPC804 keeps the old contract until it gets vendor-PAL bring-up of its own. Compile-verified in the lpc845 AutoResearch build (the DMA harness includes this header). Refs #3580, #3453. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(lpc): ISR-refillable async streaming (SPI + UART) + review fixes ## ISR-refillable drivers (#3453 follow-up) - **`lpc_dma_isr.h`** — shared DMA0 interrupt hub: one strong `DMA0_IRQHandler` (the LPC845 has a single DMA IRQ line for all 25 channels) dispatching `INTA` completion bits to per-channel callbacks registered via `fl::lpc::registerDmaChannelIsr()`. Opt-in via `FASTLED_LPC_DMA_ISR=1`; requires the ACLPC core with named weak IRQ vector slots (framework-arduino-lpc8xx#38, merging alongside). - **SPI streaming** — `ARMHardwareSPIOutputDMA::kickDmaStreamAsync()`: ping-pong halves of the encode buffer; the completion ISR arms the pre-encoded other half (~2 µs wire gap) and refills the freed one, so frames larger than the buffer stream without blocking the main thread. Bench RPC `dmaSpiStreamOverlap` (gated on the ISR build) beacon-toggles across a 1024-byte multi-chunk stream. - **UART async TX** — new `ARMHardwareUARTOutputDMA<TX_PIN, BAUD>` (`uart_arm_lpc_dma.h`): USART1 (or 2) TX paced by its fixed DMA request channel (ch3/ch5 per UM11029 Table 296), chunks chained from the ISR, DMA reading the caller's buffer in place (no staging copy). Owns its full plumbing (clock, reset, FCLKSEL, SWM, OSR/BRG baud search) per the #3580 lesson. USART0 stays free as the console — the "drive a data lane and keep printing" capability. - **Bench**: `bash autoresearch lpc845 --dma-uart` — new harness (`AutoResearchUartDma.h`, `uartDmaStreamOnce`/`Overlap` RPCs, 2048- byte streams = two descriptors so completion REQUIRES the ISR chain), host runner `test_lpc_uart_dma.py`, args/phases wiring, define injection (`FASTLED_LPC_UART_DMA=1` + `FASTLED_LPC_DMA_ISR=1`). ## CodeRabbit review fixes (PR #3550) - `test_autoresearch_phases.py`: mock patches the renamed `_build_and_deploy_nxplpc` (was silently missing the LPC path). - Watchdog tick math: u64 intermediate — `60000 ms * 125 kHz` wraps u32 above ~34.3 s and programmed a much shorter window. - `FL_LPC_WDT_NMI_BACKTRACE` → `FL_LPC_WATCHDOG_NMI_BACKTRACE` (spelled-out vocabulary; macro is new in this PR). Silicon status: SPI sync bench remains green (rebuilt, RAM 11.41 KB); the ISR paths await the ACLPC weak-alias core (framework#38) + fbuild pin bump before on-device validation. Refs #3453, #3580, framework-arduino-lpc8xx#38. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(lpc): DMA ISR hygiene — stale-INTA clear, end-of-stream quiesce, trace hooks Silicon-hardening from the first ISR-streaming bring-up session: - **Hub (`lpc_dma_isr.h`)**: `registerDmaChannelIsr` now W1C-clears any stale INTA and NVIC pending before enabling — a prior synchronous transfer (XFERCFG.SETINTA) left INTA pending and the callback fired before the caller finished initializing its stream state. - **Single-TU handler**: `DMA0_IRQHandler` moved from the hub header to `lpc_dma_isr.cpp.hpp` (unity slot) — a non-inline extern "C" definition in a header emitted one copy per TU and failed the link with 10+ "multiple definition" errors. - **End-of-stream quiesce (both drivers)**: the ISR's final branch now INTENCLRs its channel. Leaving the gate open let a residual completion fire into post-stream state and HardFault the RPC reply path (deterministic PC in the stack region; gone with the quiesce). - **SPI INTENSET.TXRDYEN removed**: a leftover from the failed pacing hypothesis (#3580 — SWTRIG was the real fix). A pending-but-disabled TXRDY line is a live grenade the moment anything enables SPI0_IRQn. - **Opt-in ISR trace** (`-DFASTLED_LPC_SPI_DMA_ISR_TRACE=1`): polled breadcrumbs from IRQ context — this is what bisected all of the above. - `--dma-spi` now also injects `FASTLED_LPC_DMA_ISR=1`. - Test helper Args factory gains the pwm_dma_cl/dma_spi/dma_uart fields (pre-existing construction failure). Silicon status (LPC845-BRK, 2026-07-02): - UART async bench: green ×3 runs including back-to-back 2048-byte streams (20,511 µs vs 20,480 theoretical; 8,455 toggles). - SPI sync bench: green (unchanged). - SPI ISR stream: FIRST stream green ("1,2577,1358" — 1024 B, 4 chained chunks, 1358 main-thread toggles); repeat-kick corrupts memory — tracked with full evidence at #3585. Refs #3453, #3580, #3585, framework-arduino-lpc8xx#38, fbuild#944. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(autoresearch): route LPC bench serial through fbuild's Rust monitor, not pyserial The LPC845 SPI/UART bench runners hand-rolled raw pyserial request/reply loops. On Windows these dropped replies ~one-per-session — `in_waiting` under-reports, a pre-write `reset_input_buffer()` races the reply, byte-at-a-time reads straddle the port timeout. The firmware answered every RPC correctly (verified with a tight manual loop); the pyserial *transport* lost them. Fix: both runners now use `ci.rpc_client.RpcClient` over `ci.util.serial_interface.create_serial_interface()` — fbuild's native (Rust) serial monitor, the same path ble/decode/driver_sweep/coroutine tests already use. Mandatory JSON-RPC id correlation + correct framing make the bench 100% deterministic (SPI: 5/5 cases green run after run; UART: 2/2). A thin `SpiBench`/`UartBench` sync facade wraps the async client so the run_* helpers are unchanged. Two supporting changes this required: - The bench C++ handlers were `(int, int)` positional — the raw-pyserial convention. RpcClient wraps args as a single JSON param, so the handlers now take `(const fl::json& args)` and read `args[N].as_int()` (the house convention every `-> fl::json` handler already uses). Handler logic is unchanged; only the bind adapter differs. - The handlers return a CSV *string*; RpcClient coerces non-dict results to {} but preserves the full line in `raw_line`, so the facade recovers the CSV there. (A later cleanup could return fl::json objects.) Docs: new "Device serial: fbuild's Rust monitor ONLY — NEVER raw pyserial" rule in agents/docs/hardware-autoresearch.md, plus a "Device serial - No raw pyserial" entry in agents/docs/python-standards.md. Also folds in the #3585 RAM fix: the SPI ISR-stream harness buffer defaults to 512 B (was 1024) so the DMA ISR's deep preemption of the RPC stack can't collide with the heap on the 16 KB part — that was the "repeat-kick corruption", a stack/heap collision, not a driver bug (the ping-pong logic is correct: 5 back-to-back streams green with headroom). Refs #3456, #3453, #3585. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(lint): PYS001 — ban raw pyserial in AutoResearch; migrate all offenders ## The checker `ci/lint_python/pyserial_checker.py` (PYS001) bans `import serial` / `from serial import ...` anywhere under `ci/autoresearch/`. No allowlist: device serial must go through fbuild's native (Rust) serial monitor via `ci.rpc_client.RpcClient` + `ci.util.serial_interface.create_serial_interface`. The genuinely-exceptional site (e.g. a not-yet-migrated BLE bridge) uses an inline `# noqa: PYS001` with a justification. Wired into the Python lint pipeline (`ci/lint/stage_impls.py`). The low-level pyserial plumbing under `ci/util/` (the backend that create_serial_interface(use_pyserial= True) selects) is out of scope — that is where pyserial legitimately lives. Why: hand-rolled pyserial request/reply loops drop replies ~one-per- session on Windows (`in_waiting` under-reports, a pre-write `reset_input_buffer()` races the reply, byte-at-a-time reads straddle the port timeout). The firmware answers every RPC; pyserial loses them. Silicon-diagnosed 2026-07-04 on the LPC845 SPI/UART benches. ## All 14 offenders across 12 files migrated - **Shared facade** `ci/autoresearch/rpc_bench.py` — `RpcBench`, a sync wrapper over the async fbuild-backed RpcClient (context-manager + CSV-result recovery, since RpcClient coerces non-dict results to {}). - **7 RPC test runners** (test_lpc_pwm_dma_cl / _ws2812_loopback / _pin_toggle_rx, test_flexio_rx_objectfled / _rx_squarewave / _spi_smoke, test_objectfled_spi_smoke) → RpcBench. - **3 debug scripts** → RpcBench (find_pins, object_fled_small) / raw SerialInterface firehose (object_fled_capture). - **ota.py + 2 phases.py port polls** → new sanctioned `port_utils.port_exists()` (OS-level list_ports enumeration, no device open). - **phases.py bring-up echo** → SerialInterface write/read_lines. Hardware-verified on LPC845: echo sentinel round-trip + REMOTE prefix + FL_WARN pipeline all PASS. Docs: "Device serial: fbuild's Rust monitor ONLY" in agents/docs/hardware-autoresearch.md + agents/docs/python-standards.md (committed earlier). KeyboardInterrupt handlers added to every new connect block (KBI001). Verified: ruff, PYS001 (0), KBI001 (0), AST all clean; the two already-migrated runners (test_lpc_dma_spi, test_lpc_uart_dma) stay green over the same transport. Co-Authored-By: Claude Fable 5 <[email protected]> * docs(agents): mandate `fbuild port scan` before any "board not attached" claim Strengthens the "Check if the target hardware might already be attached" rule (cpp-standards.md) with a MANDATORY, unconditional first step: never write "board X is not attached" / "static-verified only" without first enumerating what is physically connected via `fbuild port scan` — fbuild's native scanner that resolves each port's vendor/product from the FastLED boards DB (two rows per port). Cross-referenced from hardware-autoresearch.md with example output. History: on 2026-07-04 an agent declared the flexio/objectfled bench runners "static-verified only, target ESP32/Teensy boards not attached" without ever scanning — an ESP32-WROOM (COM11), three ESP32-S3s, and a Teensy were attached the whole time. When it then reached for raw pyserial `list_ports`, the developer corrected it to `fbuild port scan`. Both corrections are now the rule: enumerate, don't infer; use the fbuild scanner, not pyserial. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(autoresearch): drop sys.path bootstrap (SPI001), launch runners via `-m` The pyserial→RpcBench migration added a `sys.path.insert(_REPO_ROOT)` bootstrap to each runner so `from ci.autoresearch.rpc_bench import …` would resolve when run by script path. That trips the SPI001 sys-path-modification ban. Correct fix: remove the bootstrap and launch the runners as modules (`uv run python -m ci.autoresearch.<name>`), which puts the repo root on sys.path[0] so `ci.*` resolves with no hack. - Removed the `_REPO_ROOT`/`sys.path.insert` block from all 12 runners (+ dropped now-unused Path imports, obsolete E402 noqas). - phases.py: switched all 5 subprocess invocations from `"ci/autoresearch/test_lpc_*.py"` to `"-m", "ci.autoresearch.test_lpc_*"`. - Updated each runner's docstring "Usage:" to the `-m` form. Verified: SPI001=0, PYS001=0, KBI001=0, ruff clean; `-m` import resolution confirmed for the runners. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(autoresearch): satisfy ty — dict-arg RPCs + drop stale serial annotation `bash lint` ty pass flagged 3 type errors from the pyserial→RpcBench migration: - RpcBench.call typed `args: list[Any] | None`, but the flexio/objectfled runners pass a dict (object-param handlers). Widened to `list[Any] | dict[str, Any] | None`, and correspondingly widened RpcClient.send's `args` at the source — send wraps `[args]` opaquely as the single `fl::json` RPC parameter, so a dict was always valid at runtime; the annotation was just too narrow. Backward-compatible widening; existing list callers unaffected. - test_lpc_pwm_dma_cl.py: a run_* helper still annotated `s: "serial.Serial"` (leftover from the pre-migration raw-pyserial version) → `s: "RpcBench"`. Verified: ty clean, ruff clean, SPI001/PYS001/KBI001 = 0. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
Summary
pyocd load/pyocd commander resetcalls fromci/autoresearch/phases.py(_build_and_flash_nxplpc→ renamed_build_and_deploy_nxplpc). autoresearch no longer flashes anything — it delegates the deploy phase tofbuild deploy, the same layer that already ownsfbuild build.CLAUDE.md(Core Rules),agents/docs/build-system.md(full rule + rationale), andagents/docs/hardware-autoresearch.md(autoresearch-specific restatement).Why
On 2026-07-01 the LPC-Link2 CMSIS-DAP v1.0.7 firmware (2013 vintage, shipped on the LPC845-BRK) wedged pyocd's Windows HID transport for the full 8-minute autoresearch timeout —
pyocd listnever returns,pyocd loadnever returns, and the LPC845 was left halted with its shared VCOM (COM10) silenced. That's a fbuild-owned platform-integration problem that was leaking into every FastLED script that wanted to flash a board. Consolidating deploy into fbuild is the only place that fix scales.Good news that surfaced during this PR: fbuild already shipped the deployer — I just missed it before filing a redundant issue. The nxplpc
LpcDeployerlanded in fbuild#595 (2026-06-15), usinglpc21ispUART ISP that never opens the CMSIS-DAP HID interface, so it structurally cannot hit the same wedge. Follow-ups #923 (path resolver + baud/hex safety nets) and #928 (-binhandling +\.\COM10Windows prefix) refined it. This PR is the FastLED-side change needed to actually route autoresearch through that deployer — which is why ourbash autoresearch lpc845 --pwm-dma-clwas still hitting pyocd's HID wedge despite fbuild having the fix in place for three weeks.What NOT to do
The new function's error path deliberately says:
If a future PR is tempted to re-add a direct flash-tool call as a workaround, that comment is the reminder to fix it in fbuild instead.
Tracking
-binhandling +\.\COM10prefix for Windows. Merged 2026-07-01.Test plan
bash lintpasses (Python side clean; ruff verified locally).bash autoresearch lpc845 --pwm-dma-clrunsfbuild build→fbuild deploy→ RPC echo without touching pyocd or any CMSIS-DAP HID interface. First-attempt validation on the LPC845-BRK is a follow-up to this PR (blocked in this session by the pre-existing halted target from the last failedpyocd load).pwm-dma-cldriver is architecturally uncertain until NXP confirms via their forum.🤖 Generated with Claude Code
Summary by CodeRabbit