Skip to content

ESP8266: speed up generic bit-bang SPI for non-HSPI pins (baseline 1790 µs / 64 APA102 ≈ 1.4 Mbit/s) #4966

Closed

Description

@zackees

Problem

On ESP8266, clocked chipsets (APA102/SK9822/…) on any pin pair other than the HSPI pads (GPIO13 data / GPIO14 clock) go through the generic software SPI in src/platforms/shared/spi_bitbang/generic_software_spi.h. That path runs at about 1.4 Mbit/s no matter what DATA_RATE_MHZ(...) asks for. The default is 6 MHz.

This is item 2 of #4925 ("Optionally, speed up the bit-bang loop for non-HSPI pins"). #4933, #4951 and #4936 fixed the HSPI pads, but nobody took on this item. #4925 is closed, so nothing was tracking it.

Baseline (measured in #4936)

apa102ShowBitbang [64, 20] in examples/AutoResearch/AutoResearchEsp8266.h drives APA102 on GPIO4/16 through the generic bit-bang. It reports generic_bitbang: true when no define has swapped the path.

LEDs min frame time ≈ rate
64 1790 µs ~1.4 Mbit/s

#4925 measured ~56 CPU cycles per bit at 80 MHz. The delay macros aim for about 13 cycles per bit. That points to the per-bit GPIO set/clear and the loop overhead as the cost, not the pacing delay. This is inferred and has not been profiled yet.

Proposed work

  1. Profile the per-bit loop on ESP8266 (bash profile / disassembly). Confirm where the 56 cycles go.
  2. Cut the per-bit cost: write GPOS/GPOC directly with masks precomputed once per frame, unroll by byte, and skip the pacing delay once the loop is already slower than the requested rate.
  3. Keep the change inside the shared bit-bang path, or in an ESP8266 specialization chosen at the dispatch boundary (see agents/docs/cpp-standards.md → "Select Types at the Preprocessor Boundary").

Acceptance

Related: #1443 (user report of slow SK9822 on ESP8266), #4925, #4936.

Activity

  1. added
    sanitized
    on Nov 6, 2026
  2. zackees commented on Nov 21, 2026

    @zackees
    MemberAuthor

    Closing: covered by 94dab9c (#5021), which speeds up generic ESP8266 bit-bang SPI block streaming on non-HSPI pins. GPIO16 stays slower because the hardware puts it in the RTC register block rather than the main GPIO registers.

  3. moved this from Triage to Done in FastLED Trackeron Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions