Skip to content

Commit f3f8513

Browse files
dschdanieldegrasse
authored andcommitted
boards: waveshare: rp2040_plus: Initial support
Add support for Waveshare RP2040 Plus board a Raspberry Pi Pico like board including a battery charger. Signed-off-by: David Schneider <[email protected]>
1 parent 0530093 commit f3f8513

File tree

13 files changed

+450
-0
lines changed

13 files changed

+450
-0
lines changed

boards/waveshare/rp2040_plus/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 David Schneider
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_PLUS
5+
select RP2_FLASH_W25Q080
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 David Schneider
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_RP2040_PLUS
5+
6+
if I2C_DW
7+
8+
config I2C_DW_CLOCK_SPEED
9+
default 125
10+
11+
endif # I2C_DW
12+
13+
endif # BOARD_RP2040_PLUS
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 David Schneider
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_PLUS
5+
select SOC_RP2040
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
board_runner_args(uf2 "--board-id=RPI-RP2")
4+
5+
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: rp2040_plus
3+
full_name: RP2040-Plus
4+
vendor: waveshare
5+
socs:
6+
- name: rp2040
Binary file not shown.
Binary file not shown.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. zephyr:board:: rp2040_plus
2+
3+
Overview
4+
********
5+
6+
RP2040-Plus, a low-cost, high-performance Pico-like MCU board based on Raspberry Pi microcontroller RP2040
7+
including a battery charger.
8+
9+
Hardware
10+
********
11+
- Dual core Arm Cortex-M0+ processor running up to 133MHz
12+
- 264KB on-chip SRAM
13+
- 4MB/16MB on-board QSPI flash with XIP capabilities
14+
- 26 GPIO pins
15+
- 3 Analog inputs
16+
- 2 UART peripherals
17+
- 2 SPI controllers
18+
- 2 I2C controllers
19+
- 16 PWM channels
20+
- USB 1.1 controller (host/device)
21+
- 8 Programmable I/O (PIO) for custom peripherals
22+
- On-board LED
23+
- 1 Watchdog timer peripheral
24+
- on-board battery charger
25+
26+
27+
Supported Features
28+
==================
29+
30+
.. zephyr:board-supported-hw::
31+
32+
Pin Mapping
33+
===========
34+
35+
The peripherals of the RP2040 SoC can be routed to various pins on the board.
36+
The configuration of these routes can be modified through DTS. Please refer to
37+
the datasheet to see the possible routings for each peripheral.
38+
39+
.. figure:: img/rp2040_plus-details.webp
40+
:align: center
41+
:alt: Waveshare RP2040-Plus pinout overview
42+
43+
Default Zephyr Peripheral Mapping:
44+
----------------------------------
45+
46+
.. rst-class:: rst-columns
47+
48+
- UART0_TX : P0
49+
- UART0_RX : P1
50+
- I2C0_SDA : P4
51+
- I2C0_SCL : P5
52+
- I2C1_SDA : P6
53+
- I2C1_SCL : P7
54+
- SPI0_RX : P16
55+
- SPI0_CSN : P17
56+
- SPI0_SCK : P18
57+
- SPI0_TX : P19
58+
- ADC_CH0 : P26
59+
- ADC_CH1 : P27
60+
- ADC_CH2 : P28
61+
62+
Programming and Debugging
63+
*************************
64+
65+
.. zephyr:board-supported-runners::
66+
67+
Flashing
68+
========
69+
70+
Using UF2
71+
---------
72+
73+
Here is an example of building the sample for driving the built-in led.
74+
75+
.. zephyr-app-commands::
76+
:zephyr-app: samples/basic/blinky
77+
:board: rp2040_plus
78+
:goals: build
79+
:compact:
80+
81+
You must flash the RP2040-Plus with an UF2 file. One option is to use West (Zephyr’s meta-tool). To enter the UF2 flashing mode just keep the ``BOOT`` button pressed while you connect the USB port, it will appear on the host as a mass storage device. In alternative with the board already connected via USB you can keep the ``RESET`` button pressed, press and release ``BOOT``, release ``RESET``. At this point you can flash the image file by running:
82+
83+
.. code-block:: bash
84+
85+
west flash
86+
87+
Alternatively, you can locate the generated :file:`build/zephyr/zephyr.uf2` file and simply drag-and-drop to the device after entering the UF2 flashing mode.
88+
89+
References
90+
**********
91+
92+
- `Official Documentation`_
93+
94+
.. _Official Documentation: https://www.waveshare.com/wiki/RP2040-Plus
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
6+
#include <dt-bindings/i2c/i2c.h>
7+
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+
};
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
/dts-v1/;
6+
7+
#include <freq.h>
8+
#include <zephyr/dt-bindings/pwm/pwm.h>
9+
#include <raspberrypi/rpi_pico/rp2040.dtsi>
10+
11+
#include "rp2040_plus-pinctrl.dtsi"
12+
13+
/ {
14+
chosen {
15+
zephyr,sram = &sram0;
16+
zephyr,flash = &flash0;
17+
zephyr,flash-controller = &ssi;
18+
zephyr,console = &uart0;
19+
zephyr,shell-uart = &uart0;
20+
zephyr,code-partition = &code_partition;
21+
};
22+
23+
aliases {
24+
rtc = &rtc;
25+
watchdog0 = &wdt0;
26+
led0 = &led0;
27+
pwm-led0 = &pwm_led0;
28+
};
29+
30+
pico_header: connector {
31+
compatible = "raspberrypi,pico-header";
32+
#gpio-cells = <2>;
33+
gpio-map-mask = <0xffffffff 0xffffffc0>;
34+
gpio-map-pass-thru = <0 0x3f>;
35+
gpio-map = <0 0 &gpio0 0 0>, /* GP0 */
36+
<1 0 &gpio0 1 0>, /* GP1 */
37+
<2 0 &gpio0 2 0>, /* GP2 */
38+
<3 0 &gpio0 3 0>, /* GP3 */
39+
<4 0 &gpio0 4 0>, /* GP4 */
40+
<5 0 &gpio0 5 0>, /* GP5 */
41+
<6 0 &gpio0 6 0>, /* GP6 */
42+
<7 0 &gpio0 7 0>, /* GP7 */
43+
<8 0 &gpio0 8 0>, /* GP8 */
44+
<9 0 &gpio0 9 0>, /* GP9 */
45+
<10 0 &gpio0 10 0>, /* GP10 */
46+
<11 0 &gpio0 11 0>, /* GP11 */
47+
<12 0 &gpio0 12 0>, /* GP12 */
48+
<13 0 &gpio0 13 0>, /* GP13 */
49+
<14 0 &gpio0 14 0>, /* GP14 */
50+
<15 0 &gpio0 15 0>, /* GP15 */
51+
<16 0 &gpio0 16 0>, /* GP16 */
52+
<17 0 &gpio0 17 0>, /* GP17 */
53+
<18 0 &gpio0 18 0>, /* GP18 */
54+
<19 0 &gpio0 19 0>, /* GP19 */
55+
<20 0 &gpio0 20 0>, /* GP20 */
56+
<21 0 &gpio0 21 0>, /* GP21 */
57+
<22 0 &gpio0 22 0>, /* GP22 */
58+
<26 0 &gpio0 26 0>, /* GP26 */
59+
<27 0 &gpio0 27 0>, /* GP27 */
60+
<28 0 &gpio0 28 0>; /* GP28 */
61+
};
62+
63+
leds {
64+
compatible = "gpio-leds";
65+
led0: led_0 {
66+
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
67+
label = "LED";
68+
};
69+
};
70+
71+
pwm_leds {
72+
compatible = "pwm-leds";
73+
status = "disabled";
74+
pwm_led0: pwm_led_0 {
75+
pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
76+
label = "PWM_LED";
77+
};
78+
};
79+
80+
vbatt: vbatt {
81+
compatible = "voltage-divider";
82+
io-channels = <&adc 3>;
83+
output-ohms = <100000>;
84+
full-ohms = <(200000 + 100000)>;
85+
};
86+
};
87+
88+
&flash0 {
89+
reg = <0x10000000 DT_SIZE_M(4)>;
90+
91+
partitions {
92+
compatible = "fixed-partitions";
93+
#address-cells = <1>;
94+
#size-cells = <1>;
95+
96+
/* Reserved memory for the second stage bootloader */
97+
second_stage_bootloader: partition@0 {
98+
label = "second_stage_bootloader";
99+
reg = <0x00000000 0x100>;
100+
read-only;
101+
};
102+
103+
/*
104+
* Usable flash. Starts at 0x100, after the bootloader. The partition
105+
* size is 4MB minus the 0x100 bytes taken by the bootloader.
106+
*/
107+
code_partition: partition@100 {
108+
label = "code-partition";
109+
reg = <0x100 (DT_SIZE_M(4) - 0x100)>;
110+
read-only;
111+
};
112+
};
113+
};
114+
115+
&uart0 {
116+
status = "okay";
117+
current-speed = <115200>;
118+
pinctrl-0 = <&uart0_default>;
119+
pinctrl-names = "default";
120+
};
121+
122+
&i2c0 {
123+
status = "okay";
124+
pinctrl-0 = <&i2c0_default>;
125+
pinctrl-names = "default";
126+
clock-frequency = <I2C_BITRATE_STANDARD>;
127+
};
128+
129+
&i2c1 {
130+
pinctrl-0 = <&i2c1_default>;
131+
pinctrl-names = "default";
132+
clock-frequency = <I2C_BITRATE_FAST>;
133+
};
134+
135+
&spi0 {
136+
clock-frequency = <DT_FREQ_M(8)>;
137+
status = "okay";
138+
pinctrl-0 = <&spi0_default>;
139+
pinctrl-names = "default";
140+
};
141+
142+
&timer {
143+
status = "okay";
144+
};
145+
146+
&wdt0 {
147+
status = "okay";
148+
};
149+
150+
&gpio0 {
151+
status = "okay";
152+
};
153+
154+
&rtc {
155+
clocks = <&clocks RPI_PICO_CLKID_CLK_RTC>;
156+
status = "okay";
157+
};
158+
159+
&adc {
160+
status = "okay";
161+
pinctrl-0 = <&adc_default>;
162+
pinctrl-names = "default";
163+
#address-cells = <1>;
164+
#size-cells = <0>;
165+
166+
channel@3 {
167+
reg = <3>;
168+
zephyr,gain = "ADC_GAIN_1";
169+
zephyr,reference = "ADC_REF_INTERNAL";
170+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
171+
zephyr,resolution = <12>;
172+
};
173+
174+
channel@4 {
175+
reg = <4>;
176+
zephyr,gain = "ADC_GAIN_1";
177+
zephyr,reference = "ADC_REF_INTERNAL";
178+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
179+
zephyr,resolution = <12>;
180+
};
181+
};
182+
183+
zephyr_udc0: &usbd {
184+
status = "okay";
185+
};
186+
187+
&pwm {
188+
pinctrl-0 = <&pwm_ch4b_default>;
189+
pinctrl-names = "default";
190+
};
191+
192+
&vreg {
193+
regulator-always-on;
194+
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
195+
};
196+
197+
pico_spi: &spi0 {};
198+
pico_i2c0: &i2c0 {};
199+
pico_i2c1: &i2c1 {};
200+
pico_serial: &uart0 {};

0 commit comments

Comments
 (0)