Skip to content

Meta: Replace all hand-rolled LPC register maps with vendor CMSIS PAL headers #3437

Closed

Description

@zackees

Meta: Replace all hand-rolled LPC register maps with vendor CMSIS PAL headers

Single rollup tracking the end-to-end fix across three repos. All work coordinates here.

Why this exists

The FastLED LPC drivers (src/platforms/arm/lpc/) ship hand-rolled register-map shim structs because the toolchain (zackees/ArduinoCore-LPC8xx) ships only stub LPC845.h and LPC804.h headers (~50 lines each, IRQ enums + CMSIS-Core constants only — no peripheral typedefs). Those shims have shipped wrong offsets twice (#3349 fixed SYSCON.SYSAHBCLKCTRL0 _resv0[16]→[32] and DMA CHANNEL.CFG bit composition). Cross-checking the shims against NXP's canonical CMSIS PAL during this meta uncovered a third latent offset bug in the SCT shim (LIMIT/HALT/STOP/START split into nonexistent _L/_H 32-bit pairs).

@phatpaul on PR #3349:

"This seems like a waste of time debugging AI hallucinated register maps, when it would be so much easier and safer to use the vendor provided CMSIS Peripheral Access Layer. ... I want to remove all the hand-rolled register maps and require the use of the vendor provided CMSIS PAL files to build."

The pin chain — what needs to change

FastLED ci/boards.py + platformio.ini
   ↓ pinned by SHA  2ee527ae80de98e9105329a7260edb003289dfda  ✓ firm
zackees/platform-nxplpc-arduino  [v0.1.0]
   ↓ NOT pinned — platform.json uses bare URL for framework-arduino-lpc8xx  ✗ STEP 2
   ↓ opportunistically resolved to 195a2eddd31eba8472ceaffa6a1a1902f72439ae
zackees/ArduinoCore-LPC8xx  [HEAD-of-main floating]
   ↓ ships
   variants/lpc845/LPC845.h         [54-line stub, no peripheral typedefs]  ✗ STEP 1
   variants/lpc804/LPC804.h         [49-line stub, no peripheral typedefs]  ✗ STEP 1
   cores/lpc8xx/lpc8xx_registers.h  [hand-rolled, missing SCT + DMA]        (informational)

FastLED CI surface (5 board workflows)

All five route through the same package stack; fixing the two stub headers fixes all five:

Workflow Board Variant dir
build_lpc845.yml lpc845 variants/lpc845/
build_lpc845brk.yml lpc845brk + variants/lpc845/
build_lpcxpresso845max.yml lpcxpresso845max + variants/lpc845/
build_lpc804.yml lpc804 variants/lpc804/
build_lpcxpresso804.yml lpcxpresso804 + variants/lpc804/

FastLED hand-rolled register-map audit (8 sites across 6 files)

These all migrate to vendor typedefs in step 3.

A. Hand-rolled struct shims (struct FL_..._Shim + #define LPC_*)

  • 1. FL_LPC_SCT_Shim + #define LPC_SCT — clockless_arm_lpc_pwm_dma.h:225,269 → SCT_Type / SCT0
  • 2. FL_LPC_DMA_Shim + FL_LPC_DMA_ChannelShim + #define LPC_DMA — clockless_arm_lpc_pwm_dma.h:273,279,310 → DMA_Type / DMA0
  • 3. FL_LPC_SYSCON_Shim + #define LPC_SYSCON — clockless_arm_lpc_pwm_dma.h:314,321 → SYSCON_Type / SYSCON (the shim @phatpaul fixed in WIP: LPC845 PWM+DMA driver implementation #3349)
  • 4. FL_LPC_SPI_Type — spi_arm_lpc.h:60-72 → SPI_Type / SPI0 / SPI1
  • 5. FL_LPC11_LEGACY_GPIO_Type + #define LPC_GPIO0..3 — fastpin_arm_lpc11_legacy.h:57-82 → vendor LPC_GPIO_Type (LPC11xx upstream; out of CI for now)

B. Raw base + offset MMIO

  • 6. FL_LPC_GPIO_*_OFFSET + fallback helpers — fastpin_arm_lpc.h:55-86 → GPIO_Type (file already prefers vendor LPC_GPIO; delete #else fallback)
  • 7. kPluBase, kSysconBase, kOff* PLU offsets + reg32(base, off) — clockless_arm_lpc_plu.h:82-180 → LPC804 vendor PLU_Type + SYSCON_Type
  • 8. kSctBase, kDmaBase, kSwmBase, kSysconBase, dozens of kOff* + reg(base, off) — rx_sct_capture.cpp.hpp:80-220 → SCT_Type, DMA_Type, SWM_Type, SYSCON_Type

Verified cross-checks against the vendor PAL

While preparing the now-reverted V1 prototype (commits 0365745f7 + c047a586b on feat/3437-lpc-cmsis-vendoring), each shim was cross-checked against nxp-mcuxpresso/mcux-sdk/devices/LPC845/LPC845.h (rev. 1.2, BSD-3-Clause):

  • ✅ SYSCON_Type.SYSAHBCLKCTRL0 at offset 0x80 — confirms @phatpaul's WIP: LPC845 PWM+DMA driver implementation #3349 fix. Pre-WIP: LPC845 PWM+DMA driver implementation #3349 master shim places it at 0x40 (wrong).
  • ✅ DMA_Type.CHANNEL[].CFG/CTLSTAT/XFERCFG per-channel layout matches the shim. The common-register block uses DMA0->COMMON[0].INTENSET (vendor) instead of LPC_DMA->INTENSET0 (shim) — a member-name rename for step 3.
  • ⚠️ SCT_Type latent offset bug — shim splits LIMIT/HALT/STOP/START into pairs of _L/_H 32-bit registers (8 bytes each); vendor has each as a single 32-bit register (4 bytes), with optional 16-bit access via inner unions. Every shim member from COUNT_U onward is 16 bytes too high. Driver doesn't dereference those today — latent.

End-to-end fix sequence

Step 1 — Content gap (upstream zackees/ArduinoCore-LPC8xx)

Replace variants/lpc845/LPC845.h and variants/lpc804/LPC804.h stubs with the full NXP CMSIS PAL headers from nxp-mcuxpresso/mcux-sdk/devices/LPC845/LPC845.h and devices/LPC804/ (BSD-3-Clause). Also vendor companion system_LPC845.h / system_LPC804.h. Tag a release once merged.

Provides peripheral typedefs (SCT_Type, DMA_Type, SYSCON_Type, SPI_Type, GPIO_Type, SWM_Type, IOCON_Type, PINT_Type, INPUTMUX_Type, PLU_Type for LPC804) and pointer macros (SCT0, DMA0, SYSCON, etc.).

Step 2 — Pin gap (upstream zackees/platform-nxplpc-arduino)

Pin framework-arduino-lpc8xx to a specific SHA / tag in platform.json (currently a bare URL). Bump to the post-step-1 SHA. Tag a release.

Today's platform.json:

"framework-arduino-lpc8xx": {
  "type": "framework",
  "optional": true,
  "version": "https://github.com/zackees/ArduinoCore-LPC8xx.git"
}

After step 1 lands:

"framework-arduino-lpc8xx": {
  "type": "framework",
  "optional": true,
  "version": "https://github.com/zackees/ArduinoCore-LPC8xx.git#<post-step-1-sha>"
}

Step 3 — FastLED consumes (this repo)

  • V5a Bump _NXPLPC_PLATFORM SHA in ci/boards.py + platformio.ini to the post-step-2 SHA
  • V5b Add #include <LPC845.h> to led_sysdefs_arm_lpc.h inside FL_IS_ARM_LPC_845 guard; same for <LPC804.h> inside FL_IS_ARM_LPC_804
  • V6 Delete the 8 hand-rolled sites listed above; migrate every call site to vendor typedefs (SCT0->CONFIG, DMA0->CHANNEL[i].CFG, SYSCON->SYSAHBCLKCTRL0, etc.)
  • V7 Add #error guard in led_sysdefs_arm_lpc.h if the vendor header is missing — no silent fallback
  • Verify All 5 LPC CI workflows green: build_lpc845, build_lpc845brk, build_lpcxpresso845max, build_lpc804, build_lpcxpresso804
  • Update Retire the "Worked anti-example: LPC845" section in agents/docs/register-maps.md

Fallback if upstream step 1 or step 2 declines

In-tree tier-2 vendoring under src/platforms/arm/lpc/third_party/cmsis/{LPC845.h,LPC804.h,system_LPC845.h,system_LPC804.h} from nxp-mcuxpresso/mcux-sdk (BSD-3-Clause). The third_party/ path inherits FastLED's existing linter exemption for vendored code. See reverted commits 0365745f7 + c047a586b on branch feat/3437-lpc-cmsis-vendoring for the working prototype + cmsis/README.md provenance template.

Out of scope (track separately when relevant)

  • LPC11xx / LPC15xx — Compile-only in this repo today (no CI yet per LPC README). When they enter CI, file equivalent upstream issues against whatever toolchain package they use.
  • AutoResearch hardware verification — Tracked separately at #2880.

Cross-references

  • Originating PR: #3349 — @phatpaul's WIP LPC845 PWM+DMA; blocked on step 3
  • Audit-list landing PR: #3438 — docs-only docs of the 8-site audit
  • Authoring policy: agents/docs/register-maps.md
  • Originating bug: #2990 (original SYSAHBCLKCTRL0 offset bug)
  • NXP UMs: UM11029 (LPC84x), UM11065 (LPC80x), UM10398 (LPC111x), UM10462 (LPC11U)

Activity

  1. zackees commented on Jun 28, 2026

    @zackees
    MemberAuthor

    Update — pivot to upstream fix. Investigation in PR #3438 revealed:

    1. The fbuild LPC845 build toolchain (zackees/ArduinoCore-LPC8xx) ships only a 54-line LPC845.h stub — IRQ enums + CMSIS-Core constants, no peripheral typedefs. That's the entire reason FastLED's hand-rolled shims exist.
    2. The same package's cores/lpc8xx/lpc8xx_registers.h is itself a hand-rolled minimal subset (SYSCON, IOCON, SWM, USART, SPI — no SCT, no DMA) and its own SYSCON struct documents the LPC82x-vs-LPC845 offset bug @phatpaul fixed in WIP: LPC845 PWM+DMA driver implementation #3349.

    Path forward updated: tier-1 (upstream ships the full vendor header) is preferred over tier-2 (FastLED vendors). Upstream issue filed at zackees/ArduinoCore-LPC8xx#33 requesting the full NXP LPC845.h be shipped in variants/lpc845/. Once that lands, FastLED can #include <LPC845.h> directly from led_sysdefs_arm_lpc.h and delete every row in the audit list with zero in-tree vendoring.

    PR #3438 now reverts the original V1 vendoring and ships just the audit list + policy clarification.

    Updated milestones

    • V1 — Upstream ships full LPC845.h: zackees/ArduinoCore-LPC8xx#33
    • V2 — Same for LPC804.h: part of upstream How to controll 2 and more led 'blocks'? #33 ask
    • V3 — Same for LPC11xx, modern-LPC-GPIO chips: likely separate upstream issues per family
    • V5 — Wire #include <LPC845.h> into led_sysdefs_arm_lpc.h (tier-1, no vendoring)
    • V6 — Delete the 8 shim/raw-offset sites listed above and migrate call sites to vendor typedefs

    The cross-check evidence (SYSAHBCLKCTRL0=0x80, DMA CHANNEL layout, latent SCT _L/_H split bug) is preserved in #3438's body and the upstream issue.

    Fallback path

    If upstream declines, V1-fallback = FastLED-side tier-2 vendoring under src/platforms/arm/lpc/third_party/cmsis/. The third_party/ path component would inherit the existing FastLED linter exemption for vendored code.

    🤖 Generated with Claude Code

  2. zackees commented on Jun 28, 2026

    @zackees
    MemberAuthor

    Gap analysis — what "completely solved" needs across all LPC test versions.

    Pin chain audit

    FastLED ci/boards.py + platformio.ini
        ↓ pinned by SHA  2ee527ae80de98e9105329a7260edb003289dfda  ✓
    zackees/platform-nxplpc-arduino  [v0.1.0]
        ↓ NOT pinned — platform.json uses bare URL for framework-arduino-lpc8xx  ✗
        ↓ opportunistically resolved to 195a2eddd31eba8472ceaffa6a1a1902f72439ae
    zackees/ArduinoCore-LPC8xx  [HEAD-of-main floating]
        ↓ ships
        variants/lpc845/LPC845.h         [54-line stub, no peripheral typedefs]  ✗
        variants/lpc804/LPC804.h         [49-line stub, no peripheral typedefs]  ✗
        cores/lpc8xx/lpc8xx_registers.h  [hand-rolled, missing SCT + DMA]        ✗
    

    FastLED CI surface (5 board workflows)

    All five route through the same package stack:

    Workflow Board
    build_lpc845.yml lpc845 (raw LPC845M301)
    build_lpc804.yml lpc804 (raw LPC804M101)
    build_lpc845brk.yml lpc845brk (LPC845 Breakout Board)
    build_lpcxpresso845max.yml lpcxpresso845max (LPCXpresso845-MAX dev board)
    build_lpcxpresso804.yml lpcxpresso804 (LPCXpresso804 dev board)

    All five compile against cores/lpc8xx/ + the appropriate variants/<board>/ directory, which means all five see the stub LPC845.h / LPC804.h and have to fall back on FastLED's hand-rolled shims.

    End-to-end fix chain (now tracked)

    Three repos must coordinate. Each issue below has the cross-references it needs to be picked up independently.

    Step 1 — Upstream content gap

    📌 zackees/ArduinoCore-LPC8xx#33 — ship full NXP CMSIS PAL into variants/lpc845/LPC845.h + variants/lpc804/LPC804.h (both currently stubs).

    Step 2 — Upstream pin gap

    📌 zackees/platform-nxplpc-arduino#8 — pin framework-arduino-lpc8xx by SHA in platform.json (currently a bare URL), then bump to the post-#33 SHA after step 1 lands.

    Step 3 — FastLED-side consumption (this meta)

    After steps 1 + 2 ship:

    • V5 Bump _NXPLPC_PLATFORM SHA in ci/boards.py + platformio.ini to the new platform-nxplpc-arduino release SHA
    • V5 Add #include <LPC845.h> (and <LPC804.h>) to led_sysdefs_arm_lpc.h inside FL_IS_ARM_LPC_845 / FL_IS_ARM_LPC_804 guards
    • V6 Delete all 8 hand-rolled register-map sites in the audit list above; migrate call sites to vendor typedefs (SCT0, DMA0, SYSCON, SPI0, SPI1, GPIO, SWM0, IOCON)
    • V7 Add #error guard in led_sysdefs_arm_lpc.h if vendor header is missing
    • Verify All 5 CI workflows green: lpc845, lpc804, lpc845brk, lpcxpresso845max, lpcxpresso804

    Fallback if upstream declines either step

    Tier-2 in-tree vendoring under src/platforms/arm/lpc/third_party/cmsis/{LPC845.h,LPC804.h,system_LPC845.h,system_LPC804.h} — the third_party/ path inherits FastLED's existing linter exemption for vendored code. See reverted commits 0365745f7 + c047a586b on branch feat/3437-lpc-cmsis-vendoring for the working prototype.

    Out of scope for this meta

    LPC11xx / LPC15xx aren't currently in CI (README lists them as compile-only with bring-up pending). When they enter CI, the same three-step fix chain applies — file equivalents at nxp-mcuxpresso/mcux-devices-lpc upstream for those chip families.

    🤖 Generated with Claude Code

  3. moved this from Triage to Done in FastLED Trackeron Jun 28, 2026
  4. added 5 commits that reference this issue on Jun 28, 2026
    12265f7
    07d4903
    caa0f92
    b4004de
    9ae6c05
  5. zackees commented on Jun 28, 2026

    @zackees
    MemberAuthor

    Closed by PR #3438 — merged to master at defbb345.

    End-to-end resolution across 3 repos:

    Step Repo PR Merge SHA
    1 zackees/ArduinoCore-LPC8xx #34 — ship full NXP CMSIS PAL 50d76e0d
    2 zackees/platform-nxplpc-arduino #9 — pin SHA + bump v0.2.0 12265f76
    3 FastLED/FastLED #3438 — consume vendor PAL, delete shims defbb345

    Audit sites resolved:

    • ✅ Site 1 — FL_LPC_SCT_Shim deleted → vendor SCT0->
    • ✅ Site 2 — FL_LPC_DMA_Shim deleted → vendor DMA0-> (+ @phatpaul's WIP: LPC845 PWM+DMA driver implementation #3349 CHANNEL.CFG fix folded in)
    • ✅ Site 3 — FL_LPC_SYSCON_Shim deleted → vendor SYSCON->
    • ✅ Site 4 — FL_LPC_SPI_Type deleted → vendor SPI_Type
    • ⏳ Site 5 — LPC11 legacy GPIO (no CI workflow yet; deferred)
    • ⏳ Site 6 — fastpin_arm_lpc.h fallback retained for LPC11Uxx/LPC15xx until vendor CMSIS lands for those families
    • ✅ Site 7 — LPC804 PLU raw offsets → vendor PLU_Type (also uncovered 3 additional latent register-block offset bugs)
    • ⏳ Site 8 — rx_sct_capture.cpp.hpp (opt-in driver, ~48 register accesses, mechanical follow-up)

    5/8 sites migrated. 3 deferred sites tracked in src/platforms/arm/lpc/README.md.

    Latent register-offset bugs eliminated structurally:

    1. SYSCON.SYSAHBCLKCTRL0 offset (was 0x40 pre-WIP: LPC845 PWM+DMA driver implementation #3349, vendor truth 0x80 — corroborates @phatpaul's WIP: LPC845 PWM+DMA driver implementation #3349)
    2. DMA CHANNEL.CFG missing PERIPHREQEN (@phatpaul's WIP: LPC845 PWM+DMA driver implementation #3349 fix applied)
    3. SCT shim split LIMIT/HALT/STOP/START into _L/_H 32-bit pairs (vendor has each as single 32-bit reg; every shim member from COUNT onwards was 16 bytes too high — newly uncovered)
    4. PLU LUT_TRUTH at 0x000 instead of 0x800 (newly uncovered)
    5. PLU OUTPUT_MUX at 0x800 instead of 0xC00 (newly uncovered)
    6. PLU LUT_INP_MUX at 0xC00 instead of 0x000 (newly uncovered)

    Tier-1 path per agents/docs/register-maps.md now operational across all 5 LPC8xx CI workflows. @phatpaul's #3349 is unblocked — he can rebase his PWM+DMA bring-up on a vendor-PAL foundation.

  6. added a commit that references this issue on Jun 29, 2026
    50d76e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions