Repository navigation
Description
Context
Two source investigation rounds at 94dab9c for #5024; no builds or physical timing measurements. Despite its name, src/platforms/apollo3/fastspi_apollo3.h:5-7,106-117 implements software SPI through fastgpio. Every bit branches for data and runs two countdown loops containing __NOP(), so delay work includes loop overhead rather than only the requested NOP count. The dedicated implementation is included by fastled_apollo3.h:8, defines FASTLED_ALL_PINS_HARDWARE_SPI itself at line 21, and is selected by src/platforms/spi_output_template.h:35-36 through apollo3/spi_output_template.h:15.
Proposal
Replace the compile-time half-period countdown with an inline cycle-delay implementation that accounts for GPIO and loop overhead, with a bounded strategy for long delays. Audit HAL data-write code generation before selecting a branchless data operation; the FastPin port/mask/hival/loval methods return null/zero (fastpin_apollo3.h:46-49), so whole-port streaming and ESP-style register assumptions are not applicable.
Acceptance criteria
- Capture a focused RED production APOLLO3HardwareSPIOutput repro showing delay-loop branch/instruction overhead at small dividers; implement and show GREEN code-generation and edge-timing evidence. Use the real writeByte/writeBytesValueRaw/writeBytes/writePixels paths, all byte patterns, back-to-back bytes, start bits and delay boundary values, including zero/odd dividers.
- Compile actual
apollo3_redandapollo3_thing_explorableconfigurations from ci/boards.py:770-780 using the pinned Arduino Apollo3 2.2.0 core. Check HAL fastgpio definitions/assembly and output-capable PAD mappings before using any atomic optimization. Preserve unrelated pin behavior, interrupt assumptions and long-delay behavior. - Document requested vs achieved minimum high/low periods from generated instructions and vendor timing. Validate physical waveform with existing AutoResearch/fbuild paths before asserting measured throughput improvements. No host-derived physical-speed claims.
- Restore the old runtime countdown loop as a mutation; the focused delay/code-generation gate must fail and become GREEN after restoration. Trait/coverage metadata edits alone must not pass.
Decisions
- One child covers the independent Apollo3 software SPI implementation, not each board wrapper.
- Delay-loop removal is verified source opportunity; branchless HAL write feasibility remains an investigation step, not an established register capability.
- Metadata duplicate searches:
Apollo3 SPIand exactAPOLLO3HardwareSPIOutput; exact search returned none, screenedApollo3 SPI label:sanitizedreturned none. Unscreened titles/bodies were not read.
Open questions
Verify whether the selected compiler already unrolls particular small dividers; retain only optimizations with actual target instruction evidence. Next step is the focused RED generated-code repro, before changing implementation.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(apollo3): replace software SPI countdown loop with bounded phase…