Browse Source

boards: waveshare: rp2040_zero: Initial support

This PR adds supports for Waveshare RP2040 Zero

Signed-off-by: Iacopo Moles <iacopo@icpmol.es>
pull/82472/head
Iacopo Moles 9 months ago committed by Benjamin Cabé
parent
commit
bd69ae46bc
  1. 5
      boards/waveshare/rp2040_zero/Kconfig
  2. 13
      boards/waveshare/rp2040_zero/Kconfig.defconfig
  3. 5
      boards/waveshare/rp2040_zero/Kconfig.rp2040_zero
  4. 5
      boards/waveshare/rp2040_zero/board.cmake
  5. 6
      boards/waveshare/rp2040_zero/board.yml
  6. BIN
      boards/waveshare/rp2040_zero/doc/img/rp2040_zero.png
  7. 132
      boards/waveshare/rp2040_zero/doc/index.rst
  8. 69
      boards/waveshare/rp2040_zero/rp2040_zero-pinctrl.dtsi
  9. 147
      boards/waveshare/rp2040_zero/rp2040_zero.dts
  10. 24
      boards/waveshare/rp2040_zero/rp2040_zero.yaml
  11. 13
      boards/waveshare/rp2040_zero/rp2040_zero_defconfig
  12. 30
      tests/drivers/adc/adc_api/boards/rp2040_zero.overlay

5
boards/waveshare/rp2040_zero/Kconfig

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
# Copyright (c) 2024 Iacopo Moles
# SPDX-License-Identifier: Apache-2.0
config BOARD_RP2040_ZERO
select RP2_FLASH_W25Q080

13
boards/waveshare/rp2040_zero/Kconfig.defconfig

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
# Copyright (c) 2024 Iacopo Moles
# SPDX-License-Identifier: Apache-2.0
if BOARD_RP2040_ZERO
if I2C_DW
config I2C_DW_CLOCK_SPEED
default 125
endif # I2C_DW
endif # BOARD_RP2040_ZERO

5
boards/waveshare/rp2040_zero/Kconfig.rp2040_zero

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
# Copyright (c) 2024 Iacopo Moles
# SPDX-License-Identifier: Apache-2.0
config BOARD_RP2040_ZERO
select SOC_RP2040

5
boards/waveshare/rp2040_zero/board.cmake

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(uf2 "--board-id=RPI-RP2")
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)

6
boards/waveshare/rp2040_zero/board.yml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
board:
name: rp2040_zero
full_name: RP2040-Zero
vendor: waveshare
socs:
- name: rp2040

BIN
boards/waveshare/rp2040_zero/doc/img/rp2040_zero.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

132
boards/waveshare/rp2040_zero/doc/index.rst

@ -0,0 +1,132 @@ @@ -0,0 +1,132 @@
.. zephyr:board:: rp2040_zero
Overview
********
RP2040-Zero, A Low-Cost, High-Performance Pico-Like MCU Board Based On Raspberry Pi Microcontroller RP2040.
Hardware
********
- RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom.
- Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz.
- 264KB of SRAM, and 2MB of on-board Flash memory.
- USB-C connector, keeps it up to date, easier to use.
- The castellated module allows soldering direct to carrier boards.
- USB 1.1 with device and host support.
- Low-power sleep and dormant modes.
- Drag-and-drop programming using mass storage over USB.
- 29 × multi-function GPIO pins (20× via edge pinout, others via solder points).
- 2 × SPI, 2 × I2C, 2 × UART, 4 × 12-bit ADC, 16 × controllable PWM channels.
- Accurate clock and timer on-chip.
- Temperature sensor.
- Accelerated floating-point libraries on-chip.
- 8 × Programmable I/O (PIO) state machines for custom peripheral support.
Supported Features
==================
The ``rp2040_zero`` board target supports the following hardware features:
.. list-table::
:header-rows: 1
* - Peripheral
- Kconfig option
- Devicetree compatible
* - NVIC
- N/A
- :dtcompatible:`arm,v6m-nvic`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`raspberrypi,pico-uart`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`raspberrypi,pico-gpio`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`raspberrypi,pico-adc`
* - I2C
- :kconfig:option:`CONFIG_I2C`
- :dtcompatible:`snps,designware-i2c`
* - SPI
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi`
* - USB Device
- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
- :dtcompatible:`raspberrypi,pico-usbd`
* - HWINFO
- :kconfig:option:`CONFIG_HWINFO`
- N/A
* - Watchdog Timer (WDT)
- :kconfig:option:`CONFIG_WATCHDOG`
- :dtcompatible:`raspberrypi,pico-watchdog`
* - PWM
- :kconfig:option:`CONFIG_PWM`
- :dtcompatible:`raspberrypi,pico-pwm`
* - Flash
- :kconfig:option:`CONFIG_FLASH`
- :dtcompatible:`raspberrypi,pico-flash`
* - Clock controller
- :kconfig:option:`CONFIG_CLOCK_CONTROL`
- :dtcompatible:`raspberrypi,pico-clock-controller`
* - UART (PIO)
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`raspberrypi,pico-uart-pio`
* - SPI (PIO)
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi-pio`
Pin Mapping
===========
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.
Default Zephyr Peripheral Mapping:
----------------------------------
.. rst-class:: rst-columns
- UART0_TX : P0
- UART0_RX : P1
- I2C0_SDA : P4
- I2C0_SCL : P5
- I2C1_SDA : P6
- I2C1_SCL : P7
- ADC_CH0 : P26
- ADC_CH1 : P27
- ADC_CH2 : P28
- ADC_CH3 : P29
Programming and Debugging
*************************
Flashing
========
Using UF2
---------
Here is an example of building the sample for driving the built-in RGB led.
.. zephyr-app-commands::
:zephyr-app: samples/drivers/led/led_strip
:board: rp2040_zero
:goals: build
:compact:
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:
.. code-block:: bash
west flash
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.
References
**********
- `Official Documentation`_
- `WS2812 datasheet`_
.. _Official Documentation: https://www.waveshare.com/wiki/RP2040-Zero
.. _WS2812 datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812.pdf

69
boards/waveshare/rp2040_zero/rp2040_zero-pinctrl.dtsi

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
/*
* Copyright (c) 2024 Iacopo Moles
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
#include <dt-bindings/i2c/i2c.h>
&pinctrl {
uart0_default: uart0_default {
status = "okay";
group1 {
pinmux = <UART0_TX_P0>;
};
group2 {
pinmux = <UART0_RX_P1>;
input-enable;
};
};
i2c0_default: i2c0_default {
group1 {
pinmux = <I2C0_SDA_P24>;
input-enable;
};
group2 {
pinmux = <I2C0_SCL_P25>;
input-enable;
};
};
i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_P22>;
input-enable;
};
group2 {
pinmux = <I2C1_SCL_P23>;
input-enable;
};
};
spi0_default: spi0_default {
group1 {
pinmux = <SPI0_TX_P3>;
};
group2 {
pinmux = <SPI0_RX_P4>;
input-enable;
};
group3 {
pinmux = <SPI0_SCK_P6>;
};
};
adc_default: adc_default {
group1 {
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
input-enable;
};
};
ws2812_pio0_default: ws2812_pio0_default {
ws2812 {
pinmux = <PIO0_P16>;
};
};
};

147
boards/waveshare/rp2040_zero/rp2040_zero.dts

@ -0,0 +1,147 @@ @@ -0,0 +1,147 @@
/*
* Copyright (c) 2024 Iacopo Moles
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <rpi_pico/rp2040.dtsi>
#include "rp2040_zero-pinctrl.dtsi"
#include <freq.h>
#include <zephyr/dt-bindings/led/led.h>
/ {
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,flash-controller = &ssi;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,code-partition = &code_partition;
};
aliases {
rtc = &rtc;
watchdog0 = &wdt0;
led-strip = &ws2812;
};
};
&flash0 {
reg = <0x10000000 DT_SIZE_M(16)>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* Reserved memory for the second stage bootloader */
second_stage_bootloader: partition@0 {
label = "second_stage_bootloader";
reg = <0x00000000 0x100>;
read-only;
};
/*
* Usable flash. Starts at 0x100, after the bootloader. The partition
* size is 16MB minus the 0x100 bytes taken by the bootloader.
*/
code_partition: partition@100 {
label = "code-partition";
reg = <0x100 (DT_SIZE_M(16) - 0x100)>;
read-only;
};
};
};
&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-names = "default";
};
&i2c0 {
status = "okay";
pinctrl-0 = <&i2c0_default>;
pinctrl-names = "default";
clock-frequency = <I2C_BITRATE_STANDARD>;
};
&i2c1 {
status = "okay";
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
clock-frequency = <I2C_BITRATE_FAST>;
};
&spi0 {
clock-frequency = <DT_FREQ_M(8)>;
status = "okay";
pinctrl-0 = <&spi0_default>;
pinctrl-names = "default";
};
&timer {
status = "okay";
};
&wdt0 {
status = "okay";
};
&gpio0 {
status = "okay";
};
&rtc {
clocks = <&clocks RPI_PICO_CLKID_CLK_RTC>;
status = "okay";
};
&adc {
status = "okay";
pinctrl-0 = <&adc_default>;
pinctrl-names = "default";
};
&pio0 {
status = "okay";
pio-ws2812 {
compatible = "worldsemi,ws2812-rpi_pico-pio";
status = "okay";
pinctrl-0 = <&ws2812_pio0_default>;
pinctrl-names = "default";
bit-waveform = <3>, <3>, <4>;
ws2812: ws2812 {
status = "okay";
gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
reset-delay = <280>;
frequency = <800000>;
};
};
};
&pio1 {
status = "okay";
};
zephyr_udc0: &usbd {
status = "okay";
};
&vreg {
regulator-always-on;
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
};
pico_spi: &spi0 {};
pico_i2c0: &i2c0 {};
pico_i2c1: &i2c1 {};
pico_serial: &uart0 {};

24
boards/waveshare/rp2040_zero/rp2040_zero.yaml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
identifier: rp2040_zero
name: Waveshare RP2040-Zero
type: mcu
arch: arm
flash: 16384
ram: 264
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- uart
- gpio
- adc
- i2c
- spi
- hwinfo
- watchdog
- pwm
- flash
- dma
- counter
- clock
- usbd

13
boards/waveshare/rp2040_zero/rp2040_zero_defconfig

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_GPIO=y
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_BUILD_OUTPUT_UF2=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_RESET=y
CONFIG_CLOCK_CONTROL=y

30
tests/drivers/adc/adc_api/boards/rp2040_zero.overlay

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
zephyr,user {
io-channels = <&adc 0>, <&adc 1>;
};
};
&adc {
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
};
Loading…
Cancel
Save