Repository navigation
Description
Context
Two source investigation rounds at 94dab9c for #5024; no builds or tests run. src/platforms/shared/spi_manager.cpp.hpp:192-200 dispatches SOFT_SPI to softwareSPIWrite. This is reachable through FASTLED_FORCE_SOFTWARE_SPI (:602-608) and hardware fallback (:1035). softwareSPIWrite(:1039-1075) constructs runtime Pin objects, branches once per data bit and calls hi/lo for each edge. src/platforms/generic_pin.h:73-80 implements runtime hi/lo with port read/modify/write. This independent runtime loop is not GenericSoftwareSPIOutput and receives none of its new pin policies. Stub/WASM deliberately compile the function to no-op.
Proposal
Resolve safe runtime GPIO write operations once per transfer and use branchless per-pin data updates for platforms with verified atomic/masked registers. Keep a conservative generic fallback for unknown hardware, preserve runtime pin selection and avoid port-snapshot corruption under interrupts. Do not assume all Pin backends have ESP-style W1TS/W1TC.
Acceptance criteria
- RED -> GREEN tests invoke actual SPIBusManager register/initialize/transmit SOFT_SPI path, including forced and hardware-fallback selection, rather than only a helper. All 256 values, consecutive/zero-length transfers, MSB order, clock idle/final edge and unrelated GPIO interference are checked.
- On actual supported ESP32/ESP8266/CI13XX configurations compile runtime path and save code generation proving selected optimized operations avoid per-bit dispatch/data branches and unsafe port RMW; test GPIO16, bank boundaries, invalid pins and conservative unknown backend fallback. Real upstream core builds are required; stub no-op success is not evidence.
- Preserve/document timing and interrupt constraints; this path currently contains no programmable clock delay, so do not silently invent a rate guarantee. Any measured physical speedup requires AutoResearch/fbuild board evidence.
- Restore the old runtime writer as a mutation: the focused operation/RMW assertion must fail and return GREEN after restoration. Flags/metadata-only edits must fail. Use shared exhaustive gate test: gate software SPI changes on exhaustive production-path and mutation evidence #5031.
Decisions
- One child for this independent runtime implementation; generic template platform children cannot close it.
- Duplicate exact metadata query
softwareSPIWritereturned no issues. No unscreened text was ingested.
Open questions
Choose the smallest runtime backend operation resolver that preserves generic Pin compatibility. Next step is a focused production-transmit RED trace/disassembly; no physical speedup is asserted.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Nov 7, 2026
#5125 covers the ESP32/ESP8266 writer only, so this stays open. Still unmet: RED/GREEN through the real SPIBusManager path (softwareSPIWrite is a no-op on stub and WASM builds), the restore-old-writer mutation, a CI13XX build (no board entry), tests or saved code generation for GPIO16, bank boundaries, invalid pins and unknown-backend fallback, an unrelated-GPIO trace, and gate #5031. Pacing is tracked in #5124.
perf(spi): use atomic registers for runtime software SPI on ESP (Fast…
zackees commentedon Nov 22, 2026
Closing with an accepted limitation.
Fix: #5125 (06335a6). The runtime software-SPI writer in
SPIBusManager::softwareSPIWrite(src/platforms/shared/spi_manager.cpp.hpp:1041) resolves each pin once per transfer to the ESP32/ESP8266 atomicW1TS/W1TCregisters (src/platforms/shared/spi_bitbang/runtime_software_spi.h:64-74). It then writes those registers directly instead of dispatching per bit throughPin, and leaves other pins untouched.Proven by:
tests/platforms/shared/spi_bitbang/runtime_software_spi.cpp.Accepted limitations:
SPIBusManagerpath, becausesoftwareSPIWriteis a no-op on stub and WASM builds. The restore-old-writer mutation is part of the same gap.ci/boards.py.The #5031 binding is replaced by a rescoped host-side gate, tracked in #5031.