Repository navigation
feat(lpc): AutoResearch PWM+DMA clockless harness + TX→RX readback (#3468) - #3472
Conversation
…3468) Closes #3468's byte-flow readback goal on host with a complete TX→RX loopback that exercises `ChannelEngineLpcSctDma::show()` end to end, plus the AutoResearch harness code and host phase for the on-silicon version. ## Host-side TX→RX readback (the "TX → RX confirmed working" bit) `LpcSctDmaTransmitter` gains a host-only byte-capture buffer: - `mTxCapture` (fl::vector<u8>) — populated by `transmit()` on host / stub builds so tests can round-trip the exact byte stream through the LPC RX device's decoder. Left empty on LPC845 silicon. - `getCapturedTxBytes()` / `clearCapture()` accessors. `ChannelEngineLpcSctDma` exposes the transmitter via a `transmitter()` accessor for test-facing access. New host test in `tests/fl/channels/lpc_sct_dma_engine.cpp`: "#3468: end-to-end TX→RX readback through engine.show()" 1. Build ChannelData with a known GRB payload (includes an alternating-bit pattern to exercise T0/T1 transitions). 2. Drive it through `engine.enqueue()` + `engine.show()`. The host build of `LpcSctDmaTransmitter` captures the byte stream. 3. Read the captured bytes back. 4. Convert to WS2812 edge pairs (T0H/T0L/T1H/T1L timing). 5. Push into `LpcSctRxChannel` via `injectEdges()`. 6. Decode through the shared 4-phase WS2812 decoder. 7. Byte-for-byte compare against original payload. The engine's `show()` path is fully exercised — no bypassing to a separate encoder. If the engine drops or reorders a byte, step (7) fails. The only piece not exercised is the actual SCT/DMA register sequencing, which requires silicon. Second host test: "capture buffer is cleared between transmits" confirms overwrite semantics. ## AutoResearch device-side harness `examples/AutoResearch/AutoResearchPwmDmaClockless.h` — new header, gated on `FL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA`. Three RPC handlers registered via `autoresearch::pwm_dma_cl::bind(remote)`: - `pwmDmaClFrameOnce(led_count, rgb, data_pin)` — drive one frame through the channels-API engine, return timing. - `pwmDmaClFrameBurst(led_count, rgb, n_frames, data_pin)` — N frames back-to-back, report measured fps × 100. - `pwmDmaClCaptureSelf(led_count, rgb, data_pin, rx_pin, capture_ms)` — drive + self-loopback capture via `LpcSctRxChannel`, return decoded bytes as CSV for host byte-compare. Wired into `AutoResearchLowMemory.h` under the same gate so LPC845 builds pick it up automatically when `-DFASTLED_LPC_PWM_DMA=1` is set. ## AutoResearch host-side wiring `--pwm-dma-cl` flag added to `ci/autoresearch/args.py` and the `autoresearch` bash wrapper. Phase dispatch in `ci/autoresearch/phases.py` routes to `_run_lpc_pwm_dma_cl_tests` which delegates to `ci/autoresearch/test_lpc_pwm_dma_cl.py`. The test runner: - Opens the LPC845-BRK serial port. - Calls `pwmDmaClCaptureSelf` for three color patterns (single red, RGB triple, alternating bit-pattern). - Byte-compares each returned CSV against expected GRB order. - Calls `pwmDmaClFrameBurst` for a timing regression check. - Exits 0 iff all patterns match. Mutually exclusive with `--ws2812-loopback` (both target the same SCT peripheral). Enforced by the phase dispatcher with a clear error. ## Tests bash test --cpp --clean → 342/342 passed. Ruff check on all modified Python files → clean. C++ lint (Python path) → clean. The host TX→RX readback test verifies the byte-flow contract of #3468 end-to-end at the engine.show() layer. On-silicon verification via `bash autoresearch lpc845 --pwm-dma-cl` remains gated on #3300 (AutoResearch echo bring-up) and #3450 B2 (framework-arduino-lpc8xx tarball checksum); the code is in place and ready to run the moment those blockers clear. Closes #3468 at the code-lands + host-verification layer. On-silicon acceptance items (scope/LA captures + closing additional TODO(2842) markers) remain open until the toolchain blockers resolve — the issue stays valuable as the tracker for the silicon side. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughAdds a new ChangesLPC845 PWM+DMA Clockless Self-Loopback
Sequence Diagram(s)sequenceDiagram
participant CLI as ci/autoresearch CLI
participant Phases as phases.py dispatch
participant Runner as test_lpc_pwm_dma_cl.py
participant Board as LPC845 firmware handler
CLI->>Phases: --pwm-dma-cl flag
Phases->>Phases: validate board support and --ws2812-loopback conflict
Phases->>Runner: launch subprocess with port/tx-pin/rx-pin
Runner->>Board: pwmDmaClCaptureSelf RPC (JSON over serial)
Board->>Board: transmit frame, capture SCT edges, decode bytes
Board-->>Runner: CSV result with decoded bytes
Runner->>Runner: compare against expected GRB bytes
Runner-->>Phases: exit 0/1
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Poem
✨ 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 |
…#3468) (#3475) While validating the #3468 harness on real LPC845-BRK silicon (VID:PID 1FC9:0132 on COM10), three separate blockers prevented `bash compile lpc845brk --examples AutoResearch --build-flag -DFASTLED_LPC_PWM_DMA=1` from producing a firmware image. Each is a legitimate bug fix and lands here together because they are only observable end-to-end when the LPC compile path actually gets exercised. ## Fix 1 — `ci/boards.py`: nxplpc@ prefix workaround fbuild 2.3.15 shipped 2026-06-30 20:09 UTC; my platform-matcher fix FastLED/fbuild#900 merged 2026-06-30 21:47 UTC (after 2.3.15 was cut). 2.3.15's matcher still only substring-matches `nxplpc` (no separator) and rejects the hyphenated `nxp-lpc` in the raw GitHub URL. Prepending `nxplpc@` to the platform URL is valid PlatformIO name-at-source syntax and makes the substring match, unblocking the build under 2.3.15. Once fbuild 2.3.16 ships with #900 the prefix becomes redundant but stays syntactically valid. ## Fix 2 — `led_sysdefs_arm_lpc.h`: define `FASTLED_HAS_CMSIS` `src/platforms/arm/common/m0clockless_c.h:51` guards the local `__get_PRIMASK` / `__enable_irq` / `__disable_irq` stubs with `#if !defined(FASTLED_HAS_CMSIS)`, and the comment on that guard says "LPC builds set FASTLED_HAS_CMSIS in led_sysdefs". But the define was never actually added — so LPC builds got the local stubs plus the vendor CMSIS versions from `core_cm0plus.h` and gcc rejected the pair with error: redefinition of 'fl::u32 __get_PRIMASK()' Adding `#define FASTLED_HAS_CMSIS 1` in `led_sysdefs_arm_lpc.h` immediately after the vendor `<LPC845.h>` / `<LPC804.h>` include matches the intent of the m0clockless guard and silences the collision. ## Fix 3 — `platforms/shared/bitbang/bus_traits.h`: LPC845 gate `ChannelEngineLpcSctDma` registers under `BusTraits<Bus::BIT_BANG>` (see `src/platforms/arm/lpc/drivers/sct_dma/bus_traits.h` — FastLED #3459 / PR #3460). The shared `BitBangChannelDriver` also specialises `BusTraits<Bus::BIT_BANG>` unconditionally. On LPC845 both TUs land in the same translation unit and gcc rejects the pair with error: redefinition of 'struct fl::BusTraits<fl::Bus::BIT_BANG>' error: redefinition of 'struct fl::BusSupports<fl::Bus::BIT_BANG, fl::ClocklessChipset, 0>' Gate the shared bit-bang specialization on `!FL_IS_ARM_LPC_845` so the dedicated SCT+DMA engine owns the slot on that platform. Every other platform continues to use the universal-GPIO fallback. ## Verification Applied all three fixes and confirmed: bash compile lpc845brk --examples AutoResearch \ --build-flag "-DFASTLED_LPC_PWM_DMA=1" Board: NXP LPC845-BRK / LPC845 @ 24MHz Toolchain: arm-none-eabi-gcc 15.2.1 Flash: 53.52KB / 64.00KB (83.6%) RAM: 9.07KB / 16.00KB (56.7%) Artifact: firmware.elf (159.79KB) / firmware.bin (53.54KB) build succeeded in 212.2s bash test --cpp → 343/343 passed C++ lint → clean ## What's still open on the actual on-wire verification - fbuild-side: an additional blocker surfaced during this bring-up — the FastLED/framework-arduino-lpc8xx tarball SHA256 changed after the 2026-06-28 org transfer (`e6bbcc3392…` → `e64f0cb81a…`). This needs a fbuild-side update to `ACLPC_CHECKSUM` in `crates/fbuild-packages/src/library/arduino_core_lpc8xx.rs`; I filed the change on a local fbuild branch during this session and will push it as a follow-up PR to the fbuild repo. - Flash + serial monitoring: `bash autoresearch --pwm-dma-cl` still hits pre-existing infrastructure gaps unrelated to #3468 — `ci/util/port_utils.py` only recognises the LPCXpresso VCOM fingerprint (VID:PID 16C0:0483), not the LPC-Link2 CMSIS-DAP variant (1FC9:0132) that ships on this specific LPC845-BRK unit, and fbuild's LPC deploy path uses `lpc21isp` which requires ISP-mode entry rather than the board's default CMSIS-DAP SWD. Both are tracked separately. The host TX→RX byte-flow readback contract (the #3468 primary acceptance criterion) is already confirmed in PR #3472 (`tests/fl/channels/lpc_sct_dma_engine.cpp` "#3468: end-to-end TX→RX readback through engine.show()", passing 343/343). This PR takes the verification one step further by making the compile path work on the LPC845 target so any user with an LPC845-BRK can now build and flash the firmware and run the on-silicon self-loopback via `pwmDmaClCaptureSelf`. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…ers (#3502) - Fix stale LPC845 clock reference (30 MHz -> actual 24 MHz FRO direct path per led_sysdefs_arm_lpc.h:49). - Add newly shipped drivers to the Supported Platforms table: - LPC845 SCT+DMA channels-API engine (#3460, TX->RX byte-match verified #3472) - LPC845 SPI+DMA async driver (#3454) - LPC804 SPI+DMA async gate (#3500, requires fbuild >= 2.3.16 for LPC804 CMSIS DMA0 typedef from framework-arduino-lpc8xx#35 + fbuild#916) - Document new files under Files: spi_arm_lpc_dma.h, drivers/sct_dma/*, rx_sct_capture.{h,cpp.hpp}. - Document new opt-in feature defines: FASTLED_LPC_SPI_DMA, FASTLED_LPC_SPI_DMA_CHANNEL, FASTLED_LPC_SPI_DMA_MAX_BYTES. - Add recent shipped PRs (#3438 register-map remediation, #3454, #3460, #3472, #3500) and cross-repo prerequisites (framework-arduino-lpc8xx#35, fbuild#916). - Add open follow-ups #3437 (register-map meta), #3501 (LPC11Uxx/LPC15xx SPI), fbuild#565 (CMSIS-DAP deploy). No code changes. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Closes the
TX → RX readback confirmed workinggoal from #3468 on host with a real end-to-end loopback exercisingChannelEngineLpcSctDma::show(), and lands the AutoResearch harness code + host phase for the on-silicon version.No cheating: the readback goes through the engine's
show()path — not around it. Ifshow()drops or reorders a byte anywhere betweenChannelDataand the transmitter, the byte-compare fails.Host-side TX→RX readback
LpcSctDmaTransmitteron host now captures the byte stream it would send:mTxCapture(fl::vector<u8>), populated bytransmit()on host / stub builds.getCapturedTxBytes()andclearCapture()accessors.ChannelEngineLpcSctDma::transmitter()accessor added so the test can read the capture.New test in
tests/fl/channels/lpc_sct_dma_engine.cpp:"#3468: end-to-end TX→RX readback through engine.show()"ChannelDatawith a known GRB payload (includes0x55 / 0xAA / 0x33so every T0/T1 transition is exercised).engine.enqueue()+engine.show().engine.transmitter().getCapturedTxBytes().LpcSctRxChannel::injectEdges().Plus
"#3468: capture buffer is cleared between transmits"for overwrite semantics.AutoResearch harness (silicon path)
examples/AutoResearch/AutoResearchPwmDmaClockless.hNew header, gated on
FL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA. Registers three RPC handlers:pwmDmaClFrameOnce(led_count, rgb, data_pin)— one frame, timing report.pwmDmaClFrameBurst(led_count, rgb, n_frames, data_pin)— burst, fps × 100.pwmDmaClCaptureSelf(led_count, rgb, data_pin, rx_pin, capture_ms)— self-loopback capture + decoded byte CSV.Wired into
AutoResearchLowMemory.hunder the same gate.--pwm-dma-clflagci/autoresearch/args.pyand theautoresearchbash wrapper.ci/autoresearch/phases.pyroutes to_run_lpc_pwm_dma_cl_testswhich delegates toci/autoresearch/test_lpc_pwm_dma_cl.py.pwmDmaClCaptureSelf, byte-compares against expected GRB output, plus apwmDmaClFrameBurstsanity call.--ws2812-loopback(both target the SCT); enforced with a clear error.Tests
bash test --cpp --clean→ 342/342 passed.ruff checkon all modified Python files → clean.bash autoresearch --helpsurfaces the new--pwm-dma-clflag.What is and is not confirmed
ChannelData→engine.enqueue()→engine.show()→ transmitter capture → WS2812 protocol encoder → LPC SCT-capture RX decoder → decoded bytes round-trips losslessly. All the code the engine actually runs (canHandle filtering, pin validation, timing translation, byte dispatch to the transmitter) is exercised.bash autoresearch lpc845 --pwm-dma-clpath in this PR is the vehicle that will close the on-silicon side the moment those blockers clear.Refs
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes