Pico SDK 2.2.0 Upgrade Topic is solved

ChibiOS public support forum for topics related to the Raspberry Pi RP2040 and RP2350 family of micro-controllers.

Moderator: emulator

Post Reply
emulator
Posts: 25
Joined: Tue Dec 09, 2025 12:14 pm
Has thanked: 6 times
Been thanked: 7 times

Pico SDK 2.2.0 Upgrade

Post by emulator »

The following patch upgrades the existing RP2040 support in main to use Pico SDK 2.2.0. I did not include the Pico SDK 2.2.0 source as it can be fetched via https://github.com/raspberrypi/pico-sdk/releases and I wanted the diff to be as simple as possible. In theory this should be backwards compatible but the changes are large enough that this should probably be part of the next major (25 or 25) release. Note this does not, yet, add RP2350 support, just upgrades the existing device support to the latest SDK.

Code: Select all

diff --git a/demos/RP/RT-RP2040-PICO/Makefile b/demos/RP/RT-RP2040-PICO/Makefile
index fa139efbd..16082acdd 100644
--- a/demos/RP/RT-RP2040-PICO/Makefile
+++ b/demos/RP/RT-RP2040-PICO/Makefile
@@ -153,7 +153,7 @@ CPPWARN = -Wall -Wextra -Wundef
 #
 
 # List all user C define here, like -D_DEBUG=1
-UDEFS = -DCRT0_VTOR_INIT=1 -DCRT0_EXTRA_CORES_NUMBER=1 -DPICO_NO_FPGA_CHECK -DNDEBUG
+UDEFS = -DCRT0_VTOR_INIT=1 -DCRT0_EXTRA_CORES_NUMBER=1 -DPICO_NO_FPGA_CHECK -DNDEBUG -DPICO_RP2040=1
 
 # Define ASM defines here
 UADEFS = -DCRT0_VTOR_INIT=1 -DCRT0_EXTRA_CORES_NUMBER=1
diff --git a/ext/pico-sdk 1.1.0.7z b/ext/pico-sdk 1.1.0.7z
deleted file mode 100644
index a0a6ba419..000000000
Binary files a/ext/pico-sdk 1.1.0.7z and /dev/null differ
diff --git a/os/common/ext/RP/RP2040/rp2040.h b/os/common/ext/RP/RP2040/rp2040.h
index c3919457e..c380089c1 100644
--- a/os/common/ext/RP/RP2040/rp2040.h
+++ b/os/common/ext/RP/RP2040/rp2040.h
@@ -116,7 +116,7 @@ typedef struct {
   __IO uint32_t         INTE0;
   __IO uint32_t         INTF0;
   __IO uint32_t         INTS0;
-  __I  uint32_t         resvd410;
+  __IO uint32_t         INTR1;
   __IO uint32_t         INTE1;
   __IO uint32_t         INTF1;
   __IO uint32_t         INTS1;
@@ -138,7 +138,7 @@ typedef struct {
     __IO uint32_t       INTE0;
     __IO uint32_t       INTF0;
     __IO uint32_t       INTS0;
-    __I  uint32_t       resvd410;
+    __IO uint32_t       INTR1;
     __IO uint32_t       INTE1;
     __IO uint32_t       INTF1;
     __IO uint32_t       INTS1;
@@ -161,7 +161,7 @@ typedef struct {
     __IO uint32_t       INTE0;
     __IO uint32_t       INTF0;
     __IO uint32_t       INTS0;
-    __I  uint32_t       resvd410;
+    __IO uint32_t       INTR1;
     __IO uint32_t       INTE1;
     __IO uint32_t       INTF1;
     __IO uint32_t       INTS1;
@@ -184,7 +184,7 @@ typedef struct {
     __IO uint32_t       INTE0;
     __IO uint32_t       INTF0;
     __IO uint32_t       INTS0;
-    __I  uint32_t       resvd410;
+    __IO uint32_t       INTR1;
     __IO uint32_t       INTE1;
     __IO uint32_t       INTF1;
     __IO uint32_t       INTS1;
diff --git a/os/hal/ports/RP/RP2040/hal_lld.c b/os/hal/ports/RP/RP2040/hal_lld.c
index d859c333c..d69f1c8fa 100644
--- a/os/hal/ports/RP/RP2040/hal_lld.c
+++ b/os/hal/ports/RP/RP2040/hal_lld.c
@@ -100,7 +100,7 @@ static void start_core1(void) {
 void hal_lld_init(void) {
 
 #if RP_NO_INIT == FALSE
-  clocks_init();
+  runtime_init_clocks();
 
   SystemCoreClock = RP_CORE_CLK;
 
diff --git a/os/hal/ports/RP/RP2040/hal_lld.h b/os/hal/ports/RP/RP2040/hal_lld.h
index 9c822c059..62fb5aa9f 100644
--- a/os/hal/ports/RP/RP2040/hal_lld.h
+++ b/os/hal/ports/RP/RP2040/hal_lld.h
@@ -32,6 +32,7 @@
 
 /* From Pico-SDK */
 #include "hardware/clocks.h"
+#include "pico/runtime_init.h"
 
 /*===========================================================================*/
 /* Driver constants.                                                         */
diff --git a/os/various/pico_bindings/dumb/include/pico/config_autogen.h b/os/various/pico_bindings/dumb/include/pico/config_autogen.h
index 50d104c7f..8688c96a5 100644
--- a/os/various/pico_bindings/dumb/include/pico/config_autogen.h
+++ b/os/various/pico_bindings/dumb/include/pico/config_autogen.h
@@ -1,2 +1,28 @@
-#include "boards/pico.h"
+/* Platform selection for Pico SDK 2.x multi-platform support */
+#define PICO_RISCV 0
+#define PICO_RP2040 1
+#define PICO_RP2350 0
+
+#define HAS_GPIO_COPROCESSOR 0
+#define HAS_HSTX 0
+#define LIB_FREERTOS_KERNEL 0
+#define NUM_BOOT_LOCKS 0
+
+#ifndef LIB_PICO_MULTICORE
+#define LIB_PICO_MULTICORE 0
+#endif
+
+#define PICO_BOOTROM_LOCKING_ENABLED 0
+#define PICO_COMBINED_DOCS 0
+#define PICO_SECURE 0
+#define PICO_USE_GPIO_COPROCESSOR 0
 
+#define PICO_IE_26_29_UNCHANGED_ON_RESET 0
+#define PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 0
+#define PICO_USE_STACK_GUARDS 0
+
+#ifndef PICO_NO_FLASH
+#define PICO_NO_FLASH 0
+#endif
+
+#include "boards/pico.h"
diff --git a/os/various/pico_bindings/dumb/include/pico/version.h b/os/various/pico_bindings/dumb/include/pico/version.h
index c32561577..793f76460 100644
--- a/os/various/pico_bindings/dumb/include/pico/version.h
+++ b/os/various/pico_bindings/dumb/include/pico/version.h
@@ -11,9 +11,9 @@
 #ifndef _PICO_VERSION_H
 #define _PICO_VERSION_H
 
-#define PICO_SDK_VERSION_MAJOR    1
-#define PICO_SDK_VERSION_MINOR    1
+#define PICO_SDK_VERSION_MAJOR    2
+#define PICO_SDK_VERSION_MINOR    2
 #define PICO_SDK_VERSION_REVISION 0
-#define PICO_SDK_VERSION_STRING   "1.1.0"
+#define PICO_SDK_VERSION_STRING   "2.2.0"
 
 #endif
diff --git a/os/various/pico_bindings/pico-sdk.mk b/os/various/pico_bindings/pico-sdk.mk
index 02ca0e4be..69a662a7a 100644
--- a/os/various/pico_bindings/pico-sdk.mk
+++ b/os/various/pico_bindings/pico-sdk.mk
@@ -1,22 +1,41 @@
 # Pico-SDK files.
-PICOSDKROOT   := $(CHIBIOS)/ext/pico-sdk
+PICOSDKROOT   := $(CHIBIOS)/ext/pico-sdk-2.2.0
 
 PICOSDKSRC     = $(PICOSDKROOT)/src/rp2_common/hardware_clocks/clocks.c \
                  $(PICOSDKROOT)/src/rp2_common/hardware_pll/pll.c \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_ticks/ticks.c \
                  $(PICOSDKROOT)/src/rp2_common/hardware_watchdog/watchdog.c \
                  $(PICOSDKROOT)/src/rp2_common/hardware_xosc/xosc.c \
+                 $(PICOSDKROOT)/src/rp2_common/pico_runtime_init/runtime_init_clocks.c \
 
-PICOSDKINC     = $(CHIBIOS)//os/various/pico_bindings/dumb/include \
-                 $(PICOSDKROOT)/src/common/pico_base/include \
-                 $(PICOSDKROOT)/src/rp2_common/pico_platform/include \
+PICOSDKINC     = $(CHIBIOS)/os/various/pico_bindings/dumb/include \
+                 $(PICOSDKROOT)/src/common/pico_base_headers/include \
+                 $(PICOSDKROOT)/src/common/hardware_claim/include \
+                 $(PICOSDKROOT)/src/common/pico_time/include \
+                 $(PICOSDKROOT)/src/rp2040/pico_platform/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_platform_compiler/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_platform_sections/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_platform_panic/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_platform_common/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_base/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_boot_lock/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_clocks/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_gpio/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_irq/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_pll/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_resets/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_sync/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_sync_spin_lock/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_ticks/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_timer/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_watchdog/include \
+                 $(PICOSDKROOT)/src/rp2_common/hardware_vreg/include \
                  $(PICOSDKROOT)/src/rp2_common/hardware_xosc/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_bootrom/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_flash/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_runtime/include \
+                 $(PICOSDKROOT)/src/rp2_common/pico_runtime_init/include \
+                 $(PICOSDKROOT)/src/rp2_common/boot_bootrom_headers/include \
                  $(PICOSDKROOT)/src/rp2040/hardware_regs/include \
                  $(PICOSDKROOT)/src/rp2040/hardware_structs/include \
                  $(PICOSDKROOT)/src/boards/include
Post Reply