Repository navigation
fix(rp): return released pins to hi-Z instead of leaving them muxed - #4218
Conversation
Four RP teardown paths released their pins in the resource ledger but never undid the muxing that initialize() applied, so the pad kept being driven by a peripheral the ledger reported as free: rp_spi_peripheral gpio_set_function(GPIO_FUNC_SPI), no restore at all rp_uart_peripheral undid gpio_set_outover but not the UART funcsel spi_hw_8_rp pio_gpio_init on 8 data pins + clock, no restore spi_hw_2_rp pio_gpio_init on 2 data pins + clock, no restore A released-but-still-driven pin is an output-vs-output short the moment another driver takes that net, which on a loopback fixture is reachable rather than theoretical: the RP2350W bench has a soldered GPIO0<->GPIO1 bridge, and adding the GPIO3->GPIO0 jumper that SPI0 loopback needs would put the PL022 and a PIO driver on one wire across a driver sweep. The codebase already had the right idiom in the two paths that got it right -- rp_pio_tx_peripheral.cpp.hpp:190-192 and rp_pio_spi_peripheral.cpp.hpp:177-186 both restore GPIO_FUNC_SIO and set the pin to an input before releasing. This applies the same sequence to the four that omitted it, so a ledger release now means the hardware is genuinely released. Found while writing up the unreachable-path wiring constraints for #3899, after asserting the jumpers were safe and then checking. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughChangesRP pin state restoration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to RP SPI, UART, and PIO-SPI teardown now returns released pins to high-impedance SIO input state, preventing peripheral muxing from persisting after release. The change is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Four RP teardown paths release their pins in the resource ledger but never undo the muxing
initialize()applied. The pad keeps being driven by a peripheral the ledger reports as free.rp_spi_peripheralgpio_set_function(GPIO_FUNC_SPI)rp_uart_peripheralgpio_set_function(UART_FUNCSEL_NUM)gpio_set_outoveronly — pin stays muxedspi_hw_8_rppio_gpio_init× 8 data + clockspi_hw_2_rppio_gpio_init× 2 data + clockWhy this is worth fixing
A released-but-still-driven pin is an output-vs-output short as soon as another driver takes that net. That is reachable on the current bench rather than theoretical: the RP2350W fixture has a soldered GPIO0 ↔ GPIO1 bridge, and adding the
GPIO3 → GPIO0jumper that SPI0 loopback requires would put the PL022 and a PIO driver on one wire for the duration of a mixed driver sweep.The idiom already exists in this codebase
Two RP paths get this right today and were used as the model — no new convention invented:
rp_pio_tx_peripheral.cpp.hpp:190-192rp_pio_spi_peripheral.cpp.hpp:177-186Both do
gpio_set_function(pin, GPIO_FUNC_SIO)thengpio_set_dir(pin, GPIO_IN)beforereleasePins. This PR applies that same sequence to the four that omitted it, so a ledger release now means the hardware is genuinely released.Verification
bash test --cpp→ 385/385 (with fix(build): restore mtime and exec bit on zccache-served link results (#4205, #4212) #4213 applied; without it the run hits the unrelated bash test --cpp fails with 'Stale test artifact' on a healthy tree; --clean and zccache stop do not clear it #4212 stale-artifact failures)2DCB876B587EA334:RESULT: RPC smoke PASS (discovery, help, ping, payload, status, drivers, testNoSerial, RP concurrency, error handling)The SPI loopback legs themselves cannot be functionally exercised on this fixture — they need the
GPIO3 → GPIO0andGPIO11 → GPIO8jumpers documented on #3899 — so this is verified as compile-correct and non-regressing rather than as a behavioural SPI test.Provenance
Found while writing up the unreachable-path wiring constraints for #3899. I had asserted the jumpers were safe to leave fitted, then checked, and they were not. Same defect class as #4214, which fixes the matching omission in
~ClocklessController.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
Summary by CodeRabbit