Skip to content

fix(esp8266): drive the real GPIO in the clockless driver - #5259

Merged
zackees merged 1 commit into
masterfrom
fix/esp8266-clockless-real-gpio
Nov 17, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/esp8266-clockless-real-gpio

Conversation

@zackees

@zackees zackees commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes a regression that shipped in 3.10.9, introduced by #4917 (c3cc64d). ClocklessController (src/platforms/esp/8266/clockless_esp8266.h) passed the logical DATA_PIN to esp8266_clockless::sendPixel. That function writes GPOS/GPOC/GP16O for a raw GPIO number (1u << (pin & 0x0F), pin >= 16). With FASTLED_ESP8266_D1_PIN_ORDER or FASTLED_ESP8266_NODEMCU_PIN_ORDER, LEDs were driven on the wrong pad. For example, NodeMCU D2 toggled GPIO2 instead of GPIO4. 3.10.8 used FastPin<DATA_PIN>::mask() and was correct.

The fix passes FastPin<DATA_PIN>::kRealPin. Both the native _ESPPIN and the forced-software-pins _ESPPIN (#5258) define it.

Production path

FastLED.addLeds<WS2812, PIN>() on ESP8266 -> ClocklessController<PIN,...>::showRGBInternal -> sendPixel. Any sketch that opts into the D1 or NodeMCU pin order is affected.

Audit

  • clockless_block_esp8266.h drives fixed lanes (GPIO12-15, 4, 5) through PIN_MASK and sport/cport. FIRST_PIN never selects a pad, so it does not have this bug.
  • The HSPI and UART channel drivers compare runtime GPIO numbers (13/14, 2). The SPI default (spi_output_template.h) already maps through kRealPin.

Evidence

bash compile esp8266 --examples Blink (fbuild, xtensa-lx106 gcc 10.3), with firmware.bin compared:

  • RAW (default), before vs after: byte-identical (sha256 079e8a8f...).
  • NodeMCU order (Blink uses FL_PIN_CLOCKLESS_1=2, i.e. D2 = GPIO4), after: byte-identical to RAW GPIO4. Before the fix it differed in 6 bytes, because it drove GPIO2.
  • D1 order with PIN_DATA=2 (GPIO16 / GP16O path): builds.
  • FASTLED_FORCE_SOFTWARE_PINS + NodeMCU order: builds.

Tests

  • New ci/tests/test_esp8266_clockless_real_gpio.py. It fails on master and passes with the fix.
  • ci/tests/test_esp8266_forced_software_pins.py and test_esp8266_clockless_wait_time.py pass.
  • bash lint is clean.

Summary by CodeRabbit

  • Bug Fixes

    • Improved clockless LED output on ESP8266 boards that map logical pin names to different GPIO pins, helping ensure data is sent through the selected pin.
  • Tests

    • Added checks for ESP8266 clockless GPIO handling, including pins numbered 16 and above.

Regression shipped in 3.10.9 from #4917 (c3cc64d): ClocklessController
passed the logical DATA_PIN to esp8266_clockless::sendPixel, which writes
GPOS/GPOC/GP16O for a raw GPIO number. Under FASTLED_ESP8266_D1_PIN_ORDER
or FASTLED_ESP8266_NODEMCU_PIN_ORDER the strip was driven on the wrong pad
(NodeMCU D2 toggled GPIO2 instead of GPIO4). 3.10.8 used FastPin<>::mask()
and was correct.

Pass FastPin<DATA_PIN>::kRealPin, which both the native and the forced
software-pin _ESPPIN providers define. The default RAW pin order is
unchanged (byte-identical Blink firmware). The block clockless driver
uses fixed GPIO12-15/4/5 lanes and the channel drivers take runtime GPIO
numbers, so they do not share this bug.
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ESP8266 clockless driver now passes the real GPIO pin to sendPixel instead of the logical pin. New source-inspection tests check the call argument and related GPIO and FastPin source declarations.

Changes: ESP8266 clockless GPIO pin correction

Layer / File(s) Summary
Pass the real GPIO pin and check the source
src/platforms/esp/8266/clockless_esp8266.h, ci/tests/test_esp8266_clockless_real_gpio.py
The clockless driver passes FastPin<DATA_PIN>::kRealPin to sendPixel. Source-inspection tests check the raw-GPIO handling, the call argument, and FastPin declarations.

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

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 6f76d

This fixes the ESP8266 clockless output pin when a non-raw pin order such as NodeMCU or D1 is used, and leaves the default raw order unchanged. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(esp8266): drive the real GPIO in the clockless driver" matches the main change. The PR passes FastPin<DATA_PIN>::kRealPin to sendPixel in the ESP8266 clockless controller, so the driver…
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.
Full details: Title check

Explanation

The title "fix(esp8266): drive the real GPIO in the clockless driver" matches the main change. The PR passes FastPin<DATA_PIN>::kRealPin to sendPixel in the ESP8266 clockless controller, so the driver writes to raw GPIO numbers instead of logical pins. The title names the platform, the driver, and the effect. The PR objectives describe the same fix for D1 and NodeMCU pin orders.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4290e8f and 6f76d60.

Files selected for processing: 2

  • ci/tests/test_esp8266_clockless_real_gpio.py
  • src/platforms/esp/8266/clockless_esp8266.h

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

@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 17, 2026
@zackees
zackees added this pull request to the merge queue 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
@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
@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 b95c303 Nov 17, 2026
135 checks passed
@zackees
zackees deleted the fix/esp8266-clockless-real-gpio branch November 17, 2026 08:28
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker 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.

1 participant