Skip to content

Commit b6d2f40

Browse files
authored
Merge pull request #21545 from AnnsAnns/pico2_pr
CPU/Boards: Add Raspberry Pi Pico 2 (RP2350) support
2 parents a5c0bfa + 359d3a9 commit b6d2f40

34 files changed

+1358
-0
lines changed

boards/rpi-pico-2/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2025 Tom Hert <[email protected]>
2+
# SPDX-FileCopyrightText: 2025 HAW Hamburg
3+
# SPDX-License-Identifier: LGPL-2.1-only
4+
5+
config BOARD
6+
default "rpi-pico-2" if BOARD_RPI_PICO_2
7+
8+
config BOARD_RPI_PICO_2
9+
bool
10+
default y
11+
select CPU_MODEL_RP2350

boards/rpi-pico-2/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MODULE = board
2+
3+
include $(RIOTBASE)/Makefile.base

boards/rpi-pico-2/Makefile.features

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CPU := rp2350

boards/rpi-pico-2/Makefile.include

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CPU_MODEL := RP2350
2+
PORT_LINUX ?= /dev/ttyACM0
3+
4+
# JLink isnt tested yet on RP2350
5+
# ifeq ($(PROGRAMMER),jlink)
6+
# JLINK_DEVICE = RP2350_M33_0
7+
# endif

boards/rpi-pico-2/board.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Tom Hert <[email protected]>
3+
* SPDX-FileCopyrightText: 2025 HAW Hamburg
4+
* SPDX-License-Identifier: LGPL-2.1-only
5+
*/
6+
7+
#include "board.h"
8+
9+
void board_init(void) {
10+
/* Re-enable the LED0 pin
11+
* Otherwise the LED will not work after a reset
12+
* This is needed, esp. when the LED is used via
13+
* the define macros */
14+
gpio_init(LED0_PIN_ID, GPIO_OUT);
15+
}

boards/rpi-pico-2/dist/openocd.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo "Make sure to use the Raspberry Pi OpenOCD version!"
2+
source [find target/rp2350.cfg]
3+
set USE_CORE 0
4+
set RESCUE 1
5+
$_TARGETNAME_0 configure -rtos auto
6+
adapter speed 5000
7+
rp2350.dap.core1 cortex_m reset_config sysresetreq

boards/rpi-pico-2/doc.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
@defgroup boards_rpi_pico_2 Raspberry Pi Pico 2
2+
@ingroup boards
3+
@brief Support for the RP2350 based Raspberry Pi Pico board
4+
5+
@warning The support for the Raspberry Pi Pico 2 is still in a very early stage!
6+
See [Known Issues](#rpi_pico_2_known_issues).
7+
8+
## Overview
9+
10+
The Raspberry Pi Pico 2 is a microcontroller board based on the RP2350 chip,
11+
featuring dual-core Arm Cortex-M0+ processors and RISC-V Hazard secondary
12+
architecture. It is designed for a wide range of applications,
13+
from hobbyist projects to professional embedded systems
14+
for a fairly affordable price.
15+
16+
![The Raspberry Pi Pico 2 Board](https://www.raspberrypi.com/documentation/microcontrollers/images/pico-2.png)
17+
18+
## Hardware
19+
20+
| MCU | RP2350 |
21+
|:-----------|:------------------------------------------------------------|
22+
| Family | Dual Cortex-M33 or Hazard3 (RISC-V) |
23+
| Vendor | Raspberry Pi |
24+
| RAM | 520 kB on-chip SRAM (10 independent banks) |
25+
| Flash | Up to 16 MB external QSPI flash (Pico 2 has 4 MB by default)|
26+
| Frequency | up to 150 MHz (Set to 125 MHz in RIOT) |
27+
| Security | Boot signing, key storage, SHA-256 accelerator |
28+
| PIOs | 12 state machines |
29+
| UARTs | 2 |
30+
| SPIs | 2 |
31+
| I2Cs | 2 |
32+
| PWM | 24 channels |
33+
| USB | USB 1.1 controller with host and device support |
34+
| Power | On-chip switched-mode power supply with LDO sleep mode |
35+
| OTP | 8 kB of one-time-programmable storage |
36+
| Datasheet | [RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf) |
37+
38+
## User Interfaces
39+
40+
| Interface | Description |
41+
|:-----------|:-------------------------------------------------------------|
42+
| LED0 | User LED (GPIO 0 at Pin 25) |
43+
| SW0 | Button used in flash process, can be accessed using registers but difficult |
44+
45+
## Pinout
46+
47+
![Pinout Diagram](https://www.raspberrypi.com/documentation/microcontrollers/images/pico-2-r4-pinout.svg)
48+
49+
## Flashing the Board
50+
51+
The Raspberry Pi Pico 2 has a built-in bootloader that allows flashing via USB.
52+
However, you can also use OpenOCD for flashing the board.
53+
If you are using picotool, you need to hold the bootselect button
54+
(the only button on the board) while connecting the board to
55+
your computer via USB. This will put the board into bootloader mode,
56+
allowing you to flash it.
57+
58+
### Flashing using OpenOCD
59+
60+
If you have two Raspberry Pi Pico boards,
61+
you can utilize one as a programmer to program the other board.
62+
63+
Please refer to the
64+
[Debugprobe documentation](https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#getting-started)
65+
for more details.
66+
67+
Note that Raspberry Pi actually uses their own OpenOCD fork, which is available
68+
in the [RP2040 OpenOCD repository](https://github.com/raspberrypi/openocd).
69+
While technically you can use the standard OpenOCD,
70+
it is recommended to use the Raspberry Pi fork for better compatibility with the
71+
RP2350, as its still fairly "new" and under development,
72+
which is why even their own Pico SDK Extension
73+
uses the Raspberry Pi fork of OpenOCD, instead of the standard one.
74+
75+
To do this, you need to connect the board to your computer
76+
and use the following command:
77+
78+
```bash
79+
PROGRAMMER=openocd BOARD=rpi-pico-2 make flash
80+
```
81+
82+
You can then debug your application using GDB with the following command:
83+
84+
```bash
85+
PROGRAMMER=openocd BOARD=rpi-pico-2 make debug
86+
```
87+
88+
### Flashing using Picotool
89+
90+
Simply connect the board to your computer via USB and use the following command:
91+
92+
```bash
93+
BOARD=rpi-pico-2 make flash
94+
```
95+
96+
This is the default method for flashing the Raspberry Pi Pico 2.
97+
However, it does not allow for debugging using GDB.
98+
99+
@note When programming the board with the Picotool for the first time,
100+
RIOT will download and install the Picotool locally in the RIOT folder.
101+
This process will take some minutes to complete.
102+
103+
## Known Issues {#rpi_pico_2_known_issues}
104+
105+
Currently RP2350 support is rather minimal,
106+
as such peripheral support is extremely limited.
107+
The following peripherals are supported:
108+
109+
- GPIO
110+
- Non-configurable write-only UART (UART0 using Pin 0 and 1)
111+
- The UART Baudrate is set to 115200.
112+
- UART does not work via USB, you need to connect it directly to the GPIO pins.
113+
114+
More peripherals will be added in the future.
115+
It should also be noted that we currently only support the Cortex M33 cores,
116+
not the RISC-V Hazard cores.

boards/rpi-pico-2/include/board.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Tom Hert <[email protected]>
3+
* SPDX-FileCopyrightText: 2025 HAW Hamburg
4+
* SPDX-License-Identifier: LGPL-2.1-only
5+
*/
6+
7+
#pragma once
8+
9+
/**
10+
* @ingroup boards_rpi_pico_2
11+
* @{
12+
*
13+
* @file
14+
* @brief Board specific definitions for the Raspberry Pi Pico 2
15+
*
16+
* @author Tom Hert <[email protected]>
17+
*/
18+
19+
#include "RP2350.h"
20+
#include "cpu.h"
21+
#include "cpu_conf.h"
22+
#include "periph_conf.h"
23+
#include "periph_cpu.h"
24+
25+
/** GPIO Pin ID for the onboard LED */
26+
#define LED0_PIN_ID 25u
27+
#define LED0_ON gpio_set(LED0_PIN_ID)
28+
#define LED0_OFF gpio_clear(LED0_PIN_ID)
29+
#define LED0_TOGGLE gpio_toggle(LED0_PIN_ID)
30+
#define LED0_NAME "LED(Green)"
31+
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
/** Initialize the board, called from the cpu startup code */
37+
void board_init(void);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
43+
/** @} */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Tom Hert <[email protected]>
3+
* SPDX-FileCopyrightText: 2025 HAW Hamburg
4+
* SPDX-License-Identifier: LGPL-2.1-only
5+
*/
6+
7+
#pragma once
8+
9+
#include "board.h"
10+
#include "saul/periph.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#ifdef __cplusplus
17+
}
18+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Tom Hert <[email protected]>
3+
* SPDX-FileCopyrightText: 2025 HAW Hamburg
4+
* SPDX-License-Identifier: LGPL-2.1-only
5+
*/
6+
7+
#pragma once
8+
9+
#include <stdint.h>
10+
11+
#include "RP2350.h"
12+
#include "periph_cpu.h"
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
#ifdef __cplusplus
19+
}
20+
#endif

0 commit comments

Comments
 (0)