Skip to content

Commit d58792d

Browse files
pyhysnashif
authored andcommitted
boards: Add Waveshare RP2040 Matrix
Product image from https://www.waveshare.com/wiki/RP2040-Matrix Tested with the samples mentioned in the index.rst page. Signed-off-by: Jonas Berg <[email protected]>
1 parent c96dbf4 commit d58792d

File tree

11 files changed

+411
-0
lines changed

11 files changed

+411
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_MATRIX
5+
select RP2_FLASH_W25Q080
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2022 Peter Johanson
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_RP2040_MATRIX
5+
6+
if I2C_DW
7+
8+
config I2C_DW_CLOCK_SPEED
9+
default 125
10+
11+
endif # I2C_DW
12+
13+
config USB_SELF_POWERED
14+
default n
15+
16+
endif # BOARD_RP2040_MATRIX
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_MATRIX
5+
select SOC_RP2040
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright (c) 2023 TOKITA Hiroshi
3+
4+
board_runner_args(uf2 "--board-id=RPI-RP2")
5+
6+
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_matrix
3+
full_name: RP2040-Matrix
4+
vendor: waveshare
5+
socs:
6+
- name: rp2040
51 KB
Loading
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
.. zephyr:board:: rp2040_matrix
2+
3+
Overview
4+
********
5+
6+
The `Waveshare RP2040-Matrix`_ board is based on the RP2040
7+
microcontroller from Raspberry Pi Ltd.
8+
The board has a 5x5 RGB LED matrix and a USB type C connector.
9+
10+
11+
Hardware
12+
********
13+
14+
- Microcontroller Raspberry Pi RP2040, with a max frequency of 133 MHz
15+
- Dual ARM Cortex M0+ cores
16+
- 264 kByte SRAM
17+
- 2 Mbyte QSPI flash
18+
- 16 GPIO pins
19+
- 4 ADC pins
20+
- I2C
21+
- SPI
22+
- UART
23+
- USB type C connector
24+
- Reset and boot buttons
25+
- 5x5 RGB LED matrix (Neopixels)
26+
27+
28+
Default Zephyr Peripheral Mapping
29+
=================================
30+
31+
.. rst-class:: rst-columns
32+
33+
- 0 UART0 TX : GPIO0
34+
- 1 UART0 RX : GPIO1
35+
- 2 : GPIO2
36+
- 3 SPI0 MOSI : GPIO3
37+
- 4 SPI0 MISO : GPIO4
38+
- 5 : GPIO5
39+
- 6 SPI0 SCK : GPIO6
40+
- 7 : GPIO7
41+
- 8 : GPIO8
42+
- 9 : GPIO9
43+
- 10 : GPIO10
44+
- 11 : GPIO11
45+
- 12 : GPIO12
46+
- 13 : GPIO13
47+
- 14 : GPIO14
48+
- 15 : GPIO15
49+
- 26 ADC0 : GPIO26
50+
- 27 ADC1 : GPIO27
51+
- 28 ADC2 : GPIO28
52+
- 29 ADC3 : GPIO29
53+
- RGB LEDs (Neopixels): GPIO16
54+
55+
See also `schematic`_. The default pin-muxing of UART, SPI and ADC pins is the same as
56+
for the :zephyr:board:`rp2040_zero` board.
57+
58+
.. warning::
59+
60+
Do not use too many LEDs simultaneously, as the board might get too hot.
61+
See `Waveshare RP2040-Matrix wiki`_ for details.
62+
63+
64+
Supported Features
65+
==================
66+
67+
.. zephyr:board-supported-hw::
68+
69+
70+
Programming and Debugging
71+
*************************
72+
73+
.. zephyr:board-supported-runners::
74+
75+
The Waveshare RP2040-Matrix board does not expose
76+
the SWDIO and SWCLK pins, so programming must be done via the USB
77+
port. Press and hold the BOOT button, and then press the RST button,
78+
and the device will appear as a USB mass storage unit.
79+
Building your application will result in a :file:`build/zephyr/zephyr.uf2` file.
80+
Drag and drop the file to the USB mass storage unit, and the board
81+
will be reprogrammed.
82+
83+
For more details on programming RP2040-based boards, see
84+
:ref:`rpi_pico_programming_and_debugging`.
85+
86+
87+
Flashing
88+
========
89+
90+
To run the :zephyr:code-sample:`led-strip` sample:
91+
92+
.. zephyr-app-commands::
93+
:zephyr-app: samples/drivers/led/led_strip/
94+
:board: rp2040_matrix
95+
:goals: build flash
96+
97+
Try also the :zephyr:code-sample:`hello_world`, :zephyr:code-sample:`display`,
98+
:zephyr:code-sample:`usb-cdc-acm-console` and :zephyr:code-sample:`adc_dt` samples.
99+
100+
101+
References
102+
**********
103+
104+
.. target-notes::
105+
106+
.. _Waveshare RP2040-Matrix:
107+
https://www.waveshare.com/rp2040-matrix.htm
108+
109+
.. _Waveshare RP2040-Matrix wiki:
110+
https://www.waveshare.com/wiki/RP2040-Matrix
111+
112+
.. _schematic:
113+
https://files.waveshare.com/upload/4/49/RP2040-Matrix.pdf
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2024 Jonas Berg
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
8+
9+
&pinctrl {
10+
11+
adc_default: adc_default {
12+
group1 {
13+
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
14+
input-enable;
15+
};
16+
};
17+
18+
spi0_default: spi0_default {
19+
group1 {
20+
pinmux = <SPI0_TX_P3>, <SPI0_SCK_P6>;
21+
};
22+
23+
group2 {
24+
pinmux = <SPI0_RX_P4>;
25+
input-enable;
26+
};
27+
};
28+
29+
uart0_default: uart0_default {
30+
group1 {
31+
pinmux = <UART0_TX_P0>;
32+
};
33+
34+
group2 {
35+
pinmux = <UART0_RX_P1>;
36+
input-enable;
37+
};
38+
};
39+
40+
ws2812_pio0_default: ws2812_pio0_default {
41+
ws2812 {
42+
pinmux = <PIO0_P16>;
43+
};
44+
};
45+
};
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/*
2+
* Copyright (c) 2021 Yonatan Schachter
3+
* Copyright (c) 2022 Peter Johanson
4+
* Copyright (c) 2025 Jonas Berg
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
/dts-v1/;
10+
11+
#include <raspberrypi/rpi_pico/rp2040.dtsi>
12+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
13+
#include <zephyr/dt-bindings/input/input-event-codes.h>
14+
#include <zephyr/dt-bindings/led/led.h>
15+
#include "rp2040_matrix-pinctrl.dtsi"
16+
17+
/ {
18+
model = "Waveshare RP2040 Matrix";
19+
compatible = "waveshare,rp2040-matrix";
20+
21+
chosen {
22+
zephyr,sram = &sram0;
23+
zephyr,flash = &flash0;
24+
zephyr,flash-controller = &ssi;
25+
zephyr,console = &uart0;
26+
zephyr,shell-uart = &uart0;
27+
zephyr,code-partition = &code_partition;
28+
zephyr,display = &led_matrix;
29+
};
30+
31+
aliases {
32+
watchdog0 = &wdt0;
33+
led-strip = &ws2812;
34+
};
35+
36+
zephyr,user {
37+
io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>;
38+
};
39+
40+
led_matrix: led_matrix {
41+
compatible = "led-strip-matrix";
42+
status = "okay";
43+
led-strips = <&ws2812>;
44+
width = <5>;
45+
height = <5>;
46+
circulative;
47+
};
48+
};
49+
50+
&flash0 {
51+
reg = <0x10000000 DT_SIZE_M(2)>;
52+
53+
partitions {
54+
compatible = "fixed-partitions";
55+
#address-cells = <1>;
56+
#size-cells = <1>;
57+
58+
/* Reserved memory for the second stage bootloader */
59+
second_stage_bootloader: partition@0 {
60+
label = "second_stage_bootloader";
61+
reg = <0x00000000 0x100>;
62+
read-only;
63+
};
64+
65+
/*
66+
* Usable flash. Starts at 0x100, after the bootloader. The partition
67+
* size is 2 MB minus the 0x100 bytes taken by the bootloader.
68+
*/
69+
code_partition: partition@100 {
70+
label = "code-partition";
71+
reg = <0x100 (DT_SIZE_M(2) - 0x100)>;
72+
read-only;
73+
};
74+
};
75+
};
76+
77+
&gpio0 {
78+
status = "okay";
79+
};
80+
81+
&uart0 {
82+
current-speed = <115200>;
83+
status = "okay";
84+
pinctrl-0 = <&uart0_default>;
85+
pinctrl-names = "default";
86+
};
87+
88+
&spi0 {
89+
pinctrl-0 = <&spi0_default>;
90+
pinctrl-names = "default";
91+
status = "okay";
92+
};
93+
94+
&timer {
95+
status = "okay";
96+
};
97+
98+
&wdt0 {
99+
status = "okay";
100+
};
101+
102+
&adc {
103+
status = "okay";
104+
pinctrl-0 = <&adc_default>;
105+
pinctrl-names = "default";
106+
#address-cells = <1>;
107+
#size-cells = <0>;
108+
109+
channel@0 {
110+
reg = <0>;
111+
zephyr,gain = "ADC_GAIN_1";
112+
zephyr,reference = "ADC_REF_INTERNAL";
113+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
114+
zephyr,resolution = <12>;
115+
};
116+
117+
channel@1 {
118+
reg = <1>;
119+
zephyr,gain = "ADC_GAIN_1";
120+
zephyr,reference = "ADC_REF_INTERNAL";
121+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
122+
zephyr,resolution = <12>;
123+
};
124+
125+
channel@2 {
126+
reg = <2>;
127+
zephyr,gain = "ADC_GAIN_1";
128+
zephyr,reference = "ADC_REF_INTERNAL";
129+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
130+
zephyr,resolution = <12>;
131+
};
132+
133+
channel@3 {
134+
reg = <3>;
135+
zephyr,gain = "ADC_GAIN_1";
136+
zephyr,reference = "ADC_REF_INTERNAL";
137+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
138+
zephyr,resolution = <12>;
139+
};
140+
};
141+
142+
&pio0 {
143+
status = "okay";
144+
145+
pio-ws2812 {
146+
compatible = "worldsemi,ws2812-rpi_pico-pio";
147+
status = "okay";
148+
pinctrl-0 = <&ws2812_pio0_default>;
149+
pinctrl-names = "default";
150+
bit-waveform = <3>, <3>, <4>;
151+
152+
ws2812: ws2812 {
153+
status = "okay";
154+
gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
155+
chain-length = <25>;
156+
color-mapping = <LED_COLOR_ID_GREEN
157+
LED_COLOR_ID_RED
158+
LED_COLOR_ID_BLUE>;
159+
reset-delay = <280>;
160+
frequency = <800000>;
161+
};
162+
};
163+
};
164+
165+
zephyr_udc0: &usbd {
166+
status = "okay";
167+
};
168+
169+
&die_temp {
170+
status = "okay";
171+
};
172+
173+
&vreg {
174+
regulator-always-on;
175+
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
176+
};
177+
178+
&xosc {
179+
startup-delay-multiplier = <64>;
180+
};

0 commit comments

Comments
 (0)