Skip to content

Commit 2a9d10e

Browse files
pyhysnashif
authored andcommitted
boards: Add Adafruit Metro RP2040
Product photo from https://learn.adafruit.com/assets/123296 with the license CC BY-SA 3.0 Tested with the samples mentioned in the index.rst page. Signed-off-by: Jonas Berg <[email protected]>
1 parent d58792d commit 2a9d10e

12 files changed

+560
-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_ADAFRUIT_METRO_RP2040
5+
select RP2_FLASH_W25Q080
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_ADAFRUIT_METRO_RP2040
5+
select SOC_RP2040
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_ADAFRUIT_METRO_RP2040
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_ADAFRUIT_METRO_RP2040
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2025 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+
uart0_default: uart0_default {
11+
group1 {
12+
pinmux = <UART0_TX_P0>;
13+
};
14+
15+
group2 {
16+
pinmux = <UART0_RX_P1>;
17+
input-enable;
18+
};
19+
};
20+
21+
i2c0_default: i2c0_default {
22+
group1 {
23+
pinmux = <I2C0_SDA_P16>;
24+
input-enable;
25+
};
26+
27+
group2 {
28+
pinmux = <I2C0_SCL_P17>;
29+
input-enable;
30+
};
31+
};
32+
33+
spi0_default: spi0_default {
34+
group1 {
35+
/* Pin GPIO23 is used as CS (no pinmux available) */
36+
pinmux = <SPI0_TX_P19>, <SPI0_SCK_P18>;
37+
};
38+
39+
group2 {
40+
pinmux = <SPI0_RX_P20>;
41+
input-enable;
42+
};
43+
};
44+
45+
adc_default: adc_default {
46+
group1 {
47+
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
48+
input-enable;
49+
};
50+
};
51+
52+
ws2812_pio0_default: ws2812_pio0_default {
53+
ws2812 {
54+
pinmux = <PIO0_P14>;
55+
};
56+
};
57+
};
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
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 "adafruit_metro_rp2040-pinctrl.dtsi"
16+
#include "arduino_r3_connector.dtsi"
17+
18+
/ {
19+
model = "Adafruit Metro RP2040";
20+
compatible = "adafruit,metro_rp2040";
21+
22+
chosen {
23+
zephyr,sram = &sram0;
24+
zephyr,flash = &flash0;
25+
zephyr,flash-controller = &ssi;
26+
zephyr,console = &uart0;
27+
zephyr,shell-uart = &uart0;
28+
zephyr,code-partition = &code_partition;
29+
};
30+
31+
aliases {
32+
watchdog0 = &wdt0;
33+
led-strip = &ws2812;
34+
led0 = &red_led;
35+
sdhc0 = &sdhc0;
36+
};
37+
38+
zephyr,user {
39+
io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>;
40+
};
41+
42+
leds: leds {
43+
compatible = "gpio-leds";
44+
45+
red_led: red_led {
46+
gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
47+
label = "Red LED";
48+
};
49+
};
50+
51+
stemma_connector: stemma_connector {
52+
compatible = "stemma-qt-connector";
53+
#gpio-cells = <2>;
54+
gpio-map-mask = <0xffffffff 0xffffffc0>;
55+
gpio-map-pass-thru = <0 0x3f>;
56+
gpio-map = <0 0 &gpio0 17 0>, /* SCL */
57+
<1 0 &gpio0 16 0>; /* SDA */
58+
};
59+
};
60+
61+
&flash0 {
62+
reg = <0x10000000 DT_SIZE_M(16)>;
63+
64+
partitions {
65+
compatible = "fixed-partitions";
66+
#address-cells = <1>;
67+
#size-cells = <1>;
68+
69+
/* Reserved memory for the second stage bootloader */
70+
second_stage_bootloader: partition@0 {
71+
label = "second_stage_bootloader";
72+
reg = <0x00000000 0x100>;
73+
read-only;
74+
};
75+
76+
/*
77+
* Usable flash. Starts at 0x100, after the bootloader. The partition
78+
* size is 16 MB minus the 0x100 bytes taken by the bootloader.
79+
*/
80+
code_partition: partition@100 {
81+
label = "code-partition";
82+
reg = <0x100 (DT_SIZE_M(16) - 0x100)>;
83+
read-only;
84+
};
85+
};
86+
};
87+
88+
&gpio0 {
89+
status = "okay";
90+
};
91+
92+
&uart0 {
93+
current-speed = <115200>;
94+
status = "okay";
95+
pinctrl-0 = <&uart0_default>;
96+
pinctrl-names = "default";
97+
};
98+
99+
zephyr_i2c: &i2c0 {
100+
status = "okay";
101+
pinctrl-0 = <&i2c0_default>;
102+
pinctrl-names = "default";
103+
clock-frequency = <I2C_BITRATE_FAST>;
104+
};
105+
106+
&spi0 {
107+
pinctrl-0 = <&spi0_default>;
108+
pinctrl-names = "default";
109+
status = "okay";
110+
cs-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
111+
112+
sdhc0: sdhc@0 {
113+
compatible = "zephyr,sdhc-spi-slot";
114+
reg = <0>;
115+
status = "okay";
116+
spi-max-frequency = <12000000>;
117+
118+
mmc {
119+
compatible = "zephyr,sdmmc-disk";
120+
disk-name = "SD";
121+
status = "okay";
122+
};
123+
};
124+
};
125+
126+
&adc {
127+
status = "okay";
128+
pinctrl-0 = <&adc_default>;
129+
pinctrl-names = "default";
130+
#address-cells = <1>;
131+
#size-cells = <0>;
132+
133+
channel@0 {
134+
reg = <0>;
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+
channel@1 {
142+
reg = <1>;
143+
zephyr,gain = "ADC_GAIN_1";
144+
zephyr,reference = "ADC_REF_INTERNAL";
145+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
146+
zephyr,resolution = <12>;
147+
};
148+
149+
channel@2 {
150+
reg = <2>;
151+
zephyr,gain = "ADC_GAIN_1";
152+
zephyr,reference = "ADC_REF_INTERNAL";
153+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
154+
zephyr,resolution = <12>;
155+
};
156+
157+
channel@3 {
158+
reg = <3>;
159+
zephyr,gain = "ADC_GAIN_1";
160+
zephyr,reference = "ADC_REF_INTERNAL";
161+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
162+
zephyr,resolution = <12>;
163+
};
164+
};
165+
166+
&timer {
167+
status = "okay";
168+
};
169+
170+
&wdt0 {
171+
status = "okay";
172+
};
173+
174+
&pio0 {
175+
status = "okay";
176+
177+
pio-ws2812 {
178+
compatible = "worldsemi,ws2812-rpi_pico-pio";
179+
status = "okay";
180+
pinctrl-0 = <&ws2812_pio0_default>;
181+
pinctrl-names = "default";
182+
bit-waveform = <3>, <3>, <4>;
183+
184+
ws2812: ws2812 {
185+
status = "okay";
186+
gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
187+
chain-length = <1>;
188+
color-mapping = <LED_COLOR_ID_GREEN
189+
LED_COLOR_ID_RED
190+
LED_COLOR_ID_BLUE>;
191+
reset-delay = <280>;
192+
frequency = <800000>;
193+
};
194+
};
195+
};
196+
197+
zephyr_udc0: &usbd {
198+
status = "okay";
199+
};
200+
201+
&die_temp {
202+
status = "okay";
203+
};
204+
205+
&vreg {
206+
regulator-always-on;
207+
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
208+
};
209+
210+
&xosc {
211+
startup-delay-multiplier = <64>;
212+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
identifier: adafruit_metro_rp2040
2+
name: Adafruit Metro RP2040
3+
type: mcu
4+
arch: arm
5+
flash: 16384
6+
ram: 264
7+
toolchain:
8+
- zephyr
9+
- gnuarmemb
10+
supported:
11+
- adc
12+
- clock
13+
- counter
14+
- dma
15+
- flash
16+
- gpio
17+
- hwinfo
18+
- i2c
19+
- pwm
20+
- spi
21+
- uart
22+
- watchdog
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_BUILD_OUTPUT_HEX=y
5+
CONFIG_BUILD_OUTPUT_UF2=y
6+
CONFIG_CLOCK_CONTROL=y
7+
CONFIG_CONSOLE=y
8+
CONFIG_GPIO=y
9+
CONFIG_PIO_RPI_PICO=y
10+
CONFIG_RESET=y
11+
CONFIG_SERIAL=y
12+
CONFIG_UART_CONSOLE=y
13+
CONFIG_UART_INTERRUPT_DRIVEN=y
14+
CONFIG_USE_DT_CODE_PARTITION=y
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 Jonas Berg
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
arduino_header: connector {
9+
compatible = "arduino-header-r3";
10+
#gpio-cells = <2>;
11+
gpio-map-mask = <0xffffffff 0xffffffc0>;
12+
gpio-map-pass-thru = <0 0x3f>;
13+
gpio-map = <0 0 &gpio0 26 0>, /* A0 */
14+
<1 0 &gpio0 27 0>, /* A1 */
15+
<2 0 &gpio0 28 0>, /* A2 */
16+
<3 0 &gpio0 29 0>, /* A3 */
17+
<4 0 &gpio0 24 0>, /* D24 */
18+
<5 0 &gpio0 25 0>, /* D25 */
19+
<6 0 &gpio0 1 0>, /* RX */
20+
<7 0 &gpio0 0 0>, /* TX */
21+
<8 0 &gpio0 2 0>, /* D2 */
22+
<9 0 &gpio0 3 0>, /* D3 */
23+
<10 0 &gpio0 4 0>, /* D4 */
24+
<11 0 &gpio0 5 0>, /* D5 */
25+
<12 0 &gpio0 6 0>, /* D6 */
26+
<13 0 &gpio0 7 0>, /* D7 */
27+
<14 0 &gpio0 8 0>, /* D8 */
28+
<15 0 &gpio0 9 0>, /* D9 */
29+
<16 0 &gpio0 10 0>, /* D10 */
30+
<17 0 &gpio0 11 0>, /* D11 */
31+
<18 0 &gpio0 12 0>, /* D12 */
32+
<19 0 &gpio0 13 0>, /* D13 */
33+
<20 0 &gpio0 16 0>, /* SDA */
34+
<21 0 &gpio0 17 0>; /* SCL */
35+
};
36+
};
37+
38+
arduino_i2c: &i2c0 {};
39+
arduino_serial: &uart0 {};
40+
/* No SPI in the Arduino connector by default for this board */

0 commit comments

Comments
 (0)