From 384b0eef787c53fa897fffc664ff0b429a278ae9 Mon Sep 17 00:00:00 2001 From: Andrew Featherstone Date: Wed, 21 Aug 2024 22:05:51 +0100 Subject: [PATCH] boards: Add initial support for the Raspberry Pi Pico 2 The Raspberry Pi Pico 2 is Raspberry Pi's first board fitted with their RP2350 SoC. This adds a minimal board definition, sufficient to build and run `samples/hello_world` and `samples/basic/blinky` on the board. Images can be run on the target using either OpenOCD. Raspberry Pi's `picotool` can create a UF2 binary, which ensures that errata RP2350-E10 is avoided e.g. ``` > picotool uf2 convert build\rpi_pico_2\hello_world\zephyr\zephyr.elf \ build\rpi_pico_2\hello_world\zephyr\zephyr.uf2 \ --family rp2350-arm-s --abs-block` ``` Raspberry Pi Pico 2 is a low-cost, high-performance microcontroller board with flexible digital interfaces. Key features include: - RP2350 microcontroller chip designed by Raspberry Pi in the United Kingdom - Dual Cortex-M33 or Hazard3 processors at up to 150MHz - 520KB of SRAM, and 4MB of on-board flash memory - USB 1.1 with device and host support - Low-power sleep and dormant modes - Drag-and-drop programming using mass storage over USB - 26x multi-function GPIO pins including 3 that can be used for ADC - 2x SPI, 2x I2C, 2x UART, 3x 12-bit 500ksps Analogue to Digital Converter (ADC), 24x controllable PWM channels - 2x Timer with 4 alarms, 1x AON Timer - Temperature sensor - 3x Programmable IO (PIO) blocks, 12 state machines total for custom peripheral support - Flexible, user-programmable high-speed IO - Can emulate interfaces such as SD Card and VGA The Raspberry Pi Pico 2 comes as a castellated module which allows soldering direct to carrier boards. Signed-off-by: Andrew Featherstone --- .../raspberrypi/rpi_pico_2/Kconfig.defconfig | 9 ++ .../raspberrypi/rpi_pico_2/Kconfig.rpi_pico_2 | 5 + boards/raspberrypi/rpi_pico_2/board.yml | 5 + .../rpi_pico_2/rpi_pico_2-common.dtsi | 128 ++++++++++++++++++ .../rpi_pico_2/rpi_pico_2-pinctrl.dtsi | 37 +++++ boards/raspberrypi/rpi_pico_2/rpi_pico_2.dts | 33 +++++ boards/raspberrypi/rpi_pico_2/rpi_pico_2.yaml | 15 ++ .../rpi_pico_2/rpi_pico_2_defconfig | 9 ++ 8 files changed, 241 insertions(+) create mode 100644 boards/raspberrypi/rpi_pico_2/Kconfig.defconfig create mode 100644 boards/raspberrypi/rpi_pico_2/Kconfig.rpi_pico_2 create mode 100644 boards/raspberrypi/rpi_pico_2/board.yml create mode 100644 boards/raspberrypi/rpi_pico_2/rpi_pico_2-common.dtsi create mode 100644 boards/raspberrypi/rpi_pico_2/rpi_pico_2-pinctrl.dtsi create mode 100644 boards/raspberrypi/rpi_pico_2/rpi_pico_2.dts create mode 100644 boards/raspberrypi/rpi_pico_2/rpi_pico_2.yaml create mode 100644 boards/raspberrypi/rpi_pico_2/rpi_pico_2_defconfig diff --git a/boards/raspberrypi/rpi_pico_2/Kconfig.defconfig b/boards/raspberrypi/rpi_pico_2/Kconfig.defconfig new file mode 100644 index 00000000000000..25bcb08ad6f071 --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2024 Andrew Featherstone +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_RPI_PICO_2 + +config USB_SELF_POWERED + default n + +endif # BOARD_RPI_PICO_2 diff --git a/boards/raspberrypi/rpi_pico_2/Kconfig.rpi_pico_2 b/boards/raspberrypi/rpi_pico_2/Kconfig.rpi_pico_2 new file mode 100644 index 00000000000000..5f057900462e75 --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/Kconfig.rpi_pico_2 @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Andrew Featherstone +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_RPI_PICO_2 + select SOC_RP2350 diff --git a/boards/raspberrypi/rpi_pico_2/board.yml b/boards/raspberrypi/rpi_pico_2/board.yml new file mode 100644 index 00000000000000..8877d22695a724 --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/board.yml @@ -0,0 +1,5 @@ +board: + name: rpi_pico_2 + vendor: raspberrypi + socs: + - name: rp2350 diff --git a/boards/raspberrypi/rpi_pico_2/rpi_pico_2-common.dtsi b/boards/raspberrypi/rpi_pico_2/rpi_pico_2-common.dtsi new file mode 100644 index 00000000000000..dfdf06a8ac55d2 --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/rpi_pico_2-common.dtsi @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include +#include "rpi_pico_2-pinctrl.dtsi" +#include + +#include + + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,code-partition = &code_partition; + }; + + aliases { + }; + + pico_header: connector { + compatible = "raspberrypi,pico-header"; + #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 */ + }; +}; + +&flash0 { + reg = <0x10000000 DT_SIZE_M(4)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Reserved memory for an image definition block. The block is much + * smaller than 256 bytes, but in practice the linker places the vector + * table at a much larger alignment offset. + */ + image_def: partition@0 { + label = "image_def"; + reg = <0x00000000 0x100>; + read-only; + }; + + /* + * Usable flash. Starts at 0x100, after the image definition block. + * The partition size is 4MB minus the 0x100 bytes taken by the + * image definition. + */ + code_partition: partition@100 { + label = "code-partition"; + reg = <0x100 (DT_SIZE_M(4) - 0x100)>; + read-only; + }; + }; +}; + +&clocks { + pinctrl-0 = <&clocks_default>; + pinctrl-names = "default"; +}; + +&uart0 { + current-speed = <115200>; + status = "okay"; + pinctrl-0 = <&uart0_default>; + pinctrl-names = "default"; +}; + +&gpio0 { + status = "okay"; +}; + +&timer0 { + status = "disabled"; +}; + +zephyr_udc0: &usbd { + status = "okay"; +}; + +&pwm { + pinctrl-0 = <&pwm_ch4b_default>; + pinctrl-names = "default"; + divider-int-0 = <255>; +}; + +&vreg { + regulator-always-on; + regulator-allowed-modes = ; +}; + +pico_serial: &uart0 {}; diff --git a/boards/raspberrypi/rpi_pico_2/rpi_pico_2-pinctrl.dtsi b/boards/raspberrypi/rpi_pico_2/rpi_pico_2-pinctrl.dtsi new file mode 100644 index 00000000000000..1dc737457da710 --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/rpi_pico_2-pinctrl.dtsi @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024, Andrew Featherstone + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl { + uart0_default: uart0_default { + group1 { + pinmux = ; + }; + group2 { + pinmux = ; + input-enable; + }; + }; + + spi0_default: spi0_default { + group1 { + pinmux = , , ; + }; + group2 { + pinmux = ; + input-enable; + }; + }; + + pwm_ch4b_default: pwm_ch4b_default { + group1 { + pinmux = ; + }; + }; + + clocks_default: clocks_default { + }; +}; diff --git a/boards/raspberrypi/rpi_pico_2/rpi_pico_2.dts b/boards/raspberrypi/rpi_pico_2/rpi_pico_2.dts new file mode 100644 index 00000000000000..9db3b2372762be --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/rpi_pico_2.dts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include "rpi_pico_2-common.dtsi" + +/ { + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>; + label = "LED"; + }; + }; + + pwm_leds { + compatible = "pwm-leds"; + status = "disabled"; + pwm_led0: pwm_led_0 { + pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + label = "PWM_LED"; + }; + }; + + aliases { + led0 = &led0; + pwm-led0 = &pwm_led0; + }; +}; diff --git a/boards/raspberrypi/rpi_pico_2/rpi_pico_2.yaml b/boards/raspberrypi/rpi_pico_2/rpi_pico_2.yaml new file mode 100644 index 00000000000000..7e7a28e4f9655f --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/rpi_pico_2.yaml @@ -0,0 +1,15 @@ +identifier: rpi_pico_2 +name: Raspberry Pi Pico 2 +type: mcu +arch: arm +flash: 4096 +ram: 520 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - clock + - gpio + - hwinfo + - uart diff --git a/boards/raspberrypi/rpi_pico_2/rpi_pico_2_defconfig b/boards/raspberrypi/rpi_pico_2/rpi_pico_2_defconfig new file mode 100644 index 00000000000000..271bf5de90a2ab --- /dev/null +++ b/boards/raspberrypi/rpi_pico_2/rpi_pico_2_defconfig @@ -0,0 +1,9 @@ +CONFIG_CLOCK_CONTROL=y +CONFIG_CONSOLE=y +CONFIG_GPIO=y +CONFIG_RESET=y +CONFIG_SERIAL=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000 +CONFIG_UART_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_USE_DT_CODE_PARTITION=y