Skip to content

fix(mgm240): honor FASTLED_FORCE_SOFTWARE_PINS via the core pin API (#5072) - #5151

Merged
zackees merged 1 commit into
masterfrom
fix/issue-5072
Nov 7, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/issue-5072

Conversation

@zackees

@zackees zackees commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Part of #5072 (does not close it; see "Not met"). Part of #5024.

On MGM240, FASTLED_FORCE_SOFTWARE_PINS had no effect. _FL_DEFPIN in fastpin_arm_mgm240.h explicitly specialized fl::FastPin<PIN>, which overrides the forced software primary template in fastpin_base.h.

Fix

  • Native pin type: _FL_DEFPIN now always emits fl::Mgm240HwPin<PIN>, the native P_SET/P_CLR _ARMPIN. It adds the FastPin<PIN> specialization only when software pins are not forced.
  • Timing-critical drivers: the clockless driver and the ezWS2812 39 MHz and 78 MHz bit-bang drivers use Mgm240HwPin<DATA_PIN>. A software pin cannot meet their cycle-counted timing.
  • Forced mode uses the core pin API: the Silicon Labs Arduino core has no portOutputRegister; a probe build confirmed it. The portOutputRegister/digitalPinToPort fallbacks in led_sysdefs_arm_mgm240.h are placeholders, not EFR32MG24 GPIO addresses, so the register-based software pin would write to unrelated memory. Forced mode therefore also defines FASTLED_NO_PINMAP, which makes FastPin the NoPinMapPin.
  • Forced-mode signals: forced mode emits the usual warning and sets NO_HARDWARE_PIN_SUPPORT.
  • Unmapped pins: these fail with a single descriptive static assertion.

Evidence

  • Real Silabs SDK (bash compile mgm240):
    • A temporary Blink probe statically asserts:
      • which type FastPin<2|3|4|5|13> derives from;
      • in forced modes, that it derives from NoPinMapPin;
      • that Mgm240HwPin<N> is native in every mode.
    • The probe calls setOutput/hi/lo/toggle, APA102 on 4/5 (generic software SPI), MY9221 on 2/3, and the default clockless path.
    • Force off, force on, and force on with FASTLED_NO_PINMAP all build with their expected selection.
    • With the original header, force on fails with every pin still native (RED).
    • ClocklessController_ezWS2812_GPIO_39MHz and _78MHz, added and shown, build in normal and forced mode.
  • Stale objects ruled out: each probe build first removes the stale main_* object, because fbuild does not rebuild main.cpp when only the sketch changes (Incremental build reuses main.cpp object when only the included sketch .ino changes fbuild#1948).
  • ci/tests/test_mgm240_forced_software_pins.py: checks the macro shape, the driver pin type and the forced FASTLED_NO_PINMAP definition. It passes here; its first three cases fail on the original headers.
  • Tests and lint: bash lint exits 0. bash test --cpp passes (361/361 unit).
  • Probes: the Blink sketch was restored after each probe; none of it is committed.

Not met from #5072

  • No device run: no hardware run, no waveform or timing check, and no LOW-at-init, reuse or ordering proof on the selected software implementation.
  • No managed gate: the managed audit gate and artifact binding are not provided.

Limits

  • Drivers stay native: in forced mode the clockless and ezWS2812 drivers keep native GPIO by design.
  • Placeholder macros remain: they are documented as such and are no longer reached by any FastLED pin path.

Summary by CodeRabbit

  • Bug Fixes
    • Improved MGM240 compatibility when forced software-pin mode is enabled, while preserving the existing pin behavior when it is disabled.
    • Updated supported MGM240 LED output drivers to use the platform’s native pin handling, maintaining their existing timing and data transmission behavior.
    • Improved handling of pin-map configuration in forced software-pin mode.

@zackees
zackees enabled auto-merge November 7, 2026 13:59
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

MGM240 now provides a native pin type for clockless drivers while allowing FASTLED_FORCE_SOFTWARE_PINS to leave FastPin on its software implementation. The changes also set FASTLED_NO_PINMAP in forced mode when it is not already defined, and add text-based checks for these selections.

Changes: MGM240 pin selection and clockless drivers

Layer / File(s) Summary
Native pin type and forced-mode selection
src/platforms/arm/mgm240/fastpin_arm_mgm240.h, src/platforms/arm/mgm240/led_sysdefs_arm_mgm240.h, ci/tests/test_mgm240_forced_software_pins.py
Mgm240HwPin provides native pin access. _FL_DEFPIN specializes FastPin from the native type only when software pins are not forced. Forced mode updates hardware-support macros and defines FASTLED_NO_PINMAP if needed. Tests check the conditional specialization and configuration.
Clockless drivers use native pins
src/platforms/arm/mgm240/clockless_arm_mgm240.h, src/platforms/arm/mgm240/clockless_ezws2812_39mhz.h, src/platforms/arm/mgm240/clockless_ezws2812_78mhz.h, ci/tests/test_mgm240_forced_software_pins.py
The MGM240 clockless and ezWS2812 drivers use Mgm240HwPin for pin setup and GPIO access. The bit timing sequences remain unchanged. Tests check that the listed drivers use the native pin type.

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

Change: Bug fix

Possibly related issues

  • FastLED/FastLED#5072 — Addresses the MGM240 native FastPin specialization that could bypass forced software-pin selection.
  • FastLED/FastLED#5056 — Selects the shared forced software-pin implementation on MGM240; the issue also covers fallback correctness and the software SPI route.
  • FastLED/FastLED#5024 — Addresses the MGM240 forced-selection finding described in the software SPI audit.

Possibly related PRs

  • FastLED/FastLED#5105 — Defines the MGM240 native pin implementation that this change uses separately from forced-mode FastPin.
  • FastLED/FastLED#5149 — Applies a similar forced-software pin selection change for nRF52 while retaining a native pin type for drivers.
  • FastLED/FastLED#5150 — Applies a similar forced-software pin selection change for GIGA while retaining native clockless output.
Merge Risk: Moderate · up to b6396

Forced software-pin operations can disagree with clockless output about which physical pin to drive, and native initialization can make the next toggle ineffective. Resolve these inconsistencies and the repository-standard violations before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot added security: unscreened-content and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 7, 2026
@zackees
zackees added this pull request to the merge queue Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, 0 is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (0) 136 (0)

@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed security: unscreened-content labels Nov 7, 2026
Merged via the queue into master with commit cf15c98 Nov 7, 2026
131 of 132 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 7, 2026
@github-actions github-actions Bot added security: unscreened-content and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 7, 2026
@zackees
zackees deleted the fix/issue-5072 branch November 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant