Skip to content

feat(lpc): route addLeds<WS2812> through channels engine (#3517 Phase A.2) - #3527

Merged
zackees merged 2 commits into
masterfrom
feat/autoresearch-lite-tier
Jul 1, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/autoresearch-lite-tier

Conversation

@zackees

@zackees zackees commented Jul 1, 2026

Copy link
Copy Markdown
Member

Phase A.2 of #3517 meta issue burn-down. See commit body for full details.

Refs: #3517, #3522, #3460, #3468.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

zackees and others added 2 commits July 1, 2026 09:47
…M_DMA CHUNK_BITS

Two related additions from planning the AutoResearch flash-budget squeeze on
LPC845 (#3517 Phase A prerequisite):

1. `FL_AUTORESEARCH_LITE_RPC` — auto-derived from the existing memory tier
   (`!FL_PLATFORM_HAS_LARGE_MEMORY`). On LPC8xx / AVR Uno-class / STM32F1 /
   ESP8266 / Teensy LC/3.0-3.2 / Renesas UNO / ATtiny 2-3 KB it evaluates
   to 1 by default. Users can override with `-DFL_AUTORESEARCH_LITE_RPC=0`
   to force full-fat mode on a low-memory platform (will overflow) or
   `-DFL_AUTORESEARCH_LITE_RPC=1` to force lite mode on a large-memory
   platform (useful for measuring what lite mode ships).

   Follows the same override / `_OVERRIDDEN` flag pattern as the sibling
   `FL_PLATFORM_HAS_LARGE_MEMORY` tier defines.

   Rationale: LPC845 vanilla AutoResearch sits at 53.3 KB / 64 KB (83%).
   Adding `FASTLED_LPC_PWM_DMA=1` and/or `FASTLED_LPC_SPI_DMA=1` (the
   #3517 Phase A/B silicon acceptance payloads) will push over budget
   without a lite path. Ownership of the actual RPC-infrastructure
   swap-out (JSON → line-based text or protobuf) is a follow-up
   decision; this define lands first so the gate exists.

2. `src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h` — add a defensive
   `#ifndef FASTLED_LPC_PWM_DMA_CHUNK_BITS #define ... 64u #endif` at
   the top. The macro used to live in the legacy template header; it
   was moved into the channels-API runtime helper
   (`drivers/sct_dma/lpc_sct_dma_runtime.h`) as part of PR #3460 without
   leaving a fallback for the legacy path. Result: any user building
   with `-DFASTLED_LPC_PWM_DMA=1` on top of `addLeds<>` today hits
   `error: 'FASTLED_LPC_PWM_DMA_CHUNK_BITS' was not declared in this
   scope`. Fixed here so the legacy template compiles again while
   #3517 Phase A.3 retirement is being planned.

## Verification

- `bash test --cpp` — 344/344 pass
- `bash bloat lpc845 --allow-overflow` — vanilla AutoResearch still fits
  at 53.3 KB / 64 KB (83.3%) — the tier define has zero code footprint
  when it evaluates to auto-default

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… A.2)

Delivers Phase A.2 of the LPC845 DMA-driver burn-down meta issue.

## Changes

1. **`src/platforms/arm/lpc/clockless_channel_lpc.h`** (new) — LPC845
   `ClocklessController<>` template that routes classic `addLeds<WS2812,
   PIN, GRB>()` through the SCT+DMA channels-API engine via
   `BusTraits<Bus::BIT_BANG>::instancePtr()`. Mirrors the pattern from
   `src/platforms/wasm/clockless_channel_wasm.h` and
   `src/platforms/stub/clockless_channel_stub.h`. Sets
   `FL_CLOCKLESS_CONTROLLER_DEFINED` so the classic template selection
   downstream sees the adapter first. Only compiles when
   `FL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA` — vanilla LPC845 builds
   without the flag stay on the bit-bang default.

2. **`src/platforms/arm/lpc/fastled_arm_lpc.h`** — dispatch reorder.
   `FASTLED_LPC_PWM_DMA=1` now picks the channels-API adapter instead of
   the legacy `clockless_arm_lpc_pwm_dma.h` template. The bit-bang
   default is still included on any build that has NOT set
   `FL_CLOCKLESS_CONTROLLER_DEFINED` above it. The legacy header is no
   longer transitively pulled in on any path — it's slated for
   retirement per #3517 Phase A.3 once silicon validation confirms
   parity.

3. **`src/fl/remote/rpc/type_to_json.h`** — fix pre-existing u32/u16
   overload ambiguity. Adding an explicit `TypeToJson<fl::u32>` /
   `TypeToJson<fl::u16>` specialization routes unsigned 32/16-bit values
   through the `i64` json constructor. Without this, GCC 15 flags:

       error: call of overloaded 'json(const long unsigned int&)' is ambiguous

   for any RPC handler that carries a `fl::u32` (e.g.
   `pwmDmaClFrameOnce(int, fl::u32 rgb, int)` from
   `AutoResearchPwmDmaClockless.h`). Bug was masked before this PR
   because the legacy `clockless_arm_lpc_pwm_dma.h` compile error
   short-circuited the build earlier — the new adapter path exposes it
   because it actually compiles.

## Measured flash-budget impact on LPC845

- Vanilla AutoResearch: **53.29 KB / 64 KB (83.3%)** — unchanged (my
  Phase A.2 adapter is compile-gated on `FASTLED_LPC_PWM_DMA`, not
  active in vanilla)
- With `-DFASTLED_LPC_PWM_DMA=1`: **64.23 KB — 236 bytes OVER budget**

Before this PR: `-DFASTLED_LPC_PWM_DMA=1` failed to compile at all
(`FASTLED_LPC_PWM_DMA_CHUNK_BITS undeclared` + `FastPin<>` template
visibility errors from the abandoned legacy header). After this PR: it
compiles, links to 64.23 KB. The remaining 236 B is a real budget gap
that Phase A.3 (retire the legacy template file entirely) and/or the
`FL_AUTORESEARCH_LITE_RPC` implementation (from #3522) will close.

## Verification

- [x] `bash test --cpp` — 344/344 tests pass
- [x] `bash compile wasm --examples AutoResearch` — clean
- [x] `bash bloat lpc845` vanilla — 53.29 KB (unchanged)
- [ ] Silicon validation of `--pwm-dma-cl` — env-blocked (pyocd hangs
      enumerating CMSIS-DAP on this Windows session; #3517 Phase A.1
      acceptance requires working flash + serial round-trip)

Refs: #3517 (meta), #3460 (channels engine PR), #3468 (host TX→RX
byte-match), #3454 (SPI DMA driver), #3522 (LITE_RPC tier define +
CHUNK_BITS bug fix).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 244c83d6-5c96-4752-9121-8180ddb4506d

📥 Commits

Reviewing files that changed from the base of the PR and between cc6f182 and fb86fe4.

📒 Files selected for processing (5)
  • src/fl/remote/rpc/type_to_json.h
  • src/fl/system/sketch_macros.h
  • src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h
  • src/platforms/arm/lpc/clockless_channel_lpc.h
  • src/platforms/arm/lpc/fastled_arm_lpc.h
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/autoresearch-lite-tier

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.

@zackees
zackees merged commit 092b448 into master Jul 1, 2026
8 of 10 checks passed
@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
…Phase A.3) (#3529)

The classic `ClocklessController<>` template that supplied the LPC845
SCT+DMA fast path is now `clockless_channel_lpc.h` (landed in #3527),
which routes through `ChannelEngineLpcSctDma` via `BusTraits<Bus::BIT_BANG>`.
Nothing in the tree still `#include`s the legacy header:

    $ grep -rn '#include.*clockless_arm_lpc_pwm_dma' src/ examples/ tests/
    (no results)

Safe to delete. Keeping two code paths for the same peripheral risked:
1. Divergent register-programming choices (the legacy template still had
   `TODO(2842)` markers that got moved into the channels-API runtime
   `lpc_sct_dma_runtime.cpp.hpp`).
2. Confusion for users about which path they get when `FASTLED_LPC_PWM_DMA=1`
   is set.

Also updates `src/platforms/arm/lpc/README.md`:
- Supported-platforms row for LPC845 replaces "PWM+DMA legacy template
  (#2850)" with the channels-API engine + `addLeds<>` route (#3527).
- Files section marks `clockless_arm_lpc_pwm_dma.h` as retired with an
  explanation.

Historical / provenance comment references inside
`drivers/sct_dma/channel_engine_lpc_sct_dma.{h,cpp.hpp}` and
`drivers/sct_dma/lpc_sct_dma_runtime.{h,cpp.hpp}` are kept — those
narrate the design derivation, they're not `#include` breakage risks.

## Verification

- `bash test --cpp` — 345/345 pass (unchanged from master)
- `bash bloat lpc845 --allow-overflow` — vanilla LPC845 build still
  53.29 KB (the retired header was never linked in vanilla anyway;
  users had to opt into it, and #3527 already routed that opt-in
  through the channels adapter)
- With `-DFASTLED_LPC_PWM_DMA=1` build still overflows by 236 B — that
  budget gap needs the `FL_AUTORESEARCH_LITE_RPC` implementation
  (from #3522) to close.

Refs: #3517 (meta issue), #3527 (Phase A.2 addLeds routing), #3522
(tier define), #2850 (original PR that shipped this file).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jul 1, 2026
…arness (#3537)

`examples/AutoResearch/AutoResearchSpiDma.h` line 88 declares
`HarnessDriver` as `ARMHardwareSPIOutputDMA<...>` without the `fl::`
namespace prefix. The template lives in `namespace fl` inside
`src/platforms/arm/lpc/spi_arm_lpc_dma.h`, and the harness itself is in
`namespace autoresearch { namespace dma_spi { ... } }` — so the bare
name never resolves.

Under #3517 Phase B silicon-validation attempt (build LPC845
AutoResearch with `-DFASTLED_LPC_SPI_DMA=1`), the compile fails with:

    src/sketch/AutoResearchSpiDma.h:88: error: 'ARMHardwareSPIOutputDMA' does not name a type
    src/sketch/AutoResearchSpiDma.h:101: error: 'HarnessDriver' does not name a type
    src/sketch/AutoResearchSpiDma.h:128: error: 'HarnessDriver' was not declared in this scope
    (... plus 7 more cascade errors)

After this fix the LPC845 AutoResearch build with
`-DFASTLED_LPC_SPI_DMA=1` succeeds and links at 56.43 KB / 64 KB
(88.2%). Real silicon validation of #3517 Phase B.1 is now unblocked —
just requires a working deploy pipeline (env-blocked per #3517
discussion of the pyocd HIDAPI hang on LPC-Link2 CMSIS-DAP v1.0.7
firmware).

Bug was masked until now because #3527 (Phase A.2 addLeds routing)
was landing at the same time and everyone's builds hit the abandoned
legacy-header errors first — this SPI harness compile path was never
reached.

## Verification

- LPC845 with `-DFASTLED_LPC_SPI_DMA=1`: 56.43 KB / 64 KB, links clean
- Grep confirms no other bare-namespace uses in the harness files

Refs: #3517 Phase B, #3454 (SPI DMA driver PR).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/autoresearch-lite-tier branch August 21, 2026 19:15
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