embassy-rp/cyw43-pio: fix input_sync_bypass for pins >= 32 (GPIOBASE offset)#6391
Open
cedrivard wants to merge 4 commits into
Open
embassy-rp/cyw43-pio: fix input_sync_bypass for pins >= 32 (GPIOBASE offset)#6391cedrivard wants to merge 4 commits into
cedrivard wants to merge 4 commits into
Conversation
added 2 commits
June 20, 2026 12:14
set_input_sync_bypass built the bitmask with the absolute pin number, but input_sync_bypass is indexed relative to the PIO's GPIOBASE. On RP235xB with GPIOBASE=16, a pin >= 32 (e.g. GPIO 38) shifted by the full pin number, which panics in debug and wraps to the wrong bit in release. Subtract the GPIOBASE offset (read from the register) before shifting.
input_sync_bypass is indexed relative to GPIOBASE, which is only established by StateMachine::set_config. Calling it at pin creation (before set_config) read a stale GPIOBASE of 0, so the offset was wrong for the CYW43 data pin on boards that wire it to a pin >= 32 (RP235xB). Move the call after set_config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pio::Pin::set_input_sync_bypassbuilds the bitmask from the absolute pinnumber (
1 << self.pin()), butinput_sync_bypassis indexed relative to thePIO's
GPIOBASE(0 or 16 on RP235x). On RP235xB withGPIOBASE = 16, a pinThis breaks
cyw43-pioon boards that wire the CYW43 data line to a high pin.On the SparkFun IoT RedBoard RP2350 (RP2350B; CYW43 on GPIO 36/37/38),
cyw43::new()hangs: without a working sync bypass the PIO samples stale dataand the link never comes up.
Fix
1.
embassy-rp— offset the mask by GPIOBASE. Shift bypin - offset,reading the offset (0/16) from the
GPIOBASEregister instead of assuming afixed value (resolving the 16..31 ambiguity from #5116).
2.
cyw43-pio— call it afterset_config.GPIOBASEis only written byStateMachine::set_config, but the call was at pin creation, beforeset_config, so the register read returned a stale 0. Moving it aftersm.set_config(&cfg)makes the offset correct.Testing
Verified on hardware (SparkFun IoT RedBoard RP2350, RP2350B):
cyw43::new()succeeds and WiFi associates, replacing a manual
INPUT_SYNC_BYPASSwrite I'dbeen carrying downstream.
Supersedes #5116 (same root cause); credit to @diogo464 for the original report
and the ordering insight, and @Dirbaio for the GPIOBASE review note.