From b5066489c7e9c2a0ade9d0e62a15cece817667d5 Mon Sep 17 00:00:00 2001 From: Andrew Featherstone Date: Mon, 28 Oct 2024 18:31:58 +0000 Subject: [PATCH] rp2350: Define and implement a cpucluster of Cortex-M33s Assume that users want to run a dual Cortex-M33 on the Pico 2, and update various parts of the codebase to match. I expect the majority of the soc's definition will move from `dts/arm/raspberrypi` to `dts/common/raspberrypi` if/when support is added for the Hazard3 cores. Some parts of the codebase can cope without encoding the cluster in the filename (e.g. Twister's seems to use the identifier in `boards/raspberrypi/rpi_pico2/rpi_pico2.yaml` rather than the filename itself), others can't (e.g. `rpi_pico2_m33_defconfig`) which itself is a form of __defconfig and doesn't refer to the SoC. Update documentation to try to highlight the capabilities and limitations of the current support within Zephyr for the Pico 2 board and the underlying SoC. Limited tested locally with no issues found. Signed-off-by: Andrew Featherstone --- .../raspberrypi/rpi_pico2/Kconfig.rpi_pico2 | 2 +- boards/raspberrypi/rpi_pico2/doc/index.rst | 6 ++++- .../{rpi_pico2.dts => rpi_pico2.dtsi} | 4 ---- boards/raspberrypi/rpi_pico2/rpi_pico2.yaml | 4 ++-- .../raspberrypi/rpi_pico2/rpi_pico2_m33.dts | 22 +++++++++++++++++++ ...ico2_defconfig => rpi_pico2_m33_defconfig} | 3 +++ dts/arm/raspberrypi/rpi_pico/m33.dtsi | 22 +++++++++++++++++++ dts/arm/raspberrypi/rpi_pico/rp2350.dtsi | 12 +++++----- ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 soc/raspberrypi/rpi_pico/rp2350/Kconfig | 14 +++++++----- soc/raspberrypi/rpi_pico/rp2350/Kconfig.soc | 9 ++++++-- soc/raspberrypi/rpi_pico/soc.yml | 2 ++ ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 .../{rp2350a.overlay => rp2350a_m33.overlay} | 0 ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 ...pi_pico2.overlay => rpi_pico2_m33.overlay} | 0 19 files changed, 78 insertions(+), 22 deletions(-) rename boards/raspberrypi/rpi_pico2/{rpi_pico2.dts => rpi_pico2.dtsi} (98%) create mode 100644 boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts rename boards/raspberrypi/rpi_pico2/{rpi_pico2_defconfig => rpi_pico2_m33_defconfig} (61%) create mode 100644 dts/arm/raspberrypi/rpi_pico/m33.dtsi rename samples/boards/raspberrypi/rpi_pico/uart_pio/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename samples/drivers/adc/adc_dt/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename samples/drivers/led/pwm/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename samples/sensor/die_temp_polling/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename tests/drivers/adc/adc_api/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename tests/drivers/dma/chan_blen_transfer/socs/{rp2350a.overlay => rp2350a_m33.overlay} (100%) rename tests/drivers/dma/loop_transfer/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) rename tests/drivers/gpio/gpio_api_1pin/boards/{rpi_pico2.overlay => rpi_pico2_m33.overlay} (100%) diff --git a/boards/raspberrypi/rpi_pico2/Kconfig.rpi_pico2 b/boards/raspberrypi/rpi_pico2/Kconfig.rpi_pico2 index be671dc208da6ed..bcce97758fbe4c7 100644 --- a/boards/raspberrypi/rpi_pico2/Kconfig.rpi_pico2 +++ b/boards/raspberrypi/rpi_pico2/Kconfig.rpi_pico2 @@ -2,4 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_RPI_PICO2 - select SOC_RP2350A + select SOC_RP2350A_M33 if BOARD_RPI_PICO2_RP2350A_M33 diff --git a/boards/raspberrypi/rpi_pico2/doc/index.rst b/boards/raspberrypi/rpi_pico2/doc/index.rst index cf4b69f84f4f330..1457a8b849e4961 100644 --- a/boards/raspberrypi/rpi_pico2/doc/index.rst +++ b/boards/raspberrypi/rpi_pico2/doc/index.rst @@ -6,6 +6,10 @@ Overview The Raspberry Pi Pico 2 is the second-generation product in the Raspberry Pi Pico family. From the `Raspberry Pi website `_ is referred to as Pico 2. +There are many limitations of the board currently. Including but not limited to: +- The Zephyr build only supports configuring the RP2350A with the Cortex-M33 cores. +- As with the Pico 1, there's no support for running any code on the second core. + Hardware ******** @@ -26,7 +30,7 @@ Hardware Supported Features ================== -The ``rpi_pico2`` board target supports the following +The ``rpi_pico2/rp2350a/m33`` board target supports the following hardware features: .. list-table:: diff --git a/boards/raspberrypi/rpi_pico2/rpi_pico2.dts b/boards/raspberrypi/rpi_pico2/rpi_pico2.dtsi similarity index 98% rename from boards/raspberrypi/rpi_pico2/rpi_pico2.dts rename to boards/raspberrypi/rpi_pico2/rpi_pico2.dtsi index 0c07c828984ed89..85cdb97e8457edc 100644 --- a/boards/raspberrypi/rpi_pico2/rpi_pico2.dts +++ b/boards/raspberrypi/rpi_pico2/rpi_pico2.dtsi @@ -4,15 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -/dts-v1/; - #include #include #include -#include - #include "rpi_pico2-pinctrl.dtsi" #include "../common/rpi_pico-led.dtsi" diff --git a/boards/raspberrypi/rpi_pico2/rpi_pico2.yaml b/boards/raspberrypi/rpi_pico2/rpi_pico2.yaml index 9987b63471f977c..d3c340d88b14a1b 100644 --- a/boards/raspberrypi/rpi_pico2/rpi_pico2.yaml +++ b/boards/raspberrypi/rpi_pico2/rpi_pico2.yaml @@ -1,5 +1,5 @@ -identifier: rpi_pico2 -name: Raspberry Pi Pico 2 +identifier: rpi_pico2/rp2350a/m33 +name: Raspberry Pi Pico 2 (Cortex-M33) type: mcu arch: arm flash: 4096 diff --git a/boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts b/boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts new file mode 100644 index 000000000000000..f96491f44e2e5c3 --- /dev/null +++ b/boards/raspberrypi/rpi_pico2/rpi_pico2_m33.dts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +/* The build system assumes that there's a cpucluster-specific file. + * + * This file provides composition of the device tree: + * 1. The common features of the SoC + * 2. Core-specific configuration. + * 3. Board-specific configuration. + */ +#include +#include + +/* there's nothing specific to the Cortex-M33 cores vs the (not yet + * implemented) Hazard3 cores. + */ +#include "rpi_pico2.dtsi" diff --git a/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig b/boards/raspberrypi/rpi_pico2/rpi_pico2_m33_defconfig similarity index 61% rename from boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig rename to boards/raspberrypi/rpi_pico2/rpi_pico2_m33_defconfig index d47066f1a8a1af5..8bd68e3511391d1 100644 --- a/boards/raspberrypi/rpi_pico2/rpi_pico2_defconfig +++ b/boards/raspberrypi/rpi_pico2/rpi_pico2_m33_defconfig @@ -1,3 +1,6 @@ +# 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 diff --git a/dts/arm/raspberrypi/rpi_pico/m33.dtsi b/dts/arm/raspberrypi/rpi_pico/m33.dtsi new file mode 100644 index 000000000000000..3f8ff861aad842f --- /dev/null +++ b/dts/arm/raspberrypi/rpi_pico/m33.dtsi @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Andrew Featherstone + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +/* Model in the device tree a Cortex-M33 core being 'plugged' into each + * 'socket' within the SoC. Within the datasheet these are core 0 and core 1. + */ +&cpu0 { + compatible = "arm,cortex-m33"; +}; + +&cpu1 { + compatible = "arm,cortex-m33"; +}; + +&nvic { + arm,num-irq-priority-bits = <4>; +}; diff --git a/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi b/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi index 3f5b8278f32cd99..687cafc19aade7f 100644 --- a/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi +++ b/dts/arm/raspberrypi/rpi_pico/rp2350.dtsi @@ -4,7 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include #include #include #include @@ -26,13 +25,16 @@ #address-cells = <1>; #size-cells = <0>; + /* There are two CPU sockets in the RP2350-series SoCs. + * Represent the sockets in the device tree as these two + * partially-defined CPU instances. Use a separate DTSI file to + * define what kind of CPU cores they are. + */ cpu0: cpu@0 { - compatible = "arm,cortex-m33"; reg = <0>; }; cpu1: cpu@1 { - compatible = "arm,cortex-m33"; reg = <1>; }; }; @@ -434,7 +436,3 @@ status = "disabled"; }; }; - -&nvic { - arm,num-irq-priority-bits = <4>; -}; diff --git a/samples/boards/raspberrypi/rpi_pico/uart_pio/boards/rpi_pico2.overlay b/samples/boards/raspberrypi/rpi_pico/uart_pio/boards/rpi_pico2_m33.overlay similarity index 100% rename from samples/boards/raspberrypi/rpi_pico/uart_pio/boards/rpi_pico2.overlay rename to samples/boards/raspberrypi/rpi_pico/uart_pio/boards/rpi_pico2_m33.overlay diff --git a/samples/drivers/adc/adc_dt/boards/rpi_pico2.overlay b/samples/drivers/adc/adc_dt/boards/rpi_pico2_m33.overlay similarity index 100% rename from samples/drivers/adc/adc_dt/boards/rpi_pico2.overlay rename to samples/drivers/adc/adc_dt/boards/rpi_pico2_m33.overlay diff --git a/samples/drivers/led/pwm/boards/rpi_pico2.overlay b/samples/drivers/led/pwm/boards/rpi_pico2_m33.overlay similarity index 100% rename from samples/drivers/led/pwm/boards/rpi_pico2.overlay rename to samples/drivers/led/pwm/boards/rpi_pico2_m33.overlay diff --git a/samples/sensor/die_temp_polling/boards/rpi_pico2.overlay b/samples/sensor/die_temp_polling/boards/rpi_pico2_m33.overlay similarity index 100% rename from samples/sensor/die_temp_polling/boards/rpi_pico2.overlay rename to samples/sensor/die_temp_polling/boards/rpi_pico2_m33.overlay diff --git a/soc/raspberrypi/rpi_pico/rp2350/Kconfig b/soc/raspberrypi/rpi_pico/rp2350/Kconfig index 99d9cb42036330d..2de28a5dd56f274 100644 --- a/soc/raspberrypi/rpi_pico/rp2350/Kconfig +++ b/soc/raspberrypi/rpi_pico/rp2350/Kconfig @@ -4,6 +4,12 @@ # SPDX-License-Identifier: Apache-2.0 config SOC_SERIES_RP2350 + select HAS_RPI_PICO + select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE + select SOC_RESET_HOOK + select XIP + +config SOC_RP2350A_M33 select ARM select ARM_TRUSTZONE_M select CPU_CORTEX_M_HAS_SYSTICK @@ -11,15 +17,13 @@ config SOC_SERIES_RP2350 select CPU_CORTEX_M33 select CPU_HAS_ARM_MPU select CPU_HAS_ARM_SAU - select HAS_RPI_PICO - select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE - select SOC_RESET_HOOK - select XIP config RP2_REQUIRES_IMAGE_DEFINITION_BLOCK bool default y - depends on SOC_SERIES_RP2350 + # Currently the IDF only supports using the Cortex-M33 cores. Enforce + # this at build configuration time. + depends on SOC_SERIES_RP2350 && CPU_CORTEX_M33 help Include an Image Definition Block (IMAGE_DEF) to enable the bootroom in RP23XX devices to consider this a valid image in flash. diff --git a/soc/raspberrypi/rpi_pico/rp2350/Kconfig.soc b/soc/raspberrypi/rpi_pico/rp2350/Kconfig.soc index 12325e2a8dba32f..19012bb5648ab2e 100644 --- a/soc/raspberrypi/rpi_pico/rp2350/Kconfig.soc +++ b/soc/raspberrypi/rpi_pico/rp2350/Kconfig.soc @@ -1,7 +1,6 @@ # Raspberry Pi RP2350 MCU line -# Copyright (c) 2021 Nordic Semiconductor ASA -# Copyright (c) 2021 Yonatan Schachter +# Copyright (c) 2024 Andrew Featherstone # SPDX-License-Identifier: Apache-2.0 config SOC_SERIES_RP2350 @@ -15,5 +14,11 @@ config SOC_RP2350A bool select SOC_SERIES_RP2350 +config SOC_RP2350A_M33 + bool + select SOC_RP2350A + help + Use the RP2350A with a Cortex-M33 core in both 'sockets'. + config SOC default "rp2350a" if SOC_RP2350A diff --git a/soc/raspberrypi/rpi_pico/soc.yml b/soc/raspberrypi/rpi_pico/soc.yml index 29752c7df42cdaa..32039c20944012b 100644 --- a/soc/raspberrypi/rpi_pico/soc.yml +++ b/soc/raspberrypi/rpi_pico/soc.yml @@ -7,3 +7,5 @@ family: - name: rp2350 socs: - name: rp2350a + cpuclusters: + - name: m33 diff --git a/tests/drivers/adc/adc_api/boards/rpi_pico2.overlay b/tests/drivers/adc/adc_api/boards/rpi_pico2_m33.overlay similarity index 100% rename from tests/drivers/adc/adc_api/boards/rpi_pico2.overlay rename to tests/drivers/adc/adc_api/boards/rpi_pico2_m33.overlay diff --git a/tests/drivers/dma/chan_blen_transfer/socs/rp2350a.overlay b/tests/drivers/dma/chan_blen_transfer/socs/rp2350a_m33.overlay similarity index 100% rename from tests/drivers/dma/chan_blen_transfer/socs/rp2350a.overlay rename to tests/drivers/dma/chan_blen_transfer/socs/rp2350a_m33.overlay diff --git a/tests/drivers/dma/loop_transfer/boards/rpi_pico2.overlay b/tests/drivers/dma/loop_transfer/boards/rpi_pico2_m33.overlay similarity index 100% rename from tests/drivers/dma/loop_transfer/boards/rpi_pico2.overlay rename to tests/drivers/dma/loop_transfer/boards/rpi_pico2_m33.overlay diff --git a/tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2.overlay b/tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2_m33.overlay similarity index 100% rename from tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2.overlay rename to tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2_m33.overlay