-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
rp2: Fix RP2350 and RP2350B pin alt functions. #17692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8b872c3
to
3848965
Compare
Would it be reasonable to include a new I feel a readily available, generic B variant would make it much easier to test for issues/regressions in this bringup. While I say this with two B-variant boards on my desk that could be added here, a vendor custom board might introduce unknowns. There is not, and (afaik) will never be, a B-variant RPI_PICO2 so it might be the wrongest place to hang this, but it's very tidy 😆 |
Code size report:
|
I've also completely overlooked RP2350's Alt Function 0 here, which is used for HSTX. Right now |
RP2350 builds were using the incomplete rp2_af.csv alt function table which broke pins > 31 in RP2350B (48-pin QFN-80) builds: >>> machine.Pin(31) Pin(GPIO31, mode=IN, pull=PULL_DOWN) >>> machine.Pin(32) Pin(GPIO32, mode=ALT, pull=PULL_DOWN, alt=31) boards/*._af.csv: Add separate alt-functions tables for RP2040, RP2350 and RP2350B. CMakeLists.txt: Pick correct _af.csv to pass into make-pins.py. boards/make-pins.py: handle CORESIGHT and XIP_CS1 alt functions. machine_pin.c: Add PIO2, CORESIGHT and XIP_CS1 alt functions. Signed-off-by: Phil Howard <github@gadgetoid.com>
3848965
to
25c09fa
Compare
Actually running the test build on an RP2350B doesn't seem to fix the problem I was seeing, but rather makes it worse:
Looks like all pins now default to alt=31 which is Edit: Okay I have fired up vanilla MicroPython on an o.g. Pico and, indeed, |
RP2350 builds were using the incomplete rp2_af.csv alt function table which broke pins > 31 in RP2350B (48-pin QFN-80) builds:
UART_AUX
(alt function 11) andPIO2
(alt function 8, directly conflicting the RP2040 functionGPIO_FUNC_GPCK
) were also missing.Changes
boards/*._af.csv
: Add separate alt-functions tables for RP2040,RP2350 and RP2350B.
CMakeLists.txt
: Pick correct _af.csv to pass into make-pins.py.boards/make-pins.py
: handle CORESIGHT and XIP_CS1 alt functions.machine_pin.c
: Add PIO2, CORESIGHT and XIP_CS1 alt functions.Testing
UART_AUX
I tested UART_AUX on an RP2350B board with the following code and a Raspberry Pi Debug Probe:
The pins are correctly configured as
UART_AUX
(presumably this always worked?) thanks to the use ofUART_FUNCSEL_NUM
, but configuring as UART AUX is now enabled inmachine.Pin
too.To be totally sure this worked, I set up UART 0 on pins 0 and 1, then changed them with
machine.Pin()
:B-variant Build
I set up a generic B-variant for testing, built against the vanilla
RPI_PICO2
board with:And the following config:
ports/rp2/boards/RPI_PICO2/mpconfigvariant_B.cmake
ports/rp2/boards/RPI_PICO2/pico2b.h
:ports/rp2/boards/RPI_PICO2/pins_b.csv
:Trade-offs and Alternatives
I'm not sure we need
CORESIGHT
andXIP_CS1
alt functions but they are included for completeness. They needed fixups inmake-pins.py
because it naively chops the first portion of the signal name off and tries to use that as the GPIO function.UART_AUX
is more interesting, it gives some more UART options on alt-function 11, but also needs special casing to ensureGPIO_FUNC_UART_AUX
is used in place ofGPIO_FUNC_UART
. eg:The addition of a
PIO2
alt function constant might be a separate and important fix for RP2350 variants in general (and may conflict, I need to check that but I've run out of day). Edit: I checked. I don't think anyone has caught this, though there are other outstanding issues with PIO2.