From b7323e19abeb50ff530883f5e8903f405d7e0730 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 23 Apr 2020 14:34:13 +0200 Subject: [PATCH 1/5] boards: arm: nrf5340pdk: define sram0_image for image(s) RAM We should not be using sram0 for image SRAM in nrf5340pdk. sram0 represents the physical SRAM and that one includes the shared memory between the two M33 CPUs on the SoC. We should not be re-sizing sram0 to account for the shared RAM; instead we would like to have sram0 representing the whole available SRAM. For that, we define a new memory node, sram0_image to represent the 'image' SRAM that is available for Zephyr on the board. sram0_image is the chosen image SRAM for default builds, i.e. when TrustZone is ignored (TRUSTED_EXECUTION_SECURE is not defined). Signed-off-by: Ioannis Glaropoulos --- .../arm/nrf5340pdk_nrf5340/Kconfig.defconfig | 4 ++-- .../nrf5340pdk_nrf5340_cpuapp.dts | 2 +- .../nrf5340pdk_nrf5340_cpuapp_common.dts | 20 ++++++++++--------- ...f5340pdk_nrf5340_cpuapp_partition_conf.dts | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/boards/arm/nrf5340pdk_nrf5340/Kconfig.defconfig b/boards/arm/nrf5340pdk_nrf5340/Kconfig.defconfig index 117d7d24098d4..67980ca4080b1 100644 --- a/boards/arm/nrf5340pdk_nrf5340/Kconfig.defconfig +++ b/boards/arm/nrf5340pdk_nrf5340/Kconfig.defconfig @@ -26,8 +26,8 @@ config BOARD # If the secure firmware is to be combined with a non-secure image # (TRUSTED_EXECUTION_SECURE=y), the secure FW image SRAM shall always # be restricted to the secure image SRAM partition (sram-secure-partition). -# Otherwise (if TRUSTED_EXECUTION_SECURE is not set) the whole sram0 may be -# used by the image. +# Otherwise (if TRUSTED_EXECUTION_SECURE is not set) the whole zephyr,sram +# may be used by the image. # # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. diff --git a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts index e64584c71d909..78697b0348862 100644 --- a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts +++ b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts @@ -10,7 +10,7 @@ / { chosen { - zephyr,sram = &sram0; + zephyr,sram = &sram0_image; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; zephyr,sram-secure-partition = &sram0_s; diff --git a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_common.dts b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_common.dts index 41164f004d749..c3994230cb748 100644 --- a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_common.dts +++ b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_common.dts @@ -164,21 +164,23 @@ }; }; -&sram0 { +/ { - partitions { - compatible = "fixed-partitions"; + reserved-memory { #address-cells = <1>; #size-cells = <1>; + ranges; + + sram0_image: image@20000000 { + /* Zephyr image(s) memory */ + }; - /* SRAM allocated to the Secure image */ - sram0_s: memory@20000000 { - label = "secure_sram_partition"; + sram0_s: image_s@20000000 { + /* Secure image memory */ }; - /* SRAM allocated to the Non-Secure image */ - sram0_ns: memory@20010000 { - label = "non_secure_sram_partition"; + sram0_ns: image_ns@20010000 { + /* Non-Secure image memory */ }; }; }; diff --git a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_partition_conf.dts b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_partition_conf.dts index f42697e6e68c7..73c200f1c09a4 100644 --- a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_partition_conf.dts +++ b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp_partition_conf.dts @@ -44,7 +44,7 @@ * - Upper 64 kB SRAM allocated as Shared memory (sram0_shared) * (see nrf5340pdk_nrf5340_shared_sram_planning_conf.dts) */ -&sram0 { +&sram0_image { reg = <0x20000000 DT_SIZE_K(448)>; }; From c6948e4afaa6797060664019c62a6bb5f936c8c8 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 23 Apr 2020 14:38:01 +0200 Subject: [PATCH 2/5] boards: arm: nrf5340pdk: clean up sram0_shared definition We do not want sram0_shared to represent physical ram; this is just a portion of sram reserved for shared memory between Application and Network MCU. Therfore, we remove the 'mmio' compatible property and transform this node to a reserved-memory node definition, inside which we define the sram0_shared node along with its reg property. In addition we correct the documentation about the shared memory, stressing that it is placed after the image RAM of nrf5340 Application MCU (not after the secure SRAM). Signed-off-by: Ioannis Glaropoulos --- ...5340pdk_nrf5340_shared_sram_planning_conf.dts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_shared_sram_planning_conf.dts b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_shared_sram_planning_conf.dts index e0a2feece2038..b08bb94f6a578 100644 --- a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_shared_sram_planning_conf.dts +++ b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_shared_sram_planning_conf.dts @@ -8,7 +8,7 @@ * This file is included by both nRF5340 CPUAPP (Application MCU) * and nRF5340 CPUNET (Network MCU). * - 64 kB SRAM allocated as Shared memory (sram0_shared) - * - Region defined after the secure SRAM partition of CPUAPP + * - Region defined after the image SRAM of Application MCU */ / { @@ -17,10 +17,14 @@ zephyr,ipc_shm = &sram0_shared; }; - /* SRAM allocated to shared memory */ - sram0_shared: memory@20070000 { - device_type = "memory"; - compatible = "mmio-sram"; - reg = <0x20070000 DT_SIZE_K(64)>; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + sram0_shared: memory@20070000 { + /* SRAM allocated to shared memory */ + reg = <0x20070000 0x10000>; + }; }; }; From 1c3380f2bdf42c30f610bb8850c3bc385c8b27cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20=C3=98ye=20Amundsen?= Date: Tue, 21 Apr 2020 14:21:18 +0200 Subject: [PATCH 3/5] boards: arm: nRF9160: avoid resizing sram0 for nRF9160_dk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sram0 node is needed to hold the size of the total, physical SRAM available on nRF9160 SoC. We use sram0_s to represent the Secure image SRAM for nRF9160_dk builds. Signed-off-by: Håkon Øye Amundsen Signed-off-by: Ioannis Glaropoulos --- boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts | 2 +- boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts | 5 +++++ .../nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts index 1cfb957261412..0a9d62e1435ea 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts @@ -10,7 +10,7 @@ / { chosen { - zephyr,sram = &sram0; + zephyr,sram = &sram0_s; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; }; diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts index ba5623ff1840e..18917c43a22e2 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts @@ -180,6 +180,11 @@ }; / { + /* SRAM allocated to the Secure image */ + sram0_s: memory@20000000 { + label = "secure_sram_memory"; + }; + /* SRAM allocated and used by the BSD library */ sram0_bsd: memory@20010000 { compatible = "mmio-sram"; diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts index 80b40bb785f60..4b97632cf6f08 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_partition_conf.dts @@ -39,13 +39,13 @@ /* Default SRAM planning when building for nRF9160 with * ARM TrustZone-M support - * - Lowest 64 kB SRAM allocated to Secure image (sram0). + * - Lowest 64 kB SRAM allocated to Secure image (sram0_s). * - 64 kB SRAM reserved for and used by the BSD socket - * library. + * library (sram0_bsd). * - Upper 128 kB allocated to Non-Secure image (sram0_ns). */ -&sram0 { +&sram0_s { reg = <0x20000000 DT_SIZE_K(64)>; }; From 536635c3c27c290e9db7d3fb2e6dcc702d6f15e4 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 23 Apr 2020 17:28:41 +0200 Subject: [PATCH 4/5] boards: arm: nrf9160_dk: clean up sram0_ns and sram0_bsd definitions We do not want sram0_ns and sram0_bsd to represent physical ram; these are just portions of sram reserved for the non-secure image and the bsd library, respectively. Thus we can remove the compatible property from these nodes. We also make use of 'reserved-memory' to represent the different memory partitions to be used by the nrf9160 builds. Signed-off-by: Ioannis Glaropoulos --- .../nrf9160dk_nrf9160_common.dts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts index 18917c43a22e2..afaf1678d7a5c 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts @@ -180,19 +180,23 @@ }; / { - /* SRAM allocated to the Secure image */ - sram0_s: memory@20000000 { - label = "secure_sram_memory"; - }; - /* SRAM allocated and used by the BSD library */ - sram0_bsd: memory@20010000 { - compatible = "mmio-sram"; - }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; - /* SRAM allocated to the Non-Secure image */ - sram0_ns: memory@20020000 { - compatible = "mmio-sram"; + sram0_s: image_s@20000000 { + /* Secure image memory */ + }; + + sram0_bsd: image_bsd@20010000 { + /* BSD (shared) memory */ + }; + + sram0_ns: image_ns@20020000 { + /* Non-Secure image memory */ + }; }; }; From 3ffec9a6ba5e724d5471d11e9a677c3456fe1b8a Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Tue, 5 May 2020 15:12:11 +0200 Subject: [PATCH 5/5] boards: arm: nrf: add non-secure SRAM memory information in DTS When we build Zephyr as Secure image on nRF340 Application MCU and nRF9160 SoC we would like to pass the information about the reserved memory area allocated to the Non-Secure images. The information may be needed to apply proper security configuration. We add a "chosen" node in board .dts file for this purpose. Signed-off-by: Ioannis Glaropoulos --- boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts | 1 + boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts index 78697b0348862..3c3175f0e96d7 100644 --- a/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts +++ b/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts @@ -14,5 +14,6 @@ zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; zephyr,sram-secure-partition = &sram0_s; + zephyr,sram-non-secure-partition = &sram0_ns; }; }; diff --git a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts index 0a9d62e1435ea..bdb79b85d88b0 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts +++ b/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts @@ -13,5 +13,7 @@ zephyr,sram = &sram0_s; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; + zephyr,sram-secure-partition = &sram0_s; + zephyr,sram-non-secure-partition = &sram0_ns; }; };