🛠 Pico SDK 2.x sur une carte RP2350 générique : CMake, board header et PICO_BOARD
Objectives
The Pico C/C++ SDK (branch 2.x) is the official tool for leveraging the RP2350 in C: GPIO, PIO, HSTX, dual architecture. A known pitfall with generic boards: the master SDK provides pico2/pico2_w headers but no "generic RP2350" header — either your board is supported by a third-party repository that provides its header, or you write your own (pico-sdk README). This tutorial: setting up a clean CMake project, targeting PICO_BOARD=pico2 for a Pico-2 compatible board, and creating a minimal board header for an exotic module.
Hardware
- 1 × generic RP2350 board + USB data cable
- pico-sdk 2.x, CMake ≥ 3.13, toolchain arm-none-eabi-gcc (or riscv32 for the ARCHSEL tutorial)
- pico-examples as a compilation reference
- picotool tool to inspect the produced UF2
Full commands
# 1) Toolchain + SDK (Linux ; sous Windows : WSL ou l'installateur officiel)
git clone https://github.com/raspberrypi/pico-sdk.git --branch master
export PICO_SDK_PATH=$PWD/pico-sdk
# 2) Projet minimal
mkdir clignot && cd clignot
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.13)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
project(clignot C CXX ASM)
pico_sdk_init
add_executable(clignot main.c)
target_link_libraries(clignot pico_stdlib)
pico_add_extra_executables(clignot) # génère .uf2
EOF
cat > main.c <<'EOF'
#include "pico/stdlib.h"
#define LED 25
int main(void) {
stdio_init_all;
gpio_init(LED); gpio_set_dir(LED, GPIO_OUT);
for (;;) { gpio_put(LED, !gpio_get(LED)); sleep_ms(250); }
}
EOF
# 3) Configurer pour une carte compatible Pico 2, puis compiler
mkdir build && cd build
cmake -DPICO_BOARD=pico2 ..
make -j
picotool info clignot.uf2 # affiche le nom de board embarqué
Custom board header (generic module)
Copy pico-sdk/src/boards/include/boards/pico2.h to mes_boards/generic_rp2350.h, then adjust it to YOUR board's pinout: #define NUM_BANK0_GPIOS 30 (RP2350A) or 48 (RP2350B), the LED pin, the 12 MHz oscillator, and pass the header directory to CMake with -DPICO_BOARD=generic_rp2350 and the board header search variable.
Expected verification
make produces clignot.uf2; picotool info displays "Program information" with the board pico2. Drop the UF2 in BOOTSEL mode: the LED blinks. The same binary works on any board with a Pico-2 pinout (PicoPlus2, Tiny2350, etc.) since compatibility is at the board/SDK level, not silicon — the RP2350's QFN-60/80 package is not even pin-compatible with the RP2040's QFN-56.
Common errors
Could not find PICO_BOARD=xxx: the header exists neither in the SDK nor in your directories — this is THE problem with generic boards; add the header directory or grab the header from the manufacturer's repository (the Arduino-Pico core embeds one per board, including a "Generic RP2350").- Forgetting
pico_sdk_initafterproject:pico_*functions are unknown — the include/init order of SDK 2.x is strict. - Compiling for ARM while believing you are targeting RISC-V: by default
PICO_PLATFORM=rp2350= Arm Cortex-M33; for Hazard3, usePICO_PLATFORM=rp2350-riscv+ the riscv32 toolchain from pico-sdk-tools. - UF2 missing from the build folder:
pico_add_extra_executablesis missing — without this line, only the .bin/.elf exist. - Reusing a CMakeLists from a pre-SDK 2.0 RP2040 tutorial: SDK 2.x reorganized the bootstrap and platform names — start from the official template, not an old blog post.
- Neglecting the 12 MHz XOSC in the header: a board header declaring the wrong crystal results in a faulty timer —
sleep_ms(250)does not last 250 ms. - Forgetting that the SDK must know the number of GPIOs: an incorrect
NUM_BANK0_GPIOS(30 vs 48) leaves the high pins of an RP2350B inaccessible.
Other tutorials for this board
- Flasher MicroPython sur une carte RP2350 générique et faire clignoter la première LED
- Console série sur RP2350 : USB CDC natif et UART0 de secours
- Lire l'ADC 12 bits et le capteur de température interne du RP2350
- Exploiter les 3 blocs PIO et 12 machines d'état du RP2350 (avec IRQ dédiées)
- Basculer les cœurs de Arm Cortex-M33 à Hazard3 RISC-V avec ARCHSEL
- Secure boot et TrustZone-M sur RP2350 : signer son firmware sans se faire avoir
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython