Skip to content

feat(autoresearch): FL_AUTORESEARCH_LITE_RPC tier define + fix LPC PWM_DMA CHUNK_BITS - #3522

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

zackees merged 1 commit into
masterfrom
feat/autoresearch-lite-tier

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Prerequisite for #3517 Phase A / B silicon acceptance on LPC845.

1. FL_AUTORESEARCH_LITE_RPC tier define

Auto-derived from the existing memory tier: FL_AUTORESEARCH_LITE_RPC = !FL_PLATFORM_HAS_LARGE_MEMORY. On LPC8xx / AVR Uno-class / STM32F1 / ESP8266 / Teensy LC / 3.0-3.2 / Renesas UNO / ATtiny 2-3 KB parts it evaluates to 1 by default. Users can override with -DFL_AUTORESEARCH_LITE_RPC=0 (force full-fat) or =1 (force lite on big platforms for measurement).

Follows the same override / `_OVERRIDDEN` flag pattern as the sibling FL_PLATFORM_HAS_LARGE_MEMORY tier defines. Zero runtime cost — pure compile-time gate.

Rationale. LPC845 vanilla AutoResearch already sits at 53.3 KB / 64 KB flash (83.3%). Adding FASTLED_LPC_PWM_DMA=1 and/or FASTLED_LPC_SPI_DMA=1 — the #3517 Phase A/B silicon acceptance payloads — will push over the 64 KB flash budget without a lite path. This PR lands the gate first; the actual RPC-infrastructure swap-out (JSON → line-based text or protobuf) is a follow-up implementation decision.

Search keywords: lite RPC, autoresearch tier, flash budget, FL_PLATFORM_HAS_LARGE_MEMORY.

2. clockless_arm_lpc_pwm_dma.h — restore FASTLED_LPC_PWM_DMA_CHUNK_BITS

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 #3460 without a fallback for the legacy path. Result: any user building with -DFASTLED_LPC_PWM_DMA=1 on top of the classic addLeds<> template hits:

error: 'FASTLED_LPC_PWM_DMA_CHUNK_BITS' was not declared in this scope

Fixed here with a defensive #ifndef ... #define ... 64u #endif at the top of the header (same default value as the channels-API runtime). The legacy template header is scheduled for retirement in #3517 Phase A.3; this fix keeps it compiling until that ships.

Verification

  • bash test --cpp — 344/344 pass
  • bash bloat lpc845 --allow-overflow — vanilla AutoResearch still fits at 53.3 KB / 64 KB (83.3%)
  • Tier define is auto-active on LPC845 (FL_PLATFORM_HAS_LARGE_MEMORY = 0); no code path change until the lite RPC infrastructure lands

Follow-up (out of scope for this PR)

  • Decide between line-based text RPC vs. protobuf for the lite path. Recommendation in the META: LPC845 DMA driver completion — clockless + SPI, silicon-verified in one burn-down session #3517 discussion favors line-based text (~10 KB save, zero external tooling, wire stays human-readable in a terminal).
  • Implement FL_AUTORESEARCH_LITE_RPC == 1 branch in AutoResearchLowMemory.h — swap fl::Remote for the lite dispatcher, keep the CSV wire contract so ci/autoresearch/test_lpc_*.py runners don't need to branch by build mode.
  • Measure FASTLED_LPC_PWM_DMA=1 + FASTLED_LPC_SPI_DMA=1 deltas after the swap and confirm both fit in 64 KB.

Test plan

  • Vanilla LPC845 build still passes
  • Host C++ tests all pass
  • Follow-up PR measures with -DFASTLED_LPC_PWM_DMA=1 after the CHUNK_BITS fix + eventual lite RPC swap

Refs: #3517 (meta), #3460 (moved CHUNK_BITS out), #3454 (SPI DMA driver), #3468 (SCT DMA channels engine).

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

Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility across device configurations by making a feature mode choose the appropriate default automatically based on available memory.
    • Added a fallback so legacy builds continue to compile even when a timing-related setting is not provided elsewhere.

…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]>
@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: 90fcde70-4d4e-4ec6-a1cf-ce14d384b144

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc642b and b47cc2d.

📒 Files selected for processing (2)
  • src/fl/system/sketch_macros.h
  • src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h

📝 Walkthrough

Walkthrough

This PR adds two independent preprocessor macro fallbacks: FL_AUTORESEARCH_LITE_RPC in sketch_macros.h, which auto-selects lite vs. full RPC mode based on platform memory classification, and FASTLED_LPC_PWM_DMA_CHUNK_BITS in the LPC PWM DMA header, defaulting to 64u if not already defined.

Changes

Compile-time Macro Fallbacks

Layer / File(s) Summary
AutoResearch lite RPC tier macro
src/fl/system/sketch_macros.h
Adds FL_AUTORESEARCH_LITE_RPC, defaulting to 1 on non-large-memory platforms and 0 otherwise, with FL_AUTORESEARCH_LITE_RPC_OVERRIDDEN set when user-defined.
LPC PWM DMA chunk bits fallback
src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h
Adds an #ifndef/#define fallback setting FASTLED_LPC_PWM_DMA_CHUNK_BITS to 64u when not already provided.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • FastLED/FastLED#3041: Uses the same FL_PLATFORM_HAS_LARGE_MEMORY-based mechanism to gate an AutoResearch low-memory RPC-only mode.
  • FastLED/FastLED#3088: Uses FL_PLATFORM_HAS_LARGE_MEMORY to gate RPC handler features, aligning with the new lite RPC tier macro.
  • FastLED/FastLED#2850: Introduces the LPC845 PWM+DMA clockless driver that relies on the DMA chunk sizing this PR patches.
✨ 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/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 f612ff5 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
… 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]>
zackees added a commit that referenced this pull request Jul 1, 2026
… A.2) (#3527)

* feat(autoresearch): FL_AUTORESEARCH_LITE_RPC tier define + fix LPC PWM_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]>

* feat(lpc): route addLeds<WS2812> through channels engine (#3517 Phase 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]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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]>
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