Skip to content

Commit bd69ae4

Browse files
icpmoleskartben
authored andcommitted
boards: waveshare: rp2040_zero: Initial support
This PR adds supports for Waveshare RP2040 Zero Signed-off-by: Iacopo Moles <[email protected]>
1 parent 4557b2f commit bd69ae4

File tree

12 files changed

+449
-0
lines changed

12 files changed

+449
-0
lines changed

boards/waveshare/rp2040_zero/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Iacopo Moles
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_ZERO
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) 2024 Iacopo Moles
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_RP2040_ZERO
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_ZERO
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Iacopo Moles
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_RP2040_ZERO
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_zero
3+
full_name: RP2040-Zero
4+
vendor: waveshare
5+
socs:
6+
- name: rp2040
14.3 KB
Loading
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
.. zephyr:board:: rp2040_zero
2+
3+
Overview
4+
********
5+
6+
RP2040-Zero, A Low-Cost, High-Performance Pico-Like MCU Board Based On Raspberry Pi Microcontroller RP2040.
7+
8+
Hardware
9+
********
10+
- RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom.
11+
- Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz.
12+
- 264KB of SRAM, and 2MB of on-board Flash memory.
13+
- USB-C connector, keeps it up to date, easier to use.
14+
- The castellated module allows soldering direct to carrier boards.
15+
- USB 1.1 with device and host support.
16+
- Low-power sleep and dormant modes.
17+
- Drag-and-drop programming using mass storage over USB.
18+
- 29 × multi-function GPIO pins (20× via edge pinout, others via solder points).
19+
- 2 × SPI, 2 × I2C, 2 × UART, 4 × 12-bit ADC, 16 × controllable PWM channels.
20+
- Accurate clock and timer on-chip.
21+
- Temperature sensor.
22+
- Accelerated floating-point libraries on-chip.
23+
- 8 × Programmable I/O (PIO) state machines for custom peripheral support.
24+
25+
Supported Features
26+
==================
27+
28+
The ``rp2040_zero`` board target supports the following hardware features:
29+
30+
.. list-table::
31+
:header-rows: 1
32+
33+
* - Peripheral
34+
- Kconfig option
35+
- Devicetree compatible
36+
* - NVIC
37+
- N/A
38+
- :dtcompatible:`arm,v6m-nvic`
39+
* - UART
40+
- :kconfig:option:`CONFIG_SERIAL`
41+
- :dtcompatible:`raspberrypi,pico-uart`
42+
* - GPIO
43+
- :kconfig:option:`CONFIG_GPIO`
44+
- :dtcompatible:`raspberrypi,pico-gpio`
45+
* - ADC
46+
- :kconfig:option:`CONFIG_ADC`
47+
- :dtcompatible:`raspberrypi,pico-adc`
48+
* - I2C
49+
- :kconfig:option:`CONFIG_I2C`
50+
- :dtcompatible:`snps,designware-i2c`
51+
* - SPI
52+
- :kconfig:option:`CONFIG_SPI`
53+
- :dtcompatible:`raspberrypi,pico-spi`
54+
* - USB Device
55+
- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
56+
- :dtcompatible:`raspberrypi,pico-usbd`
57+
* - HWINFO
58+
- :kconfig:option:`CONFIG_HWINFO`
59+
- N/A
60+
* - Watchdog Timer (WDT)
61+
- :kconfig:option:`CONFIG_WATCHDOG`
62+
- :dtcompatible:`raspberrypi,pico-watchdog`
63+
* - PWM
64+
- :kconfig:option:`CONFIG_PWM`
65+
- :dtcompatible:`raspberrypi,pico-pwm`
66+
* - Flash
67+
- :kconfig:option:`CONFIG_FLASH`
68+
- :dtcompatible:`raspberrypi,pico-flash`
69+
* - Clock controller
70+
- :kconfig:option:`CONFIG_CLOCK_CONTROL`
71+
- :dtcompatible:`raspberrypi,pico-clock-controller`
72+
* - UART (PIO)
73+
- :kconfig:option:`CONFIG_SERIAL`
74+
- :dtcompatible:`raspberrypi,pico-uart-pio`
75+
* - SPI (PIO)
76+
- :kconfig:option:`CONFIG_SPI`
77+
- :dtcompatible:`raspberrypi,pico-spi-pio`
78+
79+
Pin Mapping
80+
===========
81+
82+
The peripherals of the RP2040 SoC can be routed to various pins on the board. The configuration of these routes can be modified through DTS. Please refer to the datasheet to see the possible routings for each peripheral.
83+
84+
Default Zephyr Peripheral Mapping:
85+
----------------------------------
86+
87+
.. rst-class:: rst-columns
88+
89+
- UART0_TX : P0
90+
- UART0_RX : P1
91+
- I2C0_SDA : P4
92+
- I2C0_SCL : P5
93+
- I2C1_SDA : P6
94+
- I2C1_SCL : P7
95+
- ADC_CH0 : P26
96+
- ADC_CH1 : P27
97+
- ADC_CH2 : P28
98+
- ADC_CH3 : P29
99+
100+
Programming and Debugging
101+
*************************
102+
103+
Flashing
104+
========
105+
106+
Using UF2
107+
---------
108+
109+
Here is an example of building the sample for driving the built-in RGB led.
110+
111+
.. zephyr-app-commands::
112+
:zephyr-app: samples/drivers/led/led_strip
113+
:board: rp2040_zero
114+
:goals: build
115+
:compact:
116+
117+
You must flash the RP2040-Zero 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:
118+
119+
.. code-block:: bash
120+
121+
west flash
122+
123+
In alternative you can locate the generated file at ``build/zephyr/zephyr.uf2 file`` and simply drag-and-drop to the device after entreing the UF2 flashing mode.
124+
125+
References
126+
**********
127+
128+
- `Official Documentation`_
129+
- `WS2812 datasheet`_
130+
131+
.. _Official Documentation: https://www.waveshare.com/wiki/RP2040-Zero
132+
.. _WS2812 datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812.pdf
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2024 Iacopo Moles
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
8+
#include <dt-bindings/i2c/i2c.h>
9+
10+
&pinctrl {
11+
uart0_default: uart0_default {
12+
status = "okay";
13+
group1 {
14+
pinmux = <UART0_TX_P0>;
15+
};
16+
group2 {
17+
pinmux = <UART0_RX_P1>;
18+
input-enable;
19+
};
20+
};
21+
22+
i2c0_default: i2c0_default {
23+
group1 {
24+
pinmux = <I2C0_SDA_P24>;
25+
input-enable;
26+
};
27+
group2 {
28+
pinmux = <I2C0_SCL_P25>;
29+
input-enable;
30+
};
31+
};
32+
33+
i2c1_default: i2c1_default {
34+
group1 {
35+
pinmux = <I2C1_SDA_P22>;
36+
input-enable;
37+
};
38+
group2 {
39+
pinmux = <I2C1_SCL_P23>;
40+
input-enable;
41+
};
42+
};
43+
44+
spi0_default: spi0_default {
45+
group1 {
46+
pinmux = <SPI0_TX_P3>;
47+
};
48+
group2 {
49+
pinmux = <SPI0_RX_P4>;
50+
input-enable;
51+
};
52+
group3 {
53+
pinmux = <SPI0_SCK_P6>;
54+
};
55+
};
56+
57+
adc_default: adc_default {
58+
group1 {
59+
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
60+
input-enable;
61+
};
62+
};
63+
64+
ws2812_pio0_default: ws2812_pio0_default {
65+
ws2812 {
66+
pinmux = <PIO0_P16>;
67+
};
68+
};
69+
};
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (c) 2024 Iacopo Moles
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include <rpi_pico/rp2040.dtsi>
10+
#include "rp2040_zero-pinctrl.dtsi"
11+
#include <freq.h>
12+
#include <zephyr/dt-bindings/led/led.h>
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+
led-strip = &ws2812;
27+
};
28+
};
29+
30+
&flash0 {
31+
reg = <0x10000000 DT_SIZE_M(16)>;
32+
33+
partitions {
34+
compatible = "fixed-partitions";
35+
#address-cells = <1>;
36+
#size-cells = <1>;
37+
38+
/* Reserved memory for the second stage bootloader */
39+
second_stage_bootloader: partition@0 {
40+
label = "second_stage_bootloader";
41+
reg = <0x00000000 0x100>;
42+
read-only;
43+
};
44+
45+
/*
46+
* Usable flash. Starts at 0x100, after the bootloader. The partition
47+
* size is 16MB minus the 0x100 bytes taken by the bootloader.
48+
*/
49+
code_partition: partition@100 {
50+
label = "code-partition";
51+
reg = <0x100 (DT_SIZE_M(16) - 0x100)>;
52+
read-only;
53+
};
54+
};
55+
};
56+
57+
&uart0 {
58+
status = "okay";
59+
current-speed = <115200>;
60+
pinctrl-0 = <&uart0_default>;
61+
pinctrl-names = "default";
62+
};
63+
64+
&i2c0 {
65+
status = "okay";
66+
pinctrl-0 = <&i2c0_default>;
67+
pinctrl-names = "default";
68+
clock-frequency = <I2C_BITRATE_STANDARD>;
69+
};
70+
71+
&i2c1 {
72+
status = "okay";
73+
pinctrl-0 = <&i2c1_default>;
74+
pinctrl-names = "default";
75+
clock-frequency = <I2C_BITRATE_FAST>;
76+
};
77+
78+
&spi0 {
79+
clock-frequency = <DT_FREQ_M(8)>;
80+
status = "okay";
81+
pinctrl-0 = <&spi0_default>;
82+
pinctrl-names = "default";
83+
};
84+
85+
&timer {
86+
status = "okay";
87+
};
88+
89+
&wdt0 {
90+
status = "okay";
91+
};
92+
93+
&gpio0 {
94+
status = "okay";
95+
};
96+
97+
&rtc {
98+
clocks = <&clocks RPI_PICO_CLKID_CLK_RTC>;
99+
status = "okay";
100+
};
101+
102+
&adc {
103+
status = "okay";
104+
pinctrl-0 = <&adc_default>;
105+
pinctrl-names = "default";
106+
};
107+
108+
&pio0 {
109+
status = "okay";
110+
111+
pio-ws2812 {
112+
compatible = "worldsemi,ws2812-rpi_pico-pio";
113+
status = "okay";
114+
pinctrl-0 = <&ws2812_pio0_default>;
115+
pinctrl-names = "default";
116+
bit-waveform = <3>, <3>, <4>;
117+
118+
ws2812: ws2812 {
119+
status = "okay";
120+
gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
121+
chain-length = <1>;
122+
color-mapping = <LED_COLOR_ID_GREEN
123+
LED_COLOR_ID_RED
124+
LED_COLOR_ID_BLUE>;
125+
reset-delay = <280>;
126+
frequency = <800000>;
127+
};
128+
};
129+
};
130+
131+
&pio1 {
132+
status = "okay";
133+
};
134+
135+
zephyr_udc0: &usbd {
136+
status = "okay";
137+
};
138+
139+
&vreg {
140+
regulator-always-on;
141+
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
142+
};
143+
144+
pico_spi: &spi0 {};
145+
pico_i2c0: &i2c0 {};
146+
pico_i2c1: &i2c1 {};
147+
pico_serial: &uart0 {};

0 commit comments

Comments
 (0)