Skip to content

fix(lpc): compile-time assert rx_sct_capture bases match vendor CMSIS PAL (#3517 Phase C partial) - #3535

Merged
zackees merged 1 commit into
masterfrom
feat/lpc-rx-capture-cmsis
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/lpc-rx-capture-cmsis

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Narrow-scope Phase C contribution to #3517.

Adds static_assert on the 5 base-address constants at the top of rx_sct_capture.cpp.hpp verifying identity with the vendor CMSIS <PERIPH>_BASE macros:

SYSCON_BASE   = 0x40048000u
SWM0_BASE     = 0x4000C000u
INPUTMUX_BASE = 0x4002C000u
SCT0_BASE     = 0x50004000u
DMA0_BASE     = 0x50008000u

All cross-checked against NXP mcux-sdk devices/LPC845/LPC845.h.

Why this narrower scope

Full Phase C calls for migrating ~48 register access sites in this file from reg(kSctBase, kOff*) to typed SCT0->FIELD access. That's a substantial mechanical refactor with real miskey risk when the LPC toolchain isn't compile-testable from this coding environment (silicon flash is env-blocked per the meta issue's pyocd discussion).

Rather than ship a risky mass-rename that could break LPC845 users, this PR does the minimum-risk safety net:

  • Base constants are already correct — the static_asserts prove it at build time
  • Any future vendor-header bump that changes a base address surfaces as a build error, not silent runtime misbehavior
  • Call-site migration deferred to a follow-up when a maintainer can compile-test each transformed line against a real LPC845 build

Verification

  • bash test --cpp — 345/345 pass (host builds skip the LPC845 gate)
  • Static asserts only evaluate on real LPC845 builds, guaranteeing the vendor headers agree with our literals

Refs: #3517 Phase C (partial), #3437.

Summary by CodeRabbit

  • Bug Fixes
    • Added stronger validation for hardware address mappings on supported LPC 845 devices, helping catch mismatches earlier and improving platform reliability.
  • Chores
    • Expanded internal configuration coverage for several system peripherals.

… PAL

Adds `static_assert` on the 5 base-address constants at the top of
`rx_sct_capture.cpp.hpp` verifying they identity-equal the vendor CMSIS
`<PERIPH>_BASE` macros from `<LPC845.h>`:

    SYSCON_BASE   = 0x40048000u
    SWM0_BASE     = 0x4000C000u
    INPUTMUX_BASE = 0x4002C000u
    SCT0_BASE     = 0x50004000u
    DMA0_BASE     = 0x50008000u

Cross-checked against NXP mcux-sdk `devices/LPC845/LPC845.h`.

## Rationale — narrow-scope contribution to #3517 Phase C

The full Phase C acceptance calls for migrating all ~48 register access
sites in this file from `reg(kSctBase, kOff*)` to `SCT0->FIELD` typed
accesses. That's a substantial mechanical refactor with real miskey
risk when the LPC toolchain is not compile-testable from this
environment (silicon flash is env-blocked; only host + WASM builds are
verifiable). Rather than ship a risky mass-rename that could break
LPC845 users, this PR does the minimum-risk compile-time safety net:

- The base-address constants are already correct — the `static_assert`s
  prove that at build time.
- Any future vendor-header bump that changes a base surfaces as a
  build error, not a silent runtime misbehavior on real silicon.
- The rest of Phase C — call-site migration — is left for a follow-up
  when a maintainer with LPC845-BRK access can compile-test each
  transformed line.

## Verification

- [x] `bash test --cpp` — 345/345 pass (host builds ignore the LPC845
  gate; static_asserts only fire on real LPC845 builds)
- [x] Grep confirms no other base-address literals in
  `src/platforms/arm/lpc/` need the same treatment (the runtime
  helper and the SPI DMA driver already use vendor typedef access
  everywhere)

Refs: #3517 Phase C (partial delivery — pins the safety net,
outstanding call-site migration deferred), #3437 register-map
remediation.

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: 163e24cc-d22a-4c4f-9709-205cb7dd6b56

📥 Commits

Reviewing files that changed from the base of the PR and between 3eff694 and 64e6fae.

📒 Files selected for processing (1)
  • src/platforms/arm/lpc/rx_sct_capture.cpp.hpp

📝 Walkthrough

Walkthrough

Added compile-time static_assert checks in rx_sct_capture.cpp.hpp for LPC845 builds, validating that hardcoded base address constants (SYSCON, SWM, INPUTMUX, SCT, DMA) match corresponding vendor-provided BASE macros.

Changes

Base Address Validation

Layer / File(s) Summary
LPC845 static_assert checks
src/platforms/arm/lpc/rx_sct_capture.cpp.hpp
Expanded existing constexpr base address constants with explanatory comments and added static_assert checks that verify kSysconBase, kSwmBase, kInputMuxBase, kSctBase, and kDmaBase match vendor macros SYSCON_BASE, SWM0_BASE, INPUTMUX_BASE, SCT0_BASE, and DMA0_BASE when FL_IS_ARM_LPC_845 is defined.

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

✨ 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/lpc-rx-capture-cmsis

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 ba90771 into master Jul 1, 2026
5 of 8 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
…3538)

Regression from #3535 — the vendor CMSIS base-address identity checks used
raw `static_assert(...)`. `BannedMacrosChecker` flags 5 violations:

    static_assert(kSysconBase   == SYSCON_BASE,   ...)
    static_assert(kSwmBase      == SWM0_BASE,     ...)
    static_assert(kInputMuxBase == INPUTMUX_BASE, ...)
    static_assert(kSctBase      == SCT0_BASE,     ...)
    static_assert(kDmaBase      == DMA0_BASE,     ...)

Rationale (from the linter): `FL_STATIC_ASSERT` keeps compile-time
assertions portable on old embedded toolchains.

Fix: include `fl/stl/static_assert.h` and replace `static_assert` with
`FL_STATIC_ASSERT` — same semantics on modern compilers, macro-based
fallback on old ones.

## Verification

- `bash test --cpp` — 345/345 pass
- The `FL_STATIC_ASSERT`s still fire against LPC845 vendor CMSIS `<PERIPH>_BASE`
  macros the same way; behavior identical
- `BannedMacrosChecker` should now find 0 violations in this file

Refs: #3535 (introduced the regression), #3517 Phase C.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/lpc-rx-capture-cmsis 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