Skip to content

docs(platforms): mandate vendor CMSIS PAL for register maps - #3350

Merged
zackees merged 1 commit into
masterfrom
docs/register-map-authoring
Jun 24, 2026
Merged

zackees merged 1 commit into
masterfrom
docs/register-map-authoring

Conversation

@zackees

@zackees zackees commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Two LPC845 register-offset bugs (issue #2990, fix PR #3349) traced back to hand-rolled FL_LPC_*_Shim structs in src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h whose offsets disagreed with NXP's LPC845.h. Both were invisible at compile time and only surfaced when contributors scoped the GPIO pin. The contributor put it bluntly: "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."

This PR lands the documentation gap that allowed those bugs to ship:

  • agents/docs/register-maps.md (new) — the rule, why hand-rolled shims fail, a vendor-source table (NXP / ST / Nordic / Atmel / RPi / SiLabs / PJRC CMSIS repos with licenses), a tier-1/2/3 integration pattern, a reviewer checklist, and the LPC845 worked anti-example.
  • CLAUDE.md — new row in "Read the Right File for Your Task" pointing at the new doc, so it shows up in the routing table every agent reads at session start.
  • .claude/agents/platform-port-agent.md + .claude/skills/platform-port/SKILL.md — cross-reference the doc before any peripheral struct is authored, with the LPC845 incident cited inline.
  • src/platforms/arm/lpc/README.md — pin the lesson at the scene of the crime; flag the existing shims as tier-3 fallbacks and tee up the longer-term tier-2 fix (vendoring LPC845.h into src/platforms/arm/lpc/cmsis/).

No code changes in this PR — a follow-up will land the tier-2 LPC845 vendoring and delete the shims.

Test plan

  • agents/docs/register-maps.md renders cleanly (Markdown only).
  • CLAUDE.md table parses (visual check — column count preserved).
  • No build files touched, so no bash compile / bash test impact.
  • Reviewer spot-check: does the vendor-source table cover the platforms FastLED currently supports?
  • Reviewer spot-check: tier-1/2/3 examples (RP2040, nRF52, SAM3X8E) match how those drivers actually use vendor headers today.

Closes the documentation gap behind issue #2990's "AI hallucinated register maps" comment.

Related: #2990, #3349

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added clear guidance for working with MCU peripheral register layouts.
    • Encourages using vendor CMSIS headers as the source of truth and avoids hand-written register shims.
    • Added step-by-step rules, review checks, and examples for safer register-map handling.
    • Updated platform porting docs with stronger register-access instructions and notes for LPC targets.

Two LPC845 register-offset bugs (issue #2990, fix PR #3349) traced back
to hand-rolled `FL_LPC_*_Shim` structs whose offsets disagreed with NXP's
`LPC845.h`. The bugs were invisible at compile time and only surfaced when
contributors scoped the GPIO pin and noticed the LED pattern was wrong.

Land documentation so future agents and contributors prefer vendor headers:

- `agents/docs/register-maps.md` — new doc with the rule, why hand-rolled
  shims fail, a vendor-source table (NXP/ST/Nordic/Atmel/RPi/SiLabs/PJRC
  CMSIS repos with licenses), a tier-1/2/3 integration pattern, a
  reviewer checklist, and the LPC845 worked anti-example.
- `CLAUDE.md` — new row in "Read the Right File for Your Task" pointing
  at the new doc.
- `.claude/agents/platform-port-agent.md` + `.claude/skills/platform-port/SKILL.md`
  — cross-reference the doc before any peripheral struct is authored.
- `src/platforms/arm/lpc/README.md` — pin the lesson at the scene of the
  crime; flag the existing shims as tier-3 fallbacks and tee up the
  longer-term tier-2 fix (vendor `LPC845.h` into `src/platforms/arm/lpc/cmsis/`).

Closes the documentation gap behind issue #2990's "AI hallucinated
register maps" comment. No code changes — follow-up PR will land the
tier-2 LPC845 vendoring.

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

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d6b5615-a296-4f12-86bf-3a07dc978a53

📥 Commits

Reviewing files that changed from the base of the PR and between abd8e8c and cc5ebb6.

📒 Files selected for processing (5)
  • .claude/agents/platform-port-agent.md
  • .claude/skills/platform-port/SKILL.md
  • CLAUDE.md
  • agents/docs/register-maps.md
  • src/platforms/arm/lpc/README.md

📝 Walkthrough

Walkthrough

Adds agents/docs/register-maps.md, a new policy document establishing a three-tier model for MCU peripheral register access (vendor CMSIS header → vendored copy → last-resort shim), a reviewer checklist, and an LPC845 anti-example. References to this document are added to CLAUDE.md, the platform-port agent and skill files, and the LPC platform README.

Changes

Register-map policy and agent wiring

Layer / File(s) Summary
New register-maps.md policy document
agents/docs/register-maps.md
Adds the full guide: vendor CMSIS header authority rule, rationale against hand-rolled shims, canonical header locations by vendor family, Tier 1/2/3 integration definitions with code examples, escalation rule, reviewer checklist, LPC845 worked anti-example, and cross-references.
LPC platform README shim authoring note
src/platforms/arm/lpc/README.md
New section documents existing tier-3 shim structs in clockless_arm_lpc_pwm_dma.h, records historical offset mistakes, imposes citation and include-guard requirements for future edits, and states the planned tier-2 vendoring removal path.
Agent, skill, and CLAUDE.md cross-references
CLAUDE.md, .claude/agents/platform-port-agent.md, .claude/skills/platform-port/SKILL.md
Adds a task-routing entry in CLAUDE.md, expands the clockless-driver section and key-rules bullet in the platform-port agent, and adds a register-map authoring directive in the skill file—all pointing to agents/docs/register-maps.md and enforcing the no-hand-rolled-shim rule.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit once typed offsets by paw,
And found every shim had a flaw.
Now CMSIS leads,
The vendor doc feeds,
No more structs built from guesswork and awe! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the docs change to require vendor CMSIS PAL headers for register maps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/register-map-authoring

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 8e4af45 into master Jun 24, 2026
6 of 9 checks passed
@zackees
zackees deleted the docs/register-map-authoring branch June 24, 2026 16:28
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 24, 2026
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