diff --git a/boards/waveshare/rp2350_zero/Kconfig.defconfig b/boards/waveshare/rp2350_zero/Kconfig.defconfig new file mode 100644 index 0000000000000..35967256fdef8 --- /dev/null +++ b/boards/waveshare/rp2350_zero/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2025 Stephano Cetola +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_RP2350_ZERO + +config USB_SELF_POWERED + default n + +endif # BOARD_RP2350_ZERO diff --git a/boards/waveshare/rp2350_zero/Kconfig.rp2350_zero b/boards/waveshare/rp2350_zero/Kconfig.rp2350_zero new file mode 100644 index 0000000000000..3b1de87de0d57 --- /dev/null +++ b/boards/waveshare/rp2350_zero/Kconfig.rp2350_zero @@ -0,0 +1,6 @@ +# Copyright (c) 2025 Stephano Cetola +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_RP2350_ZERO + select SOC_RP2350A_HAZARD3 if BOARD_RP2350_ZERO_RP2350A_HAZARD3 + select SOC_RP2350A_M33 if BOARD_RP2350_ZERO_RP2350A_M33 diff --git a/boards/waveshare/rp2350_zero/board.cmake b/boards/waveshare/rp2350_zero/board.cmake new file mode 100644 index 0000000000000..14be6dbf5d465 --- /dev/null +++ b/boards/waveshare/rp2350_zero/board.cmake @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 + +if("${RPI_PICO_DEBUG_ADAPTER}" STREQUAL "") + set(RPI_PICO_DEBUG_ADAPTER "cmsis-dap") +endif() + +board_runner_args(openocd --cmd-pre-init "source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]") +if(CONFIG_ARM) + board_runner_args(openocd --cmd-pre-init "source [find target/rp2350.cfg]") +else() + board_runner_args(openocd --cmd-pre-init "source [find target/rp2350-riscv.cfg]") +endif() + +# The adapter speed is expected to be set by interface configuration. +# The Raspberry Pi's OpenOCD fork doesn't, so match their documentation at +# https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#debugging-with-swd +board_runner_args(openocd --cmd-pre-init "set_adapter_speed_if_not_set 5000") +board_runner_args(probe-rs "--chip=RP235x") + +board_runner_args(uf2 "--board-id=RP2350") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake) +include(${ZEPHYR_BASE}/boards/common/probe-rs.board.cmake) diff --git a/boards/waveshare/rp2350_zero/board.yml b/boards/waveshare/rp2350_zero/board.yml new file mode 100644 index 0000000000000..978d827644923 --- /dev/null +++ b/boards/waveshare/rp2350_zero/board.yml @@ -0,0 +1,6 @@ +board: + name: rp2350_zero + full_name: RP2350-Zero + vendor: waveshare + socs: + - name: rp2350a diff --git a/boards/waveshare/rp2350_zero/doc/img/rp2350_zero.webp b/boards/waveshare/rp2350_zero/doc/img/rp2350_zero.webp new file mode 100644 index 0000000000000..0b728ff2f13c5 Binary files /dev/null and b/boards/waveshare/rp2350_zero/doc/img/rp2350_zero.webp differ diff --git a/boards/waveshare/rp2350_zero/doc/index.rst b/boards/waveshare/rp2350_zero/doc/index.rst new file mode 100644 index 0000000000000..3b2c721d48d4a --- /dev/null +++ b/boards/waveshare/rp2350_zero/doc/index.rst @@ -0,0 +1,88 @@ +.. zephyr:board:: rp2350_zero + +Overview +******** + +RP2350-Zero, A Low-Cost, High-Performance Pico-Like MCU Board Based On Raspberry Pi Microcontroller RP2350. + +Hardware +******** +- RP2350A microcontroller chip designed by Raspberry Pi in the United Kingdom +- Adopts unique dual-core and dual-architecture design: dual-core Arm Cortex-M33 processor and dual-core Hazard 3 RISC-V processor, flexible clock running up to 150 MHz +- 520KB of SRAM, and 4MB of on-board Flash memory +- Uses a modern and convenient USB Type-C connector +- Castellated module allows soldering directly 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, 24 × controllable PWM channels +- Accurate on-chip clock and timer peripherals +- Temperature sensor +- Accelerated floating-point libraries on-chip +- 12 × Programmable I/O (PIO) state machines for custom peripheral support + +Supported Features +================== + +.. zephyr:board-supported-hw:: + +Pin Mapping +=========== + +The peripherals of the RP2350 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. + +For detailed hardware information, see the `RP2350-Zero – Waveshare Wiki `_. + + +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 +************************* + +.. zephyr:board-supported-runners:: + +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: rp2350_zero/rp2350/m33 + :goals: build + :compact: + +You can flash the RP2350-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. Alternatively, with the board already connected via USB you can keep the ``BOOT`` button pressed, press and release ``RESET``, release ``BOOT``. At this point you can flash the image file by running: + +.. code-block:: bash + + west flash + +Alternatively, you can locate the generated file at ``build/zephyr/zephyr.uf2 file`` and simply drag-and-drop to the device after entering the UF2 flashing mode. + +References +********** + +- `Official Documentation`_ +- `WS2812 datasheet`_ + +.. _Official Documentation: https://www.waveshare.com/wiki/RP2350-Zero +.. _WS2812 datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812.pdf diff --git a/boards/waveshare/rp2350_zero/rp2350_zero-pinctrl.dtsi b/boards/waveshare/rp2350_zero/rp2350_zero-pinctrl.dtsi new file mode 100644 index 0000000000000..d9147c338c575 --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero-pinctrl.dtsi @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Stephano Cetola + * + * SPDX-License-Identifier: Apache-2.0 + */ +&pinctrl { + uart0_default: uart0_default { + group1 { + pinmux = ; + }; + + group2 { + pinmux = ; + input-enable; + }; + }; + + i2c0_default: i2c0_default { + group1 { + pinmux = , ; + input-enable; + input-schmitt-enable; + }; + }; + + i2c1_default: i2c1_default { + group1 { + pinmux = , ; + input-enable; + input-schmitt-enable; + }; + }; + + spi0_default: spi0_default { + group1 { + pinmux = , , ; + }; + + group2 { + pinmux = ; + input-enable; + }; + }; + + pwm_ch4b_default: pwm_ch4b_default { + group1 { + pinmux = ; + }; + }; + + adc_default: adc_default { + group1 { + pinmux = , , , ; + input-enable; + }; + }; + + ws2812_pio0_default: ws2812_pio0_default { + ws2812 { + pinmux = ; + }; + }; +}; diff --git a/boards/waveshare/rp2350_zero/rp2350_zero.dtsi b/boards/waveshare/rp2350_zero/rp2350_zero.dtsi new file mode 100644 index 0000000000000..5723a5f25c7fe --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero.dtsi @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2025 Stephano Cetola + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include + +#include +#include +#include + +#include +#include "rp2350_zero-pinctrl.dtsi" + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + }; + + aliases { + watchdog0 = &wdt0; + led-strip = &ws2812; + }; + + wszero_header: connector { + compatible = "gpio-connector"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpio0 0 0>, /* GP0 */ + <1 0 &gpio0 1 0>, /* GP1 */ + <2 0 &gpio0 2 0>, /* GP2 */ + <3 0 &gpio0 3 0>, /* GP3 */ + <4 0 &gpio0 4 0>, /* GP4 */ + <5 0 &gpio0 5 0>, /* GP5 */ + <6 0 &gpio0 6 0>, /* GP6 */ + <7 0 &gpio0 7 0>, /* GP7 */ + <8 0 &gpio0 8 0>, /* GP8 */ + <9 0 &gpio0 9 0>, /* GP9 */ + <10 0 &gpio0 10 0>, /* GP10 */ + <11 0 &gpio0 11 0>, /* GP11 */ + <12 0 &gpio0 12 0>, /* GP12 */ + <13 0 &gpio0 13 0>, /* GP13 */ + <14 0 &gpio0 14 0>, /* GP14 */ + <15 0 &gpio0 15 0>, /* GP15 */ + <16 0 &gpio0 16 0>, /* GP16 */ + <17 0 &gpio0 17 0>, /* GP17 */ + <18 0 &gpio0 18 0>, /* GP18 */ + <19 0 &gpio0 19 0>, /* GP19 */ + <20 0 &gpio0 20 0>, /* GP20 */ + <21 0 &gpio0 21 0>, /* GP21 */ + <22 0 &gpio0 22 0>, /* GP22 */ + <26 0 &gpio0 26 0>, /* GP26 */ + <27 0 &gpio0 27 0>, /* GP27 */ + <28 0 &gpio0 28 0>, /* GP28 */ + <29 0 &gpio0 29 0>; /* GP29 */ + }; +}; + +&flash0 { + reg = <0x10000000 DT_SIZE_M(4)>; +}; + +&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 = ; +}; + +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_default>; + pinctrl-names = "default"; + clock-frequency = ; +}; + +&spi0 { + clock-frequency = ; + status = "okay"; + pinctrl-0 = <&spi0_default>; + pinctrl-names = "default"; +}; + +&gpio0 { + 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 = ; + reset-delay = <280>; + frequency = ; + }; + }; +}; + +&pio1 { + status = "okay"; +}; + +&pwm { + pinctrl-0 = <&pwm_ch4b_default>; + pinctrl-names = "default"; + divider-int-0 = <255>; +}; + +&timer0 { + status = "okay"; +}; + +&wdt0 { + status = "okay"; +}; + +zephyr_udc0: &usbd { + status = "okay"; +}; + +pico_spi: &spi0 {}; +pico_i2c0: &i2c0 {}; +pico_i2c1: &i2c1 {}; +pico_serial: &uart0 {}; diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.dts b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.dts new file mode 100644 index 0000000000000..f9650163c029d --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.dts @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2025 Stephano Cetola + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include +#include "rp2350_zero.dtsi" diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.yaml b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.yaml new file mode 100644 index 0000000000000..3c19e64fc5ff5 --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3.yaml @@ -0,0 +1,22 @@ +identifier: rp2350_zero/rp2350/hazard3 +name: Waveshare RP2350-Zero (Hazard3) +type: mcu +arch: riscv +flash: 4096 +ram: 520 +toolchain: + - zephyr +supported: + - uart + - gpio + - adc + - i2c + - spi + - hwinfo + - watchdog + - pwm + - flash + - dma + - counter + - clock + - usbd diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3_defconfig b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3_defconfig new file mode 100644 index 0000000000000..29f747ed7db57 --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_hazard3_defconfig @@ -0,0 +1,13 @@ +# This configuration is orthogonal to whether the Cortex-M33 or Hazard3 cores +# are in use, but Zephyr does not support providing a qualifier-agnostic +# _defconfig file. +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_CLOCK_CONTROL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_SERIAL=y +CONFIG_USE_DT_CODE_PARTITION=y +CONFIG_GPIO=y +CONFIG_RESET=y diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.dts b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.dts new file mode 100644 index 0000000000000..1f0ef18851cbb --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.dts @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2025 Stephano Cetola + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include + +#include "rp2350_zero.dtsi" diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.yaml b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.yaml new file mode 100644 index 0000000000000..520ae4286fa6e --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33.yaml @@ -0,0 +1,23 @@ +identifier: rp2350_zero/rp2350/m33 +name: Waveshare RP2350-Zero (Cortex M33) +type: mcu +arch: arm +flash: 4096 +ram: 520 +toolchain: + - zephyr + - gnuarmemb +supported: + - uart + - gpio + - adc + - i2c + - spi + - hwinfo + - watchdog + - pwm + - flash + - dma + - counter + - clock + - usbd diff --git a/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33_defconfig b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33_defconfig new file mode 100644 index 0000000000000..29f747ed7db57 --- /dev/null +++ b/boards/waveshare/rp2350_zero/rp2350_zero_rp2350a_m33_defconfig @@ -0,0 +1,13 @@ +# This configuration is orthogonal to whether the Cortex-M33 or Hazard3 cores +# are in use, but Zephyr does not support providing a qualifier-agnostic +# _defconfig file. +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_CLOCK_CONTROL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_SERIAL=y +CONFIG_USE_DT_CODE_PARTITION=y +CONFIG_GPIO=y +CONFIG_RESET=y