You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ESP8266: speed up generic bit-bang SPI for non-HSPI pins (baseline 1790 µs / 64 APA102 ≈ 1.4 Mbit/s) #4966
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.
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
Profile the per-bit loop on ESP8266 (bash profile / disassembly). Confirm where the 56 cycles go.
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.
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
Rerun bash autoresearch with apa102ShowBitbang [64, 20] on an ESP8266 @ 80 MHz. min_us drops clearly below the 1790 µs baseline. Report the new number in the PR.
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.
Activity
zackees commentedon Nov 21, 2026
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.