Skip to content

feat(lpc): AutoResearch PWM+DMA clockless harness + TX→RX readback (#3468) - #3472

Merged
zackees merged 1 commit into
masterfrom
feat/3468-clockless-autoresearch
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3468-clockless-autoresearch

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes the TX → RX readback confirmed working goal from #3468 on host with a real end-to-end loopback exercising ChannelEngineLpcSctDma::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. If show() drops or reorders a byte anywhere between ChannelData and the transmitter, the byte-compare fails.

Host-side TX→RX readback

LpcSctDmaTransmitter on host now captures the byte stream it would send:

  • mTxCapture (fl::vector<u8>), populated by transmit() on host / stub builds.
  • getCapturedTxBytes() and clearCapture() accessors.
  • Empty on LPC845 silicon — the wire is the observation surface there.

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()"

  1. Build ChannelData with a known GRB payload (includes 0x55 / 0xAA / 0x33 so every T0/T1 transition is exercised).
  2. Drive it through engine.enqueue() + engine.show().
  3. Read captured bytes back via engine.transmitter().getCapturedTxBytes().
  4. Convert to WS2812 edge pairs.
  5. Push through LpcSctRxChannel::injectEdges().
  6. Decode via the shared 4-phase WS2812 decoder.
  7. Byte-for-byte compare against the original payload.

Plus "#3468: capture buffer is cleared between transmits" for overwrite semantics.

AutoResearch harness (silicon path)

examples/AutoResearch/AutoResearchPwmDmaClockless.h

New 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.h under the same gate.

--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.
  • Test runner drives three color patterns through pwmDmaClCaptureSelf, byte-compares against expected GRB output, plus a pwmDmaClFrameBurst sanity call.
  • Mutually exclusive with --ws2812-loopback (both target the SCT); enforced 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.
  • bash autoresearch --help surfaces the new --pwm-dma-cl flag.

What is and is not confirmed

Refs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new LPC845 clockless self-loopback test mode with CLI help and wiring guidance.
    • Expanded low-memory AutoResearch support to include the new PWM/DMA validation path.
  • Bug Fixes

    • Improved end-to-end verification so transmitted data can be read back and checked more reliably.
    • Ensured captured transmit data is cleared between runs, preventing stale results from affecting later tests.

…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]>
@zackees
zackees merged commit 6cfd0fe into master Jul 1, 2026
7 of 10 checks passed
@zackees
zackees deleted the feat/3468-clockless-autoresearch branch July 1, 2026 00:49
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 178ffd22-89f9-4e1e-ba1b-d14bc12f40b4

📥 Commits

Reviewing files that changed from the base of the PR and between c848659 and 3502b53.

📒 Files selected for processing (10)
  • autoresearch
  • ci/autoresearch/args.py
  • ci/autoresearch/phases.py
  • ci/autoresearch/test_lpc_pwm_dma_cl.py
  • examples/AutoResearch/AutoResearchLowMemory.h
  • examples/AutoResearch/AutoResearchPwmDmaClockless.h
  • src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h
  • src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.cpp.hpp
  • src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.h
  • tests/fl/channels/lpc_sct_dma_engine.cpp

📝 Walkthrough

Walkthrough

Adds a new --pwm-dma-cl AutoResearch mode for LPC845 SCT+DMA clockless channels-API self-loopback validation: CLI flag and dispatch, a host serial test runner, firmware RPC handlers, transmitter TX-capture accessors on the SCT+DMA engine, and new engine-level TX→RX readback unit tests.

Changes

LPC845 PWM+DMA Clockless Self-Loopback

Layer / File(s) Summary
CLI flag and help text
ci/autoresearch/args.py, autoresearch
Adds pwm_dma_cl field, --pwm-dma-cl argparse flag with wiring, and updated help text describing jumper requirements and exclusivity with --ws2812-loopback.
Bring-up phase dispatch and async runner
ci/autoresearch/phases.py
Adds dispatch branch validating platform/exclusivity and a new async phase function that selects pins and runs the test script.
Transmitter TX capture accessors
src/platforms/arm/lpc/drivers/sct_dma/channel_engine_lpc_sct_dma.h, .../lpc_sct_dma_runtime.h, .../lpc_sct_dma_runtime.cpp.hpp
Adds transmitter() accessors, host-mode byte capture into mTxCapture, and getCapturedTxBytes()/clearCapture() API.
Firmware RPC handlers and wiring
examples/AutoResearch/AutoResearchPwmDmaClockless.h, examples/AutoResearch/AutoResearchLowMemory.h
Adds WS2812B timing helpers, frame-once/burst/capture-self RPC handlers, bind() registration, and low-memory sketch wiring under a compile-time guard.
Host test runner script
ci/autoresearch/test_lpc_pwm_dma_cl.py
Implements JSON-RPC framing, expected byte computation, capture validation, and a CLI-driven test orchestration with pass/fail exit codes.
Engine TX→RX readback unit tests
tests/fl/channels/lpc_sct_dma_engine.cpp
Adds documentation updates and two new tests validating end-to-end TX→RX readback and capture-buffer overwrite behavior.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3034: The new capture-self handler builds on the SCT→DMA RX capture path (LpcSctRxChannel) introduced there.
  • FastLED/FastLED#3460: Extends the LPC845 channels-API SCT+DMA engine scaffold with transmitter/capture accessors on the same engine dispatch path.
  • FastLED/FastLED#3464: Builds on the same test file's capture/edge round-trip infrastructure to add new TX→RX readback cases.

Poem

Hop, hop, through DMA I go,
SCT clocks a-tickin', bytes in tow,
Loop the wire from ten to eleven,
GRB pulses, decoded even,
A rabbit's proud of self-loopback flow! 🐇⚡

✨ 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/3468-clockless-autoresearch

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 1, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 1, 2026
zackees added a commit that referenced this pull request Jul 1, 2026
…#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]>
zackees added a commit that referenced this pull request Jul 1, 2026
…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]>
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