rp2040: add RP2350 A4 stepping support#174
Conversation
* rp2040: add RP2350 A4 stepping and RP2350b support Port changes from Klipper PRs #7141 and #7146: - Fix BOOTROM_WELL_KNOWN_PTR_SIZE to constant 2, removing the runtime A2 silicon revision check. Required for RP2350 A4 stepping (current production) to correctly locate bootrom functions. - Add void *sio field to gpio_out/gpio_in structs and update all GPIO operations to use it, enabling support for the RP2350b's 48 GPIO pins (GPIOs 32-47 use the SIO hi-bank via a +4 byte pointer offset). - Expand CAN GPIO range to 0-47 for RP2350, keeping 0-29 for RP2040. * docs: update README to include rp2350 MCU support and flashing instructions
|
Thanks. It appears to me that Kevin updated the entire Pico SDK and made some changes to The changes to gpio.h and gpio.c look okay to me. The change to the KConfig does not appear to have been made upstream, so until Klipper supports the expanded range of GPIOs we should avoid making that change here. |
|
Hello @Arksine and thanks for having a look at my PR. I will revert the changes regarding KConfig for now if everything else seems fine by you. Updating the SDK headers feels like something I could make another PR for if it's all the same with you. |
|
Thanks, I'm okay with making the SDK change in another PR. In that case it would be preferable to remove the change to the SDK header in this PR so all changes can be done once in the same place. |
Summary
Ports RP2350-related improvements from Klipper (#7141, #7146) to Katapult. The initial RP2350 scaffolding (bootrom, clocks, linker scripts, double-reset detection) was already present; this PR brings in two follow-on fixes that landed in Klipper after that initial work.
Changes
Fix RP2350 A4 stepping (from Klipper #7141)
lib/pico-sdk/pico/bootrom_constants.h: removes the runtime silicon revision check and simplifiesBOOTROM_WELL_KNOWN_PTR_SIZEto the constant2.The original code read byte
0x13from bootrom memory at runtime to detect whether the chip was an A2 stepping, choosing between pointer sizes of 2 and 4. All production RP2350 silicon (A4 stepping) uses size 2, making the check dead code. More critically, if it ever evaluated to4,rom_table_lookupwould be found at the wrong address, causingbootrom_reboot_usb_bootloader()andbootrom_read_unique_id()to fail silently or crash. This matches the fix in pico-sdk v2.2.0.### RP2350b 48-GPIO support (from Klipper #7146)The RP2350b package variant exposes 48 GPIO pins. The SIO peripheral exposes these as two banks — lo (GPIOs 0–31) and hi (GPIOs 32–47) — with each hi-bank register sitting exactly 4 bytes after its lo-bank counterpart in the struct layout.-src/rp2040/gpio.h: addsvoid *siotogpio_outandgpio_into track which SIO bank a pin belongs to-src/rp2040/gpio.c: addsNUM_GPIO(30 for RP2040, 48 for RP2350), updates all GPIO setup/read/write/toggle functions to store and use the sio bank pointer; for pins ≥ 32,sio = (void*)sio_hw + 4shifts all subsequent register accesses onto the hi-bank registers without any branching in the hot path-src/rp2040/Kconfig: expands CAN GPIO range to 0–47 for RP2350, keeps 0–29 for RP2040Notes
CONFIG_MACH_RP2350compile-time constants