From e645d95e9f8ecfdbf62e55f49ab50af9cbac139e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 28 Apr 2026 08:07:55 +0100 Subject: [PATCH 01/23] [nrf fromtree] boards: holyiot: yj16019: Fix missing chosen SRAM node Adds the missing chosen node to specify the board's SRAM Signed-off-by: Jamie McCrae (cherry picked from commit 8176356de01b3b9c68b610ab8e6e93e8c9fa6944) --- boards/holyiot/yj16019/holyiot_yj16019.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/holyiot/yj16019/holyiot_yj16019.dts b/boards/holyiot/yj16019/holyiot_yj16019.dts index 561f394f1a10..d8a2adbcf8d3 100644 --- a/boards/holyiot/yj16019/holyiot_yj16019.dts +++ b/boards/holyiot/yj16019/holyiot_yj16019.dts @@ -13,6 +13,10 @@ model = "Holyiot YJ-16019"; compatible = "holyiot,yj-16019"; + chosen { + zephyr,sram = &sram0; + }; + leds { compatible = "gpio-leds"; From a875ad36a1c1004888f67e1a277d3476506f7d9d Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 27 Apr 2026 14:17:35 +0100 Subject: [PATCH 02/23] [nrf fromtree] boards: nordic: Rmove duplicate/invalid SRAM Kconfig defaults Some boards were setting variables that were never referenced, others were setting a default for a Kconfig that was already the default, this removes these Signed-off-by: Jamie McCrae (cherry picked from commit f8b81e914bdf5d1d91429f58304d4d3e84566165) --- boards/actinius/icarus/Kconfig.defconfig | 22 ++------------- boards/actinius/icarus_bee/Kconfig.defconfig | 22 ++------------- boards/actinius/icarus_som/Kconfig.defconfig | 22 ++------------- .../actinius/icarus_som_dk/Kconfig.defconfig | 22 ++------------- boards/circuitdojo/feather/Kconfig.defconfig | 22 ++------------- boards/ct/ctcc/Kconfig.defconfig | 22 ++------------- boards/ezurio/bl5340_dvk/Kconfig.defconfig | 24 ++-------------- boards/ezurio/bl54l15_dvk/Kconfig.defconfig | 13 ++------- boards/ezurio/bl54l15u_dvk/Kconfig.defconfig | 13 ++------- boards/innblue/innblue21/Kconfig.defconfig | 26 ++--------------- boards/innblue/innblue22/Kconfig.defconfig | 26 ++--------------- .../nordic/nrf5340_audio_dk/Kconfig.defconfig | 28 ++----------------- boards/nordic/nrf5340dk/Kconfig.defconfig | 10 ------- boards/nordic/thingy53/Kconfig.defconfig | 24 ++-------------- .../norik/octopus_io_board/Kconfig.defconfig | 22 ++------------- boards/norik/octopus_som/Kconfig.defconfig | 22 ++------------- boards/panasonic/panb611evb/Kconfig.defconfig | 13 ++------- boards/raytac/mdbt53_db_40/Kconfig.defconfig | 24 ++-------------- boards/raytac/mdbt53v_db_40/Kconfig.defconfig | 24 ++-------------- boards/sparkfun/thing_plus/Kconfig.defconfig | 22 ++------------- 20 files changed, 41 insertions(+), 382 deletions(-) diff --git a/boards/actinius/icarus/Kconfig.defconfig b/boards/actinius/icarus/Kconfig.defconfig index b5a635ca0d4c..bd3aab4e66f8 100644 --- a/boards/actinius/icarus/Kconfig.defconfig +++ b/boards/actinius/icarus/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2019 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS +config BOARD_ACTINIUS_ICARUS + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_NRF9160_NS diff --git a/boards/actinius/icarus_bee/Kconfig.defconfig b/boards/actinius/icarus_bee/Kconfig.defconfig index 3c191e96cede..b97e9df4caa3 100644 --- a/boards/actinius/icarus_bee/Kconfig.defconfig +++ b/boards/actinius/icarus_bee/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2021 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_BEE - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_BEE_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_BEE +config BOARD_ACTINIUS_ICARUS_BEE + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS diff --git a/boards/actinius/icarus_som/Kconfig.defconfig b/boards/actinius/icarus_som/Kconfig.defconfig index 42d244ac763d..9c709b8e7179 100644 --- a/boards/actinius/icarus_som/Kconfig.defconfig +++ b/boards/actinius/icarus_som/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2021 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_SOM - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_SOM_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_SOM +config BOARD_ACTINIUS_ICARUS_SOM + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS diff --git a/boards/actinius/icarus_som_dk/Kconfig.defconfig b/boards/actinius/icarus_som_dk/Kconfig.defconfig index 3993f59dbf22..cd0c9885526c 100644 --- a/boards/actinius/icarus_som_dk/Kconfig.defconfig +++ b/boards/actinius/icarus_som_dk/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2022 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_SOM_DK - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_SOM_DK +config BOARD_ACTINIUS_ICARUS_SOM_DK + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS diff --git a/boards/circuitdojo/feather/Kconfig.defconfig b/boards/circuitdojo/feather/Kconfig.defconfig index f093911dc477..3a1dafc2ac3f 100644 --- a/boards/circuitdojo/feather/Kconfig.defconfig +++ b/boards/circuitdojo/feather/Kconfig.defconfig @@ -4,8 +4,6 @@ # Copyright (c) 2020 Circuit Dojo LLC # SPDX-License-Identifier: Apache-2.0 -if BOARD_CIRCUITDOJO_FEATHER - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -16,21 +14,5 @@ if BOARD_CIRCUITDOJO_FEATHER # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_CIRCUITDOJO_FEATHER_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS - -endif # BOARD_CIRCUITDOJO_FEATHER +config BOARD_CIRCUITDOJO_FEATHER + select USE_DT_CODE_PARTITION if BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS diff --git a/boards/ct/ctcc/Kconfig.defconfig b/boards/ct/ctcc/Kconfig.defconfig index 298f3d2fe218..6087f4fd5dbd 100644 --- a/boards/ct/ctcc/Kconfig.defconfig +++ b/boards/ct/ctcc/Kconfig.defconfig @@ -9,23 +9,5 @@ source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig" endif # BOARD_CTCC_NRF52840 -if BOARD_CTCC_NRF9161 || BOARD_CTCC_NRF9161_NS - -# Workaround for not being able to have commas in macro arguments. -# For explanation please see: boards/nordic/nrf9161dk/Kconfig.defconfig -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_CTCC_NRF9161 && TRUSTED_EXECUTION_SECURE - -if BOARD_CTCC_NRF9161_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_CTCC_NRF9161_NS -endif # BOARD_CTCC_NRF9161 || BOARD_CTCC_NRF9161_NS +config BOARD_CTCC + select USE_DT_CODE_PARTITION if BOARD_CTCC_NRF9161_NS diff --git a/boards/ezurio/bl5340_dvk/Kconfig.defconfig b/boards/ezurio/bl5340_dvk/Kconfig.defconfig index b4ae23988e0b..b1284f731927 100644 --- a/boards/ezurio/bl5340_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl5340_dvk/Kconfig.defconfig @@ -33,29 +33,9 @@ config I2C # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_BL5340_DVK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_BL5340_DVK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_BL5340_DVK_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_BL5340_DVK_NRF5340_CPUAPP_NS +config BOARD_BL5340_DVK + select USE_DT_CODE_PARTITION if BOARD_BL5340_DVK_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/ezurio/bl54l15_dvk/Kconfig.defconfig b/boards/ezurio/bl54l15_dvk/Kconfig.defconfig index 2ff8fe6e3027..6ea4cac9bba5 100644 --- a/boards/ezurio/bl54l15_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl54l15_dvk/Kconfig.defconfig @@ -2,21 +2,14 @@ # Copyright (c) 2025 Ezurio LLC # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_BL54L15_DVK_NRF54L10_CPUAPP_NS || BOARD_BL54L15_DVK_NRF54L15_CPUAPP_NS +config BOARD_BL54L15_DVK + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # By default, if we build for a Non-Secure version of the board, # enable building with TF-M as the Secure Execution Environment. config BUILD_WITH_TFM diff --git a/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig b/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig index 1e706cb66dd2..b3f51eddb637 100644 --- a/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig @@ -2,21 +2,14 @@ # Copyright (c) 2025 Ezurio LLC # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_BL54L15U_DVK_NRF54L15_CPUAPP_NS +config BOARD_BL54L15U_DVK + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # By default, if we build for a Non-Secure version of the board, # enable building with TF-M as the Secure Execution Environment. config BUILD_WITH_TFM diff --git a/boards/innblue/innblue21/Kconfig.defconfig b/boards/innblue/innblue21/Kconfig.defconfig index abf57a46a11b..c7fc47f75e3b 100644 --- a/boards/innblue/innblue21/Kconfig.defconfig +++ b/boards/innblue/innblue21/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2020 InnBlue # SPDX-License-Identifier: Apache-2.0 -if BOARD_INNBLUE21 - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -15,31 +13,11 @@ if BOARD_INNBLUE21 # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -if BOARD_INNBLUE21_NRF9160 && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE21_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_INNBLUE21_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE21_NRF9160_NS +config BOARD_INNBLUE21 + select USE_DT_CODE_PARTITION if BOARD_INNBLUE21_NRF9160_NS config BT_HCI_VS default y if BT config REGULATOR default y if SENSOR - -endif # BOARD_INNBLUE21 diff --git a/boards/innblue/innblue22/Kconfig.defconfig b/boards/innblue/innblue22/Kconfig.defconfig index 540a784ec975..ee1d7a11e3eb 100644 --- a/boards/innblue/innblue22/Kconfig.defconfig +++ b/boards/innblue/innblue22/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2020 InnBlue # SPDX-License-Identifier: Apache-2.0 -if BOARD_INNBLUE22 - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -15,31 +13,11 @@ if BOARD_INNBLUE22 # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -if BOARD_INNBLUE22_NRF9160 && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE22_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_INNBLUE22_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE22_NRF9160_NS +config BOARD_INNBLUE22 + select USE_DT_CODE_PARTITION if BOARD_INNBLUE22_NRF9160_NS config BT_HCI_VS default y if BT config REGULATOR default y if SENSOR - -endif # BOARD_INNBLUE22 diff --git a/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig b/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig index de77a9846f82..58d37f48dfa5 100644 --- a/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig +++ b/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig @@ -32,29 +32,9 @@ if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP || BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAP # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS +config BOARD_NRF5340_AUDIO_DK + select USE_DT_CODE_PARTITION if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI @@ -64,7 +44,3 @@ config HEAP_MEM_POOL_ADD_SIZE_BOARD default 4096 if BT_HCI_IPC endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP || BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS - -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUNET - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUNET diff --git a/boards/nordic/nrf5340dk/Kconfig.defconfig b/boards/nordic/nrf5340dk/Kconfig.defconfig index c0ac00bcfe54..48e892a04fff 100644 --- a/boards/nordic/nrf5340dk/Kconfig.defconfig +++ b/boards/nordic/nrf5340dk/Kconfig.defconfig @@ -40,16 +40,6 @@ if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF5340DK_NRF5340_CPUAPP_NS # always restricted to the allocated non-secure SRAM partition. # -if BOARD_NRF5340DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_NRF5340DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - config BOARD_NRF5340DK select USE_DT_CODE_PARTITION if BOARD_NRF5340DK_NRF5340_CPUAPP_NS diff --git a/boards/nordic/thingy53/Kconfig.defconfig b/boards/nordic/thingy53/Kconfig.defconfig index 4a478c8db254..a8ba0d17382c 100644 --- a/boards/nordic/thingy53/Kconfig.defconfig +++ b/boards/nordic/thingy53/Kconfig.defconfig @@ -53,29 +53,9 @@ endif # BUILD_WITH_TFM # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_THINGY53_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_THINGY53_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_THINGY53_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_THINGY53_NRF5340_CPUAPP_NS +config BOARD_THINGY53 + select USE_DT_CODE_PARTITION if BOARD_THINGY53_NRF5340_CPUAPP_NS if !TRUSTED_EXECUTION_SECURE diff --git a/boards/norik/octopus_io_board/Kconfig.defconfig b/boards/norik/octopus_io_board/Kconfig.defconfig index 4c00ab52ab59..76c48f90db55 100644 --- a/boards/norik/octopus_io_board/Kconfig.defconfig +++ b/boards/norik/octopus_io_board/Kconfig.defconfig @@ -1,8 +1,6 @@ # Copyright (c) 2024 Norik Systems # SPDX-License-Identifier: Apache-2.0 -if BOARD_OCTOPUS_IO_BOARD - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -13,21 +11,5 @@ if BOARD_OCTOPUS_IO_BOARD # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_OCTOPUS_IO_BOARD && TRUSTED_EXECUTION_SECURE - -if BOARD_OCTOPUS_IO_BOARD_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_OCTOPUS_IO_BOARD_NRF9160_NS - -endif # BOARD_OCTOPUS_IO_BOARD +config BOARD_OCTOPUS_IO_BOARD + select USE_DT_CODE_PARTITION if BOARD_OCTOPUS_IO_BOARD_NRF9160_NS diff --git a/boards/norik/octopus_som/Kconfig.defconfig b/boards/norik/octopus_som/Kconfig.defconfig index 6fe9d1618a5b..35a31fd95c11 100644 --- a/boards/norik/octopus_som/Kconfig.defconfig +++ b/boards/norik/octopus_som/Kconfig.defconfig @@ -1,8 +1,6 @@ # Copyright (c) 2024 Norik Systems # SPDX-License-Identifier: Apache-2.0 -if BOARD_OCTOPUS_SOM - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -13,21 +11,5 @@ if BOARD_OCTOPUS_SOM # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_OCTOPUS_SOM && TRUSTED_EXECUTION_SECURE - -if BOARD_OCTOPUS_SOM_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_OCTOPUS_SOM_NRF9160_NS - -endif # BOARD_OCTOPUS_SOM +config BOARD_OCTOPUS_SOM + select USE_DT_CODE_PARTITION if BOARD_OCTOPUS_SOM_NRF9160_NS diff --git a/boards/panasonic/panb611evb/Kconfig.defconfig b/boards/panasonic/panb611evb/Kconfig.defconfig index 1b469232537f..5c1da70d2375 100644 --- a/boards/panasonic/panb611evb/Kconfig.defconfig +++ b/boards/panasonic/panb611evb/Kconfig.defconfig @@ -1,21 +1,14 @@ # Copyright (c) 2025 Panasonic Industrial Devices Europe GmbH # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_PANB611EVB_NRF54L15_CPUAPP_NS +config BOARD_PANB611EVB + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # By default, if we build for a Non-Secure version of the board, # enable building with TF-M as the Secure Execution Environment. config BUILD_WITH_TFM diff --git a/boards/raytac/mdbt53_db_40/Kconfig.defconfig b/boards/raytac/mdbt53_db_40/Kconfig.defconfig index 128e5fc62dbc..780df72d1342 100644 --- a/boards/raytac/mdbt53_db_40/Kconfig.defconfig +++ b/boards/raytac/mdbt53_db_40/Kconfig.defconfig @@ -29,29 +29,9 @@ if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP || BOARD_RAYTAC_MDBT53_DB_40_NRF5340 # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS +config BOARD_RAYTAC_MDBT53_DB_40 + select USE_DT_CODE_PARTITION if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/raytac/mdbt53v_db_40/Kconfig.defconfig b/boards/raytac/mdbt53v_db_40/Kconfig.defconfig index c30d57c073d0..63eaac0cac98 100644 --- a/boards/raytac/mdbt53v_db_40/Kconfig.defconfig +++ b/boards/raytac/mdbt53v_db_40/Kconfig.defconfig @@ -29,29 +29,9 @@ if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP || BOARD_RAYTAC_MDBT53V_DB_40_NRF53 # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS +config BOARD_RAYTAC_MDBT53V_DB_40 + select USE_DT_CODE_PARTITION if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/sparkfun/thing_plus/Kconfig.defconfig b/boards/sparkfun/thing_plus/Kconfig.defconfig index 5273768aa501..cb9ac1d590dc 100644 --- a/boards/sparkfun/thing_plus/Kconfig.defconfig +++ b/boards/sparkfun/thing_plus/Kconfig.defconfig @@ -4,8 +4,6 @@ # Copyright (c) 2020 Circuit Dojo LLC # SPDX-License-Identifier: Apache-2.0 -if BOARD_SPARKFUN_THING_PLUS - # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- @@ -16,21 +14,5 @@ if BOARD_SPARKFUN_THING_PLUS # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_SPARKFUN_THING_PLUS_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_SPARKFUN_THING_PLUS_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_SPARKFUN_THING_PLUS_NRF9160 - -endif # BOARD_SPARKFUN_THING_PLUS +config BOARD_SPARKFUN_THING_PLUS + select USE_DT_CODE_PARTITION if BOARD_SPARKFUN_THING_PLUS_NRF9160_NS From 5f2c976e1ca3a03bd4d6c2cdd75a38f0f53752e0 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 1 May 2026 08:16:59 +0100 Subject: [PATCH 03/23] Revert "[nrf noup] drivers: flash: Update to support PM removal" This reverts commit 6995eb05922ddf6cf2bd1842748de220dfd26cca. Signed-off-by: Jamie McCrae --- drivers/flash/soc_flash_nrf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 3e735a7edf78..27fda598be20 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,12 +36,10 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) -#if CONFIG_TRUSTED_EXECUTION_NONSECURE +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER #include -#if USE_PARTITION_MANAGER #include -#endif /* USE_PARTITION_MANAGER */ -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 @@ -172,17 +170,11 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif -#if CONFIG_TRUSTED_EXECUTION_NONSECURE -#if USE_PARTITION_MANAGER && PM_APP_ADDRESS +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS if (addr < PM_APP_ADDRESS) { return soc_secure_mem_read(data, (void *)addr, len); } -#elif !USE_PARTITION_MANAGER && DT_NODE_EXISTS(DT_NODELABEL(slot0_ns_partition)) - if ((uintptr_t)addr < DT_REG_ADDR(DT_NODELABEL(slot0_ns_partition))) { - return soc_secure_mem_read(data, (void *)addr, len); - } #endif -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ nrf_nvmc_buffer_read(data, (uint32_t)addr, len); From 83a3cc999e1d40cd3f778a7cbecf5f724fa61baf Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 1 May 2026 08:17:03 +0100 Subject: [PATCH 04/23] Revert "[nrf noup] tree-wide: support NCS Partition Manager (PM) definitions" This reverts commit 9991882440b7100fbcbe81bec51c6ce73c2f7aeb. Signed-off-by: Jamie McCrae --- arch/arm/core/mpu/arm_mpu_regions.c | 13 ----- cmake/linker/ld/target.cmake | 1 - cmake/linker/lld/target.cmake | 1 - cmake/modules/kernel.cmake | 4 -- drivers/flash/soc_flash_nrf.c | 11 ---- drivers/flash/soc_flash_nrf_rram.c | 11 ---- .../arch/arm/cortex_m/scripts/linker.ld | 50 ------------------- include/zephyr/storage/flash_map.h | 6 --- lib/heap/Kconfig | 2 +- lib/libc/common/source/stdlib/malloc.c | 18 +------ subsys/dfu/boot/mcuboot_shell.c | 40 --------------- subsys/fs/littlefs_fs.c | 7 +-- subsys/ipc/rpmsg_service/rpmsg_backend.h | 27 ---------- 13 files changed, 4 insertions(+), 187 deletions(-) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 71c0a9a2b739..4771c5914ce6 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,9 +8,6 @@ #include #include -#if USE_PARTITION_MANAGER -#include -#endif #ifdef CONFIG_ARM_MPU_SRAM_WRITE_THROUGH #define ARM_MPU_SRAM_REGION_ATTR REGION_RAM_WT_ATTR @@ -33,14 +30,6 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", -#if USE_PARTITION_MANAGER - PM_SRAM_ADDRESS, -#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) - REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), -#else - REGION_RAM_ATTR(REGION_SRAM_SIZE)), -#endif -#else CONFIG_SRAM_BASE_ADDRESS, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) ARM_MPU_SRAM_REGION_ATTR(CONFIG_SRAM_BASE_ADDRESS, @@ -48,8 +37,6 @@ static const struct arm_mpu_region mpu_regions[] = { #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif - -#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index ccf6a1903162..592596576d11 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,7 +80,6 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} - -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index fe8aad62c73d..96df1c123796 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,7 +52,6 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} - -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index 53aa705fdc9b..310a836eebcf 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -257,7 +257,3 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() - -if(ZEPHYR_NRF_MODULE_DIR) - include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) -endif() diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 27fda598be20..f6b8a6f5eef3 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,11 +36,6 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER -#include -#include -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ - #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -170,12 +165,6 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS - if (addr < PM_APP_ADDRESS) { - return soc_secure_mem_read(data, (void *)addr, len); - } -#endif - nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index cd217a5f2c2d..1f7f89b5509f 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,11 +54,6 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER -#include -#include -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ - #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -297,12 +292,6 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS - if (addr < PM_APP_ADDRESS) { - return soc_secure_mem_read(data, (void *)addr, len); - } -#endif - memcpy(data, (void *)addr, len); return 0; diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 7b5e9358af02..2f3d55412f06 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,39 +34,6 @@ #define ROMSTART_REGION ROMABLE_REGION #endif -#if USE_PARTITION_MANAGER - -#include - -#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) -/* We are linking against S1, create symbol containing the flash ID of S0. - * This is used when writing code operating on the "other" slot. - */ -_image_1_primary_slot_id = PM_S0_ID; - -#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ - -#ifdef PM_S1_ID -/* We are linking against S0, create symbol containing the flash ID of S1. - * This is used when writing code operating on the "other" slot. - */ -_image_1_primary_slot_id = PM_S1_ID; -#endif /* PM_S1_ID */ - -#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ - -#define ROM_ADDR PM_ADDRESS -#define ROM_SIZE PM_SIZE - -#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) -#define RAM_SIZE CONFIG_PM_SRAM_SIZE -#else -#define RAM_SIZE PM_SRAM_SIZE -#endif -#define RAM_ADDR PM_SRAM_ADDRESS - -#else /* ! USE_PARTITION_MANAGER */ - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else @@ -93,23 +60,6 @@ _image_1_primary_slot_id = PM_S1_ID; #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS -#endif /* USE_PARTITION_MANAGER */ - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) -#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) -#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) -#endif - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) -#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) -#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) -#endif - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) -#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) -#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) -#endif - #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index 819f94182474..13f381e135fd 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -351,10 +351,6 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); -#if USE_PARTITION_MANAGER -#include -#else - /** * Returns non-0 value if partition of given DTS node label exists. * @@ -624,8 +620,6 @@ DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOR_EACH_SUBPARTITION_TABLE) #undef FOR_EACH_SUBPARTITION_TABLE /** @endcond */ -#endif /* USE_PARTITION_MANAGER */ - #ifdef __cplusplus } #endif diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index f9f98db27c52..b9e6371fabff 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -160,7 +160,7 @@ source "subsys/logging/Kconfig.template.log_config" choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) && !PARTITION_MANAGER_ENABLED + default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 368342cc86de..74193fbdce48 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,20 +25,6 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); -#if USE_PARTITION_MANAGER - -#include - -#define RAM_SIZE PM_SRAM_SIZE -#define RAM_ADDR PM_SRAM_ADDRESS - -#else /* ! USE_PARTITION_MANAGER */ - -#define RAM_SIZE (KB((size_t) CONFIG_SRAM_SIZE)) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS - -#endif /* USE_PARTITION_MANAGER */ - #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -120,8 +106,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((RAM_SIZE - \ - ((size_t) HEAP_BASE - (size_t) RAM_ADDR)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ + ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index 06eb79baa92b..583bc4778362 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,16 +20,6 @@ #endif #endif -#if USE_PARTITION_MANAGER -#include - -#ifdef CONFIG_NCS_IS_VARIANT_IMAGE -#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID -#else -#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID -#endif -#endif - struct area_desc { const char *name; unsigned int id; @@ -103,35 +93,6 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ -#if USE_PARTITION_MANAGER -#ifdef PM_MCUBOOT_ID - if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { - shell_error(sh, "Cannot erase boot partition"); - return -EACCES; - } -#endif - -#ifdef PM_APP_ID - if (id == PM_APP_ID) { - shell_error(sh, "Cannot erase this area"); - return -EACCES; - } -#endif - -#ifdef PM_MCUBOOT_PRIMARY_APP_ID - if (id == PM_MCUBOOT_PRIMARY_APP_ID) { - shell_error(sh, "Cannot erase this area"); - return -EACCES; - } -#endif - -#ifdef ACTIVE_IMAGE_ID - if (id == ACTIVE_IMAGE_ID) { - shell_error(sh, "Cannot erase active partitions"); - return -EACCES; - } -#endif -#else #if PARTITION_EXISTS(boot_partition) if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -144,7 +105,6 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } -#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index 094cb761756b..e41287edf2f6 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,12 +1133,7 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *) \ - COND_CODE_1(USE_PARTITION_MANAGER, \ - (COND_CODE_1(FIXED_PARTITION_EXISTS(littlefs_storage), \ - (FIXED_PARTITION_ID(littlefs_storage)), \ - (FIXED_PARTITION_ID(storage)))), \ - (DT_PARTITION_ID(FS_PARTITION(inst)))), \ + .storage_dev = (void *)DT_PARTITION_ID(FS_PARTITION(inst)), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index e7015d512d36..349eee664810 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,35 +13,8 @@ extern "C" { #endif -#if CONFIG_PARTITION_MANAGER_ENABLED - -#include "pm_config.h" - -#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) - -#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) -#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS -#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE -#else -/* The current image is a child image in a different domain than the image - * which defined the required values. To reach the values of the parent domain - * we use the 'PM__' variant of the define. - */ -#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS -#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE -#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ - -#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) -#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ - -#else - -#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) -#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) - -#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #ifdef CONFIG_OPENAMP_RSC_TABLE #define SHM_START_ADDR (VDEV_START_ADDR) From c0e025e4efe8c37563539e853e50748cd39e55d2 Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Wed, 15 Apr 2026 16:06:15 +0200 Subject: [PATCH 05/23] [nrf fromtree] arm64: mm: increase MAX_XLAT_TABLES for USERSPACE && TEST Since commit 0026a5610ac ("arm64: mm: use identity mapping for device MMIO"), device_map() creates identity mappings (VA = PA) instead of allocating virtual addresses from a contiguous pool. Each device at a distinct 2MB-aligned physical address now requires its own L3 page table, increasing the total number of translation tables needed. Bump the USERSPACE && TEST default from 24 to 28 to accommodate the additional tables required by identity-mapped device MMIO. Signed-off-by: Carlo Caione (cherry picked from commit acc53653b4707aa40c22aec8c33f1d733e5e670f) --- arch/arm64/core/Kconfig | 2 +- .../demand_paging/mem_map/boards/qemu_cortex_a53.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 61021a9e35b7..d4d40fe86864 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -382,7 +382,7 @@ config ARM64_PA_BITS config MAX_XLAT_TABLES int "Maximum numbers of translation tables" default 32 if USERSPACE && TEST && SMP - default 24 if USERSPACE && TEST + default 28 if USERSPACE && TEST default 20 if USERSPACE && (ARM64_VA_BITS >= 40) default 16 if USERSPACE default 12 if (ARM64_VA_BITS >= 40) diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf index 91a28adf437d..6da2825758a4 100644 --- a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf @@ -3,4 +3,4 @@ CONFIG_BACKING_STORE_RAM=y CONFIG_BACKING_STORE_RAM_PAGES=24 -CONFIG_SRAM_SIZE=440 +CONFIG_SRAM_SIZE=456 From feda5c05b300c40c835a346b9b302b7029ab531a Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:45:31 +0100 Subject: [PATCH 06/23] [nrf fromtree] arch: kconfig: Add Kconfig for deprecated SRAM configuration Adds a Kconfig which will be used to determine where the source of truth will be for RAM configuration for a board target, to allow moving to a pure DTS approach Signed-off-by: Jamie McCrae (cherry picked from commit 29b11f9e6998609eecfe23783c1af916a7f5f39d) --- arch/Kconfig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 051d953f87cf..a4bcc2c5e85e 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -223,6 +223,13 @@ config 64BIT soc/**/Kconfig, or boards/**/Kconfig and the user should generally avoid modifying it. +config SRAM_DEPRECATED_KCONFIG_SET + bool + help + Indicates that either `CONFIG_SRAM_SIZE` or `CONFIG_SRAM_BASE_ADDRESS` have been + manually set, these Kconfigs are now deprecated and should be replaced by referencing + the devicetree `zephyr,sram` chosen node instead. + # Workaround for not being able to have commas in macro arguments DT_CHOSEN_Z_SRAM := zephyr,sram @@ -232,7 +239,8 @@ config SRAM_SIZE help The SRAM size in kB. The default value comes from /chosen/zephyr,sram in devicetree. The user should generally avoid changing it via menuconfig or - in configuration files. + in configuration files. This option is now deprecated and must be replaced by referencing + the devicetree `zephyr,sram` chosen node instead. config SRAM_BASE_ADDRESS hex "SRAM Base Address" @@ -240,7 +248,8 @@ config SRAM_BASE_ADDRESS help The SRAM base address. The default value comes from /chosen/zephyr,sram in devicetree. The user should generally avoid - changing it via menuconfig or in configuration files. + changing it via menuconfig or in configuration files. This option is now deprecated and + must be replaced by referencing the devicetree `zephyr,sram` chosen node instead. config XIP bool "Execute in place" From 8ccf4000eab4785b9b45410257cb4f9cfd8703d1 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 6 May 2026 13:25:33 +0100 Subject: [PATCH 07/23] [nrf fromtree] include: devicetree: Add SRAM macros Adds macros to get the chosen SRAM node's address and size Signed-off-by: Jamie McCrae (cherry picked from commit ab077598094454b23d08f4a7abd01d333f750fa8) --- include/zephyr/devicetree.h | 1 + include/zephyr/devicetree/sram.h | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 include/zephyr/devicetree/sram.h diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 929af69a865a..bc981a1d4874 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5911,5 +5911,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/sram.h b/include/zephyr/devicetree/sram.h new file mode 100644 index 000000000000..bf83a14808aa --- /dev/null +++ b/include/zephyr/devicetree/sram.h @@ -0,0 +1,59 @@ +/** + * @file + * @brief Chosen SRAM Devicetree macro public API header file. + */ + +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ + +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-chosen-sram Devicetree SRAM API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get chosen SRAM node address + * + * @return Absolute address of chosen SRAM node, if it exists + */ +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#define DT_CHOSEN_SRAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#else +#define DT_CHOSEN_SRAM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_sram)) +#endif + +/** + * @brief Get chosen SRAM node size + * + * @return Size of chosen SRAM node, if it exists + */ +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#define DT_CHOSEN_SRAM_SIZE (CONFIG_SRAM_SIZE * 1024) +#else +#define DT_CHOSEN_SRAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ */ From 8b5497cd16352a60f691d70c3218c63854ce2857 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:47:10 +0100 Subject: [PATCH 08/23] [nrf fromtree] arch: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 96d1142210e36b6985ccb3ffbbea7b3569809c0d) --- arch/arm/core/cortex_a_r/reboot.c | 2 +- arch/arm/core/cortex_m/prep_c.c | 2 +- arch/arm/core/mpu/arm_mpu_regions.c | 6 +++--- arch/arm64/core/CMakeLists.txt | 8 +++++++- arch/riscv/Kconfig | 7 +++++-- arch/x86/Kconfig | 5 ++++- arch/x86/core/x86_mmu.c | 4 ++-- arch/x86/gen_mmu.py | 18 ++++++++++++++++-- arch/xtensa/core/ptables.c | 2 +- 9 files changed, 40 insertions(+), 14 deletions(-) diff --git a/arch/arm/core/cortex_a_r/reboot.c b/arch/arm/core/cortex_a_r/reboot.c index e5e44e13cfd0..afe272cec20e 100644 --- a/arch/arm/core/cortex_a_r/reboot.c +++ b/arch/arm/core/cortex_a_r/reboot.c @@ -44,7 +44,7 @@ TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_NONNULL) void __weak relocate_vector_table(void) { #if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \ - !defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0) + !defined(CONFIG_XIP) && (DT_CHOSEN_SRAM_ADDR != 0) write_sctlr(read_sctlr() & ~HIVECS); size_t vector_size = (size_t)_vector_end - (size_t)_vector_start; (void)arch_early_memcpy(VECTOR_ADDRESS, _vector_start, vector_size); diff --git a/arch/arm/core/cortex_m/prep_c.c b/arch/arm/core/cortex_m/prep_c.c index 6daa0ae250e0..5f5fde43f44d 100644 --- a/arch/arm/core/cortex_m/prep_c.c +++ b/arch/arm/core/cortex_m/prep_c.c @@ -74,7 +74,7 @@ void __weak relocate_vector_table(void) void __weak relocate_vector_table(void) { #if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \ - !defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0) + !defined(CONFIG_XIP) && (DT_CHOSEN_SRAM_ADDR != 0) size_t vector_size = (size_t)_vector_end - (size_t)_vector_start; (void)memcpy(VECTOR_ADDRESS, _vector_start, vector_size); #elif defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 4771c5914ce6..9a0970353277 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -30,10 +30,10 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", - CONFIG_SRAM_BASE_ADDRESS, + DT_CHOSEN_SRAM_ADDR, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) - ARM_MPU_SRAM_REGION_ATTR(CONFIG_SRAM_BASE_ADDRESS, - CONFIG_SRAM_SIZE * 1024)), + ARM_MPU_SRAM_REGION_ATTR(DT_CHOSEN_SRAM_ADDR, + DT_CHOSEN_SRAM_SIZE)), #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif diff --git a/arch/arm64/core/CMakeLists.txt b/arch/arm64/core/CMakeLists.txt index d93cf61d88a8..4044de905cd4 100644 --- a/arch/arm64/core/CMakeLists.txt +++ b/arch/arm64/core/CMakeLists.txt @@ -22,7 +22,13 @@ zephyr_library_sources( # simple numeric comparison because these values may be # beyond the numeric range of integers for cmake. -string(LENGTH "x${CONFIG_SRAM_BASE_ADDRESS}" SRAM_LENGTH) +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + string(LENGTH "x${CONFIG_SRAM_BASE_ADDRESS}" SRAM_LENGTH) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + string(LENGTH "x${ram_addr}" SRAM_LENGTH) +endif() string(LENGTH "x${CONFIG_KERNEL_VM_BASE}" KERNEL_VM_LENGTH) if(${SRAM_LENGTH} GREATER 11 OR ${KERNEL_VM_LENGTH} GREATER 11) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0cf427b67180..0fcbb7f82208 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -67,10 +67,13 @@ config RISCV_ALWAYS_SWITCH_THROUGH_ECALL and most people should say n here to minimize context switching overhead. +DT_CHOSEN_Z_SRAM = zephyr,sram + choice RISCV_CMODEL prompt "RISC-V Code Model" - default RISCV_CMODEL_LARGE if (SRAM_BASE_ADDRESS > 0xffffffff) || \ - (KERNEL_VM_BASE > 0xffffffff) + default RISCV_CMODEL_LARGE if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_BASE_ADDRESS > 0xffffffff) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_addr_int,$(DT_CHOSEN_Z_SRAM),0) > 0xffffffff) || \ + (KERNEL_VM_BASE > 0xffffffff) default RISCV_CMODEL_MEDANY if 64BIT default RISCV_CMODEL_MEDLOW diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e014766f6344..a4bac28ec959 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -356,9 +356,12 @@ config X86_MAX_ADDITIONAL_MEM_DOMAINS Zephyr test cases assume 3 additional domains can be instantiated. +DT_CHOSEN_Z_SRAM = zephyr,sram + config X86_EXTRA_PAGE_TABLE_PAGES int "Reserve extra pages in page table" - default 1 if X86_PAE && (KERNEL_VM_BASE != SRAM_BASE_ADDRESS) + default 1 if X86_PAE && ((SRAM_DEPRECATED_KCONFIG_SET && KERNEL_VM_BASE != SRAM_BASE_ADDRESS) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && KERNEL_VM_BASE != $(dt_chosen_reg_addr_int,$(DT_CHOSEN_Z_SRAM),0))) default 0 depends on X86_MMU help diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index 9bece5dd9f5c..eff5bdef4072 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -1325,8 +1325,8 @@ static void identity_map_remove(uint32_t level) pentry_t *entry_ptr; k_mem_region_align((uintptr_t *)&pos, &size, - (uintptr_t)CONFIG_SRAM_BASE_ADDRESS, - (size_t)CONFIG_SRAM_SIZE * 1024U, scope); + (uintptr_t)DT_CHOSEN_SRAM_ADDR, + (size_t)DT_CHOSEN_SRAM_SIZE, scope); while (size != 0U) { /* Need to get to the correct table */ diff --git a/arch/x86/gen_mmu.py b/arch/x86/gen_mmu.py index 827cfa9c38ca..444c9dfc9bdf 100755 --- a/arch/x86/gen_mmu.py +++ b/arch/x86/gen_mmu.py @@ -69,16 +69,21 @@ import array import ctypes import os +import pickle import re import struct import sys import textwrap +from pathlib import Path import elftools from elftools.elf.elffile import ELFFile from elftools.elf.sections import SymbolTableSection from packaging import version +sys.path.append(str(Path(__file__).parents[2] / "scripts" / "dts" / "python-devicetree" / "src")) +from devicetree import edtlib # noqa: F401 + if version.parse(elftools.__version__) < version.parse('0.24'): sys.exit("pyelftools is out of date, need version 0.24 or later") @@ -784,8 +789,17 @@ def main(): vm_size = syms["CONFIG_KERNEL_VM_SIZE"] vm_offset = syms["CONFIG_KERNEL_VM_OFFSET"] - sram_base = syms["CONFIG_SRAM_BASE_ADDRESS"] - sram_size = syms["CONFIG_SRAM_SIZE"] * 1024 + if isdef("CONFIG_SRAM_DEPRECATED_KCONFIG_SET"): + sram_base = syms["CONFIG_SRAM_BASE_ADDRESS"] + sram_size = syms["CONFIG_SRAM_SIZE"] * 1024 + else: + edt_pickle_path = str(Path(args.kernel).parents[1] / "zephyr" / 'edt.pickle') + with open(edt_pickle_path, "rb") as f: + edt = pickle.load(f) + chosen_sram = edt.chosen_node("zephyr,sram") + + sram_base = chosen_sram.regs[0].addr + sram_size = chosen_sram.regs[0].size mapped_kernel_base = syms["z_mapped_start"] mapped_kernel_size = syms["z_mapped_size"] diff --git a/arch/xtensa/core/ptables.c b/arch/xtensa/core/ptables.c index 2f6d17d8f43a..a23073880f17 100644 --- a/arch/xtensa/core/ptables.c +++ b/arch/xtensa/core/ptables.c @@ -570,7 +570,7 @@ __weak void arch_reserved_pages_update(void) uintptr_t page; int idx; - for (page = CONFIG_SRAM_BASE_ADDRESS, idx = 0; + for (page = DT_CHOSEN_SRAM_ADDR, idx = 0; page < (uintptr_t)z_mapped_start; page += CONFIG_MMU_PAGE_SIZE, idx++) { k_mem_page_frame_set(&k_mem_page_frames[idx], K_MEM_PAGE_FRAME_RESERVED); From 32b019de1ed1418f1b60975e66d687c3a162eb07 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:48:01 +0100 Subject: [PATCH 09/23] [nrf fromtree] cmake: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 1c65d60a40b0765450358842d9b88ea64300bae5) --- CMakeLists.txt | 21 ++++++++++++++++++--- cmake/linker_script/arm/linker.cmake | 10 ++++++++-- cmake/modules/extensions.cmake | 18 ++++++++++++++---- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0cbd8e59898..4bb3dc1fbcda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1880,12 +1880,27 @@ if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2) # are typically loaded to RAM if(NOT CONFIG_XIP) if(CONFIG_BUILD_OUTPUT_ADJUST_LMA) - math(EXPR code_address + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR code_address "${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_BUILD_OUTPUT_ADJUST_LMA} + 0" OUTPUT_FORMAT HEXADECIMAL - ) + ) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + + math(EXPR code_address + "${ram_addr} + ${CONFIG_BUILD_OUTPUT_ADJUST_LMA} + 0" + OUTPUT_FORMAT HEXADECIMAL + ) + endif() else() - set(code_address "${CONFIG_SRAM_BASE_ADDRESS}") + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + set(code_address ${CONFIG_SRAM_BASE_ADDRESS}) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(code_address PATH "${chosen_sram_path}") + endif() endif() endif() diff --git a/cmake/linker_script/arm/linker.cmake b/cmake/linker_script/arm/linker.cmake index b6d2254911bd..a2b83ffb3149 100644 --- a/cmake/linker_script/arm/linker.cmake +++ b/cmake/linker_script/arm/linker.cmake @@ -63,8 +63,14 @@ else() endif() endif() -set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) -math(EXPR RAM_SIZE "(${CONFIG_SRAM_SIZE} + 0) * 1024" OUTPUT_FORMAT HEXADECIMAL) +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) + math(EXPR RAM_SIZE "(${CONFIG_SRAM_SIZE} + 0) * 1024" OUTPUT_FORMAT HEXADECIMAL) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(RAM_ADDR PATH "${chosen_sram_path}") + dt_reg_size(RAM_SIZE PATH "${chosen_sram_path}") +endif() # ToDo: decide on the optimal location for this. # linker/ld/target.cmake based on arch, or directly in arch and scatter_script.cmake can ignore diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 845a89833836..093e830cd378 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -5308,10 +5308,20 @@ function(zephyr_linker_section) # If KVMA is set and the Kernel virtual memory settings reqs are met, we # substitute the VMA setting with the specified KVMA value. if(CONFIG_MMU) - math(EXPR KERNEL_MEM_VM_OFFSET - "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET})\ - - (${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_SRAM_OFFSET})" - ) + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR KERNEL_MEM_VM_OFFSET + "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET}) \ + - (${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_SRAM_OFFSET})" + ) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + + math(EXPR KERNEL_MEM_VM_OFFSET + "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET}) \ + - (${ram_addr} + ${CONFIG_SRAM_OFFSET})" + ) + endif() if(NOT (${KERNEL_MEM_VM_OFFSET} EQUAL 0)) set(SECTION_VMA ${SECTION_KVMA}) From 74344ff14b875752a7a1348c50330efbe4f60db9 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:48:21 +0100 Subject: [PATCH 10/23] [nrf fromtree] include: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit c17b8678c6a331336c0e0a3e3a22abf8477b1c77) --- .../arch/arm/cortex_a_r/scripts/linker.ld | 4 +- .../arch/arm/cortex_m/scripts/linker.ld | 4 +- include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h | 42 ++++++++++--------- include/zephyr/arch/arm64/scripts/linker.ld | 4 +- include/zephyr/arch/mips/linker.ld | 11 +++-- include/zephyr/arch/openrisc/linker.ld | 10 ++--- include/zephyr/arch/riscv/common/linker.ld | 8 ++-- include/zephyr/arch/rx/linker.ld | 6 +-- include/zephyr/arch/x86/memory.ld | 2 +- include/zephyr/kernel/internal/mm.h | 17 ++++---- include/zephyr/linker/linker-tool-gcc.h | 2 +- include/zephyr/sys/mem_manage.h | 6 +-- 12 files changed, 61 insertions(+), 55 deletions(-) diff --git a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld index 04cc147bf8b7..82af01208258 100644 --- a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld @@ -57,8 +57,8 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE /* Set alignment to CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE * to make linker section alignment comply with MPU granularity. diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 2f3d55412f06..3f8bfe9d5900 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -57,8 +57,8 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; diff --git a/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h b/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h index a99223262d64..7d3eb3797539 100644 --- a/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h +++ b/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h @@ -52,49 +52,53 @@ #error "Unsupported flash size configuration" #endif +#define Z_SRAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + /* SRAM Region Definitions */ -#if CONFIG_SRAM_SIZE <= 16 +#if Z_SRAM_SIZE <= 16 #define REGION_SRAM_SIZE REGION_16K -#elif CONFIG_SRAM_SIZE <= 32 +#elif Z_SRAM_SIZE <= 32 #define REGION_SRAM_SIZE REGION_32K -#elif CONFIG_SRAM_SIZE <= 64 +#elif Z_SRAM_SIZE <= 64 #define REGION_SRAM_SIZE REGION_64K -#elif CONFIG_SRAM_SIZE <= 128 +#elif Z_SRAM_SIZE <= 128 #define REGION_SRAM_SIZE REGION_128K -#elif CONFIG_SRAM_SIZE <= 256 +#elif Z_SRAM_SIZE <= 256 #define REGION_SRAM_SIZE REGION_256K -#elif CONFIG_SRAM_SIZE <= 512 +#elif Z_SRAM_SIZE <= 512 #define REGION_SRAM_SIZE REGION_512K -#elif CONFIG_SRAM_SIZE <= 1024 +#elif Z_SRAM_SIZE <= 1024 #define REGION_SRAM_SIZE REGION_1M -#elif CONFIG_SRAM_SIZE <= 2048 +#elif Z_SRAM_SIZE <= 2048 #define REGION_SRAM_SIZE REGION_2M -#elif CONFIG_SRAM_SIZE <= 4096 +#elif Z_SRAM_SIZE <= 4096 #define REGION_SRAM_SIZE REGION_4M -#elif CONFIG_SRAM_SIZE <= 8192 +#elif Z_SRAM_SIZE <= 8192 #define REGION_SRAM_SIZE REGION_8M -#elif CONFIG_SRAM_SIZE <= 16384 +#elif Z_SRAM_SIZE <= 16384 #define REGION_SRAM_SIZE REGION_16M -#elif CONFIG_SRAM_SIZE <= 32768 +#elif Z_SRAM_SIZE <= 32768 #define REGION_SRAM_SIZE REGION_32M -#elif CONFIG_SRAM_SIZE <= 65536 +#elif Z_SRAM_SIZE <= 65536 #define REGION_SRAM_SIZE REGION_64M -#elif CONFIG_SRAM_SIZE <= 131072 +#elif Z_SRAM_SIZE <= 131072 #define REGION_SRAM_SIZE REGION_128M -#elif CONFIG_SRAM_SIZE <= 262144 +#elif Z_SRAM_SIZE <= 262144 #define REGION_SRAM_SIZE REGION_256M -#elif CONFIG_SRAM_SIZE <= 524288 +#elif Z_SRAM_SIZE <= 524288 #define REGION_SRAM_SIZE REGION_512M -#elif CONFIG_SRAM_SIZE <= 1048576 +#elif Z_SRAM_SIZE <= 1048576 #define REGION_SRAM_SIZE REGION_1G -#elif CONFIG_SRAM_SIZE <= 2097152 +#elif Z_SRAM_SIZE <= 2097152 #define REGION_SRAM_SIZE REGION_2G -#elif CONFIG_SRAM_SIZE <= 4194304 +#elif Z_SRAM_SIZE <= 4194304 #define REGION_SRAM_SIZE REGION_4G #else #error "Unsupported sram size configuration" #endif +#undef Z_SRAM_SIZE + /* Define Wrong value */ #define REGION_SIZE_UNSUPPORTED -1 diff --git a/include/zephyr/arch/arm64/scripts/linker.ld b/include/zephyr/arch/arm64/scripts/linker.ld index 93c8b2f5db64..cc87826d4918 100644 --- a/include/zephyr/arch/arm64/scripts/linker.ld +++ b/include/zephyr/arch/arm64/scripts/linker.ld @@ -49,8 +49,8 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #if defined(CONFIG_ARM_MMU) _region_min_align = CONFIG_MMU_PAGE_SIZE; diff --git a/include/zephyr/arch/mips/linker.ld b/include/zephyr/arch/mips/linker.ld index e82d756bdee8..66e865b34799 100644 --- a/include/zephyr/arch/mips/linker.ld +++ b/include/zephyr/arch/mips/linker.ld @@ -22,9 +22,12 @@ #define _EXCEPTION_SECTION_NAME exceptions #define _RESET_SECTION_NAME reset +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE + MEMORY { - RAM (rwx) : ORIGIN = CONFIG_SRAM_BASE_ADDRESS, LENGTH = KB(CONFIG_SRAM_SIZE) + RAM (rwx) : ORIGIN = RAM_BASE, LENGTH = RAM_SIZE /* Used by and documented in include/linker/intlist.ld */ IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K } @@ -37,9 +40,9 @@ REGION_ALIAS("REGION_BSS", RAM); ENTRY(CONFIG_KERNEL_ENTRY) -PROVIDE (__memory_base = CONFIG_SRAM_BASE_ADDRESS); -PROVIDE (__memory_size = CONFIG_SRAM_SIZE * 1024); -PROVIDE (__stack = CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE - 1) * 1024); +PROVIDE (__memory_base = RAM_BASE); +PROVIDE (__memory_size = RAM_SIZE); +PROVIDE (__stack = RAM_BASE + (RAM_SIZE - 1024)); SECTIONS { diff --git a/include/zephyr/arch/openrisc/linker.ld b/include/zephyr/arch/openrisc/linker.ld index 6b2357b02d61..e840dafde3dc 100644 --- a/include/zephyr/arch/openrisc/linker.ld +++ b/include/zephyr/arch/openrisc/linker.ld @@ -38,8 +38,8 @@ #define ROM_SIZE (CONFIG_FLASH_SIZE * 1024) #endif -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_BASE CONFIG_SRAM_BASE_ADDRESS +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #define _EXCEPTION_SECTION_NAME exception @@ -57,9 +57,9 @@ MEMORY ENTRY(CONFIG_KERNEL_ENTRY) -PROVIDE (__memory_base = CONFIG_SRAM_BASE_ADDRESS); -PROVIDE (__memory_size = CONFIG_SRAM_SIZE * 1024); -PROVIDE (__stack = CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE - 1) * 1024); +PROVIDE (__memory_base = RAM_BASE); +PROVIDE (__memory_size = RAM_SIZE); +PROVIDE (__stack = RAM_BASE + (RAM_SIZE - 1024)); SECTIONS { diff --git a/include/zephyr/arch/riscv/common/linker.ld b/include/zephyr/arch/riscv/common/linker.ld index ac6015b88746..d272f621be5f 100644 --- a/include/zephyr/arch/riscv/common/linker.ld +++ b/include/zephyr/arch/riscv/common/linker.ld @@ -82,13 +82,13 @@ #endif /* DT_NODE_HAS_COMPAT_STATUS */ #else /* CONFIG_XIP */ -#define ROM_BASE CONFIG_SRAM_BASE_ADDRESS -#define ROM_SIZE (KB(CONFIG_SRAM_SIZE) - ROM_END_OFFSET) +#define ROM_BASE DT_CHOSEN_SRAM_ADDR +#define ROM_SIZE (DT_CHOSEN_SRAM_SIZE - ROM_END_OFFSET) #endif /* CONFIG_XIP */ #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) */ -#define RAM_BASE CONFIG_SRAM_BASE_ADDRESS -#define RAM_SIZE KB(CONFIG_SRAM_SIZE) +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #ifdef CONFIG_RISCV_PMP #define MPU_MIN_SIZE CONFIG_PMP_GRANULARITY diff --git a/include/zephyr/arch/rx/linker.ld b/include/zephyr/arch/rx/linker.ld index 91d81612eb56..c09459a6eff1 100644 --- a/include/zephyr/arch/rx/linker.ld +++ b/include/zephyr/arch/rx/linker.ld @@ -45,8 +45,8 @@ #endif #endif -#define RAM_START (CONFIG_SRAM_BASE_ADDRESS) -#define RAM_SIZE (KB(CONFIG_SRAM_SIZE)) +#define RAM_START DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE _region_min_align = 4; @@ -230,7 +230,7 @@ SECTIONS _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); #endif /* CONFIG_USERSPACE */ - #if CONFIG_SRAM_BASE_ADDRESS == 0 + #if DT_CHOSEN_SRAM_ADDR == 0 /* RX memory starts at address 0 which can be confused with NULL. To prevent this, block * the first memory page (16 Bytes). */ diff --git a/include/zephyr/arch/x86/memory.ld b/include/zephyr/arch/x86/memory.ld index 3e2c0b693527..8dfc636be511 100644 --- a/include/zephyr/arch/x86/memory.ld +++ b/include/zephyr/arch/x86/memory.ld @@ -37,7 +37,7 @@ /* Virtual base address for the kernel; with CONFIG_MMU this is not necessarily * the same as its physical location, although an identity mapping for RAM - * is still supported by setting CONFIG_KERNEL_VM_BASE=CONFIG_SRAM_BASE_ADDRESS. + * is still supported by setting CONFIG_KERNEL_VM_BASE=DT_CHOSEN_SRAM_ADDR. */ #ifdef K_MEM_IS_VM_KERNEL #define KERNEL_BASE_ADDR (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) diff --git a/include/zephyr/kernel/internal/mm.h b/include/zephyr/kernel/internal/mm.h index cd5927e1c062..7b7cc9a1b6bd 100644 --- a/include/zephyr/kernel/internal/mm.h +++ b/include/zephyr/kernel/internal/mm.h @@ -9,6 +9,7 @@ #include #include +#include /** * @defgroup kernel_mm_internal_apis Kernel Memory Management Internal APIs @@ -26,7 +27,7 @@ * virt_addr = phys_addr + K_MEM_VIRT_OFFSET * * This only works for virtual addresses within the interval - * [CONFIG_KERNEL_VM_BASE, CONFIG_KERNEL_VM_BASE + (CONFIG_SRAM_SIZE * 1024)). + * [CONFIG_KERNEL_VM_BASE, CONFIG_KERNEL_VM_BASE + DT_CHOSEN_SRAM_ADDR). * * These macros are intended for assembly, linker code, and static initializers. * Use with care. @@ -39,22 +40,20 @@ */ #ifdef CONFIG_MMU #define K_MEM_VIRT_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ - (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET)) + (DT_CHOSEN_SRAM_ADDR + CONFIG_SRAM_OFFSET)) #else #define K_MEM_VIRT_OFFSET 0 #endif /* CONFIG_MMU */ -#if CONFIG_SRAM_BASE_ADDRESS != 0 -#define IS_SRAM_ADDRESS_LOWER(ADDR) ((ADDR) >= CONFIG_SRAM_BASE_ADDRESS) +#if DT_CHOSEN_SRAM_ADDR != 0 +#define IS_SRAM_ADDRESS_LOWER(ADDR) ((ADDR) >= DT_CHOSEN_SRAM_ADDR) #else #define IS_SRAM_ADDRESS_LOWER(ADDR) true -#endif /* CONFIG_SRAM_BASE_ADDRESS != 0 */ +#endif /* DT_CHOSEN_SRAM_ADDR != 0 */ - -#if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0 +#if (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE) != 0 #define IS_SRAM_ADDRESS_UPPER(ADDR) \ - ((ADDR) < (CONFIG_SRAM_BASE_ADDRESS + \ - (CONFIG_SRAM_SIZE * 1024UL))) + ((ADDR) < (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE)) #else #define IS_SRAM_ADDRESS_UPPER(ADDR) false #endif diff --git a/include/zephyr/linker/linker-tool-gcc.h b/include/zephyr/linker/linker-tool-gcc.h index d21524bc5420..f5b972d67ac3 100644 --- a/include/zephyr/linker/linker-tool-gcc.h +++ b/include/zephyr/linker/linker-tool-gcc.h @@ -83,7 +83,7 @@ * the memory area specified by 'where' argument. * * This macro is intentionally undefined for CONFIG_MMU systems when - * CONFIG_KERNEL_VM_BASE is not the same as CONFIG_SRAM_BASE_ADDRESS, + * CONFIG_KERNEL_VM_BASE is not the same as DT_CHOSEN_SRAM_ADDR, * as both the LMA and VMA destinations must be known for all sections * as this corresponds to physical vs. virtual location. * diff --git a/include/zephyr/sys/mem_manage.h b/include/zephyr/sys/mem_manage.h index a05b72d3886e..ab55a1f9ede1 100644 --- a/include/zephyr/sys/mem_manage.h +++ b/include/zephyr/sys/mem_manage.h @@ -23,9 +23,9 @@ * * This checks if the physical address (@p virt) is within * permissible range, e.g. between - * :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` and - * (:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + - * :kconfig:option:`CONFIG_SRAM_SIZE`). + * :c:macro:`DT_CHOSEN_SRAM_ADDR` and + * (:c:macro:`DT_CHOSEN_SRAM_ADDR` + + * :c:macro:`DT_CHOSEN_SRAM_SIZE`). * * @note Only used if * :kconfig:option:`CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK` From 4439dd025b98d1ff7012a15674bce161ee61559b Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:48:42 +0100 Subject: [PATCH 11/23] [nrf fromtree] lib: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit a036c6ab5bb39c65c3e7408f6de9c61c27ab8906) --- lib/heap/Kconfig | 6 +++++- lib/libc/common/source/stdlib/malloc.c | 4 ++-- lib/libc/newlib/libc-hooks.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index b9e6371fabff..18976e4ffec7 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -157,10 +157,14 @@ module = SYS_HEAP module-str = sys_heap source "subsys/logging/Kconfig.template.log_config" +DT_CHOSEN_Z_SRAM = zephyr,sram +DT_SRAM_SIZE = $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) + choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) + default SYS_HEAP_SMALL_ONLY if ((SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 256) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(DT_SRAM_SIZE) <= 256)) default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 74193fbdce48..7cfeadd00b71 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -106,8 +106,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ - ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((size_t) DT_CHOSEN_SRAM_SIZE - \ + ((size_t) HEAP_BASE - (size_t) DT_CHOSEN_SRAM_ADDR), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index 55c109d8fe84..f7cd15da0324 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -111,8 +111,8 @@ int _getpid(void); #define MAX_HEAP_SIZE (POINTER_TO_UINT(&_heap_sentry) - \ HEAP_BASE) #else - #define MAX_HEAP_SIZE (KB(CONFIG_SRAM_SIZE) - (HEAP_BASE - \ - CONFIG_SRAM_BASE_ADDRESS)) + #define MAX_HEAP_SIZE (DT_CHOSEN_SRAM_SIZE - (HEAP_BASE - \ + DT_CHOSEN_SRAM_ADDR)) #endif /* CONFIG_XTENSA */ #endif From fe71db7b8073e80844690c341fb99d201e3a4c68 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:49:01 +0100 Subject: [PATCH 12/23] [nrf fromtree] drivers: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit ceb26f67f0a0f66a317de89d2bf08a3d68d36ffc) --- drivers/cache/cache_aspeed.c | 4 ++-- drivers/spi/spi_egis_et171.c | 5 +++-- drivers/usb/device/usb_dc_smartbond.c | 2 +- drivers/usb/udc/udc_smartbond.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/cache/cache_aspeed.c b/drivers/cache/cache_aspeed.c index b8fe9a81880b..c8b68510cbb5 100644 --- a/drivers/cache/cache_aspeed.c +++ b/drivers/cache/cache_aspeed.c @@ -23,8 +23,8 @@ #define CACHE_INVALID_REG 0xa54 #define CACHE_FUNC_CTRL_REG 0xa58 -#define CACHED_SRAM_ADDR CONFIG_SRAM_BASE_ADDRESS -#define CACHED_SRAM_SIZE KB(CONFIG_SRAM_SIZE) +#define CACHED_SRAM_ADDR DT_CHOSEN_SRAM_ADDR +#define CACHED_SRAM_SIZE DT_CHOSEN_SRAM_SIZE #define CACHED_SRAM_END (CACHED_SRAM_ADDR + CACHED_SRAM_SIZE - 1) #define CACHE_AREA_SIZE_LOG2 15 diff --git a/drivers/spi/spi_egis_et171.c b/drivers/spi/spi_egis_et171.c index ab0d61520d01..0a12b5528ab2 100644 --- a/drivers/spi/spi_egis_et171.c +++ b/drivers/spi/spi_egis_et171.c @@ -16,8 +16,9 @@ typedef void (*et171_cfg_func_t)(void); #ifdef CONFIG_CACHE_MANAGEMENT #include #define IS_ALIGN(x) (((uintptr_t)(x) & (sys_cache_data_line_size_get() - 1)) == 0) -#define DRAM_START CONFIG_SRAM_BASE_ADDRESS -#define DRAM_SIZE KB(CONFIG_SRAM_SIZE) + +#define DRAM_START DT_CHOSEN_SRAM_ADDR +#define DRAM_SIZE DT_CHOSEN_SRAM_SIZE #define DRAM_END (DRAM_START + DRAM_SIZE - 1) #define IS_ADDR_IN_RAM(addr) (((addr) >= DRAM_START) && ((addr) <= DRAM_END)) #endif diff --git a/drivers/usb/device/usb_dc_smartbond.c b/drivers/usb/device/usb_dc_smartbond.c index 21a2f5fc8177..60990d00946f 100644 --- a/drivers/usb/device/usb_dc_smartbond.c +++ b/drivers/usb/device/usb_dc_smartbond.c @@ -505,7 +505,7 @@ static void start_tx_packet(struct smartbond_ep_state *ep_state) if (ep_state->ep_addr != EP0_IN && remaining > DMA_MIN_TRANSFER_SIZE && - (uint32_t)(ep_state->buffer) >= CONFIG_SRAM_BASE_ADDRESS && + (uint32_t)(ep_state->buffer) >= DT_CHOSEN_SRAM_ADDR && try_allocate_dma(ep_state, USB_EP_DIR_IN)) { /* * Whole packet will be put in FIFO by DMA. diff --git a/drivers/usb/udc/udc_smartbond.c b/drivers/usb/udc/udc_smartbond.c index 1e64470e02a4..3e7445e9c2bd 100644 --- a/drivers/usb/udc/udc_smartbond.c +++ b/drivers/usb/udc/udc_smartbond.c @@ -431,7 +431,7 @@ static void start_tx_packet(struct usb_smartbond_data *data, struct smartbond_ep } if (ep != USB_CONTROL_EP_IN && size > config->dma_min_transfer_size && - (uint32_t)(buf->data) >= CONFIG_SRAM_BASE_ADDRESS && try_allocate_dma(data, ep_state)) { + (uint32_t)(buf->data) >= DT_CHOSEN_SRAM_ADDR && try_allocate_dma(data, ep_state)) { start_tx_dma(&config->dma_cfg, (uintptr_t)buf->data, (uintptr_t)®s->txd, size); } else { fill_tx_fifo(ep_state); From 6810ff182734f633f546846339277547506d3585 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:49:11 +0100 Subject: [PATCH 13/23] [nrf fromtree] kernel: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 1d935da7002997d8fd2eacd18af4c728d4869c7d) --- kernel/include/mmu.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/include/mmu.h b/kernel/include/mmu.h index e4a9f84d334a..f3b4b5f370e9 100644 --- a/kernel/include/mmu.h +++ b/kernel/include/mmu.h @@ -14,12 +14,13 @@ #include #include #include +#include /** Start address of physical memory. */ -#define K_MEM_PHYS_RAM_START ((uintptr_t)CONFIG_SRAM_BASE_ADDRESS) +#define K_MEM_PHYS_RAM_START ((uintptr_t)DT_CHOSEN_SRAM_ADDR) /** Size of physical memory. */ -#define K_MEM_PHYS_RAM_SIZE (KB(CONFIG_SRAM_SIZE)) +#define K_MEM_PHYS_RAM_SIZE DT_CHOSEN_SRAM_SIZE /** End address (exclusive) of physical memory. */ #define K_MEM_PHYS_RAM_END (K_MEM_PHYS_RAM_START + K_MEM_PHYS_RAM_SIZE) @@ -49,7 +50,7 @@ */ #define K_MEM_VM_OFFSET \ ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ - (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET)) + (K_MEM_PHYS_RAM_START + CONFIG_SRAM_OFFSET)) /** * @brief Get physical address from virtual address for boot RAM mappings. @@ -87,7 +88,7 @@ * * - If it is enabled, which means all physical memory are mapped in virtual * memory address space, and it is the same as - * (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE). + * (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE). * * - If it is disabled, K_MEM_VM_FREE_START is the same K_MEM_KERNEL_VIRT_END which * is the end of the kernel image. @@ -113,8 +114,8 @@ * @brief Number of page frames. * * At present, page frame management is only done for main system RAM, - * and we generate paging structures based on CONFIG_SRAM_BASE_ADDRESS - * and CONFIG_SRAM_SIZE. + * and we generate paging structures based on DT_CHOSEN_SRAM_ADDR + * and DT_CHOSEN_SRAM_SIZE. * * If we have other RAM regions (DCCM, etc) these typically have special * properties and shouldn't be used generically for demand paging or From c7483e9786404ce69f961e786112b94f8e7fa6de Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:50:08 +0100 Subject: [PATCH 14/23] [nrf fromtree] soc: nordic: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 831e1ea3a227d41ff6459751c786eb51f2ba5d40) --- soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c b/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c index 303fdf8ac8ae..62d4af22bbf8 100644 --- a/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c +++ b/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c @@ -22,6 +22,9 @@ #define SOFTPERIPH_BASE DT_REG_ADDR(DT_NODELABEL(softperiph_ram)) #define SOFTPERIPH_SIZE DT_REG_SIZE(DT_NODELABEL(softperiph_ram)) +#define RAM_BASE DT_REG_ADDR(DT_CHOSEN(zephyr_sram)) +#define RAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) + static struct arm_mpu_region mpu_regions[] = { #ifdef CONFIG_XIP MPU_REGION_ENTRY("FLASH_0", @@ -30,9 +33,8 @@ static struct arm_mpu_region mpu_regions[] = { CONFIG_FLASH_SIZE * 1024)), #endif MPU_REGION_ENTRY("SRAM_0", - CONFIG_SRAM_BASE_ADDRESS, - REGION_RAM_ATTR(CONFIG_SRAM_BASE_ADDRESS, - CONFIG_SRAM_SIZE * 1024)), + RAM_BASE, + REGION_RAM_ATTR(RAM_BASE, RAM_SIZE)), #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usbhs)) MPU_REGION_ENTRY("USBHS_CORE", USBHS_BASE, From ed71dd10c568dbe478e02dc477642ae797f46bbc Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:54:05 +0100 Subject: [PATCH 15/23] [nrf fromtree] boards: qemu: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 387b9042302a64a50dd80da721b0e3342b94eeb1) --- boards/qemu/x86/board.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/boards/qemu/x86/board.cmake b/boards/qemu/x86/board.cmake index e8a4758f1303..b4a6530f3d5b 100644 --- a/boards/qemu/x86/board.cmake +++ b/boards/qemu/x86/board.cmake @@ -20,15 +20,23 @@ else() set(QEMU_CPU_TYPE_${ARCH} qemu32,+nx,+pae) endif() +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR RAM_SIZE "${CONFIG_SRAM_SIZE} / 1024" OUTPUT_FORMAT HEXADECIMAL) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_size(RAM_SIZE PATH "${chosen_sram_path}") + math(EXPR RAM_SIZE "${RAM_SIZE} / 1024 / 1024" OUTPUT_FORMAT HEXADECIMAL) +endif() + if(CONFIG_XIP) # Extra 4MB to emulate flash area - math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024 + 4") + math(EXPR QEMU_MEMORY_SIZE_MB "${RAM_SIZE} + 4") elseif(CONFIG_BOARD_QEMU_X86_TINY AND CONFIG_DEMAND_PAGING AND NOT CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT) # Flash is at 4MB-8MB, so need this to be large enough math(EXPR QEMU_MEMORY_SIZE_MB "8") else() - math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024") + math(EXPR QEMU_MEMORY_SIZE_MB "${RAM_SIZE}") endif() set(QEMU_CPU_FLAGS "") From a68165aa6a9fde75d9447a5292f5a5cde53dfb74 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:54:18 +0100 Subject: [PATCH 16/23] [nrf fromtree] tests: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit 46cde6837d77043be4558813406852f86afeb225) --- .../code_relocation/linker_arm_sram2.ld | 8 ++++--- .../linker_riscv_qemu_sram2.ld | 7 +++--- .../linker_xtensa_qemu_sram2.ld | 4 ++-- .../ram_context_for_isr/src/main.c | 16 ++++++------- .../vector_table_relocation/src/main.c | 4 ++-- .../arm64_high_addresses/high_address.overlay | 3 +++ .../arm64_high_addresses/low_address.overlay | 3 +++ .../arm64/arm64_high_addresses/testcase.yaml | 24 ++++++++++++------- tests/arch/x86/pagetables/src/main.c | 4 +++- tests/benchmarks/sys_kernel/src/syskernel.h | 4 +++- tests/boot/uefi/app.overlay | 3 +++ tests/boot/uefi/prj.conf | 1 - tests/drivers/disk/disk_access/src/main.c | 6 +++-- .../drivers/disk/disk_performance/src/main.c | 6 +++-- tests/drivers/tee/optee/app.overlay | 14 +++++++++++ .../tee/optee/boards/native_sim_64.overlay | 14 +++++++++++ tests/drivers/tee/optee/prj.conf | 1 - .../mem_map/boards/qemu_cortex_a53.conf | 1 - .../mem_map/boards/qemu_cortex_a53.overlay | 3 +++ .../mem_map/boards/qemu_cortex_a53_smp.conf | 1 - .../boards/qemu_cortex_a53_smp.overlay | 3 +++ .../src/test_priority_scheduling.c | 6 +++-- .../schedule_api/src/test_slice_scheduling.c | 4 ++-- tests/kernel/timer/timer_behavior/Kconfig | 17 +++++++++---- tests/lib/heap/src/main.c | 6 ++--- 25 files changed, 114 insertions(+), 49 deletions(-) create mode 100644 tests/arch/arm64/arm64_high_addresses/high_address.overlay create mode 100644 tests/arch/arm64/arm64_high_addresses/low_address.overlay create mode 100644 tests/boot/uefi/app.overlay create mode 100644 tests/drivers/tee/optee/app.overlay create mode 100644 tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay create mode 100644 tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay diff --git a/tests/application_development/code_relocation/linker_arm_sram2.ld b/tests/application_development/code_relocation/linker_arm_sram2.ld index deb2c6f5aca6..91fb21dd0db3 100644 --- a/tests/application_development/code_relocation/linker_arm_sram2.ld +++ b/tests/application_development/code_relocation/linker_arm_sram2.ld @@ -25,14 +25,16 @@ #define _SRAM2_DATA_SECTION_NAME .sram2_data #define _SRAM2_BSS_SECTION_NAME .sram2_bss #define _SRAM2_TEXT_SECTION_NAME .sram2_text - #define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) + + #define SRAM2_ADDR (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) #endif -#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512) +#define RAM_SIZE2 (DT_CHOSEN_SRAM_SIZE / 2) + MEMORY { #ifdef CONFIG_SRAM2 - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = SRAM2_ADDR, LENGTH = RAM_SIZE2 #endif } diff --git a/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld b/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld index cf59a6aad69c..9c0e57c742a5 100644 --- a/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld +++ b/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld @@ -16,12 +16,13 @@ #define _SRAM2_DATA_SECTION_NAME .sram2_data #define _SRAM2_BSS_SECTION_NAME .sram2_bss #define _SRAM2_TEXT_SECTION_NAME .sram2_text -#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) -#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512) +#define RAM_SIZE2 (DT_CHOSEN_SRAM_SIZE / 2) +#define RAM_BASE2 (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) + MEMORY { - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = RAM_BASE2, LENGTH = RAM_SIZE2 } #include diff --git a/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld b/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld index 3fd33186a8f4..1526d2e580ae 100644 --- a/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld +++ b/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld @@ -10,12 +10,12 @@ #include #include -#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) #define RAM_SIZE2 (0x4000000) +#define SRAM2_ADDR (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) MEMORY { - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = SRAM2_ADDR, LENGTH = RAM_SIZE2 } PHDRS diff --git a/tests/application_development/ram_context_for_isr/src/main.c b/tests/application_development/ram_context_for_isr/src/main.c index 64955e7e2a2f..b06ea584ee69 100644 --- a/tests/application_development/ram_context_for_isr/src/main.c +++ b/tests/application_development/ram_context_for_isr/src/main.c @@ -37,17 +37,17 @@ static void test_irq_callback(const struct device *dev, void *user_data) driver_isr_addr = (uintptr_t)user_data; /* Check that the function and its call stack are in RAM */ - zassert_true(func_addr >= CONFIG_SRAM_BASE_ADDRESS && - func_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(func_addr >= DT_CHOSEN_SRAM_ADDR && + func_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "%s is not in RAM! Address: 0x%lx", __func__, func_addr); - zassert_true(driver_isr_addr >= CONFIG_SRAM_BASE_ADDRESS && - driver_isr_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(driver_isr_addr >= DT_CHOSEN_SRAM_ADDR && + driver_isr_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "fake_driver_isr is not in RAM! Address: 0x%lx", driver_isr_addr); - zassert_true(arch_isr_wrapper_addr >= CONFIG_SRAM_BASE_ADDRESS && + zassert_true(arch_isr_wrapper_addr >= DT_CHOSEN_SRAM_ADDR && arch_isr_wrapper_addr <= - CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "arch_isr_wrapper_addr is not in RAM! Address: 0x%lx", arch_isr_wrapper_addr); TC_PRINT("Callback function address: 0x%lx\n", func_addr); @@ -61,8 +61,8 @@ ZTEST(ram_context_for_isr, test_fake_driver_in_ram) const struct fake_driver_api *api = DEVICE_API_GET(fake, dev); uintptr_t dev_addr = (uintptr_t)dev; - zassert_true(dev_addr >= CONFIG_SRAM_BASE_ADDRESS && - dev_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(dev_addr >= DT_CHOSEN_SRAM_ADDR && + dev_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "fake driver device is not in RAM! Address: 0x%lx", dev_addr); TC_PRINT("Fake driver device address: 0x%lx\n", dev_addr); diff --git a/tests/application_development/vector_table_relocation/src/main.c b/tests/application_development/vector_table_relocation/src/main.c index 5de58fcb43bf..c21bab03f145 100644 --- a/tests/application_development/vector_table_relocation/src/main.c +++ b/tests/application_development/vector_table_relocation/src/main.c @@ -22,8 +22,8 @@ #define SRAM_VT_BASE DT_REG_ADDR(ITCM_NODE) #define SRAM_VT_SIZE DT_REG_SIZE(ITCM_NODE) #else -#define SRAM_VT_BASE CONFIG_SRAM_BASE_ADDRESS -#define SRAM_VT_SIZE (CONFIG_SRAM_SIZE * 1024U) +#define SRAM_VT_BASE DT_CHOSEN_SRAM_ADDR +#define SRAM_VT_SIZE DT_CHOSEN_SRAM_SIZE #endif #ifdef SCB_VTOR_TBLBASE_Msk diff --git a/tests/arch/arm64/arm64_high_addresses/high_address.overlay b/tests/arch/arm64/arm64_high_addresses/high_address.overlay new file mode 100644 index 000000000000..21a335fe5708 --- /dev/null +++ b/tests/arch/arm64/arm64_high_addresses/high_address.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x2 0x00880000 0x0 0x80000>; +}; diff --git a/tests/arch/arm64/arm64_high_addresses/low_address.overlay b/tests/arch/arm64/arm64_high_addresses/low_address.overlay new file mode 100644 index 000000000000..11e27cae9abf --- /dev/null +++ b/tests/arch/arm64/arm64_high_addresses/low_address.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x400000 0x0 0x80000>; +}; diff --git a/tests/arch/arm64/arm64_high_addresses/testcase.yaml b/tests/arch/arm64/arm64_high_addresses/testcase.yaml index 9b09f9745a61..fe350f2f0261 100644 --- a/tests/arch/arm64/arm64_high_addresses/testcase.yaml +++ b/tests/arch/arm64/arm64_high_addresses/testcase.yaml @@ -10,48 +10,56 @@ common: tests: arch.arm64.high_addr.high_sram_low_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x00400000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.low_sram_high_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x00400000 - CONFIG_KERNEL_VM_BASE=0x200880000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="low_address.overlay" arch.arm64.high_addr.high_sram_equal_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200880000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_high_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200800000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_low_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x00400000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.low_sram_high_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x00400000 - CONFIG_KERNEL_VM_BASE=0x200880000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="low_address.overlay" arch.arm64.high_addr.high_sram_equal_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200880000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_high_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200800000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" diff --git a/tests/arch/x86/pagetables/src/main.c b/tests/arch/x86/pagetables/src/main.c index c75c73bfbec4..c1f0d9cbffc6 100644 --- a/tests/arch/x86/pagetables/src/main.c +++ b/tests/arch/x86/pagetables/src/main.c @@ -242,9 +242,11 @@ void z_vrfy_dump_my_ptables(void) #include #endif /* CONFIG_USERSPACE */ +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + void dump_pagetables(void) { -#if CONFIG_SRAM_SIZE > (32 << 10) +#if RAM_SIZE > (32 << 10) /* * Takes too long to dump page table, so skip dumping * if memory size is larger than 32MB. diff --git a/tests/benchmarks/sys_kernel/src/syskernel.h b/tests/benchmarks/sys_kernel/src/syskernel.h index f12c2ea21d73..d8827ee60644 100644 --- a/tests/benchmarks/sys_kernel/src/syskernel.h +++ b/tests/benchmarks/sys_kernel/src/syskernel.h @@ -15,7 +15,9 @@ #include #define STACK_SIZE 2048 -#if CONFIG_SRAM_SIZE <= 32 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE <= 32 #define NUMBER_OF_LOOPS 100 #else #define NUMBER_OF_LOOPS 1000 diff --git a/tests/boot/uefi/app.overlay b/tests/boot/uefi/app.overlay new file mode 100644 index 000000000000..3867176dbcda --- /dev/null +++ b/tests/boot/uefi/app.overlay @@ -0,0 +1,3 @@ +&dram0 { + reg = <0x0 0xc800000>; +}; diff --git a/tests/boot/uefi/prj.conf b/tests/boot/uefi/prj.conf index 48ca509cdd56..5ba848d79bef 100644 --- a/tests/boot/uefi/prj.conf +++ b/tests/boot/uefi/prj.conf @@ -1,4 +1,3 @@ CONFIG_QEMU_UEFI_BOOT=y CONFIG_BUILD_OUTPUT_EFI=y -CONFIG_SRAM_SIZE=204800 CONFIG_ACPI=y diff --git a/tests/drivers/disk/disk_access/src/main.c b/tests/drivers/disk/disk_access/src/main.c index fa891e946829..bca4dc991cb8 100644 --- a/tests/drivers/disk/disk_access/src/main.c +++ b/tests/drivers/disk/disk_access/src/main.c @@ -37,7 +37,9 @@ #error "No disk device defined, is your board supported?" #endif -#if CONFIG_SRAM_SIZE >= 512 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE >= 512 /* Cap buffer size at 128 KiB */ #define MAX_TOTAL_BUF_SIZE 128 #elif CONFIG_SOC_POSIX @@ -45,7 +47,7 @@ #define MAX_TOTAL_BUF_SIZE 128 #else /* Use half of all SRAM */ -#define MAX_TOTAL_BUF_SIZE (CONFIG_SRAM_SIZE / 2) +#define MAX_TOTAL_BUF_SIZE (RAM_SIZE / 2) #endif #define BUF_SIZE ((MAX_TOTAL_BUF_SIZE * 1024) / 2) diff --git a/tests/drivers/disk/disk_performance/src/main.c b/tests/drivers/disk/disk_performance/src/main.c index d10968535f6d..3e79e4186900 100644 --- a/tests/drivers/disk/disk_performance/src/main.c +++ b/tests/drivers/disk/disk_performance/src/main.c @@ -24,7 +24,9 @@ #error "No disk device defined, is your board supported?" #endif -#if CONFIG_SRAM_SIZE >= 512 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE >= 512 /* Cap buffer size at 128 KiB */ #define MAX_TOTAL_BUF_SIZE 128 #elif CONFIG_SOC_POSIX @@ -32,7 +34,7 @@ #define MAX_TOTAL_BUF_SIZE 128 #else /* Use half of all SRAM */ -#define MAX_TOTAL_BUF_SIZE (CONFIG_SRAM_SIZE / 2) +#define MAX_TOTAL_BUF_SIZE (RAM_SIZE / 2) #endif #define BUF_SIZE ((MAX_TOTAL_BUF_SIZE * 1024) / 2) diff --git a/tests/drivers/tee/optee/app.overlay b/tests/drivers/tee/optee/app.overlay new file mode 100644 index 000000000000..0a472c90132e --- /dev/null +++ b/tests/drivers/tee/optee/app.overlay @@ -0,0 +1,14 @@ +/ { + chosen { + zephyr,sram = &sram0; + }; +}; + +&soc { + sram0: memory@0 { + compatible = "mmio-sram"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x80000000>; + }; +}; diff --git a/tests/drivers/tee/optee/boards/native_sim_64.overlay b/tests/drivers/tee/optee/boards/native_sim_64.overlay index 65ceec3f5fb2..9276c56cfa53 100644 --- a/tests/drivers/tee/optee/boards/native_sim_64.overlay +++ b/tests/drivers/tee/optee/boards/native_sim_64.overlay @@ -10,4 +10,18 @@ status = "okay"; }; }; + + chosen { + zephyr,sram = &sram0; + }; + + soc { + #address-cells = <1>; + #size-cells = <2>; + + sram0: memory@0 { + compatible = "mmio-sram"; + reg = <0x0 0x20ffbe6 0xe4000000>; + }; + }; }; diff --git a/tests/drivers/tee/optee/prj.conf b/tests/drivers/tee/optee/prj.conf index 7550829f1dd3..6df8e7992066 100644 --- a/tests/drivers/tee/optee/prj.conf +++ b/tests/drivers/tee/optee/prj.conf @@ -3,4 +3,3 @@ CONFIG_BOOT_BANNER=n CONFIG_HEAP_MEM_POOL_SIZE=270044 CONFIG_TEE=y CONFIG_OPTEE=y -CONFIG_SRAM_SIZE=145131134582784 diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf index 6da2825758a4..a66a33df93c7 100644 --- a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf @@ -3,4 +3,3 @@ CONFIG_BACKING_STORE_RAM=y CONFIG_BACKING_STORE_RAM_PAGES=24 -CONFIG_SRAM_SIZE=456 diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay new file mode 100644 index 000000000000..3ba24b9fb01b --- /dev/null +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x72000>; +}; diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf index 1ce923d0cbb9..bc16db15e462 100644 --- a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf @@ -3,5 +3,4 @@ CONFIG_BACKING_STORE_RAM=y CONFIG_BACKING_STORE_RAM_PAGES=24 -CONFIG_SRAM_SIZE=560 CONFIG_DEMAND_PAGING_ALLOW_IRQ=y diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay new file mode 100644 index 000000000000..df9069553ee6 --- /dev/null +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x8c000>; +}; diff --git a/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c b/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c index 7d72b54c0d6f..e0aebf988e17 100644 --- a/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c +++ b/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c @@ -7,10 +7,12 @@ #include #include "test_sched.h" +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + /* nrf 51 has lower ram, so creating less number of threads */ -#if CONFIG_SRAM_SIZE <= 24 +#if RAM_SIZE <= 24 #define NUM_THREAD 2 -#elif (CONFIG_SRAM_SIZE <= 32) \ +#elif (RAM_SIZE <= 32) \ || defined(CONFIG_SOC_EMSK_EM7D) #define NUM_THREAD 3 #else diff --git a/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c b/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c index a65e7dcb3c7e..a301d07200b4 100644 --- a/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c +++ b/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c @@ -10,9 +10,9 @@ #ifdef CONFIG_TIMESLICING /* nrf 51 has lower ram, so creating less number of threads */ -#if CONFIG_SRAM_SIZE <= 24 +#if (DT_CHOSEN_SRAM_SIZE / 1024) <= 24 #define NUM_THREAD 2 -#elif (CONFIG_SRAM_SIZE <= 32) \ +#elif ((DT_CHOSEN_SRAM_SIZE / 1024) <= 32) \ || defined(CONFIG_SOC_EMSK_EM7D) #define NUM_THREAD 3 #else diff --git a/tests/kernel/timer/timer_behavior/Kconfig b/tests/kernel/timer/timer_behavior/Kconfig index 520354416762..cd4890c5d906 100644 --- a/tests/kernel/timer/timer_behavior/Kconfig +++ b/tests/kernel/timer/timer_behavior/Kconfig @@ -8,13 +8,20 @@ config SYS_CLOCK_TICKS_PER_SEC source "Kconfig.zephyr" +DT_CHOSEN_Z_SRAM = zephyr,sram + config TIMER_TEST_SAMPLES int "The number of timer samples to gather for statistics" - default 1000 if (SRAM_SIZE <= 24) - default 2000 if (SRAM_SIZE <= 32) - default 3000 if (SRAM_SIZE <= 48) - default 5000 if (SRAM_SIZE <= 64) - default 7000 if (SRAM_SIZE <= 96) + default 1000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 24) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 24) + default 2000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 32) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 32) + default 3000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 48) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 48) + default 5000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 64) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 64) + default 7000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 96) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 96) default 10000 config TIMER_TEST_PERIOD diff --git a/tests/lib/heap/src/main.c b/tests/lib/heap/src/main.c index 8804fb13cea0..87b4e53d69b4 100644 --- a/tests/lib/heap/src/main.c +++ b/tests/lib/heap/src/main.c @@ -21,7 +21,7 @@ */ # define MEMSZ (192 * 1024) #elif defined(CONFIG_ARCH_POSIX) -/* POSIX arch based targets don't support CONFIG_SRAM_SIZE at all (because +/* POSIX arch based targets don't support DT_CHOSEN_SRAM_SIZE at all (because * they can link anything big enough to fit on the host), so just use a * reasonable value. */ @@ -33,9 +33,7 @@ */ # define MEMSZ (16 * 1024) #else -/* Otherwise just trust CONFIG_SRAM_SIZE - */ -# define MEMSZ (1024 * (size_t) CONFIG_SRAM_SIZE) +# define MEMSZ DT_CHOSEN_SRAM_SIZE #endif #define BIG_HEAP_SZ MIN(256 * 1024, MEMSZ / 3) From 262062e2af2d6c792ee20cafe6d22d3b3f7825f1 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:54:32 +0100 Subject: [PATCH 17/23] [nrf fromtree] samples: Add support for dts RAM configuration Allows using the chosen SRAM node for RAM configuration without using Kconfig values Signed-off-by: Jamie McCrae (cherry picked from commit b06f9b011e3ad4008789a068ef36ea15c5005230) --- samples/arch/mpu/mpu_test/src/main.c | 5 +++-- samples/drivers/i2s/echo/src/main.c | 4 +++- samples/kernel/bootargs/app_efi.overlay | 3 +++ samples/kernel/bootargs/prj_efi.conf | 2 +- samples/kernel/bootargs/sample.yaml | 2 +- samples/subsys/demand_paging/app.overlay | 3 +++ samples/subsys/demand_paging/prj.conf | 1 - 7 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 samples/kernel/bootargs/app_efi.overlay create mode 100644 samples/subsys/demand_paging/app.overlay diff --git a/samples/arch/mpu/mpu_test/src/main.c b/samples/arch/mpu/mpu_test/src/main.c index c850a9dd9029..e5cb626dbaee 100644 --- a/samples/arch/mpu/mpu_test/src/main.c +++ b/samples/arch/mpu/mpu_test/src/main.c @@ -18,9 +18,10 @@ shell_fprintf(sh, SHELL_ERROR, fmt, ##__VA_ARGS__) /* Assumption: our devices have less than 64MB of memory */ -#define RESERVED_MEM_MAP (CONFIG_SRAM_BASE_ADDRESS + 0x4000000) +#define RESERVED_MEM_MAP (DT_CHOSEN_SRAM_ADDR + 0x4000000) +#define RAM_MEM DT_CHOSEN_SRAM_ADDR + #define FLASH_MEM CONFIG_FLASH_BASE_ADDRESS -#define RAM_MEM CONFIG_SRAM_BASE_ADDRESS /* MPU test command help texts */ #define READ_CMD_HELP "Read from a reserved address in the memory map" diff --git a/samples/drivers/i2s/echo/src/main.c b/samples/drivers/i2s/echo/src/main.c index 31b8cf1e8619..031bbae3d73a 100644 --- a/samples/drivers/i2s/echo/src/main.c +++ b/samples/drivers/i2s/echo/src/main.c @@ -21,8 +21,10 @@ #define I2S_TX_NODE DT_NODELABEL(i2s_tx) #endif +#define RAM_SIZE (DT_CHOSEN_SRAM_ADDR / 1024) + /* Reduce echo delay when running on low ram devices */ -#if CONFIG_SRAM_SIZE <= 48 +#if SRAM_SIZE <= 48 #define ECHO_DELAY 30 #else #define ECHO_DELAY 10 diff --git a/samples/kernel/bootargs/app_efi.overlay b/samples/kernel/bootargs/app_efi.overlay new file mode 100644 index 000000000000..3867176dbcda --- /dev/null +++ b/samples/kernel/bootargs/app_efi.overlay @@ -0,0 +1,3 @@ +&dram0 { + reg = <0x0 0xc800000>; +}; diff --git a/samples/kernel/bootargs/prj_efi.conf b/samples/kernel/bootargs/prj_efi.conf index 75a723633012..8b3416d3a6db 100644 --- a/samples/kernel/bootargs/prj_efi.conf +++ b/samples/kernel/bootargs/prj_efi.conf @@ -1,4 +1,4 @@ +CONFIG_BOOTARGS=y CONFIG_DYNAMIC_BOOTARGS=y CONFIG_QEMU_UEFI_BOOT=y CONFIG_BUILD_OUTPUT_EFI=y -CONFIG_SRAM_SIZE=204800 diff --git a/samples/kernel/bootargs/sample.yaml b/samples/kernel/bootargs/sample.yaml index 020f07188f68..8ff0d7cc2a44 100644 --- a/samples/kernel/bootargs/sample.yaml +++ b/samples/kernel/bootargs/sample.yaml @@ -12,7 +12,7 @@ tests: regex: - "argv\\[0\\] = .*/zephyr(-qemu-locore)?.elf" sample.kernel.bootargs.efi: - extra_args: EXTRA_CONF_FILE=prj_efi.conf + extra_args: FILE_SUFFIX=efi platform_allow: qemu_x86_64 harness: console harness_config: diff --git a/samples/subsys/demand_paging/app.overlay b/samples/subsys/demand_paging/app.overlay new file mode 100644 index 000000000000..9035cfd48e20 --- /dev/null +++ b/samples/subsys/demand_paging/app.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x40000>; +}; diff --git a/samples/subsys/demand_paging/prj.conf b/samples/subsys/demand_paging/prj.conf index c1111f3b8348..f03ea52ffc4d 100644 --- a/samples/subsys/demand_paging/prj.conf +++ b/samples/subsys/demand_paging/prj.conf @@ -1,4 +1,3 @@ -CONFIG_SRAM_SIZE=256 CONFIG_DEMAND_PAGING=y CONFIG_DEMAND_PAGING_ALLOW_IRQ=y CONFIG_DEMAND_PAGING_STATS=y From 75928bcf03364e60f171167b0259ae3f331466bc Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 28 Apr 2026 08:09:07 +0100 Subject: [PATCH 18/23] [nrf fromtree] scripts: west_commands: runners: core: Add dts SRAM support Adds support for using the chosen SRAM node for getting the RAM start address instead of having to rely on Kconfigs Signed-off-by: Jamie McCrae (cherry picked from commit aada3b2f734123623978d1f179c894fd317bb269) --- scripts/west_commands/runners/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/runners/core.py b/scripts/west_commands/runners/core.py index ef90eee4b3f9..f5389661563a 100644 --- a/scripts/west_commands/runners/core.py +++ b/scripts/west_commands/runners/core.py @@ -781,9 +781,13 @@ def flash_address_from_build_conf(build_conf: BuildConfiguration): @staticmethod def sram_address_from_build_conf(build_conf: BuildConfiguration): - '''return CONFIG_SRAM_BASE_ADDRESS. + '''return SRAM address. ''' - return build_conf['CONFIG_SRAM_BASE_ADDRESS'] + if build_conf.getboolean('CONFIG_SRAM_DEPRECATED_KCONFIG_SET'): + return build_conf['CONFIG_SRAM_BASE_ADDRESS'] + else: + sram_node = build_conf.edt.chosen_node('zephyr,sram') + return sram_node.regs[0].addr def run(self, command: str, **kwargs): '''Runs command ('flash', 'debug', 'debugserver', 'attach'). From 392a1ef27ac3d3235a71d85b6b7a9c4c89bae4c0 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 8 May 2026 13:17:11 +0100 Subject: [PATCH 19/23] [nrf fromtree] doc: Update Kconfig -> dts for RAM configuration Updates old Kconfig usage with C macros (which come from dts) Signed-off-by: Jamie McCrae (cherry picked from commit 02cfde161534e5cdcd2ccd1f553a578918d21128) --- boards/udoo/udoo_neo_full/doc/index.rst | 4 +--- doc/hardware/arch/x86.rst | 10 +++++----- doc/kernel/memory_management/virtual_memory.rst | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/boards/udoo/udoo_neo_full/doc/index.rst b/boards/udoo/udoo_neo_full/doc/index.rst index 020d43e33ac9..d3c75d84e4c5 100644 --- a/boards/udoo/udoo_neo_full/doc/index.rst +++ b/boards/udoo/udoo_neo_full/doc/index.rst @@ -179,9 +179,7 @@ DT_FLASH_SIZE macro to determine the region size and DT_FLASH_ADDR to determine the address where the region begins. If you want to have the data placed in the subregion of a memory, which will -likely be the case when using DDR, select "zephyr,sram = &sram", which sets the -CONFIG_SRAM_SIZE macro to determine the region size and -CONFIG_SRAM_BASE_ADDRESS to determine the address where the region begins. +likely be the case when using DDR, select "zephyr,sram = &sram". Otherwise set "zephyr,flash" and/or "zephyr,sram" to one of the predefined regions: diff --git a/doc/hardware/arch/x86.rst b/doc/hardware/arch/x86.rst index 1587efa38c34..668aee24c80a 100644 --- a/doc/hardware/arch/x86.rst +++ b/doc/hardware/arch/x86.rst @@ -16,8 +16,8 @@ During very early boot, page tables are loaded so technically the kernel is executing in virtual address space. By default, physical and virtual memory are identity mapped and thus giving the appearance of execution taking place in physical address space. The physical address space is -marked by kconfig :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` and -:kconfig:option:`CONFIG_SRAM_SIZE` while the virtual address space is marked by +marked by dts :c:macro:`DT_CHOSEN_SRAM_ADDR` and +:c:macro:`DT_CHOSEN_SRAM_SIZE` while the virtual address space is marked by :kconfig:option:`CONFIG_KERNEL_VM_BASE` and :kconfig:option:`CONFIG_KERNEL_VM_SIZE`. Note that :kconfig:option:`CONFIG_SRAM_OFFSET` controls where the Zephyr kernel is being placed in the memory, and its counterpart @@ -60,17 +60,17 @@ There are restrictions on where virtual address space can be: - Assuming ``CONFIG_SRAM_OFFSET`` and ``CONFIG_KERNEL_VM_OFFSET`` are both ``0x0``. - - ``CONFIG_SRAM_BASE_ADDRESS == 0x00000000`` and + - ``DT_CHOSEN_SRAM_ADDR == 0x00000000`` and ``CONFIG_KERNEL_VM_BASE = 0x40000000`` is valid, while - - ``CONFIG_SRAM_BASE_ADDRESS == 0x00000000`` and + - ``DT_CHOSEN_SRAM_ADDR == 0x00000000`` and ``CONFIG_KERNEL_VM_BASE = 0x20000000`` is not. - If :kconfig:option:`CONFIG_X86_PAE` is disabled (``=n``), each address space must reside in their own 4MB region, due to each entry of PD (Page Directory) covers 4MB of memory. - - Both ``CONFIG_SRAM_BASE_ADDRESS`` and ``CONFIG_KERNEL_VM_BASE`` + - Both ``DT_CHOSEN_SRAM_ADDR`` and ``CONFIG_KERNEL_VM_BASE`` must also align with the starting addresses of targeted regions. Specifying Additional Memory Mappings at Build Time diff --git a/doc/kernel/memory_management/virtual_memory.rst b/doc/kernel/memory_management/virtual_memory.rst index 4e2f11e90c7b..e566166d2e97 100644 --- a/doc/kernel/memory_management/virtual_memory.rst +++ b/doc/kernel/memory_management/virtual_memory.rst @@ -121,7 +121,7 @@ below. * If it is enabled, which means all physical memory are mapped in virtual memory address space, and it is the same as - (:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + :kconfig:option:`CONFIG_SRAM_SIZE`). + (:c:macro:`DT_CHOSEN_SRAM_ADDR` + :c:macro:`DT_CHOSEN_SRAM_SIZE`). * If it is disabled, ``K_MEM_VM_FREE_START`` is the same ``K_MEM_KERNEL_VIRT_END`` which is the end of the kernel image. From 0181e1e80975c5ca039ca60ad9be7fbe17e478e8 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Apr 2026 12:58:14 +0100 Subject: [PATCH 20/23] [nrf fromtree] arch: kconfig: Deprecatee SRAM_SIZE and SRAM_BASE_ADDRESS Deprecates these Kconfigs and emits a deprecated warning when either of them are changed from their defaults (on a different symbol, due to Kconfig limitations) Signed-off-by: Jamie McCrae (cherry picked from commit 4476a811e87b8af65fff252240391c63b0a9a3e9) --- arch/Kconfig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index a4bcc2c5e85e..b4b668489a4d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -225,6 +225,10 @@ config 64BIT config SRAM_DEPRECATED_KCONFIG_SET bool + default y if SRAM_SIZE != $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) + default y if SRAM_BASE_ADDRESS != $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM)) + default n + select DEPRECATED help Indicates that either `CONFIG_SRAM_SIZE` or `CONFIG_SRAM_BASE_ADDRESS` have been manually set, these Kconfigs are now deprecated and should be replaced by referencing @@ -234,7 +238,7 @@ config SRAM_DEPRECATED_KCONFIG_SET DT_CHOSEN_Z_SRAM := zephyr,sram config SRAM_SIZE - int "SRAM Size in kB" + int "SRAM Size in kB [DEPRECATED]" default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) help The SRAM size in kB. The default value comes from /chosen/zephyr,sram in @@ -243,7 +247,7 @@ config SRAM_SIZE the devicetree `zephyr,sram` chosen node instead. config SRAM_BASE_ADDRESS - hex "SRAM Base Address" + hex "SRAM Base Address [DEPRECATED]" default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM)) help The SRAM base address. The default value comes from From d70840dddeec25002b66f9eae7995e6dff36a1fe Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 29 Apr 2026 10:11:50 +0100 Subject: [PATCH 21/23] [nrf fromtree] doc: release: migration_guide: 4.5: Add note on SRAM Kconfig change Adds details about this switching to Kconfig Signed-off-by: Jamie McCrae (cherry picked from commit e4af38d73e8b7f84804a31b19df45992f6735c3b) --- doc/releases/migration-guide-4.5.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/releases/migration-guide-4.5.rst b/doc/releases/migration-guide-4.5.rst index e928cb873858..a21a720ba5d1 100644 --- a/doc/releases/migration-guide-4.5.rst +++ b/doc/releases/migration-guide-4.5.rst @@ -32,6 +32,12 @@ Kernel Boards ****** +* The Kconfig options :kconfig:option:`CONFIG_SRAM_SIZE` and + :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` have been deprecated, boards should instead use the + devicetree ``zephyr.sram`` chosen node to specify the RAM node which will be used (whose values + populated the Kconfig values). If either option is manually adjusted, it will cause + :kconfig:option:`CONFIG_SRAM_DEPRECATED_KCONFIG_SET` to be set which indicates this deprecation. + Device Drivers and Devicetree ***************************** From 60457aa2f127c5245dc11e1042d8812a2e434cdc Mon Sep 17 00:00:00 2001 From: Sigvart Hovland Date: Fri, 3 May 2019 14:21:52 +0200 Subject: [PATCH 22/23] [nrf noup] tree-wide: support NCS Partition Manager (PM) definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partition Manager (PM) is a component of the nRF Connect SDK (NCS) which uses yaml files to resolve flash partition placement with a holistic view of the entire device, including each firmware image present on the flash device, and various subsystems, such as settings and NFFS. When this NCS extension is used, various source files which would use partition information from devicetree in "vanilla" zephyr instead use defines generated by PM instead. This commit removes support for HEX_FILES_TO_MERGE, as it conflicts with PM. The settings subsystem pm.yml defines a partition 'settings_storage'. The nffs subsystem pm.yml defines 'nffs_storage'. Leverage label translation to avoid patching partition names. Refer to the NCS documentation page for this feature for more details. This is a long-running out of tree patch which has been worked on by several people. The following sign-offs are in alphabetical order by first name. Signed-off-by: Andrzej Głąbek Signed-off-by: Andrzej Puzdrowski Signed-off-by: Håkon Øye Amundsen Signed-off-by: Ioannis Glaropoulos Signed-off-by: Joakim Andersson Signed-off-by: Johann Fischer Signed-off-by: Martí Bolívar Signed-off-by: Ole Sæther Signed-off-by: Robert Lubos Signed-off-by: Sebastian Bøe Signed-off-by: Sigvart Hovland Signed-off-by: Thomas Stenersen Signed-off-by: Torsten Rasmussen Signed-off-by: Øyvind Rønningstad Signed-off-by: Trond Einar Snekvik Signed-off-by: Gerard Marull-Paretas Signed-off-by: Tomasz Moń Signed-off-by: Dominik Ermel Signed-off-by: Jamie McCrae (cherry picked from commit a8cb6e26828c238cb4f46f81c1f45215f6a83deb) --- arch/arm/core/mpu/arm_mpu_regions.c | 13 +++++ cmake/linker/ld/target.cmake | 1 + cmake/linker/lld/target.cmake | 1 + cmake/modules/kernel.cmake | 4 ++ drivers/flash/soc_flash_nrf.c | 11 ++++ drivers/flash/soc_flash_nrf_rram.c | 11 ++++ .../arch/arm/cortex_m/scripts/linker.ld | 50 +++++++++++++++++++ include/zephyr/storage/flash_map.h | 6 +++ lib/heap/Kconfig | 2 +- lib/libc/common/source/stdlib/malloc.c | 14 +++++- subsys/dfu/boot/mcuboot_shell.c | 40 +++++++++++++++ subsys/fs/littlefs_fs.c | 7 ++- subsys/ipc/rpmsg_service/rpmsg_backend.h | 27 ++++++++++ 13 files changed, 183 insertions(+), 4 deletions(-) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 9a0970353277..113b47ebcde9 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,6 +8,9 @@ #include #include +#if USE_PARTITION_MANAGER +#include +#endif #ifdef CONFIG_ARM_MPU_SRAM_WRITE_THROUGH #define ARM_MPU_SRAM_REGION_ATTR REGION_RAM_WT_ATTR @@ -30,6 +33,14 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", +#if USE_PARTITION_MANAGER + PM_SRAM_ADDRESS, +#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) + REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), +#else + REGION_RAM_ATTR(REGION_SRAM_SIZE)), +#endif +#else DT_CHOSEN_SRAM_ADDR, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) ARM_MPU_SRAM_REGION_ATTR(DT_CHOSEN_SRAM_ADDR, @@ -37,6 +48,8 @@ static const struct arm_mpu_region mpu_regions[] = { #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif + +#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 592596576d11..ccf6a1903162 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,6 +80,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index 96df1c123796..fe8aad62c73d 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,6 +52,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index 310a836eebcf..53aa705fdc9b 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -257,3 +257,7 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() + +if(ZEPHYR_NRF_MODULE_DIR) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) +endif() diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index f6b8a6f5eef3..27fda598be20 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,6 +36,11 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -165,6 +170,12 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index 1f7f89b5509f..cd217a5f2c2d 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -292,6 +297,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + memcpy(data, (void *)addr, len); return 0; diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 3f8bfe9d5900..c05e6f4b5c80 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,6 +34,39 @@ #define ROMSTART_REGION ROMABLE_REGION #endif +#if USE_PARTITION_MANAGER + +#include + +#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) +/* We are linking against S1, create symbol containing the flash ID of S0. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S0_ID; + +#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ + +#ifdef PM_S1_ID +/* We are linking against S0, create symbol containing the flash ID of S1. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S1_ID; +#endif /* PM_S1_ID */ + +#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ + +#define ROM_ADDR PM_ADDRESS +#define ROM_SIZE PM_SIZE + +#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) +#define RAM_SIZE CONFIG_PM_SRAM_SIZE +#else +#define RAM_SIZE PM_SRAM_SIZE +#endif +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else @@ -60,6 +93,23 @@ #define RAM_ADDR DT_CHOSEN_SRAM_ADDR #define RAM_SIZE DT_CHOSEN_SRAM_SIZE +#endif /* USE_PARTITION_MANAGER */ + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) +#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) +#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) +#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) +#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) +#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) +#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) +#endif + #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index 13f381e135fd..819f94182474 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -351,6 +351,10 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); +#if USE_PARTITION_MANAGER +#include +#else + /** * Returns non-0 value if partition of given DTS node label exists. * @@ -620,6 +624,8 @@ DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOR_EACH_SUBPARTITION_TABLE) #undef FOR_EACH_SUBPARTITION_TABLE /** @endcond */ +#endif /* USE_PARTITION_MANAGER */ + #ifdef __cplusplus } #endif diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 18976e4ffec7..b50427aeaa73 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -164,7 +164,7 @@ choice prompt "Supported heap sizes" depends on !64BIT default SYS_HEAP_SMALL_ONLY if ((SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 256) || \ - (!SRAM_DEPRECATED_KCONFIG_SET && $(DT_SRAM_SIZE) <= 256)) + (!SRAM_DEPRECATED_KCONFIG_SET && $(DT_SRAM_SIZE) <= 256)) && !PARTITION_MANAGER_ENABLED default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 7cfeadd00b71..f4d8be2671d9 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,6 +25,16 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); +#if USE_PARTITION_MANAGER +#include + +#define RAM_SIZE PM_SRAM_SIZE +#define RAM_ADDR PM_SRAM_ADDRESS +#else /* ! USE_PARTITION_MANAGER */ +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE +#endif /* USE_PARTITION_MANAGER */ + #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -106,8 +116,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((size_t) DT_CHOSEN_SRAM_SIZE - \ - ((size_t) HEAP_BASE - (size_t) DT_CHOSEN_SRAM_ADDR), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((size_t) RAM_SIZE - \ + ((size_t) HEAP_BASE - (size_t) RAM_ADDR), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index 583bc4778362..06eb79baa92b 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,6 +20,16 @@ #endif #endif +#if USE_PARTITION_MANAGER +#include + +#ifdef CONFIG_NCS_IS_VARIANT_IMAGE +#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif + struct area_desc { const char *name; unsigned int id; @@ -93,6 +103,35 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ +#if USE_PARTITION_MANAGER +#ifdef PM_MCUBOOT_ID + if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { + shell_error(sh, "Cannot erase boot partition"); + return -EACCES; + } +#endif + +#ifdef PM_APP_ID + if (id == PM_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef PM_MCUBOOT_PRIMARY_APP_ID + if (id == PM_MCUBOOT_PRIMARY_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef ACTIVE_IMAGE_ID + if (id == ACTIVE_IMAGE_ID) { + shell_error(sh, "Cannot erase active partitions"); + return -EACCES; + } +#endif +#else #if PARTITION_EXISTS(boot_partition) if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -105,6 +144,7 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } +#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index e41287edf2f6..094cb761756b 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,7 +1133,12 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_PARTITION_ID(FS_PARTITION(inst)), \ + .storage_dev = (void *) \ + COND_CODE_1(USE_PARTITION_MANAGER, \ + (COND_CODE_1(FIXED_PARTITION_EXISTS(littlefs_storage), \ + (FIXED_PARTITION_ID(littlefs_storage)), \ + (FIXED_PARTITION_ID(storage)))), \ + (DT_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index 349eee664810..e7015d512d36 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,8 +13,35 @@ extern "C" { #endif +#if CONFIG_PARTITION_MANAGER_ENABLED + +#include "pm_config.h" + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) +#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE +#else +/* The current image is a child image in a different domain than the image + * which defined the required values. To reach the values of the parent domain + * we use the 'PM__' variant of the define. + */ +#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ + +#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ + +#else + +#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #ifdef CONFIG_OPENAMP_RSC_TABLE #define SHM_START_ADDR (VDEV_START_ADDR) From bf381f38349617e1c772f3f06141ff1505977e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag=20Erik=20Gj=C3=B8rvad?= Date: Wed, 8 Apr 2026 10:01:31 +0200 Subject: [PATCH 23/23] [nrf noup] drivers: flash: Update to support PM removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update conditions for soc_secure_mem_read to support Non-Secure builds without Partition Manager. noup as Partition Manager is a NCS construct. Signed-off-by: Dag Erik Gjørvad (cherry picked from commit b71134cf5d2186b50b78dcded1059f399591536c) --- drivers/flash/soc_flash_nrf.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 27fda598be20..3e735a7edf78 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,10 +36,12 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#if CONFIG_TRUSTED_EXECUTION_NONSECURE #include +#if USE_PARTITION_MANAGER #include -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ +#endif /* USE_PARTITION_MANAGER */ +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 @@ -170,11 +172,17 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS +#if CONFIG_TRUSTED_EXECUTION_NONSECURE +#if USE_PARTITION_MANAGER && PM_APP_ADDRESS if (addr < PM_APP_ADDRESS) { return soc_secure_mem_read(data, (void *)addr, len); } +#elif !USE_PARTITION_MANAGER && DT_NODE_EXISTS(DT_NODELABEL(slot0_ns_partition)) + if ((uintptr_t)addr < DT_REG_ADDR(DT_NODELABEL(slot0_ns_partition))) { + return soc_secure_mem_read(data, (void *)addr, len); + } #endif +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ nrf_nvmc_buffer_read(data, (uint32_t)addr, len);