Repository navigation
Description
Context
Discovery at 94dab9c for #5024, two source investigation rounds; no builds or device measurements were performed. src/fastspi.h:117-119 exposes SoftwareSPIOutput publicly. Normal ESP32 SPIOutput uses the hardware proxy (src/platforms/esp/32/drivers/spi/spi_output_template.h:15); this work concerns explicit software output only.
src/platforms/shared/spi_bitbang/generic_software_spi.h:204-238 has a separate ESP32 path: it branches on each data bit, issues an extra clock-low store for ones, then calls clock toggle(). src/platforms/esp/32/core/fastpin_esp32.h:63-71 implements toggle through an output-register read and another branch. Set/clear addresses are already selected per GPIO bank at lines 33-40, and hi/lo are atomic stores at lines 49-54. The generic atomic BitbangPin mechanism is bypassed entirely by this ESP32 branch.
Proposal
Introduce an ESP32-specific verified atomic data write and explicit clock edge sequence for the software implementation, eliminating data-dependent control flow and clock readback where vendor GPIO ordering permits. Preserve the historical adjacent-write restriction documented at lines 215-218 until target evidence permits removing it. Do not route normal hardware output through software.
Acceptance criteria
- Record RED -> GREEN evidence using actual production SoftwareSPIOutput writeByte/writeBytes/writeBytesValueRaw/writePixels paths: all 256 byte values, back-to-back bytes, start bits, empty transfers, first/last edges and delay boundaries. Trace data stability at every rising edge and preserve unrelated pins during injected concurrent updates.
- Compile actual ESP32, esp32s2, esp32s3, esp32c3, esp32c6 and esp32p4 configurations (ci/boards.py:956-1049 includes these variants); use safe valid output pin pairs, test low-bank and upper-bank pairs where silicon supports them, cross-bank pairs and invalid/input-only pins. Native fake headers alone do not satisfy board compilation.
- Save target disassembly proving production data writes have no data-bit branch, clock output readback or out-of-line tiny-delay call. For Xtensa and RISC-V separately establish legal consecutive MMIO ordering from vendor sources, then verify representative real boards through existing AutoResearch and fbuild routes. Preserve interrupt safety; do not claim cycle/ns or physical throughput gains from host traces.
- Restore the old ESP32 writeBit/toggle path as a mutation: the focused branch/readback/transaction evidence must fail, then pass after restoration. Merely changing kAtomicWrite or kTwoWriteStream must not satisfy the gate.
Decisions
- One child for the shared ESP32 implementation, with the target/bank matrix above rather than one issue per chip.
- Keep whole-port two-store streaming disabled: output snapshot ownership and concurrent GPIO safety are separate from per-pin atomic writes.
- Search metadata:
software SPI ESP32,BitbangPin; screened title queryESP32 software SPI label:sanitizedreturned no items. Unsanitized issue bodies/titles were not ingested.
Open questions
The old adjacent-write workaround needs target-specific vendor evidence; no physical speedup or safe universal sequence has been established by this audit. Next step is a focused failing code-generation/edge trace before implementation.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(esp32): use atomic branch-free generic software SPI writes (Fast…