Skip to content

fix(esp8266): honor forced software pins in native FastPin specializations - #5258

Merged
zackees merged 1 commit into
masterfrom
fix/esp8266-forced-software-pins-5068
Nov 17, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/esp8266-forced-software-pins-5068

Conversation

@zackees

@zackees zackees commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #5068.

Problem

FASTLED_FORCE_SOFTWARE_PINS selects the primary FastPin provider in fl/system/fastpin_base.h, but every ESP8266 _FL_DEFPIN (RAW, D1 and NodeMCU orders) explicitly specializes FastPin<N> to the register-level _ESPPIN. Those specializations override the primary template, so forced software pins were never used on ESP8266.

Fix (mirrors the ESP32 fix in #5241)

  • fastpin_base.h: forced pins on FL_IS_ESP8266 select FL_FASTPIN_HAS_NO_PINMAP. As on ESP32, pins with no specialization stay invalid (validpin() == false, static assert on use).
  • fastpin_esp8266.h: when FL_FASTPIN_HAS_NO_PINMAP is set, _ESPPIN<REAL_PIN, MASK> derives from NoPinMapPin<REAL_PIN>. The RAW/D1/NodeMCU logical-to-GPIO mapping is kept and kRealPin is still provided, so the HSPI pair resolution keeps compiling. The register-level BitbangPin policy and HAS_HARDWARE_PIN_SUPPORT are left out in forced mode.
  • clockless_block_esp8266.h: the parallel block driver needs sport()/cport(). In forced mode it now fails with a static assert that names the cause instead of a cryptic missing-member error (same pattern as d51/renesas).
  • Default (non-forced) builds are unchanged: the native Blink image is the same size (258.46KB) before and after.

Production path

User sketch with -DFASTLED_FORCE_SOFTWARE_PINS -> FastLED.h -> platforms/fastpin.h ESP8266 branch -> fastpin_esp8266.h _FL_DEFPIN -> now NoPinMapPin<GPIO> -> fl::pinMode/fl::digitalWrite. GenericSoftwareSPIOutput (APA102 on non-HSPI pins) detects this through isNoPinMapPin and uses per-pin writes.

Evidence (real ESP8266 SDK builds: fbuild, xtensa-lx106 gcc 10.3, esp8266 Arduino 3.1.2)

A temporary probe (not committed) was appended to fastpin_esp8266.h:

  • EXPECT=1: FL_STATIC_ASSERT(isNoPinMapPin(FastPin<FL_PIN_CLOCKLESS_1>)), the same for FL_PIN_SPI_DATA_1, and !FastPin<17>::validpin().
  • EXPECT=0: #error if FL_FASTPIN_HAS_NO_PINMAP is defined or HAS_HARDWARE_PIN_SUPPORT is missing.
Build Result
Blink, native, EXPECT=0 pass (258.46KB)
Blink, native, EXPECT=1 (negative control) fails on probe5068 selection asserts
Blink, forced, RAW / D1 / NodeMCU, EXPECT=1 pass (258.45KB each)
Apa102 on GPIO4/5, native, EXPECT=0 pass
Apa102 on GPIO4/5 (generic software SPI), forced, EXPECT=1 pass
Apa102 on GPIO4/16, forced + RAW order, EXPECT=1 pass
Apa102 on GPIO4/5, forced + FASTLED_NO_PINMAP pass
Apa102, forced pins + FASTLED_FORCE_SOFTWARE_SPI pass
Pre-fix headers restored, Apa102 GPIO4/5 forced, EXPECT=1 fails on probe5068 forced selection (the #5068 defect)
Pre-fix headers restored, Blink forced D1, EXPECT=1 fails on probe5068 forced selection

Also run: bash lint (green); uv run pytest on all ci/tests/test_*forced_software_pins.py plus test_esp8266_default_pins.py (pass); bash test fastpin, fastpin_forced_no_pinmap and fastpin_no_pinmap (pass). The new ci/tests/test_esp8266_forced_software_pins.py pins the selection guard and the block-driver rejection.

Scope / not claimed

  • These are selection and compile results only. No runtime, electrical or timing validation is claimed.
  • The single-pin clockless driver (sendPixel) still writes GPIO registers directly. That is the timing-critical path, and the ESP32 RMT/forced behavior is the same.
  • Forced pins do not move the declared HSPI pair off the hardware peripheral (that is FASTLED_FORCE_SOFTWARE_SPI's job, same as ESP32).
  • With forced pins, FastLED.h emits its "No pin/port mappings found" warning, which is accurate and the same as ESP32 forced builds.

Summary by CodeRabbit

  • New Features
    • Forced software-pin mode now applies to ESP8266 as well as ESP32, using the generic software-pin implementation when pin mapping is disabled.
  • Bug Fixes
    • Unspecified ESP8266 pins are now rejected during compilation instead of being treated as valid.
    • ESP8266 block clockless output now reports a compile-time error when forced software pins are enabled, as this driver does not support that mode.
    • ESP8266 software SPI uses the appropriate implementation when pin mapping is unavailable.

…tions

Under FASTLED_FORCE_SOFTWARE_PINS the ESP8266 _FL_DEFPIN specializations
still selected the register-level _ESPPIN, so the forced core-API
provider was never used. Mirror the ESP32 fix (#5241): select
FL_FASTPIN_HAS_NO_PINMAP on ESP8266, derive _ESPPIN from NoPinMapPin
(keeping kRealPin for the RAW/D1/NodeMCU mapping), keep unspecified
pins invalid, gate the register-level BitbangPin policy and
HAS_HARDWARE_PIN_SUPPORT, and reject the block clockless driver with
a clear static assert. Default (non-forced) builds are unchanged.

Fixes #5068
@zackees
zackees enabled auto-merge November 17, 2026 08:00
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Forced software-pin handling now includes ESP8266. Its no-pin-map provider and software-SPI path are adjusted, and the ESP8266 block clockless driver rejects this configuration at compile time.

Changes: ESP8266 Forced Software Pins

Layer / File(s) Summary
Shared forced-pin selection
src/fl/system/fastpin_base.h, ci/tests/test_esp32_forced_software_pins.py, ci/tests/test_stm32_forced_software_pins.py
The no-pin-map condition and checked generic fallback now include ESP8266. The ESP32 and STM32 source-text tests recognize the expanded condition.
ESP8266 no-pin-map provider
src/platforms/esp/8266/fastpin_esp8266.h, ci/tests/test_esp8266_forced_software_pins.py
The no-pin-map path uses NoPinMapPin, does not define hardware-pin support, and excludes the optimized direct-register software-SPI specialization. Tests check these conditions and unspecified-pin handling.
Block clockless rejection
src/platforms/esp/8266/clockless_block_esp8266.h, ci/tests/test_esp8266_forced_software_pins.py
The block clockless controller now triggers a compile-time assertion when the no-pin-map flag is set. A source-text test checks the rejection.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Merge Risk: Low · up to e6723

With forced software pins on ESP8266, toggling a pin after another API has written it can fail to produce an edge. This only affects the opt-in forced mode, and default builds are unchanged. The fix is small and localized, so the change is mergeable with that follow-up.

- [ ] 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 the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 17, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 17, 2026
@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 17, 2026
@zackees
zackees added this pull request to the merge queue Nov 17, 2026
@github-actions

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, Same is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (Same) 136 (Same)
esp8266 264,667 (Same) 6,808 (Same)

@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 17, 2026
Merged via the queue into master with commit 4290e8f Nov 17, 2026
133 of 134 checks passed
@zackees
zackees deleted the fix/esp8266-forced-software-pins-5068 branch November 17, 2026 08:09
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 17, 2026
@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanitized Title, body and conversation screened; review text requires separate screening.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ESP8266 native FastPin definitions bypass forced software pin selection

1 participant