Skip to content

Commit fb5048f

Browse files
ajf58kartben
andcommitted
boards: Add initial support for the Raspberry Pi Pico 2
The Raspberry Pi Pico 2 is Raspberry Pi's first board fitted with their RP2350A SoC. This adds a minimal board definition, sufficient to build and run `samples/hello_world` and `samples/basic/blinky` on the board. Images can be run on the target using OpenOCD. Raspberry Pi's `picotool` can create a UF2 binary, which ensures that errata RP2350-E10 is avoided e.g. ``` > picotool uf2 convert build\rpi_pico2\hello_world\zephyr\zephyr.elf \ build\rpi_pico2\hello_world\zephyr\zephyr.uf2 \ --family rp2350-arm-s --abs-block` ``` Raspberry Pi Pico 2 is a low-cost, high-performance microcontroller board with flexible digital interfaces. Key features include: - RP2350A microcontroller chip designed by Raspberry Pi in the United Kingdom - Dual Cortex-M33 or Hazard3 processors at up to 150MHz - 520KB of SRAM, and 4MB of on-board flash memory - USB 1.1 with device and host support - Low-power sleep and dormant modes - Drag-and-drop programming using mass storage over USB - 26x multi-function GPIO pins including 3 that can be used for ADC - 2x SPI, 2x I2C, 2x UART, 3x 12-bit 500ksps Analogue to Digital Converter (ADC), 24x controllable PWM channels - 2x Timer with 4 alarms, 1x AON Timer - Temperature sensor - 3x Programmable IO (PIO) blocks, 12 state machines total for custom peripheral support - Flexible, user-programmable high-speed IO - Can emulate interfaces such as SD Card and VGA The Raspberry Pi Pico 2 comes as a castellated module which allows soldering direct to carrier boards. Only enable timer 0 for now. Timer 1 won't work correctly until the rpi_pico HAL has picked up the fix for `hardware_alarm_irq_handler`. See raspberrypi/pico-sdk#1949 . Co-authored-by: Benjamin Cabé <[email protected]> Signed-off-by: Andrew Featherstone <[email protected]>
1 parent ba1b5e7 commit fb5048f

File tree

11 files changed

+293
-74
lines changed

11 files changed

+293
-74
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2021 Yonatan Schachter
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* Pico and Pico 2 boards (but not Pico W) have a common LED placement. */
8+
/ {
9+
leds {
10+
compatible = "gpio-leds";
11+
led0: led_0 {
12+
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
13+
label = "LED";
14+
};
15+
};
16+
17+
pwm_leds {
18+
compatible = "pwm-leds";
19+
status = "disabled";
20+
pwm_led0: pwm_led_0 {
21+
pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
22+
label = "PWM_LED";
23+
};
24+
};
25+
26+
aliases {
27+
led0 = &led0;
28+
pwm-led0 = &pwm_led0;
29+
};
30+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2021, Yonatan Schachter
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/* The Pico and Pico 2 are pin compatible. */
7+
&pinctrl {
8+
uart0_default: uart0_default {
9+
group1 {
10+
pinmux = <UART0_TX_P0>;
11+
};
12+
group2 {
13+
pinmux = <UART0_RX_P1>;
14+
input-enable;
15+
};
16+
};
17+
18+
i2c0_default: i2c0_default {
19+
group1 {
20+
pinmux = <I2C0_SDA_P4>, <I2C0_SCL_P5>;
21+
input-enable;
22+
input-schmitt-enable;
23+
};
24+
};
25+
26+
i2c1_default: i2c1_default {
27+
group1 {
28+
pinmux = <I2C1_SDA_P6>, <I2C1_SCL_P7>;
29+
input-enable;
30+
input-schmitt-enable;
31+
};
32+
};
33+
34+
spi0_default: spi0_default {
35+
group1 {
36+
pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
37+
};
38+
group2 {
39+
pinmux = <SPI0_RX_P16>;
40+
input-enable;
41+
};
42+
};
43+
44+
pwm_ch4b_default: pwm_ch4b_default {
45+
group1 {
46+
pinmux = <PWM_4B_P25>;
47+
};
48+
};
49+
50+
adc_default: adc_default {
51+
group1 {
52+
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
53+
input-enable;
54+
};
55+
};
56+
};

boards/raspberrypi/rpi_pico/rpi_pico-pinctrl.dtsi

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,4 @@
55

66
#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
77

8-
&pinctrl {
9-
uart0_default: uart0_default {
10-
group1 {
11-
pinmux = <UART0_TX_P0>;
12-
};
13-
group2 {
14-
pinmux = <UART0_RX_P1>;
15-
input-enable;
16-
};
17-
};
18-
19-
i2c0_default: i2c0_default {
20-
group1 {
21-
pinmux = <I2C0_SDA_P4>, <I2C0_SCL_P5>;
22-
input-enable;
23-
input-schmitt-enable;
24-
};
25-
};
26-
27-
i2c1_default: i2c1_default {
28-
group1 {
29-
pinmux = <I2C1_SDA_P6>, <I2C1_SCL_P7>;
30-
input-enable;
31-
input-schmitt-enable;
32-
};
33-
};
34-
35-
spi0_default: spi0_default {
36-
group1 {
37-
pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
38-
};
39-
group2 {
40-
pinmux = <SPI0_RX_P16>;
41-
input-enable;
42-
};
43-
};
44-
45-
pwm_ch4b_default: pwm_ch4b_default {
46-
group1 {
47-
pinmux = <PWM_4B_P25>;
48-
};
49-
};
50-
51-
adc_default: adc_default {
52-
group1 {
53-
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
54-
input-enable;
55-
};
56-
};
57-
};
8+
#include "../common/rpi_pico-pinctrl-common.dtsi"

boards/raspberrypi/rpi_pico/rpi_pico.dts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,4 @@
77
/dts-v1/;
88

99
#include "rpi_pico-common.dtsi"
10-
11-
/ {
12-
leds {
13-
compatible = "gpio-leds";
14-
led0: led_0 {
15-
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
16-
label = "LED";
17-
};
18-
};
19-
20-
pwm_leds {
21-
compatible = "pwm-leds";
22-
status = "disabled";
23-
pwm_led0: pwm_led_0 {
24-
pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
25-
label = "PWM_LED";
26-
};
27-
};
28-
29-
aliases {
30-
led0 = &led0;
31-
pwm-led0 = &pwm_led0;
32-
};
33-
};
10+
#include "../common/rpi_pico-led.dtsi"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Andrew Featherstone
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_RPI_PICO2
5+
6+
config USB_SELF_POWERED
7+
default n
8+
9+
endif # BOARD_RPI_PICO2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Andrew Featherstone
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RPI_PICO2
5+
select SOC_RP2350A
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: rpi_pico2
3+
full_name: Raspberry Pi Pico 2
4+
vendor: raspberrypi
5+
socs:
6+
- name: rp2350a
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright (c) 2024, Andrew Featherstone
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2350a-pinctrl.h>
7+
8+
#include "../common/rpi_pico-pinctrl-common.dtsi"
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* Copyright (c) 2024 Andrew Featherstone
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include <freq.h>
10+
11+
#include <zephyr/dt-bindings/i2c/i2c.h>
12+
#include <zephyr/dt-bindings/pwm/pwm.h>
13+
14+
#include <raspberrypi/rpi_pico/rp2350a.dtsi>
15+
16+
#include "rpi_pico2-pinctrl.dtsi"
17+
#include "../common/rpi_pico-led.dtsi"
18+
19+
/ {
20+
chosen {
21+
zephyr,sram = &sram0;
22+
zephyr,flash = &flash0;
23+
zephyr,console = &uart0;
24+
zephyr,shell-uart = &uart0;
25+
zephyr,code-partition = &code_partition;
26+
};
27+
28+
aliases {
29+
watchdog0 = &wdt0;
30+
};
31+
32+
pico_header: connector {
33+
compatible = "raspberrypi,pico-header";
34+
#gpio-cells = <2>;
35+
gpio-map-mask = <0xffffffff 0xffffffc0>;
36+
gpio-map-pass-thru = <0 0x3f>;
37+
gpio-map = <0 0 &gpio0 0 0>, /* GP0 */
38+
<1 0 &gpio0 1 0>, /* GP1 */
39+
<2 0 &gpio0 2 0>, /* GP2 */
40+
<3 0 &gpio0 3 0>, /* GP3 */
41+
<4 0 &gpio0 4 0>, /* GP4 */
42+
<5 0 &gpio0 5 0>, /* GP5 */
43+
<6 0 &gpio0 6 0>, /* GP6 */
44+
<7 0 &gpio0 7 0>, /* GP7 */
45+
<8 0 &gpio0 8 0>, /* GP8 */
46+
<9 0 &gpio0 9 0>, /* GP9 */
47+
<10 0 &gpio0 10 0>, /* GP10 */
48+
<11 0 &gpio0 11 0>, /* GP11 */
49+
<12 0 &gpio0 12 0>, /* GP12 */
50+
<13 0 &gpio0 13 0>, /* GP13 */
51+
<14 0 &gpio0 14 0>, /* GP14 */
52+
<15 0 &gpio0 15 0>, /* GP15 */
53+
<16 0 &gpio0 16 0>, /* GP16 */
54+
<17 0 &gpio0 17 0>, /* GP17 */
55+
<18 0 &gpio0 18 0>, /* GP18 */
56+
<19 0 &gpio0 19 0>, /* GP19 */
57+
<20 0 &gpio0 20 0>, /* GP20 */
58+
<21 0 &gpio0 21 0>, /* GP21 */
59+
<22 0 &gpio0 22 0>, /* GP22 */
60+
<26 0 &gpio0 26 0>, /* GP26 */
61+
<27 0 &gpio0 27 0>, /* GP27 */
62+
<28 0 &gpio0 28 0>; /* GP28 */
63+
};
64+
};
65+
66+
&flash0 {
67+
reg = <0x10000000 DT_SIZE_M(4)>;
68+
69+
partitions {
70+
compatible = "fixed-partitions";
71+
#address-cells = <1>;
72+
#size-cells = <1>;
73+
74+
/* Reserved memory for an image definition block. The block is much
75+
* smaller than 256 bytes, but in practice the linker places the vector
76+
* table at a much larger alignment offset.
77+
*/
78+
image_def: partition@0 {
79+
label = "image_def";
80+
reg = <0x00000000 0x100>;
81+
read-only;
82+
};
83+
84+
/*
85+
* Usable flash. Starts at 0x100, after the image definition block.
86+
* The partition size is 4MB minus the 0x100 bytes taken by the
87+
* image definition.
88+
*/
89+
code_partition: partition@100 {
90+
label = "code-partition";
91+
reg = <0x100 (DT_SIZE_M(4) - 0x100)>;
92+
read-only;
93+
};
94+
};
95+
};
96+
97+
&uart0 {
98+
current-speed = <115200>;
99+
status = "okay";
100+
pinctrl-0 = <&uart0_default>;
101+
pinctrl-names = "default";
102+
};
103+
104+
&gpio0 {
105+
status = "okay";
106+
};
107+
108+
&spi0 {
109+
clock-frequency = <DT_FREQ_M(8)>;
110+
pinctrl-0 = <&spi0_default>;
111+
pinctrl-names = "default";
112+
};
113+
114+
&i2c0 {
115+
clock-frequency = <I2C_BITRATE_STANDARD>;
116+
pinctrl-0 = <&i2c0_default>;
117+
pinctrl-names = "default";
118+
status = "okay";
119+
};
120+
121+
&i2c1 {
122+
clock-frequency = <I2C_BITRATE_STANDARD>;
123+
pinctrl-0 = <&i2c1_default>;
124+
pinctrl-names = "default";
125+
status = "okay";
126+
};
127+
128+
&adc {
129+
pinctrl-0 = <&adc_default>;
130+
pinctrl-names = "default";
131+
status = "okay";
132+
};
133+
134+
&pwm {
135+
pinctrl-0 = <&pwm_ch4b_default>;
136+
pinctrl-names = "default";
137+
divider-int-0 = <255>;
138+
};
139+
140+
&timer0 {
141+
status = "okay";
142+
};
143+
144+
zephyr_udc0: &usbd {
145+
status = "okay";
146+
};
147+
148+
pico_serial: &uart0 {};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
identifier: rpi_pico2
2+
name: Raspberry Pi Pico 2
3+
type: mcu
4+
arch: arm
5+
flash: 4096
6+
ram: 520
7+
toolchain:
8+
- zephyr
9+
- gnuarmemb
10+
- xtools
11+
supported:
12+
- adc
13+
- clock
14+
- counter
15+
- gpio
16+
- hwinfo
17+
- i2c
18+
- pwm
19+
- spi
20+
- uart

0 commit comments

Comments
 (0)