Skip to content

fix(stm32): defer legacy debug registers to CMSIS 6 - #4410

Merged
zackees merged 1 commit into
masterfrom
fix/4408-stm32-cmsis6
Sep 13, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/4408-stm32-cmsis6

Conversation

@zackees

@zackees zackees commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #4408.

Including FastLED on the Zephyr-based Arduino Uno Q reaches the legacy STM32 register fallback even though CMSIS 6 has already declared CoreDebug_Type and DWT_Type. CMSIS 6 does not define the old CoreDebug_BASE guard, and STM32 HAL's COMP1/COMP2 macros also expand inside the fallback struct.

Suppress the fallback when a CMSIS core or existing register base is present, preserve the legacy layout while prefixing its comparator member names, and prefer CMSIS 6's DCB for trace enable with the older CoreDebug path retained. Add host regressions for CMSIS suppression, macro coexistence, and legacy register offsets/sizes. No new register maps or dependency changes.

Validation:

  • bash test --cpp: baseline 305/305 unit tests and 84/84 examples passed; after the fix, 2/2 affected unit tests passed, with unchanged tests/examples cached.
  • Both new tests failed before the fix; both passed afterward in debug mode with Nix library directories supplied through LD_LIBRARY_PATH.
  • bash lint: passed (one existing JavaScript warning); code review found no blocking issues.
  • bash compile arduino_uno_q --examples Blink: baseline passed, 40,943 bytes flash / 4,032 bytes RAM. This target is an STM32duino surrogate, not ArduinoCore-zephyr.
  • An external /tmp probe cross-compiled ST's actual STM32U585 device PAL with its core include redirected to Arm CMSIS 6.1.0. Including the original fallback reproduced both typedef conflicts and the HAL comparator syntax errors. The patched fallback passed: 25,812 bytes flash / 3,344 bytes RAM.

The actual Zephyr Arduino core and physical Uno Q were not tested. The vendor-header probe validates the reported CMSIS/HAL collision with real headers and the ARM toolchain; it does not establish hardware timing behavior.

The CMSIS 6 probe also passed with CMSIS_DISABLE_DEPRECATED and source assertions requiring DCB present / CoreDebug absent: bash compile arduino_uno_q --examples /tmp/fastled-4408-probe --defines CMSIS_DISABLE_DEPRECATED, rebuilt successfully in 23.8s (25,812 bytes flash / 3,344 bytes RAM). The initial flag-only invocation reused cached artifacts, so the source assertion forced actual recompilation. Absolute example paths also caused a nonfatal build-metadata filename warning; firmware compilation/linking succeeded.

Summary by CodeRabbit

  • Bug Fixes

    • Improved STM32 compatibility across CMSIS versions, including CMSIS 6 and Zephyr-based Uno Q platforms.
    • Prevented legacy register definitions from conflicting with existing vendor CMSIS definitions.
    • Resolved naming conflicts with STM32 HAL macros while preserving access to DWT comparator registers.
    • Improved clockless-driver tracing support across newer and older CMSIS environments.
  • Documentation

    • Clarified STM32 register fallback behavior and precedence of vendor-provided CMSIS definitions.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Review Change StackReview 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: Advanced

Run ID: 39bda00e-af5a-4624-8fd4-103ac5e91cff

📥 Commits

Reviewing files that changed from the base of the PR and between 8049f0b and 90607a1.

📒 Files selected for processing (5)
  • src/platforms/arm/stm32/README.md
  • src/platforms/arm/stm32/clockless_arm_stm32.h
  • src/platforms/arm/stm32/cm3_regs.h
  • tests/platforms/arm/stm32/cm3_regs_cmsis.cpp
  • tests/platforms/arm/stm32/cm3_regs_legacy.cpp

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The STM32 register fallback now defers to CMSIS definitions, avoids comparator macro collisions, and supports legacy layouts. The clockless driver enables DWT tracing through CMSIS 6 DCB or older CoreDebug definitions. Tests cover both paths.

Changes

STM32 CMSIS compatibility

Layer / File(s) Summary
Legacy register fallback and compatibility tests
src/platforms/arm/stm32/cm3_regs.h, tests/platforms/arm/stm32/cm3_regs_*.cpp, src/platforms/arm/stm32/README.md
The fallback is disabled when CMSIS core markers or CoreDebug_BASE/DWT_BASE exist. DWT comparator fields use DWT_COMP0–DWT_COMP3. Tests verify CMSIS suppression, register layout, sizes, offsets, and preservation of COMP0–COMP3 macros.
CMSIS tracing integration
src/platforms/arm/stm32/clockless_arm_stm32.h
The clockless driver uses existing CMSIS definitions and supports DWT tracing through DCB/DWT or CoreDebug/DWT.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 90607

The STM32 CMSIS compatibility changes have no remaining actionable merge risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: STM32 legacy debug-register definitions now defer to CMSIS 6.
Linked Issues check ✅ Passed Issue #4408 requires FastLED to compile with CMSIS 6 and STM32 HAL headers on the Uno Q STM32U585. The fallback in cm3_regs.h is disabled when CMSIS markers or register bases exist. This prevents du…
Out of Scope Changes check ✅ Passed The changed README documents the STM32 fallback behavior. The clockless change supports the CMSIS 6 register path required by issue #4408. The register changes and tests verify the same compilation-co…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4408-stm32-cmsis6

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 9aa7254 into master Sep 13, 2026
22 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 13, 2026
@zackees
zackees deleted the fix/4408-stm32-cmsis6 branch November 5, 2026 05:52
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.

Arduino Uno Q Error

1 participant