Repository navigation
Description
Goal
Move the LPC8xx output drivers from CPU-driven to DMA-driven, in two phases:
- Phase 1 (async SPI): extend
src/platforms/arm/lpc/spi_arm_lpc.hfrom polled (STAT.RXRDY+ per-wordTXDATCTLwrites) to a DMA0-driven TX stream soshow()returns immediately and the CPU is free during pixel transmission. - Phase 2 (clockless DMA): finish the path that already exists at
src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h— bench-validate Stage 2c on real LPC845-BRK silicon (feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (Stage 2c of #2836) #2842) and bring the same SCT+DMA-to-GPIO engine to LPC804 and to multi-strip parallel output (feat(platform/lpc): multi-strip parallel output for LPC845 (SCT + DMA) — Stage 4.4 from #2845, gated on Stage 2c hardware validation #2879).
Both phases share the same LPC_DMA0 controller and the same opt-in pattern (FASTLED_LPC_*_DMA build macro, polled / bit-bang remains the default).
Current state (inventory, 2026-06-30)
Clockless (TX):
clockless_arm_lpc.h— default, M0 cycle-counted bit-bang via sharedm0clockless. CPU-driven.clockless_arm_lpc_plu.h— LPC804 PLU. Gated onFL_IS_ARM_LPC_804 && FASTLED_LPC_PLU. CPU writes one data bit per LED bit; PLU does the pulse-shape. Not DMA.clockless_arm_lpc_pwm_dma.h— DMA, LPC845 only, gated onFL_IS_ARM_LPC_845 && FASTLED_LPC_PWM_DMA. SCT match events drive 3 DMA channels into GPIO SET/CLR bitmasks. Stage 2c of meta: port FastLED to NXP LPC8xx (LPC804 + LPC845) — two-stage plan #2836, issue feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (Stage 2c of #2836) #2842. Bench validation against real silicon is still open.
SPI (TX):
spi_arm_lpc.h— LPC845/804 hardware SPI (UM11029 §"SPI"). PolledSTAT.RXRDY+TXDATCTLper word. SPI0 @0x40058000, SPI1 @0x4005C000(LPC845 only).
DMA controller:
- LPC845: DMA0 with 25 channels, peripheral triggers from SPI0/SPI1, USART0/1/2, I2C0/1/2/3, SCT (match events), ADC, MRT, capt sense. UM11029 Chapter 12.
- LPC804: subset, 4 channels (UM11065 Chapter 12).
Phase 1 — Async SPI via DMA (the new work)
Scope
Add a DMA-capable peer to spi_arm_lpc.h, keeping the polled implementation as the default fallback. Gate is FASTLED_LPC_SPI_DMA. Header file naming should mirror the existing pattern: either spi_arm_lpc_dma.h as a sibling header, or an #if defined(FASTLED_LPC_SPI_DMA) branch inside spi_arm_lpc.h. (The _pwm_dma clockless precedent has a sibling header — keep that.)
Acceptance criteria
- New file
src/platforms/arm/lpc/spi_arm_lpc_dma.h(or DMA branch inspi_arm_lpc.h). - Gated on
FL_IS_ARM_LPC_845 && FASTLED_LPC_SPI_DMAinitially. LPC804 follow-up tracked under meta: LPC dev roadmap — Stages 3 + 4 (port completion, family expansion) #2845 Stage 4 (LPC804 has only 4 DMA channels — needs allocation review before enabling). -
ARMHardwareSPIOutput(or DMA-variant template) exposes the same template surface as today:<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER, pSPIX>. No user-facing API change. -
writePixels()/writeBytes()programs a single TX DMA descriptor at the SPI0/SPI1 TX trigger, returns immediately, exposesdone()/wait()soshow()can be async. -
show()returns ASYNC: caller can run pixel preparation for the next frame while the DMA stream completes the current one. - DMA-IRQ end-of-transfer marks the frame complete and (if present) signals the channel manager's completion future.
- No partial-frame writes on early
show()re-entry — either drop the new frame or wait, documented and tested. - FastPin / SWM routing matches existing polled driver (assumes the user's
SystemInithas routedSPIx_MOSI/SPIx_SCK). - Polled fallback (
spi_arm_lpc.h) untouched and remains the default whenFASTLED_LPC_SPI_DMAis not set. - Host / WASM compile-only smoke (DMA branch compiles out cleanly when
FL_IS_ARM_LPCis not set). - LPC845-BRK bench validation: APA102 / SK9822 / WS2801 200 LEDs, scope-verified
SCKfrequency vs. requested divider, scope-verified end-of-frame timing, no CPU-stall during transmission (measure GPIO toggle on a free pin from a tight loop duringshow()).
Implementation notes
- The LPC8xx SPI block has separate TX and RX FIFOs and supports DMA on both via
INTENSET.TXRDYEN/INTENSET.RXRDYENredirected to DMA triggers (UM11029 §15.6.6 + DMA mux table). For clocked-strip output we only need TX DMA — RX is ignored (TXCTL.RXIGNORE = 1, already set in the polled driver atFL_LPC_SPI_TXCTL_RXIGNORE). - DMA channel selection: prefer a single channel for SPI TX. Channel allocation overlaps with the clockless PWM-DMA driver (3 channels starting at
FASTLED_LPC_PWM_DMA_BASECH), so document a default channel that doesn't collide. Suggested default: channel 12 (well clear of channel 0–2 used by the clockless driver). - DMA descriptor layout: TXDATCTL word with
LEN=7for 8-bit,EOTbit set on the last byte of the frame, source = pixel buffer, destination =SPIx->TXDATCTL, width = 16-bit (the lower half of TXDATCTL carries data; the upper half is control). Verify the SPI block accepts back-to-back DMA writes without manual control bit re-injection (UM11029 figure in §15.6.6). - ChannelEngine integration: this driver is a peripheral-level SPI driver, not a parallel-IO multi-mode engine, so the "one engine for both clockless and SPI modes" rule in
src/fl/channels/README.mddoes NOT apply here — it's SPI-only.
Phase 2 — Clockless DMA bring-up
Phase 2 is the existing clockless_arm_lpc_pwm_dma.h engine, not new code:
- feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (Stage 2c of #2836) #2842 bench validation on LPC845-BRK — scope-verify WS2812 bit timing (T0H, T0L, T1H, T1L, RES) against the data sheet on real silicon. Specifically validate that the 24 MHz F_CPU correction landed in
led_sysdefs_arm_lpc.hproduces correct SCT match values (the same constants that historically drifted ~25% under the prior 30 MHz default). - feat(platform/lpc): multi-strip parallel output for LPC845 (SCT + DMA) — Stage 4.4 from #2845, gated on Stage 2c hardware validation #2879 multi-strip parallel output — extend the engine to drive N strips in parallel from a single SCT timing pass + N pre-encoded DMA streams. LPC845 has 25 DMA channels; budget 3-per-strip plus 1 for SPI = ~7 strips feasible.
- LPC804 port (subject to feasibility) — LPC804 has only 4 DMA channels. A 3-channel single-strip engine just fits; multi-strip is infeasible. Decision: either ship single-strip LPC804 DMA clockless gated on
FL_IS_ARM_LPC_804 && FASTLED_LPC_PWM_DMA_LIGHT(slightly different topology), or skip and leave LPC804 on PLU + bit-bang.
Phase 2 does not start until Phase 1 ships and the AutoResearch bring-up (#3300) is green on hardware — otherwise we have no way to validate DMA timing on the bench.
Dependencies / order
- Blocker: LPC compile path on master is currently broken at the toolchain level — see meta [META] LPC8xx compile + autoresearch + channels API end-to-end restoration — all blockers #3450 (fbuild matcher PR fix(core): match
nxp-lpc(hyphenated GitHub form) in platform parser fbuild#900, framework-arduino-lpc8xx tarball checksum). Phase 1 lands cleanly in source but needs the compile path restored for CI to gate it. - Soft blocker: AutoResearch echo bring-up ([BLOCKER] LPC845-BRK AutoResearch bring-up echo returns empty RX (suspected HardFault) — blocks #3102 #3300) needs to land so device-side scope-validation work has an RPC harness.
Relationships
- Lives under the LPC8xx Stage 4 umbrella (meta: LPC dev roadmap — Stages 3 + 4 (port completion, family expansion) #2845).
- Phase 2 absorbs / closes part of feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (Stage 2c of #2836) #2842 (Stage 2c bench) and feat(platform/lpc): multi-strip parallel output for LPC845 (SCT + DMA) — Stage 4.4 from #2845, gated on Stage 2c hardware validation #2879 (multi-strip).
- The async-future / completion-signalling design should align with the channels-API
IChannelDrivercompletion path used by Teensy 4 OBJECT_FLED and ESP32 LCD_SPI — not a one-off LPC-only future type. - Issue hardware: bring up LPC845 + WS2812 + AutoResearch UART (Stages 3.5, 3.6 from #2845) #2880 hardware sign-off checklist is the validation harness Phase 1 reports into.
Out of scope
- LPC11Uxx / LPC15xx SPI DMA — different register layouts, tracked under meta: LPC dev roadmap — Stages 3 + 4 (port completion, family expansion) #2845 Stage 4.
- Async monitoring / Tx FIFO underrun recovery beyond what the SPI block already reports via
STAT.TXUR— Phase 1 just blocks the nextshow()on the previous frame's completion. - Replacing the polled driver. Polled stays as the default; DMA is opt-in.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 (#3454)
feat(lpc): widen spi_arm_lpc_dma.h gate to include LPC804 (#3499) (#3500
feat(autoresearch): LPC845 SPI+DMA async driver validation harness (#…
zackees commentedon Jul 1, 2026
Status snapshot (2026-07-01)
Cross-linking recent work that shipped against this meta's Phase 1 + Phase 2 acceptance:
Phase 1 — Async SPI (all code items delivered, silicon pending):
src/platforms/arm/lpc/spi_arm_lpc_dma.h— feat(lpc): LPC845 SPI + DMA0 async driver — Phase 1 of #3453 #3454FL_IS_ARM_LPC_845 && FASTLED_LPC_SPI_DMA(1UL << 29)withSYSCON_SYSAHBCLKCTRL0_DMA_MASK--dma-spiRPCs + Python runner) — AutoResearch: SPI-DMA validation harness for LPC845 (Phase 1 of #3453 bench bring-up) #3456 / feat(autoresearch): LPC845 SPI+DMA async driver validation harness (#3456) #3503dap_infoHID read; see META: LPC845 DMA driver completion — clockless + SPI, silicon-verified in one burn-down session #3517 discussion). Requires either a modernized debug probe or macOS/Linux env.Phase 2 — Clockless DMA (channels-API path delivered, silicon pending):
ChannelEngineLpcSctDmachannels-API engine — feat(lpc): channels-API SCT+DMA clockless engine scaffold (#3459) #3460 / feat(lpc): wire show()/poll() body via runtime SCT+DMA transmitter (#3459) #3466engine.show()— feat(lpc): AutoResearch PWM+DMA clockless harness + TX→RX readback (#3468) #3472 (closed AutoResearch: PWM+DMA clockless validation harness for LPC845 (paired sibling of #3456) #3468)show()— feat(lpc): drive SCT+DMA chunk progression via poll() — no busy-wait (#3459) #3498addLeds<WS2812>()routes through the channels engine viaclockless_channel_lpc.h— feat(lpc): route addLeds<WS2812> through channels engine (#3517 Phase A.2) #3527 (Phase A.2 of META: LPC845 DMA driver completion — clockless + SPI, silicon-verified in one burn-down session #3517)clockless_arm_lpc_pwm_dma.htemplate retired — feat(lpc): retire legacy clockless_arm_lpc_pwm_dma.h template (#3517 Phase A.3) #3529 (Phase A.3 of META: LPC845 DMA driver completion — clockless + SPI, silicon-verified in one burn-down session #3517)--pwm-dma-clharness — LPC845: clockless+DMA channels-API engine — ChannelEngineLpcSctDma wrapping clockless_arm_lpc_pwm_dma.h #3459 / feat(lpc): channels-API SCT+DMA clockless engine scaffold (#3459) #3460This is now empirically wrong. LPC804 has zero DMA channels. NXP's own
mcux-sdk/devices/LPC804/LPC804.hhas noDMA_Typetypedef, noDMA0_BASEmacro, noFSL_FEATURE_SOC_DMA_COUNTin features; UM11065 has no DMA chapter (only 3 copy-paste leftovers); 0x50008000 is a reserved AHB slot. Diagnosed by @phatpaul on #3499. #3513 reverted the phantom-DMA cascade. Preventive guardrail: #3506/#3507 (agents/docs/peripheral-existence.md).Recommend closing the LPC804 line-item of Phase 2 as OUT OF SCOPE — silicon does not support the peripheral. LPC804 stays on PLU + bit-bang exclusively. Non-blocker for closing this meta.
Compile-path blocker resolved
The issue text notes "LPC compile path on master is currently broken at the toolchain level." That block cleared — #3450 is closed, fbuild is pinned to a working release (2.3.16), and
ci/bloat.py lpc845 --example AutoResearchsucceeds at 53.3 KB / 64 KB in this session.Remaining scope for closing this meta: (a) silicon bench validation, or (b) maintainer decision to close as "code complete, silicon validation split" — same disposition as #3517.
fix(lpc): WWDT actually arms now (MOD/TC swap) + NMI wedge backtrace …
fix(lpc): SPI+DMA driver works on silicon — 6 stacked hardware bugs (c…
fix(lpc): polled SPI driver owns its LPC845 peripheral plumbing too
feat(lpc): ISR-refillable async streaming (SPI + UART) + review fixes
feat(startup): named weak IRQ handlers for LPC845/LPC804 vector slots (…
fix(lpc): DMA ISR hygiene — stale-INTA clear, end-of-stream quiesce, …
fix(autoresearch): route LPC bench serial through fbuild's Rust monit…
Delegate all flashing to fbuild + LPC845 drivers + ban raw pyserial i…
zackees commentedon Jul 6, 2026
Closing this roll-up to consolidate active LPC board work under #3348.
The remaining local hardware validation should be tracked through #3348 and its sub-issues #3300 and #3302. Historical DMA implementation details remain in this issue for reference.