diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 89c45793bdfb..722880dce22d 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -99,19 +99,29 @@ config USE_DT_CODE_PARTITION # Workaround for not being able to have commas in macro arguments DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition DT_CHOSEN_Z_FLASH := zephyr,flash +DT_COMPAT_Z_MAPPED_PARTITION := zephyr,mapped-partition -config FLASH_CODE_PARTITION_ADDRESS_INVALID +config FLASH_USES_MAPPED_PARTITION bool - default y if XIP && $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) < FLASH_BASE_ADDRESS + default $(dt_node_has_compat,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION)),$(DT_COMPAT_Z_MAPPED_PARTITION)) + depends on USE_DT_CODE_PARTITION + help + Temporary Kconfig to indicate if underlying chosen chosen flash partition uses the + zephyr,mapped-partition compatible, this is to allow ease of migration from + fixed-partitions and should not be relied upon outside of the zephyr build system and + will be removed in future. + +config FLASH_CODE_PARTITION_USING_FIXED_PARTITIONS + bool + default y if XIP && \ + $(dt_chosen_has_compat,$(dt_node_parent,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION))),fixed-partitions) || \ + $(dt_chosen_has_compat,$(dt_node_parent,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION))),fixed-subpartitions) depends on USE_DT_CODE_PARTITION select DEPRECATED help - If this item is selected, it is likely selected because your board/SoC/base DTS files - are wrong and have a flash memory that does not start at absolute address 0x0 and: - * Do not have a ``ranges <>;`` property in the flash node passing down the address - and size to child nodes - * Do not have a ``ranges;`` property in the partitions node passing down the previous - ranges to child nodes + If this item is selected then it is because your device is using ``fixed-partitions`` or + ``fixed-subpartitions`` for partition layout, this has been replaced with + ``zephyr,mapped-partitions``. Support for this will be removed and required that your files be updated correctly for a future release, check the Zephyr 4.4 migration notes. @@ -119,10 +129,7 @@ config FLASH_CODE_PARTITION_ADDRESS_INVALID config FLASH_LOAD_OFFSET # Only user-configurable when USE_DT_CODE_PARTITION is disabled hex "Kernel load offset" if !USE_DT_CODE_PARTITION - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) \ - if FLASH_CODE_PARTITION_ADDRESS_INVALID - default $(sub_hex, $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)), \ - $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))) if USE_DT_CODE_PARTITION + default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_DT_CODE_PARTITION default 0 help This option specifies the byte offset from the beginning of flash that diff --git a/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi b/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi index b73f177a8d79..33619f57c7fb 100644 --- a/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi +++ b/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi @@ -31,36 +31,31 @@ }; &flash1 { - /* - * For more information, see: - * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions - */ partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; - /* 48K */ boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; - /* 88K */ slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x16000>; }; - /* 88K */ slot1_partition: partition@22000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00022000 0x16000>; }; - /* 32K */ storage_partition: partition@38000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00038000 0x8000>; }; diff --git a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts index 96abc76fa453..a5df432a4c13 100644 --- a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts +++ b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts @@ -20,11 +20,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - /* Include default memory partition configuration file */ #include diff --git a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts index c0584b08c98c..df912059cc65 100644 --- a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "bl54l15_dvk_common.dtsi" / { @@ -22,21 +22,14 @@ }; }; -&cpuflpr_sram { - status = "okay"; - /* size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - ranges = <0x0 0x20028000 0x18000>; -}; - &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts index 2211743673c0..f51574f254c0 100644 --- a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "bl54l15u_dvk_common.dtsi" / { @@ -22,21 +22,14 @@ }; }; -&cpuflpr_sram { - status = "okay"; - /* size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - ranges = <0x0 0x20028000 0x18000>; -}; - &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/holyiot/yj16019/holyiot_yj16019.dts b/boards/holyiot/yj16019/holyiot_yj16019.dts index e97ae44c7536..561f394f1a10 100644 --- a/boards/holyiot/yj16019/holyiot_yj16019.dts +++ b/boards/holyiot/yj16019/holyiot_yj16019.dts @@ -6,7 +6,6 @@ /dts-v1/; #include -#include #include "holyiot_yj16019-pinctrl.dtsi" #include diff --git a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts index 32ed9916a382..40f54dc265e8 100644 --- a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts +++ b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts @@ -94,13 +94,15 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00000000 DT_SIZE_K(1024)>; }; diff --git a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts index 94f1ee0ccbbd..f88051eab004 100644 --- a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts +++ b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts @@ -58,12 +58,12 @@ ranges = <0x0 0x01000000 DT_SIZE_K(256)>; partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; storage_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00000000 DT_SIZE_K(256)>; }; diff --git a/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts b/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts index 801782c35efe..e78122660716 100644 --- a/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts +++ b/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts @@ -273,21 +273,24 @@ fem_spi: &spi3 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x0000c000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x00076000>; }; slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00082000 0x00076000>; }; @@ -302,6 +305,7 @@ fem_spi: &spi3 { * if enabled. */ storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts b/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts index c5c288182791..38d3182050bd 100644 --- a/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts +++ b/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts @@ -160,26 +160,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x8000>; }; slot0_partition: partition@8000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00008000 0x1b000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x1b000>; }; storage_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003e000 0x00002000>; }; diff --git a/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts b/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts index 07de5fadcaab..be2f3677c507 100644 --- a/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts +++ b/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts @@ -88,26 +88,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x8000>; }; slot0_partition: partition@8000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00008000 0x1b000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x1b000>; }; storage_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003e000 0x00002000>; }; diff --git a/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts b/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts index 6516a779928f..8bc2bda0660d 100644 --- a/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts +++ b/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts @@ -161,26 +161,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x00006000>; }; diff --git a/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts b/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts index 098632f622b5..90609c425755 100644 --- a/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts +++ b/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts @@ -231,26 +231,30 @@ arduino_spi: &spi3 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x37000>; }; slot1_partition: partition@43000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00043000 0x37000>; }; storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts b/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts index 6dc7731389f8..61904879381b 100644 --- a/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts +++ b/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts @@ -164,26 +164,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts index e446c5aaf54e..3cb02df53c9d 100644 --- a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts @@ -12,7 +12,7 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -21,21 +21,25 @@ * be built with CDC ACM support and w/o optimizations. */ boot_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00001000 0x0000f000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x00066000>; }; slot1_partition: partition@76000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00076000 0x00066000>; }; storage_partition: partition@dc000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000dc000 0x00004000>; }; diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts index b8b76a8e63be..74ac37ef0adb 100644 --- a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts @@ -12,7 +12,7 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -20,21 +20,25 @@ * with an RTT console, CDC ACM support, and w/o optimizations. */ boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00012000>; }; slot0_partition: partition@12000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00012000 0x00075000>; }; slot1_partition: partition@87000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00087000 0x00075000>; }; storage_partition: partition@fc000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000fc000 0x00004000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts index a27bae1c72cf..704f11325b86 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts @@ -139,26 +139,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts index 8c72a1b5fa30..699694bcb00d 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts @@ -141,26 +141,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts index 9f1b167c2165..5dc66561195e 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts @@ -228,26 +228,30 @@ arduino_spi: &spi2 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x37000>; }; slot1_partition: partition@43000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00043000 0x37000>; }; storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts index 11d75635e32e..b5282d7aac67 100644 --- a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts @@ -58,27 +58,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x12000>; }; slot1_partition: partition@1e000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001e000 0x12000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts b/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts index 69c9cd860730..93a573e1bd9d 100644 --- a/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts @@ -77,27 +77,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi index 91ee56a6ecc8..23ff92dc56fc 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi @@ -127,60 +127,72 @@ &mram1x { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuapp_boot_partition: partition@30000 { + compatible = "zephyr,mapped-partition"; reg = <0x30000 DT_SIZE_K(64)>; }; cpuapp_slot0_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; reg = <0x40000 DT_SIZE_K(328)>; }; cpurad_slot0_partition: partition@92000 { + compatible = "zephyr,mapped-partition"; reg = <0x92000 DT_SIZE_K(328)>; }; cpuppr_code_partition: partition@e4000 { + compatible = "zephyr,mapped-partition"; reg = <0xe4000 DT_SIZE_K(64)>; }; cpuflpr_code_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; reg = <0xf4000 DT_SIZE_K(48)>; }; cpuapp_slot1_partition: partition@100000 { + compatible = "zephyr,mapped-partition"; reg = <0x100000 DT_SIZE_K(328)>; }; cpurad_slot1_partition: partition@152000 { + compatible = "zephyr,mapped-partition"; reg = <0x152000 DT_SIZE_K(328)>; }; storage_partition: partition@1a4000 { + compatible = "zephyr,mapped-partition"; reg = <0x1a4000 DT_SIZE_K(40)>; }; periphconf_partition: partition@1ae000 { + compatible = "zephyr,mapped-partition"; reg = <0x1ae000 DT_SIZE_K(8)>; }; secondary_partition: partition@1b0000 { + compatible = "zephyr,mapped-partition"; reg = <0x1b0000 DT_SIZE_K(64)>; }; secondary_periphconf_partition: partition@1c0000 { + compatible = "zephyr,mapped-partition"; reg = <0x1c0000 DT_SIZE_K(8)>; }; mpcconf_partition: partition@1c2000 { + compatible = "zephyr,mapped-partition"; reg = <0x1c2000 512>; }; secondary_mpcconf_partition: partition@1c2200 { + compatible = "zephyr,mapped-partition"; reg = <0x1c2200 512>; }; @@ -190,25 +202,29 @@ * there is no more space after secure_storage_partition. */ secure_storage_partition: partition@1fd000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; reg = <0x1fd000 DT_SIZE_K(12)>; ranges = <0x0 0x1fd000 0x3000>; #address-cells = <1>; #size-cells = <1>; cpuapp_crypto_partition: partition@0 { + compatible = "zephyr,mapped-partition"; reg = <0x0 DT_SIZE_K(4)>; }; cpurad_crypto_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; reg = <0x1000 DT_SIZE_K(4)>; }; cpuapp_its_partition: partition@2000 { + compatible = "zephyr,mapped-partition"; reg = <0x2000 DT_SIZE_K(2)>; }; cpurad_its_partition: partition@2800 { + compatible = "zephyr,mapped-partition"; reg = <0x2800 DT_SIZE_K(2)>; }; }; diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts index 2c30c7270059..f09e6574cd79 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts @@ -19,11 +19,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(96)>; - ranges = <0x0 0x20000000 DT_SIZE_K(96)>; -}; - /* Include default memory partition configuration file */ -#include +#include diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts index c94d2a178133..c7736a7f3ce0 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts @@ -19,11 +19,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - /* Include default memory partition configuration file */ #include diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts index edaad821d37b..f4cef37e5282 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts @@ -5,11 +5,9 @@ */ /dts-v1/; -#include +#include #include "nrf54l15dk_common.dtsi" -/delete-node/ &cpuflpr_sram; - / { model = "Nordic nRF54L15 DK nRF54L15 FLPR MCU"; compatible = "nordic,nrf54l15dk_nrf54l15-cpuflpr"; @@ -21,16 +19,6 @@ zephyr,flash = &cpuflpr_rram; zephyr,sram = &cpuflpr_sram; }; - - cpuflpr_sram: memory@20028000 { - compatible = "mmio-sram"; - /* Size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20028000 0x18000>; - status = "okay"; - }; }; &cpuflpr_rram { @@ -41,6 +29,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi b/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi index 96c440092450..1d41b30033ca 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include "nrf54l15tag_common.dtsi" diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts index d1e39d3e5d96..8839a482e027 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts @@ -11,19 +11,6 @@ / { model = "Nordic nRF54L15 TAG nRF54L15 FLPR MCU"; compatible = "nordic,nrf54l15tag_nrf54l15-cpuflpr"; - - soc { - /* Resize SRAM partition */ - /delete-node/ memory@2002f000; - - cpuflpr_sram: memory@20028000 { - compatible = "mmio-sram"; - reg = <0x20028000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20028000 0x18000>; - }; - }; }; &cpuflpr_rram { @@ -34,6 +21,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts index 26bdbe51a22d..8839a482e027 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts @@ -21,6 +21,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi b/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi index f7969b3de49c..a84d2623fd94 100644 --- a/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi +++ b/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi @@ -19,6 +19,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts index 044e38e497e8..bca0b2a52e71 100644 --- a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts @@ -151,27 +151,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts index b8132ee9ef3c..6da7f6794ba4 100644 --- a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts +++ b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts @@ -31,12 +31,12 @@ &cpuflpr_mram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "nordic,mapped-partition"; label = "image-0"; reg = <0 DT_SIZE_K(116)>; }; diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi index 4be968ed3df2..0840127adf92 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi @@ -186,44 +186,52 @@ &mram1x { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuapp_boot_partition: partition@312000 { + compatible = "zephyr,mapped-partition"; reg = <0x312000 DT_SIZE_K(64)>; }; cpuapp_slot0_partition: partition@322000 { + compatible = "zephyr,mapped-partition"; reg = <0x322000 DT_SIZE_K(336)>; }; cpuapp_slot1_partition: partition@376000 { + compatible = "zephyr,mapped-partition"; reg = <0x376000 DT_SIZE_K(440)>; }; cpuppr_code_partition: partition@3e4000 { + compatible = "zephyr,mapped-partition"; reg = <0x3e4000 DT_SIZE_K(64)>; }; cpuflpr_code_partition: partition@3f4000 { + compatible = "zephyr,mapped-partition"; reg = <0x3f4000 DT_SIZE_K(48)>; }; cpurad_slot0_partition: partition@400000 { + compatible = "zephyr,mapped-partition"; reg = <0x400000 DT_SIZE_K(336)>; }; cpurad_slot1_partition: partition@454000 { + compatible = "zephyr,mapped-partition"; reg = <0x454000 DT_SIZE_K(336)>; }; storage_partition: partition@600000 { + compatible = "zephyr,mapped-partition"; reg = <0x600000 DT_SIZE_K(40)>; }; periphconf_partition: partition@60a000 { + compatible = "zephyr,mapped-partition"; reg = <0x60a000 DT_SIZE_K(8)>; }; @@ -231,17 +239,19 @@ * it resides in the beginning of MRAM11 in storage partition. */ secure_storage_partition: partition@60c000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; reg = <0x60c000 DT_SIZE_K(8)>; ranges = <0x0 0x60c000 0x2000>; #address-cells = <1>; #size-cells = <1>; cpuapp_crypto_partition: partition@0 { + compatible = "zephyr,mapped-partition"; reg = <0x0 DT_SIZE_K(4)>; }; cpuapp_its_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; reg = <0x1000 DT_SIZE_K(4)>; }; }; diff --git a/boards/nordic/thingy52/thingy52_nrf52832.dts b/boards/nordic/thingy52/thingy52_nrf52832.dts index a023b06e55b9..1fa794e84f06 100644 --- a/boards/nordic/thingy52/thingy52_nrf52832.dts +++ b/boards/nordic/thingy52/thingy52_nrf52832.dts @@ -195,26 +195,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x32000>; }; slot1_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0003e000 0x32000>; }; scratch_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "image-scratch"; reg = <0x00070000 0xa000>; }; @@ -227,6 +231,7 @@ * if enabled. */ storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts b/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts index d74952119839..22383728bf00 100644 --- a/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts +++ b/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts @@ -142,27 +142,30 @@ fem_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi b/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi index f25de361d20c..7822e8920798 100644 --- a/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi +++ b/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi @@ -182,27 +182,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts index 3dc55b73513d..fad9a3dd9a39 100644 --- a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts +++ b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "panb611evb_nrf54l15_common.dtsi" / { @@ -30,12 +30,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts index 76a52b128622..5bd51f2f41d7 100644 --- a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts +++ b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "raytac_an54lq_db_15_common.dtsi" / { @@ -31,12 +31,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts b/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts index cd362309e198..76d5c739c245 100644 --- a/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts +++ b/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts @@ -122,27 +122,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts index 85802f9c8766..7e2019e1e1fd 100644 --- a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts +++ b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts @@ -32,27 +32,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts index 85802f9c8766..7e2019e1e1fd 100644 --- a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts +++ b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts @@ -32,27 +32,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts index 20a7b22e46c0..0905ecb7b649 100644 --- a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts +++ b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "xiao_nrf54l15_common.dtsi" / { @@ -28,12 +28,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts index a22b84bc102c..12db2ac98511 100644 --- a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts +++ b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "ophelia4ev_common.dtsi" / { @@ -32,12 +32,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/cmake/linker_script/arm/linker.cmake b/cmake/linker_script/arm/linker.cmake index ff0c5da48460..8449997f4a87 100644 --- a/cmake/linker_script/arm/linker.cmake +++ b/cmake/linker_script/arm/linker.cmake @@ -33,23 +33,34 @@ endif() zephyr_linker_include_var(VAR APP_SHARED_ALIGN_BYTES VALUE ${region_min_align}) zephyr_linker_include_var(VAR SMEM_PARTITION_ALIGN_BYTES VALUE ${MPU_ALIGN_BYTES}) -# Note, the `+ 0` in formulas below avoids errors in cases where a Kconfig -# variable is undefined and thus expands to nothing. -math(EXPR FLASH_ADDR - "${CONFIG_FLASH_BASE_ADDRESS} + ${CONFIG_FLASH_LOAD_OFFSET} + 0" - OUTPUT_FORMAT HEXADECIMAL -) +if(CONFIG_FLASH_USES_MAPPED_PARTITION) + dt_chosen(chosen_partition_path PROPERTY "zephyr,code-partition") + dt_reg_addr(FLASH_ADDR PATH "${chosen_partition_path}") + dt_reg_size(chosen_partition_size PATH "${chosen_partition_path}") -if(CONFIG_FLASH_LOAD_SIZE GREATER 0) math(EXPR FLASH_SIZE - "(${CONFIG_FLASH_LOAD_SIZE} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" - OUTPUT_FORMAT HEXADECIMAL + "(${chosen_partition_size} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL ) else() - math(EXPR FLASH_SIZE - "(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" - OUTPUT_FORMAT HEXADECIMAL + # Note, the `+ 0` in formulas below avoids errors in cases where a Kconfig + # variable is undefined and thus expands to nothing. + math(EXPR FLASH_ADDR + "${CONFIG_FLASH_BASE_ADDRESS} + ${CONFIG_FLASH_LOAD_OFFSET} + 0" + OUTPUT_FORMAT HEXADECIMAL ) + + if(CONFIG_FLASH_LOAD_SIZE GREATER 0) + math(EXPR FLASH_SIZE + "(${CONFIG_FLASH_LOAD_SIZE} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL + ) + else() + math(EXPR FLASH_SIZE + "(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL + ) + endif() endif() set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) diff --git a/doc/build/dts/macros.bnf b/doc/build/dts/macros.bnf index 75bb431ecbb1..f02461c32822 100644 --- a/doc/build/dts/macros.bnf +++ b/doc/build/dts/macros.bnf @@ -22,6 +22,8 @@ node-macro = property-macro node-macro =/ pinctrl-macro ; A macro about the GPIO hog properties in a node. node-macro =/ gpiohogs-macro +; A macro about the map properties in a node. +node-macro =/ map-macro ; EXISTS macro: node exists in the devicetree node-macro =/ %s"DT_N" path-id %s"_EXISTS" ; Bus macros: the plain BUS is a way to access a node's bus controller. @@ -233,6 +235,71 @@ gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags_EXIST ; #define DT_N__GPIO_HOGS_IDX_0_VAL_flags 0x30 gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags" + +; -------------------------------------------------------------------- +; map-macro: a macro related to map properties +; +; Macros are generated when there is a property ending with '-map' as shown below. +; +; connector { +; ... +; interrupt-map = <0 1 &intc0 2 3>; +; }; +; +; The existence of map entry; +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_EXISTS" +; +; The child address length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0 0 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT %s"_EXISTS" +; +; The length of child specifiers length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0_EXISTS 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0 0 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT %s"_EXISTS" +; +; The parent node of this map. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT DT_N_S_gpio_emul +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT" +; +; The length of parent address, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0 2 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT %s"_EXISTS" +; +; The length of parent specifiers length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0_EXISTS 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0 3 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT %s"_EXISTS" +; +; Iteration helpers for map. +; +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_VARGS" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP_VARGS" + + ; -------------------------------------------------------------------- ; property-macro: a macro related to a node property ; diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 8706f7535882..80441ece7e75 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -100,5 +100,6 @@ add_subdirectory_ifdef(CONFIG_VIRTUALIZATION virtualization) add_subdirectory_ifdef(CONFIG_W1 w1) add_subdirectory_ifdef(CONFIG_WATCHDOG watchdog) add_subdirectory_ifdef(CONFIG_WIFI wifi) +add_subdirectory_ifdef(CONFIG_WUC wuc) add_subdirectory_ifdef(CONFIG_XEN xen) # zephyr-keep-sorted-stop diff --git a/drivers/Kconfig b/drivers/Kconfig index 7b98396266b5..59aa779f7b85 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -99,6 +99,7 @@ source "drivers/virtualization/Kconfig" source "drivers/w1/Kconfig" source "drivers/watchdog/Kconfig" source "drivers/wifi/Kconfig" +source "drivers/wuc/Kconfig" source "drivers/xen/Kconfig" # zephyr-keep-sorted-stop diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 73832cdba358..a23b719d4291 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -522,8 +522,8 @@ DT_INST_FOREACH_STATUS_OKAY(DEFINE_FLASHDISKS_CACHE) .ops = &flash_disk_ops, \ .name = DT_INST_PROP(n, disk_name), \ }, \ - .area_id = DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)), \ - .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ + .area_id = DT_PARTITION_ID(PARTITION_PHANDLE(n)), \ + .offset = PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ .cache = flashdisk##n##_cache, \ .cache_size = sizeof(flashdisk##n##_cache), \ .size = DT_REG_SIZE(PARTITION_PHANDLE(n)), \ diff --git a/drivers/flash/flash_mcux_c40.c b/drivers/flash/flash_mcux_c40.c index 075aca0c495d..781222afaf6b 100644 --- a/drivers/flash/flash_mcux_c40.c +++ b/drivers/flash/flash_mcux_c40.c @@ -336,8 +336,8 @@ static const struct flash_driver_api mcux_c40_api = { DT_SAME_NODE( \ DT_PARENT(DT_NODELABEL(lbl)), \ C40_FLASH_NODE(inst)), \ - ({ .off = (uint32_t)FIXED_PARTITION_OFFSET(lbl), \ - .len = (uint32_t)FIXED_PARTITION_SIZE(lbl), \ + ({ .off = (uint32_t)PARTITION_OFFSET(lbl), \ + .len = (uint32_t)PARTITION_SIZE(lbl), \ .name = #lbl },), \ ()) \ ), \ diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c index 22eeba1506fd..7fe32c8667a3 100644 --- a/drivers/flash/flash_simulator.c +++ b/drivers/flash/flash_simulator.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2023-2024 Nordic Semiconductor ASA + * Copyright (c) 2026 CodeWrights GmbH * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,6 +16,7 @@ #include #include #include +#include #include #include @@ -24,33 +26,42 @@ #include "flash_simulator_native.h" #include "cmdline.h" #include "soc.h" -#define DEFAULT_FLASH_FILE_PATH "flash.bin" + +/* For backward compatibility, default file name for instance 0 is "flash.bin" */ +#define DEFAULT_FLASH_FILE_PATH(n) COND_CODE_0(n, ("flash.bin"), ("flash" #n ".bin")) #endif /* CONFIG_ARCH_POSIX */ -/* configuration derived from DT */ +struct flash_simulator_config { + uint8_t *prog_unit_buf; + const struct flash_parameters *flash_parameters; +#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS + const struct flash_simulator_params *flash_simulator_params; +#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ +#ifdef CONFIG_FLASH_PAGE_LAYOUT + const struct flash_pages_layout *pages_layout; +#endif /* CONFIG_FLASH_PAGE_LAYOUT */ #ifdef CONFIG_ARCH_POSIX -#define SOC_NV_FLASH_NODE DT_INST_CHILD(0, flash_0) -#else -#define SOC_NV_FLASH_NODE DT_INST_CHILD(0, flash_sim_0) + const char *flash_file_default_path; #endif /* CONFIG_ARCH_POSIX */ + size_t base_offset; + size_t erase_unit; + size_t flash_size; +}; -#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) -#define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) -#define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) -#define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) - -#define FLASH_SIMULATOR_ERASE_VALUE \ - DT_PROP(DT_PARENT(SOC_NV_FLASH_NODE), erase_value) - -#define FLASH_SIMULATOR_PAGE_COUNT (FLASH_SIMULATOR_FLASH_SIZE / \ - FLASH_SIMULATOR_ERASE_UNIT) - -#if (FLASH_SIMULATOR_ERASE_UNIT % FLASH_SIMULATOR_PROG_UNIT) -#error "Erase unit must be a multiple of program unit" -#endif - -#define MOCK_FLASH(offset) (mock_flash + (offset)) +struct flash_simulator_data { + uint8_t *mock_flash; + bool flash_erase_at_start; +#ifdef CONFIG_ARCH_POSIX + int flash_fd; + const char *flash_file_path; + bool flash_rm_at_exit; + bool flash_in_ram; +#endif /* CONFIG_ARCH_POSIX */ +#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS + const struct flash_simulator_cb *flash_simulator_cbs; +#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ +}; /* maximum number of pages that can be tracked by the stats module */ #define STATS_PAGE_COUNT_THRESHOLD 256 @@ -141,60 +152,13 @@ STATS_NAME_END(flash_sim_thresholds); #endif /* CONFIG_FLASH_SIMULATOR_STATS */ - -#ifdef CONFIG_ARCH_POSIX -static uint8_t *mock_flash; -static int flash_fd = -1; -static const char *flash_file_path; -static bool flash_erase_at_start; -static bool flash_rm_at_exit; -static bool flash_in_ram; -#else -#if DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) -#define FLASH_SIMULATOR_MREGION \ - LINKER_DT_NODE_REGION_NAME( \ - DT_PHANDLE(DT_PARENT(SOC_NV_FLASH_NODE), memory_region)) -static uint8_t mock_flash[FLASH_SIMULATOR_FLASH_SIZE] Z_GENERIC_SECTION(FLASH_SIMULATOR_MREGION); -#else -static uint8_t mock_flash[FLASH_SIMULATOR_FLASH_SIZE]; -#endif -#endif /* CONFIG_ARCH_POSIX */ - -uint8_t prog_unit_buf[FLASH_SIMULATOR_PROG_UNIT]; - -static DEVICE_API(flash, flash_sim_api); - -static const struct flash_parameters flash_sim_parameters = { - .write_block_size = FLASH_SIMULATOR_PROG_UNIT, - .erase_value = FLASH_SIMULATOR_ERASE_VALUE, - .caps = { -#if !defined(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE) - .no_explicit_erase = false, -#endif - }, -}; - - -#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS -static const struct flash_simulator_params flash_sim_params = { - .memory_size = FLASH_SIMULATOR_FLASH_SIZE, - .base_offset = FLASH_SIMULATOR_BASE_OFFSET, - .erase_unit = FLASH_SIMULATOR_ERASE_UNIT, - .prog_unit = FLASH_SIMULATOR_PROG_UNIT, - .explicit_erase = IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), - .erase_value = FLASH_SIMULATOR_ERASE_VALUE, -}; -static const struct flash_simulator_cb *flash_simulator_cbs; -#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ - - static int flash_range_is_valid(const struct device *dev, off_t offset, size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - if ((offset < 0 || offset >= FLASH_SIMULATOR_FLASH_SIZE || - (FLASH_SIMULATOR_FLASH_SIZE - offset) < len)) { + if ((offset < 0 || offset >= cfg->flash_size || + (cfg->flash_size - offset) < len)) { return 0; } @@ -205,22 +169,23 @@ static int flash_sim_read(const struct device *dev, const off_t offset, void *data, const size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } if (!IS_ENABLED(CONFIG_FLASH_SIMULATOR_UNALIGNED_READ)) { - if ((offset % FLASH_SIMULATOR_PROG_UNIT) || - (len % FLASH_SIMULATOR_PROG_UNIT)) { + if ((offset % cfg->flash_parameters->write_block_size) || + (len % cfg->flash_parameters->write_block_size)) { return -EINVAL; } } FLASH_SIM_STATS_INC(flash_sim_stats, flash_read_calls); - memcpy(data, MOCK_FLASH(offset), len); + memcpy(data, dev_data->mock_flash + offset, len); FLASH_SIM_STATS_INCN(flash_sim_stats, bytes_read, len); #ifdef CONFIG_FLASH_SIMULATOR_SIMULATE_TIMING @@ -235,14 +200,15 @@ static int flash_sim_read(const struct device *dev, const off_t offset, static int flash_sim_write(const struct device *dev, const off_t offset, const void *data, const size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } - if ((offset % FLASH_SIMULATOR_PROG_UNIT) || - (len % FLASH_SIMULATOR_PROG_UNIT)) { + if ((offset % cfg->flash_parameters->write_block_size) || + (len % cfg->flash_parameters->write_block_size)) { return -EINVAL; } @@ -250,12 +216,15 @@ static int flash_sim_write(const struct device *dev, const off_t offset, #ifdef CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE /* check if any unit has been already programmed */ - memset(prog_unit_buf, FLASH_SIMULATOR_ERASE_VALUE, sizeof(prog_unit_buf)); + memset(cfg->prog_unit_buf, cfg->flash_parameters->erase_value, + cfg->flash_parameters->write_block_size); #else - memcpy(prog_unit_buf, MOCK_FLASH(offset), sizeof(prog_unit_buf)); + memcpy(cfg->prog_unit_buf, dev_data->mock_flash + offset, + cfg->flash_parameters->write_block_size); #endif - for (uint32_t i = 0; i < len; i += FLASH_SIMULATOR_PROG_UNIT) { - if (memcmp(prog_unit_buf, MOCK_FLASH(offset + i), sizeof(prog_unit_buf))) { + for (uint32_t i = 0; i < len; i += cfg->flash_parameters->write_block_size) { + if (memcmp(cfg->prog_unit_buf, dev_data->mock_flash + offset + i, + cfg->flash_parameters->write_block_size)) { FLASH_SIM_STATS_INC(flash_sim_stats, double_writes); #if !CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES return -EIO; @@ -283,7 +252,7 @@ static int flash_sim_write(const struct device *dev, const off_t offset, #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS flash_simulator_write_byte_cb_t write_cb = NULL; - const struct flash_simulator_cb *cb = flash_simulator_cbs; + const struct flash_simulator_cb *cb = dev_data->flash_simulator_cbs; if (cb != NULL) { write_cb = cb->write_byte; @@ -302,13 +271,13 @@ static int flash_sim_write(const struct device *dev, const off_t offset, uint8_t data_val = *((const uint8_t *)data + i); #ifdef CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE -#if FLASH_SIMULATOR_ERASE_VALUE == 0xFF - /* only pull bits to zero */ - data_val &= *(MOCK_FLASH(offset + i)); -#else - /* only pull bits to one */ - data_val |= *(MOCK_FLASH(offset + i)); -#endif + if (cfg->flash_parameters->erase_value == 0xff) { + /* only pull bits to zero */ + data_val &= *(dev_data->mock_flash + offset + i); + } else { + /* only pull bits to one */ + data_val |= *(dev_data->mock_flash + offset + i); + } #endif #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS if (write_cb != NULL) { @@ -320,7 +289,7 @@ static int flash_sim_write(const struct device *dev, const off_t offset, data_val = (uint8_t)ret; } #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ - *(MOCK_FLASH(offset + i)) = data_val; + *(dev_data->mock_flash + offset + i) = data_val; } FLASH_SIM_STATS_INCN(flash_sim_stats, bytes_written, len); @@ -337,11 +306,13 @@ static int flash_sim_write(const struct device *dev, const off_t offset, static int unit_erase(const struct device *dev, const uint32_t unit) { - const off_t unit_addr = unit * FLASH_SIMULATOR_ERASE_UNIT; + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; + const off_t unit_addr = unit * cfg->erase_unit; #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS flash_simulator_erase_unit_cb_t erase_cb = NULL; - const struct flash_simulator_cb *cb = flash_simulator_cbs; + const struct flash_simulator_cb *cb = dev_data->flash_simulator_cbs; if (cb != NULL) { erase_cb = cb->erase_unit; @@ -352,21 +323,22 @@ static int unit_erase(const struct device *dev, const uint32_t unit) #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ /* erase the memory unit by setting it to erase value */ - memset(MOCK_FLASH(unit_addr), FLASH_SIMULATOR_ERASE_VALUE, - FLASH_SIMULATOR_ERASE_UNIT); + memset(dev_data->mock_flash + unit_addr, cfg->flash_parameters->erase_value, + cfg->erase_unit); return 0; } static int flash_sim_erase(const struct device *dev, const off_t offset, const size_t len) { + const struct flash_simulator_config *cfg = dev->config; + if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } /* erase operation must be aligned to the erase unit boundary */ - if ((offset % FLASH_SIMULATOR_ERASE_UNIT) || - (len % FLASH_SIMULATOR_ERASE_UNIT)) { + if ((offset % cfg->erase_unit) || (len % cfg->erase_unit)) { return -EINVAL; } @@ -380,10 +352,10 @@ static int flash_sim_erase(const struct device *dev, const off_t offset, } #endif /* the first unit to be erased */ - uint32_t unit_start = offset / FLASH_SIMULATOR_ERASE_UNIT; + uint32_t unit_start = offset / cfg->erase_unit; /* erase as many units as necessary and increase their erase counter */ - for (uint32_t i = 0; i < len / FLASH_SIMULATOR_ERASE_UNIT; i++) { + for (uint32_t i = 0; i < len / cfg->erase_unit; i++) { int ret; ERASE_CYCLES_INC(unit_start + i); @@ -404,34 +376,31 @@ static int flash_sim_erase(const struct device *dev, const off_t offset, } #ifdef CONFIG_FLASH_PAGE_LAYOUT -static const struct flash_pages_layout flash_sim_pages_layout = { - .pages_count = FLASH_SIMULATOR_PAGE_COUNT, - .pages_size = FLASH_SIMULATOR_ERASE_UNIT, -}; - static void flash_sim_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { - *layout = &flash_sim_pages_layout; + const struct flash_simulator_config *cfg = dev->config; + + *layout = cfg->pages_layout; *layout_size = 1; } #endif static int flash_sim_get_size(const struct device *dev, uint64_t *size) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - *size = FLASH_SIMULATOR_FLASH_SIZE; + *size = cfg->flash_size; return 0; } static const struct flash_parameters * flash_sim_get_parameters(const struct device *dev) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - return &flash_sim_parameters; + return cfg->flash_parameters; } static DEVICE_API(flash, flash_sim_api) = { @@ -450,15 +419,17 @@ static DEVICE_API(flash, flash_sim_api) = { static int flash_mock_init(const struct device *dev) { int rc; - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; - if (flash_in_ram == false && flash_file_path == NULL) { - flash_file_path = DEFAULT_FLASH_FILE_PATH; + if (dev_data->flash_in_ram == false && dev_data->flash_file_path == NULL) { + dev_data->flash_file_path = cfg->flash_file_default_path; } - rc = flash_mock_init_native(flash_in_ram, &mock_flash, FLASH_SIMULATOR_FLASH_SIZE, - &flash_fd, flash_file_path, FLASH_SIMULATOR_ERASE_VALUE, - flash_erase_at_start); + rc = flash_mock_init_native(dev_data->flash_in_ram, &dev_data->mock_flash, cfg->flash_size, + &dev_data->flash_fd, dev_data->flash_file_path, + cfg->flash_parameters->erase_value, + dev_data->flash_erase_at_start); if (rc < 0) { return -EIO; @@ -468,96 +439,56 @@ static int flash_mock_init(const struct device *dev) } #else -#if DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) static int flash_mock_init(const struct device *dev) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; + + if (dev_data->flash_erase_at_start) { + memset(dev_data->mock_flash, cfg->flash_parameters->erase_value, cfg->flash_size); + } + return 0; } -#else -static int flash_mock_init(const struct device *dev) +#endif /* CONFIG_ARCH_POSIX */ + +static int flash_sim_pm_control(const struct device *dev, enum pm_device_action action) { - ARG_UNUSED(dev); - memset(mock_flash, FLASH_SIMULATOR_ERASE_VALUE, ARRAY_SIZE(mock_flash)); + /* No action needed, exists only to enable validating get/put balancing in tests */ return 0; } -#endif /* DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) */ -#endif /* CONFIG_ARCH_POSIX */ static int flash_init(const struct device *dev) { + int rc; + FLASH_SIM_STATS_INIT_AND_REG(flash_sim_stats, STATS_SIZE_32, "flash_sim_stats"); FLASH_SIM_STATS_INIT_AND_REG(flash_sim_thresholds, STATS_SIZE_32, "flash_sim_thresholds"); - return flash_mock_init(dev); -} - -DEVICE_DT_INST_DEFINE(0, flash_init, NULL, - NULL, NULL, POST_KERNEL, CONFIG_FLASH_INIT_PRIORITY, - &flash_sim_api); - -#ifdef CONFIG_ARCH_POSIX - -static void flash_native_cleanup(void) -{ - flash_mock_cleanup_native(flash_in_ram, flash_fd, mock_flash, - FLASH_SIMULATOR_FLASH_SIZE, flash_file_path, - flash_rm_at_exit); -} - -static void flash_native_options(void) -{ - static struct args_struct_t flash_options[] = { - { .option = "flash", - .name = "path", - .type = 's', - .dest = (void *)&flash_file_path, - .descript = "Path to binary file to be used as flash, by default \"" - DEFAULT_FLASH_FILE_PATH "\""}, - { .is_switch = true, - .option = "flash_erase", - .type = 'b', - .dest = (void *)&flash_erase_at_start, - .descript = "Erase the flash content at startup" }, - { .is_switch = true, - .option = "flash_rm", - .type = 'b', - .dest = (void *)&flash_rm_at_exit, - .descript = "Remove the flash file when terminating the execution" }, - { .is_switch = true, - .option = "flash_in_ram", - .type = 'b', - .dest = (void *)&flash_in_ram, - .descript = "Instead of a file, keep the file content just in RAM. If this is " - "set, flash, flash_erase & flash_rm are ignored. The flash content" - " is always erased at startup" }, - ARG_TABLE_ENDMARKER - }; - - native_add_command_line_opts(flash_options); + rc = flash_mock_init(dev); + if (rc == 0) { + rc = pm_device_driver_init(dev, flash_sim_pm_control); + } + return rc; } -NATIVE_TASK(flash_native_options, PRE_BOOT_1, 1); -NATIVE_TASK(flash_native_cleanup, ON_EXIT, 1); - -#endif /* CONFIG_ARCH_POSIX */ - /* Extension to generic flash driver API */ void *z_impl_flash_simulator_get_memory(const struct device *dev, size_t *mock_size) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; - *mock_size = FLASH_SIMULATOR_FLASH_SIZE; - return mock_flash; + *mock_size = cfg->flash_size; + return dev_data->mock_flash; } const struct flash_simulator_params *z_impl_flash_simulator_get_params(const struct device *dev) { - ARG_UNUSED(dev); + __maybe_unused const struct flash_simulator_config *cfg = dev->config; #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS - return &flash_sim_params; + return cfg->flash_simulator_params; #else return NULL; #endif @@ -567,8 +498,9 @@ const struct flash_simulator_params *z_impl_flash_simulator_get_params(const str void z_impl_flash_simulator_set_callbacks(const struct device *dev, const struct flash_simulator_cb *cb) { - ARG_UNUSED(dev); - flash_simulator_cbs = cb; + struct flash_simulator_data *dev_data = dev->data; + + dev_data->flash_simulator_cbs = cb; } #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ @@ -602,3 +534,163 @@ const struct flash_simulator_params *z_vrfy_flash_simulator_get_params(const str #include #endif /* CONFIG_USERSPACE */ + +#define SOC_NV_FLASH_COMPAT(n) COND_CODE_1(DT_NODE_HAS_COMPAT(n, soc_nv_flash), (n), ()) +#define SOC_NV_FLASH_NODE(n) DT_INST_FOREACH_CHILD_STATUS_OKAY(n, SOC_NV_FLASH_COMPAT) +#define FLASH_SIMULATOR_BASE_OFFSET(n) DT_REG_ADDR(SOC_NV_FLASH_NODE(n)) +#define FLASH_SIMULATOR_ERASE_UNIT(n) DT_PROP(SOC_NV_FLASH_NODE(n), erase_block_size) +#define FLASH_SIMULATOR_PROG_UNIT(n) DT_PROP(SOC_NV_FLASH_NODE(n), write_block_size) +#define FLASH_SIMULATOR_FLASH_SIZE(n) DT_REG_SIZE(SOC_NV_FLASH_NODE(n)) +#define FLASH_SIMULATOR_ERASE_VALUE(n) DT_INST_PROP(n, erase_value) +#define FLASH_SIMULATOR_PAGE_COUNT(n) \ + (FLASH_SIMULATOR_FLASH_SIZE(n) / FLASH_SIMULATOR_ERASE_UNIT(n)) + +/* Resolve the no_explicit_erase capability per device instance. + * DT_INST_PROP for a boolean type is 0 when absent, 1 when set in DTS, + * so a logical OR with the Kconfig fallback covers all cases correctly. + */ +#define FLASH_SIMULATOR_NO_EXPLICIT_ERASE(n) \ + (DT_INST_PROP(n, no_explicit_erase) || \ + !IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE)) + +#define MOCK_FLASH_SECTION(n) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(n, memory_region), \ + (Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_INST_PHANDLE(n, memory_region)))), ()) + +#define FLASH_SIMULATOR_INIT(n) \ + IF_DISABLED(CONFIG_ARCH_POSIX, ( \ + static uint8_t mock_flash_##n[FLASH_SIMULATOR_FLASH_SIZE(n)] MOCK_FLASH_SECTION(n);\ + )) \ + static uint8_t prog_unit_buf_##n[FLASH_SIMULATOR_PROG_UNIT(n)]; \ + static struct flash_simulator_data flash_simulator_data_##n = { \ + .mock_flash = COND_CODE_1(CONFIG_ARCH_POSIX, (NULL), (mock_flash_##n)), \ + .flash_erase_at_start = !DT_INST_NODE_HAS_PROP(n, memory_region), \ + IF_ENABLED(CONFIG_ARCH_POSIX, ( \ + .flash_fd = -1, \ + )) \ + }; \ + \ + static const struct flash_parameters flash_parameters_##n = { \ + .write_block_size = FLASH_SIMULATOR_PROG_UNIT(n), \ + .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), \ + .caps = { \ + .no_explicit_erase = FLASH_SIMULATOR_NO_EXPLICIT_ERASE(n), \ + }, \ + }; \ + \ + IF_ENABLED(CONFIG_FLASH_SIMULATOR_CALLBACKS, ( \ + static const struct flash_simulator_params flash_simulator_params_##n = { \ + .memory_size = FLASH_SIMULATOR_FLASH_SIZE(n), \ + .base_offset = FLASH_SIMULATOR_BASE_OFFSET(n), \ + .erase_unit = FLASH_SIMULATOR_ERASE_UNIT(n), \ + .prog_unit = FLASH_SIMULATOR_PROG_UNIT(n), \ + .explicit_erase = IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), \ + .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), \ + }; \ + )) \ + \ + IF_ENABLED(CONFIG_FLASH_PAGE_LAYOUT, ( \ + static const struct flash_pages_layout flash_sim_pages_layout_##n = { \ + .pages_count = FLASH_SIMULATOR_PAGE_COUNT(n), \ + .pages_size = FLASH_SIMULATOR_ERASE_UNIT(n), \ + }; \ + )) \ + \ + static const struct flash_simulator_config flash_simulator_config_##n = { \ + .prog_unit_buf = prog_unit_buf_##n, \ + .flash_parameters = &flash_parameters_##n, \ + .base_offset = FLASH_SIMULATOR_BASE_OFFSET(n), \ + .erase_unit = FLASH_SIMULATOR_ERASE_UNIT(n), \ + .flash_size = FLASH_SIMULATOR_FLASH_SIZE(n), \ + IF_ENABLED(CONFIG_FLASH_SIMULATOR_CALLBACKS, ( \ + .flash_simulator_params = &flash_simulator_params_##n, \ + )) \ + IF_ENABLED(CONFIG_FLASH_PAGE_LAYOUT, ( \ + .pages_layout = &flash_sim_pages_layout_##n, \ + )) \ + IF_ENABLED(CONFIG_ARCH_POSIX, ( \ + .flash_file_default_path = DEFAULT_FLASH_FILE_PATH(n) \ + )) \ + }; \ + \ + BUILD_ASSERT((FLASH_SIMULATOR_ERASE_UNIT(n) % FLASH_SIMULATOR_PROG_UNIT(n)) == 0, \ + "Erase unit must be a multiple of program unit"); \ + \ + PM_DEVICE_DT_INST_DEFINE(n, flash_sim_pm_control); \ + DEVICE_DT_INST_DEFINE(n, flash_init, PM_DEVICE_DT_INST_GET(n), &flash_simulator_data_##n, \ + &flash_simulator_config_##n, POST_KERNEL, \ + CONFIG_FLASH_INIT_PRIORITY, &flash_sim_api); + +DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_INIT); + +#ifdef CONFIG_ARCH_POSIX + +#define FLASH_SIMULATOR_CLEANUP(n) \ + flash_mock_cleanup_native( \ + flash_simulator_data_##n.flash_in_ram, flash_simulator_data_##n.flash_fd, \ + flash_simulator_data_##n.mock_flash, flash_simulator_config_##n.flash_size, \ + flash_simulator_data_##n.flash_file_path, \ + flash_simulator_data_##n.flash_rm_at_exit); + +static void flash_native_cleanup(void) +{ + DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_CLEANUP) +} + +#define FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(n, INST_NAME) \ + { \ + .option = INST_NAME, \ + .name = "path", \ + .type = 's', \ + .dest = (void *)&flash_simulator_data_##n.flash_file_path, \ + .descript = "Path to binary file to be used as flash by " INST_NAME \ + ", by default \"" DEFAULT_FLASH_FILE_PATH(n) "\"" \ + }, \ + { \ + .option = INST_NAME "_erase", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_erase_at_start, \ + .descript = "Erase the flash content of " INST_NAME " at startup" \ + }, \ + { \ + .option = INST_NAME "_rm", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_rm_at_exit, \ + .descript = "Remove the flash file of " INST_NAME " when terminating the " \ + "execution" \ + }, \ + { \ + .option = INST_NAME "_in_ram", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_in_ram, \ + .descript = "Instead of a file, keep the content of " INST_NAME " just in RAM. " \ + "If this is set, " INST_NAME ", " INST_NAME "_erase & " \ + INST_NAME "_rm are ignored. The flash content is always erased at startup." \ + }, + +#define FLASH_SIMULATOR_COMMAND_LINE_OPTS(n) \ + FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(n, DEVICE_DT_NAME(SOC_NV_FLASH_NODE(n))) + +static void flash_native_options(void) +{ + static struct args_struct_t flash_options[] = { + /* For backward compatibility, instance 0 is also available with "flash" */ + /* as command line option prefix. */ + COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), ( + FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(0, "flash") + ), ()) + + DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_COMMAND_LINE_OPTS) + ARG_TABLE_ENDMARKER + }; + + native_add_command_line_opts(flash_options); +} + +NATIVE_TASK(flash_native_options, PRE_BOOT_1, 1); +NATIVE_TASK(flash_native_cleanup, ON_EXIT, 1); + +#endif /* CONFIG_ARCH_POSIX */ diff --git a/drivers/flash/soc_flash_nrf_mram.c b/drivers/flash/soc_flash_nrf_mram.c index 51331786dcf5..3fad53d31dd1 100644 --- a/drivers/flash/soc_flash_nrf_mram.c +++ b/drivers/flash/soc_flash_nrf_mram.c @@ -14,14 +14,16 @@ LOG_MODULE_REGISTER(flash_nrf_mram, CONFIG_FLASH_LOG_LEVEL); #define DT_DRV_COMPAT nordic_mram -#define MRAM_START DT_INST_REG_ADDR(0) -#define MRAM_SIZE DT_INST_REG_SIZE(0) +#define MRAM_NVM_CHILD_NODE DT_INST_CHILD(0, mram_memory_0) + +#define MRAM_START DT_REG_ADDR(MRAM_NVM_CHILD_NODE) +#define MRAM_SIZE DT_REG_SIZE(MRAM_NVM_CHILD_NODE) #define MRAM_WORD_SIZE 16 #define MRAM_WORD_MASK 0xf -#define WRITE_BLOCK_SIZE DT_INST_PROP_OR(0, write_block_size, MRAM_WORD_SIZE) -#define ERASE_BLOCK_SIZE DT_INST_PROP_OR(0, erase_block_size, WRITE_BLOCK_SIZE) +#define WRITE_BLOCK_SIZE DT_PROP_OR(MRAM_NVM_CHILD_NODE, write_block_size, MRAM_WORD_SIZE) +#define ERASE_BLOCK_SIZE DT_PROP_OR(MRAM_NVM_CHILD_NODE, erase_block_size, WRITE_BLOCK_SIZE) #define ERASE_VALUE 0xff diff --git a/drivers/haptics/cs40l5x.c b/drivers/haptics/cs40l5x.c index 76111e902a5d..5cf14a828a52 100644 --- a/drivers/haptics/cs40l5x.c +++ b/drivers/haptics/cs40l5x.c @@ -2624,15 +2624,15 @@ __maybe_unused static int cs40l5x_deinit(const struct device *dev) (.interrupt_gpio = {.port = NULL, .pin = 0},)) #define HAPTICS_CS40L5X_FLASH_DEVICE(inst) \ - DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(DT_INST_PHANDLE(inst, flash_storage))) + DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_PARTITION(DT_INST_PHANDLE(inst, flash_storage))) #define HAPTICS_CS40L5X_FLASH_OFFSET(inst) \ - FIXED_PARTITION_NODE_OFFSET(DT_INST_PHANDLE(inst, flash_storage)) + \ + PARTITION_NODE_OFFSET(DT_INST_PHANDLE(inst, flash_storage)) + \ DT_INST_PROP_OR(inst, flash_offset, 0) #define HAPTICS_CS40L5X_FLASH(inst) \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, flash_storage), \ - (COND_CODE_1(DT_FIXED_PARTITION_EXISTS(DT_INST_PHANDLE(inst, flash_storage)), \ + (COND_CODE_1(DT_PARTITION_EXISTS(DT_INST_PHANDLE(inst, flash_storage)), \ (.flash = HAPTICS_CS40L5X_FLASH_DEVICE(inst), \ .flash_offset = HAPTICS_CS40L5X_FLASH_OFFSET(inst),), \ (.flash = DEVICE_DT_GET(DT_INST_PHANDLE(inst, flash_storage)), \ diff --git a/drivers/ieee802154/ieee802154_mcxw.c b/drivers/ieee802154/ieee802154_mcxw.c index b724c3a5cb6a..49d6f1ead038 100644 --- a/drivers/ieee802154/ieee802154_mcxw.c +++ b/drivers/ieee802154/ieee802154_mcxw.c @@ -66,7 +66,7 @@ static uint16_t rf_compute_csl_phase(uint32_t aTimeUs); #endif /* CONFIG_IEEE802154_CSL_ENDPOINT */ /* Hardware parameters partition and offsets */ -#define HW_PARAMS_PARTITION_ID FIXED_PARTITION_ID(hw_params_partition) +#define HW_PARAMS_PARTITION_ID PARTITION_ID(hw_params_partition) #define MAC_ADDRESS_OFFSET 0x00 #define MAC_ADDRESS_LEN 8 diff --git a/drivers/wuc/Kconfig b/drivers/wuc/Kconfig new file mode 100644 index 000000000000..7e06af4094f9 --- /dev/null +++ b/drivers/wuc/Kconfig @@ -0,0 +1,26 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +menuconfig WUC + bool "Wakeup Controller drivers" + help + Enable wakeup controller driver configuration + +if WUC + +module = WUC +module-str = WUC +source "subsys/logging/Kconfig.template.log_config" + +config WUC_INIT_PRIORITY + int "Wakeup controller init priority" + default KERNEL_INIT_PRIORITY_DEVICE + help + Wakeup controller device driver initialization priority. + + +# zephyr-keep-sorted-start + +# zephyr-keep-sorted-stop + +endif # WAKEUP_CONTROL diff --git a/dts/arm/nordic/nrf51822.dtsi b/dts/arm/nordic/nrf51822.dtsi index 5644ea2787bf..d5445555787f 100644 --- a/dts/arm/nordic/nrf51822.dtsi +++ b/dts/arm/nordic/nrf51822.dtsi @@ -32,6 +32,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -309,7 +311,7 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf51-flash-controller"; reg = <0x4001e000 0x1000>; - + ranges; #address-cells = <1>; #size-cells = <1>; @@ -317,6 +319,9 @@ compatible = "soc-nv-flash"; erase-block-size = <1024>; write-block-size = <4>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf51822_qfaa.dtsi b/dts/arm/nordic/nrf51822_qfaa.dtsi index b2ce647684e9..c2166a6134c7 100644 --- a/dts/arm/nordic/nrf51822_qfaa.dtsi +++ b/dts/arm/nordic/nrf51822_qfaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(16)>; ranges = <0x0 0x20000000 DT_SIZE_K(16)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf51822_qfab.dtsi b/dts/arm/nordic/nrf51822_qfab.dtsi index d4327bb2b755..89d26d0daf5b 100644 --- a/dts/arm/nordic/nrf51822_qfab.dtsi +++ b/dts/arm/nordic/nrf51822_qfab.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(128)>; + ranges = <0x0 0x00000000 DT_SIZE_K(128)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(16)>; ranges = <0x0 0x20000000 DT_SIZE_K(16)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf51822_qfac.dtsi b/dts/arm/nordic/nrf51822_qfac.dtsi index f41890945e47..350d552e6661 100644 --- a/dts/arm/nordic/nrf51822_qfac.dtsi +++ b/dts/arm/nordic/nrf51822_qfac.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52805.dtsi b/dts/arm/nordic/nrf52805.dtsi index 0d564955f8c1..ce9ce4e0f816 100644 --- a/dts/arm/nordic/nrf52805.dtsi +++ b/dts/arm/nordic/nrf52805.dtsi @@ -37,6 +37,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -318,8 +320,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -327,6 +329,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52805_caaa.dtsi b/dts/arm/nordic/nrf52805_caaa.dtsi index 38daaff88d0e..c796fa94acf2 100644 --- a/dts/arm/nordic/nrf52805_caaa.dtsi +++ b/dts/arm/nordic/nrf52805_caaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index d95751752109..95e636ac2cb5 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -348,8 +350,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -357,6 +359,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52810_qfaa.dtsi b/dts/arm/nordic/nrf52810_qfaa.dtsi index 344eca772f37..6c5484ae4e2c 100644 --- a/dts/arm/nordic/nrf52810_qfaa.dtsi +++ b/dts/arm/nordic/nrf52810_qfaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52811.dtsi b/dts/arm/nordic/nrf52811.dtsi index 5c55cf44edcf..b46e9c19a2fc 100644 --- a/dts/arm/nordic/nrf52811.dtsi +++ b/dts/arm/nordic/nrf52811.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -375,8 +377,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -384,6 +386,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52811_qfaa.dtsi b/dts/arm/nordic/nrf52811_qfaa.dtsi index 18eacff06234..e22d206cbabc 100644 --- a/dts/arm/nordic/nrf52811_qfaa.dtsi +++ b/dts/arm/nordic/nrf52811_qfaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52820.dtsi b/dts/arm/nordic/nrf52820.dtsi index d67d81686a4a..2ba1de52bd99 100644 --- a/dts/arm/nordic/nrf52820.dtsi +++ b/dts/arm/nordic/nrf52820.dtsi @@ -44,6 +44,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -386,8 +388,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -395,6 +397,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52820_qdaa.dtsi b/dts/arm/nordic/nrf52820_qdaa.dtsi index 585926d1a166..3f94d2637c59 100644 --- a/dts/arm/nordic/nrf52820_qdaa.dtsi +++ b/dts/arm/nordic/nrf52820_qdaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(256)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index a127ffb194d9..cfef9324daaf 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -415,7 +417,7 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; - + ranges; #address-cells = <1>; #size-cells = <1>; @@ -423,6 +425,9 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52832_ciaa.dtsi b/dts/arm/nordic/nrf52832_ciaa.dtsi index 28848a4d1213..e9f8c99279ea 100644 --- a/dts/arm/nordic/nrf52832_ciaa.dtsi +++ b/dts/arm/nordic/nrf52832_ciaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(64)>; ranges = <0x0 0x20000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832_qfaa.dtsi b/dts/arm/nordic/nrf52832_qfaa.dtsi index 28848a4d1213..e9f8c99279ea 100644 --- a/dts/arm/nordic/nrf52832_qfaa.dtsi +++ b/dts/arm/nordic/nrf52832_qfaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(64)>; ranges = <0x0 0x20000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832_qfab.dtsi b/dts/arm/nordic/nrf52832_qfab.dtsi index 5c0d3dd8abdb..1daf479f8bea 100644 --- a/dts/arm/nordic/nrf52832_qfab.dtsi +++ b/dts/arm/nordic/nrf52832_qfab.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52833.dtsi b/dts/arm/nordic/nrf52833.dtsi index 33df68336231..11b3e5c0d348 100644 --- a/dts/arm/nordic/nrf52833.dtsi +++ b/dts/arm/nordic/nrf52833.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -432,8 +434,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -441,6 +443,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52833_qdaa.dtsi b/dts/arm/nordic/nrf52833_qdaa.dtsi index 2c4ebaa0014a..c18fda8a0f08 100644 --- a/dts/arm/nordic/nrf52833_qdaa.dtsi +++ b/dts/arm/nordic/nrf52833_qdaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(512)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(128)>; ranges = <0x0 0x20000000 DT_SIZE_K(128)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52833_qiaa.dtsi b/dts/arm/nordic/nrf52833_qiaa.dtsi index 2b15451b3306..e6487d077f9c 100644 --- a/dts/arm/nordic/nrf52833_qiaa.dtsi +++ b/dts/arm/nordic/nrf52833_qiaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(512)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(128)>; ranges = <0x0 0x20000000 DT_SIZE_K(128)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 15052e2e82a4..6ef3d3e0bb6a 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -60,6 +62,8 @@ sram0: memory@20000000 { compatible = "mmio-sram"; + reg = <0x20000000 DT_SIZE_K(256)>; + ranges = <0x0 0x20000000 DT_SIZE_K(256)>; #address-cells = <1>; #size-cells = <1>; }; @@ -423,8 +427,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -432,6 +436,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52840_qfaa.dtsi b/dts/arm/nordic/nrf52840_qfaa.dtsi index 9c4b70a10d0b..9b7a8c105f13 100644 --- a/dts/arm/nordic/nrf52840_qfaa.dtsi +++ b/dts/arm/nordic/nrf52840_qfaa.dtsi @@ -7,19 +7,4 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - -&sram0 { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - -/ { - soc { - compatible = "simple-bus"; - }; -}; - /delete-node/ &usbd; diff --git a/dts/arm/nordic/nrf52840_qiaa.dtsi b/dts/arm/nordic/nrf52840_qiaa.dtsi index 3ad3537a05d7..b83f0bde4033 100644 --- a/dts/arm/nordic/nrf52840_qiaa.dtsi +++ b/dts/arm/nordic/nrf52840_qiaa.dtsi @@ -7,15 +7,6 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - -&sram0 { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - &power { reg0: regulator@40000580 { compatible = "nordic,nrf52x-regulator-hv"; @@ -24,9 +15,3 @@ status = "disabled"; }; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf5340_cpuapp.dtsi b/dts/arm/nordic/nrf5340_cpuapp.dtsi index cca54846a8a7..47983b1ef5ac 100644 --- a/dts/arm/nordic/nrf5340_cpuapp.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp.dtsi @@ -39,6 +39,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@ff0000 { compatible = "nordic,nrf-ficr"; reg = <0xff0000 0x1000>; @@ -71,6 +73,26 @@ #include "nrf5340_cpuapp_peripherals.dtsi" }; + flash_controller: flash-controller@50039000 { + compatible = "nordic,nrf53-flash-controller"; + reg = <0x50039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* Additional Secure peripherals */ spu: spu@50003000 { diff --git a/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi index 2fe9dc6b7292..784a670fe03e 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi @@ -35,6 +35,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -53,6 +55,26 @@ #include "nrf5340_cpuapp_peripherals.dtsi" }; + flash_controller: flash-controller@40039000 { + compatible = "nordic,nrf53-flash-controller"; + reg = <0x40039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* * GPIOTE1 is always accessible as a non-secure peripheral, * so we give it the 'gpiote' label for use when building diff --git a/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi index bdcd4d9d462c..aad593f7129a 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi index 31c3cd827d6e..46e2a0364758 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi @@ -530,21 +530,6 @@ usbreg: regulator@37000 { status = "okay"; }; -flash_controller: flash-controller@39000 { - compatible = "nordic,nrf53-flash-controller"; - reg = <0x39000 0x1000>; - partial-erase; - - #address-cells = <1>; - #size-cells = <1>; - - flash0: flash@0 { - compatible = "soc-nv-flash"; - erase-block-size = <4096>; - write-block-size = <4>; - }; -}; - kmu: kmu@39000 { compatible = "nordic,nrf-kmu"; reg = <0x39000 0x1000>; diff --git a/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi index cd9983d949ec..1a75ccd2d067 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf5340_cpunet.dtsi b/dts/arm/nordic/nrf5340_cpunet.dtsi index 49348ff83991..b29a66012482 100644 --- a/dts/arm/nordic/nrf5340_cpunet.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@1ff0000 { compatible = "nordic,nrf-ficr"; reg = <0x01ff0000 0x1000>; @@ -311,8 +313,8 @@ flash_controller: flash-controller@41080000 { compatible = "nordic,nrf53-flash-controller"; reg = <0x41080000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -320,6 +322,9 @@ compatible = "soc-nv-flash"; erase-block-size = <2048>; write-block-size = <4>; + reg = <0x1000000 DT_SIZE_K(256)>; + ranges = <0x0 0x1000000 DT_SIZE_K(256)>; + status = "okay"; #address-cells = <1>; #size-cells = <1>; }; diff --git a/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi index 6c06e3479927..e5546c705c18 100644 --- a/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi @@ -7,11 +7,6 @@ #include #include -&flash1 { - reg = <0x01000000 DT_SIZE_K(256)>; - ranges = <0x0 0x01000000 DT_SIZE_K(256)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; @@ -21,9 +16,3 @@ reg = <0x21000000 DT_SIZE_K(64)>; ranges = <0x0 0x21000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi index 6e0b57f0f0d4..a94b246e0fd1 100644 --- a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi @@ -13,11 +13,6 @@ nvic: &cpuapp_nvic {}; /delete-node/ &cpuflpr; /delete-node/ &cpuflpr_clic; -#ifndef USE_NON_SECURE_ADDRESS_MAP -/delete-node/ &cpuflpr_rram; -/delete-node/ &cpuflpr_sram; -#endif - / { chosen { zephyr,bt-hci = &bt_hci_sdc; diff --git a/dts/arm/nordic/nrf91.dtsi b/dts/arm/nordic/nrf91.dtsi index 74afa25f76a7..b384ccb38beb 100644 --- a/dts/arm/nordic/nrf91.dtsi +++ b/dts/arm/nordic/nrf91.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -49,6 +51,26 @@ #include "nrf91_peripherals.dtsi" }; + flash_controller: flash-controller@50039000 { + compatible = "nordic,nrf91-flash-controller"; + reg = <0x50039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* Additional Secure peripherals */ cryptocell: crypto@50840000 { compatible = "arm,cryptocell-310"; diff --git a/dts/arm/nordic/nrf9131_laca.dtsi b/dts/arm/nordic/nrf9131_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9131_laca.dtsi +++ b/dts/arm/nordic/nrf9131_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9131_ns_laca.dtsi b/dts/arm/nordic/nrf9131_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9131_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9131_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9151_laca.dtsi b/dts/arm/nordic/nrf9151_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9151_laca.dtsi +++ b/dts/arm/nordic/nrf9151_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9151_ns_laca.dtsi b/dts/arm/nordic/nrf9151_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9151_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9151_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9160_ns_sica.dtsi b/dts/arm/nordic/nrf9160_ns_sica.dtsi index 3fad45ebb2d9..a2b3025a694a 100644 --- a/dts/arm/nordic/nrf9160_ns_sica.dtsi +++ b/dts/arm/nordic/nrf9160_ns_sica.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9160_sica.dtsi b/dts/arm/nordic/nrf9160_sica.dtsi index e00d03fb5afc..f7db48076e33 100644 --- a/dts/arm/nordic/nrf9160_sica.dtsi +++ b/dts/arm/nordic/nrf9160_sica.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9161_laca.dtsi b/dts/arm/nordic/nrf9161_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9161_laca.dtsi +++ b/dts/arm/nordic/nrf9161_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9161_ns_laca.dtsi b/dts/arm/nordic/nrf9161_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9161_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9161_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf91_ns.dtsi b/dts/arm/nordic/nrf91_ns.dtsi index 7d52cd28902c..20c962595d9b 100644 --- a/dts/arm/nordic/nrf91_ns.dtsi +++ b/dts/arm/nordic/nrf91_ns.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -49,6 +51,26 @@ #include "nrf91_peripherals.dtsi" }; + flash_controller: flash-controller@40039000 { + compatible = "nordic,nrf91-flash-controller"; + reg = <0x40039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* * GPIOTE1 is always accessible as a non-secure peripheral, * so we give it the 'gpiote' label for use when building diff --git a/dts/arm/nordic/nrf91_peripherals.dtsi b/dts/arm/nordic/nrf91_peripherals.dtsi index 1108b6f66501..d7a8f8b7d0af 100644 --- a/dts/arm/nordic/nrf91_peripherals.dtsi +++ b/dts/arm/nordic/nrf91_peripherals.dtsi @@ -4,21 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -flash_controller: flash-controller@39000 { - compatible = "nordic,nrf91-flash-controller"; - reg = <0x39000 0x1000>; - partial-erase; - - #address-cells = <1>; - #size-cells = <1>; - - flash0: flash@0 { - compatible = "soc-nv-flash"; - erase-block-size = <4096>; - write-block-size = <4>; - }; -}; - adc: adc@e000 { compatible = "nordic,nrf-saadc"; reg = <0xe000 0x1000>; diff --git a/dts/bindings/flash_controller/zephyr,sim-flash.yaml b/dts/bindings/flash_controller/zephyr,sim-flash.yaml index 21b78b750126..f28e076a2fc0 100644 --- a/dts/bindings/flash_controller/zephyr,sim-flash.yaml +++ b/dts/bindings/flash_controller/zephyr,sim-flash.yaml @@ -16,3 +16,10 @@ properties: description: | Memory region used by the simulated flash memory. If this option is used the memory that is used by the simulated flash memory is not erased. + no-explicit-erase: + type: boolean + description: | + When set, this instance behaves as a RAM-like device that does not + require explicit erase before write. Overrides the global + CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE Kconfig option for this instance, + allowing different simulator instances to have different erase modes. diff --git a/dts/bindings/mtd/fixed-partitions.yaml b/dts/bindings/mtd/fixed-partitions.yaml index 365762bf8df3..fd791e93b1a7 100644 --- a/dts/bindings/mtd/fixed-partitions.yaml +++ b/dts/bindings/mtd/fixed-partitions.yaml @@ -53,6 +53,8 @@ description: | compatible: "fixed-partitions" +include: base.yaml + properties: "#address-cells": type: int diff --git a/dts/bindings/mtd/fixed-subpartitions.yaml b/dts/bindings/mtd/fixed-subpartitions.yaml index ac70d1815f7b..42d985d34612 100644 --- a/dts/bindings/mtd/fixed-subpartitions.yaml +++ b/dts/bindings/mtd/fixed-subpartitions.yaml @@ -32,6 +32,8 @@ description: | compatible: "fixed-subpartitions" +include: base.yaml + properties: label: type: string diff --git a/dts/bindings/mtd/zephyr,mapped-partition.yaml b/dts/bindings/mtd/zephyr,mapped-partition.yaml new file mode 100644 index 000000000000..eb7f351a7c04 --- /dev/null +++ b/dts/bindings/mtd/zephyr,mapped-partition.yaml @@ -0,0 +1,149 @@ +description: | + Memory-mapped partition of a flash (or other non-volatile storage) memory. + + The `zephyr,mapped-partition` node should be (descendant) children of the NVM memory node, either + directly or through intermediatory grouping child nodes or through parent + `zephyr,mapped-partition` nodes. Note that the NVM memory node and NVM controller nodes must have + `ranges` properties to indicate that they are all part of the SoC's address space which specify + the full range of the NVM area (usually the same as the `reg` property with a 0x0 prepended + before the offset value). Nested `zephyr,mapped-partition` nodes are supported, and should have + `ranges` properties set to indicate their range to their child nodes. + +compatible: "zephyr,mapped-partition" + +include: base.yaml + +properties: + "#address-cells": + type: int + description: | + Number of cells required to represent a child node's reg property address. This must be + large enough to represent the start offset of each partition. + + "#size-cells": + type: int + description: | + Number of cells required to represent a child node's reg property address. This must be + large enough to represent the size of each partition in bytes. + + label: + type: string + description: Human readable string describing the NVM partition. + + read-only: + type: boolean + description: Set this property if the partition is read-only + + reg: + type: array + required: true + description: | + This should be in the format , where OFFSET is the offset of the flash + partition relative to the base address of the parent memory, and SIZE is the size of the + partition in bytes. + +examples: + - | + /* + * The NVM controller node defines the ranges which map the NVM memory nodes to the CPU address + * space. + */ + flash_controller: flash-controller@4001e000 { + compatible = "vnd,flash-controller" + reg = <0x4001e000 0x1000> + ranges; + #address-cells = <1>; + #size-cells = <1>; + + /* + * An NVM memory node describes a consecutive block of non volatile physical memory. + * Partitions are added to the this node, adhering to physical limitations like + * write-block-size. An empty `ranges;` property is required to ensure any partition + * added to the NVM memory is mapped correctly to the CPU address space, and a + * nodelabel should be defined make it easier for applications to add add partitions + * to the NVM memory node. + */ + flash0: flash@0 { + compatible = "soc-nv-flash" + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)> + #address-cells = <1>; + #size-cells = <1>; + + /* + * The 'partitions' grouping is optional, it allows for clearing all partitions + * in a device (e.g. using a dtc overlay file) but is not required. If used, + * then it needs a `ranges;` property and to specify the #address-cells and + * #size-cells properties + */ + partitions { + ranges; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Offsets are relative to the flash0 node, if flash0 had an address of + * 0x10000000 then the below offset of 0x0 means address 0x10000000 + */ + boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mcuboot"; + reg = <0x0 0xc000>; + }; + + slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; + label = "image-0"; + reg = <0xc000 0x76000>; + }; + + slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; + label = "image-1"; + reg = <0x82000 0x76000>; + }; + + /* + * Below example disables an NVM partition, if using the flash map + * subsystem with the default mappings then the below partition will + * not be present in the flash map + */ + storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; + label = "storage"; + reg = <0xf8000 0x8000>; + status = "disabled"; + }; + }; + }; + + flash1: flash@10000000 { + compatible = "soc-nv-flash" + reg = <0x10000000 DT_SIZE_K(256)>; + ranges = <0x0 0x10000000 DT_SIZE_K(256)>; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Below demonstrates usage without partitions {}; grouping, and demos + * partitions inside of a parent partition + */ + external_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + reg = <0x0 0x10000>; + ranges = <0x0 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <1>; + + external_inner_a_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + reg = <0x0 0x6000>; + }; + + external_inner_b_partition: partition@6000 { + compatible = "zephyr,mapped-partition"; + reg = <0x6000 0xa000>; + }; + }; + }; + }; diff --git a/dts/bindings/test/vnd,gpio-nexus.yaml b/dts/bindings/test/vnd,gpio-nexus.yaml new file mode 100644 index 000000000000..2274be7451da --- /dev/null +++ b/dts/bindings/test/vnd,gpio-nexus.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025, TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +description: VND GPIO nexus + +include: [gpio-nexus.yaml] + +compatible: "vnd,gpio-nexus" diff --git a/dts/bindings/test/vnd,intr-nexus.yaml b/dts/bindings/test/vnd,intr-nexus.yaml new file mode 100644 index 000000000000..f3b194c55838 --- /dev/null +++ b/dts/bindings/test/vnd,intr-nexus.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025, TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +description: VND interrupt nexus + +include: [interrupt-nexus.yaml] + +compatible: "vnd,intr-nexus" diff --git a/dts/bindings/wuc/wuc-controller.yaml b/dts/bindings/wuc/wuc-controller.yaml new file mode 100644 index 000000000000..314e9fb2d60c --- /dev/null +++ b/dts/bindings/wuc/wuc-controller.yaml @@ -0,0 +1,13 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +description: | + Common file for Wakeup Controllers + +properties: + "#wakeup-ctrl-cells": + type: int + required: true + description: | + Number of cells in wakeup-ctrls property. There must be a cell + name "id" to use. diff --git a/dts/bindings/wuc/wuc-device.yaml b/dts/bindings/wuc/wuc-device.yaml new file mode 100644 index 000000000000..c8c2cedd01a5 --- /dev/null +++ b/dts/bindings/wuc/wuc-device.yaml @@ -0,0 +1,11 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +description: | + Common file for wake-up source devices referencing wake up controller(s). + +properties: + wakeup-ctrls: + type: phandle-array + description: | + Phandle and wakeup source identifier of the corresponding wakeup controller. diff --git a/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi b/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi deleted file mode 100644 index 4dedf1fbca55..000000000000 --- a/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "nrf54l_05_10_15_cpuflpr.dtsi" diff --git a/dts/vendor/nordic/nrf52840_partition.dtsi b/dts/vendor/nordic/nrf52840_partition.dtsi index 8b5df504d422..4d6c5d4b8557 100644 --- a/dts/vendor/nordic/nrf52840_partition.dtsi +++ b/dts/vendor/nordic/nrf52840_partition.dtsi @@ -14,21 +14,24 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x0000c000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x00076000>; }; slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00082000 0x00076000>; }; @@ -43,6 +46,7 @@ * if enabled. */ storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi index fdf17828390d..f03132baf5ab 100644 --- a/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi @@ -25,17 +25,18 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x70000>; ranges = <0x0 0x10000 0x70000>; @@ -43,18 +44,20 @@ #size-cells = <1>; slot0_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0-secure"; reg = <0x00000000 0x40000>; }; slot0_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x00040000 0x30000>; }; }; slot1_partition: partition@80000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00080000 0x70000>; ranges = <0x0 0x80000 0x70000>; @@ -62,32 +65,38 @@ #size-cells = <1>; slot1_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-1-secure"; reg = <0x00000000 0x40000>; }; slot1_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1-nonsecure"; reg = <0x00040000 0x30000>; }; }; tfm_ps_partition: partition@f0000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x000f0000 0x00004000>; }; tfm_its_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x000f4000 0x00002000>; }; tfm_otp_partition: partition@f6000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x000f6000 0x00002000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi index 37158c092b59..58a3284c24e2 100644 --- a/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi @@ -9,26 +9,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x74000>; }; slot1_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00084000 0x74000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/dts/vendor/nordic/nrf54h20.dtsi b/dts/vendor/nordic/nrf54h20.dtsi index e4a8096701be..cf0821d36e7d 100644 --- a/dts/vendor/nordic/nrf54h20.dtsi +++ b/dts/vendor/nordic/nrf54h20.dtsi @@ -268,14 +268,22 @@ #address-cells = <1>; #size-cells = <1>; - mram1x: mram@e000000 { + mram1x_controller: mram-controller@5f092000 { compatible = "nordic,mram"; - reg = <0xe000000 DT_SIZE_K(2048)>; + reg = <0x5f092000 0x2000>; ranges = <0x0 0xe000000 DT_SIZE_K(2048)>; - erase-block-size = <4096>; - write-block-size = <16>; #address-cells = <1>; #size-cells = <1>; + + mram1x: mram-memory@0 { + compatible = "soc-nv-flash"; + reg = <0 DT_SIZE_K(2048)>; + ranges; + erase-block-size = <4096>; + write-block-size = <16>; + #address-cells = <1>; + #size-cells = <1>; + }; }; uicr: uicr@fff8000 { diff --git a/dts/vendor/nordic/nrf54l05.dtsi b/dts/vendor/nordic/nrf54l05.dtsi index 8213db7612db..ed7cb38afb12 100644 --- a/dts/vendor/nordic/nrf54l05.dtsi +++ b/dts/vendor/nordic/nrf54l05.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(72)>; - ranges = <0x0 0x20000000 DT_SIZE_K(72)>; -}; - -/* 72 + 24 = 96KB */ -/ { - soc { - cpuflpr_sram: memory@20012000 { - compatible = "mmio-sram"; - reg = <0x20012000 DT_SIZE_K(24)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20012000 DT_SIZE_K(24)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(96)>; + ranges = <0x0 0x20000000 DT_SIZE_K(96)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(470)>; -}; - -/* 470 + 30 = 500KB */ -&rram_controller { - cpuflpr_rram: rram@75800 { - compatible = "soc-nv-flash"; - reg = <0x75800 DT_SIZE_K(30)>; - ranges = <0x0 0x75800 DT_SIZE_K(30)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(500)>; + ranges = <0x0 0x0 DT_SIZE_K(500)>; }; diff --git a/dts/vendor/nordic/nrf54l05_partition.dtsi b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi similarity index 85% rename from dts/vendor/nordic/nrf54l05_partition.dtsi rename to dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi index aa2ea04bce0d..e5fbc2f16c9e 100644 --- a/dts/vendor/nordic/nrf54l05_partition.dtsi +++ b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi @@ -4,11 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(500)>; -}; - -/* These partition sizes assume no FLPR area in RRAM */ &cpuapp_rram { partitions { compatible = "fixed-partitions"; diff --git a/dts/vendor/nordic/nrf54l10.dtsi b/dts/vendor/nordic/nrf54l10.dtsi index 1ef1e5fbba0c..fe94f299982b 100644 --- a/dts/vendor/nordic/nrf54l10.dtsi +++ b/dts/vendor/nordic/nrf54l10.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(144)>; - ranges = <0x0 0x20000000 DT_SIZE_K(144)>; -}; - -/* 144 + 48 = 192KB */ -/ { - soc { - cpuflpr_sram: memory@20024000 { - compatible = "mmio-sram"; - reg = <0x20024000 DT_SIZE_K(48)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20024000 DT_SIZE_K(48)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(192)>; + ranges = <0x0 0x20000000 DT_SIZE_K(192)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(950)>; -}; - -/* 950 + 62 = 1012KB */ -&rram_controller { - cpuflpr_rram: rram@ed800 { - compatible = "soc-nv-flash"; - reg = <0xed800 DT_SIZE_K(62)>; - ranges = <0x0 0xed800 DT_SIZE_K(62)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(1012)>; + ranges = <0x0 0x0 DT_SIZE_K(1012)>; }; diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi index 1ee743b11786..e4c4601defc8 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi @@ -4,13 +4,4 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "nrf54l_05_10_15.dtsi" - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1012)>; -}; +#include "nrf54l10.dtsi" diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi index 92bcd8bb8a30..c88800205b4b 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi @@ -35,7 +35,7 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -46,31 +46,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(384)>; }; tfm_ps_partition: partition@60000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00060000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@64000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00064000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@68000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00068000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@6a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0006a000 DT_SIZE_K(556)>; }; storage_partition: partition@f5000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f5000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi index e73b1c5f0e3f..b0c011d6ac9b 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi @@ -4,11 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1012)>; -}; - -/* These partition sizes assume no FLPR area in RRAM */ &cpuapp_rram { partitions { compatible = "fixed-partitions"; diff --git a/dts/vendor/nordic/nrf54l15.dtsi b/dts/vendor/nordic/nrf54l15.dtsi index d6af3f385f60..ddd0651990dd 100644 --- a/dts/vendor/nordic/nrf54l15.dtsi +++ b/dts/vendor/nordic/nrf54l15.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(188)>; - ranges = <0x0 0x20000000 DT_SIZE_K(188)>; -}; - -/* 188 + 68 = 256KB */ -/ { - soc { - cpuflpr_sram: memory@2002f000 { - compatible = "mmio-sram"; - reg = <0x2002f000 DT_SIZE_K(68)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2002f000 DT_SIZE_K(68)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(256)>; + ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(1428)>; -}; - -/* 1428 + 96 = 1524KB */ -&rram_controller { - cpuflpr_rram: rram@165000 { - compatible = "soc-nv-flash"; - reg = <0x165000 DT_SIZE_K(96)>; - ranges = <0x0 0x165000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(1524)>; + ranges = <0x0 0x0 DT_SIZE_K(1524)>; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi index a96865325b8a..f09cee88c69c 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi @@ -4,13 +4,4 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "nrf54l_05_10_15.dtsi" - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1524)>; -}; +#include "nrf54l15.dtsi" diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi index ab1f686caa24..1794c49c031f 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi @@ -46,7 +46,7 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -57,31 +57,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(940)>; }; storage_partition: partition@175000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000175000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi index 4988de3ed544..96f8e7910556 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi @@ -6,28 +6,51 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x0 DT_SIZE_K(64)>; }; +#ifdef WITH_FLPR_PARTITIONS slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x10000 DT_SIZE_K(664)>; }; slot1_partition: partition@b6000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0xb6000 DT_SIZE_K(664)>; }; storage_partition: partition@15c000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x15c000 DT_SIZE_K(36)>; }; +#else + slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; + label = "image-0"; + reg = <0x10000 DT_SIZE_K(712)>; + }; + + slot1_partition: partition@c2000 { + compatible = "zephyr,mapped-partition"; + label = "image-1"; + reg = <0xc2000 DT_SIZE_K(712)>; + }; + + storage_partition: partition@174000 { + compatible = "zephyr,mapped-partition"; + label = "storage"; + reg = <0x174000 DT_SIZE_K(36)>; + }; +#endif }; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi b/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi new file mode 100644 index 000000000000..6e0b924b5c5f --- /dev/null +++ b/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/* 188 + 68 = 256KB */ +/ { + soc { + cpuflpr_sram: memory@20028000 { + compatible = "mmio-sram"; + reg = <0x20028000 DT_SIZE_K(96)>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x2002f000 DT_SIZE_K(96)>; + }; + }; +}; + +/* 1428 + 96 = 1524KB */ +&rram_controller { + cpuflpr_rram: rram@165000 { + compatible = "soc-nv-flash"; + reg = <0x165000 DT_SIZE_K(96)>; + ranges = <0x0 0x165000 DT_SIZE_K(96)>; + #address-cells = <1>; + #size-cells = <1>; + erase-block-size = <4096>; + write-block-size = <16>; + }; +}; diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index 4e289e69c553..2a6c72959008 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -750,6 +750,7 @@ rram_controller: rram-controller@5004b000 { compatible = "nordic,rram-controller"; reg = <0x5004b000 0x1000>; + ranges; #address-cells = <1>; #size-cells = <1>; interrupts = <75 NRF_DEFAULT_IRQ_PRIORITY>; @@ -758,6 +759,9 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <16>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/vendor/nordic/nrf54lm20_a_b.dtsi b/dts/vendor/nordic/nrf54lm20_a_b.dtsi index 889935b46bd3..e4619349a3ca 100644 --- a/dts/vendor/nordic/nrf54lm20_a_b.dtsi +++ b/dts/vendor/nordic/nrf54lm20_a_b.dtsi @@ -888,6 +888,7 @@ rram_controller: rram-controller@5004e000 { compatible = "nordic,rram-controller"; reg = <0x5004e000 0x1000>; + ranges; interrupts = <78 NRF_DEFAULT_IRQ_PRIORITY>; #address-cells = <1>; #size-cells = <1>; diff --git a/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi index ea354b033632..cfdb6c56097f 100644 --- a/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi @@ -48,7 +48,7 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -59,31 +59,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(1452)>; }; storage_partition: partition@1f5000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x001f5000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi index 538091d11d4e..e9155960313e 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi @@ -48,7 +48,6 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; @@ -59,31 +58,37 @@ */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(844)>; }; storage_partition: partition@15d000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00015d000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi index 64d5e69e2068..480f784223f2 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi @@ -6,34 +6,33 @@ * Default memory partitioning for nRF7120 application CPU. */ -&cpuapp_mram { - reg = <0x0 DT_SIZE_K(4076)>; -}; - /* These partition sizes assume no FLPR area in MRAM */ &cpuapp_mram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 DT_SIZE_K(64)>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 DT_SIZE_K(1988)>; }; - slot1_partition: partition@202000 { + slot1_partition: partition@201000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00201000 DT_SIZE_K(1988)>; }; - storage_partition: partition@3f4000 { + storage_partition: partition@3f2000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x003f2000 DT_SIZE_K(36)>; }; diff --git a/dts/vendor/nordic/nrf91xx_partition.dtsi b/dts/vendor/nordic/nrf91xx_partition.dtsi index f1984fb85a53..2b86c62fe4ee 100644 --- a/dts/vendor/nordic/nrf91xx_partition.dtsi +++ b/dts/vendor/nordic/nrf91xx_partition.dtsi @@ -25,17 +25,18 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x70000>; ranges = <0x0 0x10000 0x70000>; @@ -43,18 +44,20 @@ #size-cells = <1>; slot0_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0-secure"; reg = <0x00000000 0x40000>; }; slot0_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x00040000 0x30000>; }; }; slot1_partition: partition@80000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00080000 0x70000>; ranges = <0x0 0x80000 0x70000>; @@ -62,32 +65,38 @@ #size-cells = <1>; slot1_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-1-secure"; reg = <0x00000000 0x40000>; }; slot1_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1-nonsecure"; reg = <0x00040000 0x30000>; }; }; tfm_ps_partition: partition@f0000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x000f0000 0x00004000>; }; tfm_its_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x000f4000 0x00002000>; }; tfm_otp_partition: partition@f6000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x000f6000 0x00002000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/dts/vendor/nordic/nrf9280.dtsi b/dts/vendor/nordic/nrf9280.dtsi index 0e196147880c..5ee45960e828 100644 --- a/dts/vendor/nordic/nrf9280.dtsi +++ b/dts/vendor/nordic/nrf9280.dtsi @@ -136,14 +136,22 @@ #address-cells = <1>; #size-cells = <1>; - mram1x: mram@e000000 { + mram1x_controller: mram-controller@5f092000 { compatible = "nordic,mram"; - reg = <0xe000000 DT_SIZE_K(8192)>; + reg = <0x5f092000 0x2000>; ranges = <0x0 0xe000000 DT_SIZE_K(8192)>; - erase-block-size = <4096>; - write-block-size = <16>; #address-cells = <1>; #size-cells = <1>; + + mram1x: mram-memory@0 { + compatible = "soc-nv-flash"; + reg = <0x0 DT_SIZE_K(8192)>; + ranges; + erase-block-size = <4096>; + write-block-size = <16>; + #address-cells = <1>; + #size-cells = <1>; + }; }; uicr: uicr@fff8000 { 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 cd3bc8e1cd0b..7da87f8702e2 100644 --- a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld @@ -34,23 +34,28 @@ #define ROMSTART_REGION ROMABLE_REGION #endif -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) - #define ROM_ADDR RAM_ADDR -#else - #define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 82e417900ff0..f6b7c3649745 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -27,7 +27,7 @@ #define RAMABLE_REGION RAM /* Region of the irq vectors and boot-vector SP/PC */ -#if defined(CONFIG_ROMSTART_RELOCATION_ROM) +#if defined(CONFIG_ROMSTART_RELOCATION_ROM) && defined(CONFIG_XIP) #define ROMSTART_ADDR CONFIG_ROMSTART_REGION_ADDRESS #define ROMSTART_SIZE (CONFIG_ROMSTART_REGION_SIZE * 1K) #else @@ -67,23 +67,28 @@ _image_1_primary_slot_id = PM_S1_ID; #else /* ! USE_PARTITION_MANAGER */ -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) -#define ROM_ADDR RAM_ADDR -#else -#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif /* !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) */ + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE * 1024 - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS diff --git a/include/zephyr/arch/arm64/scripts/linker.ld b/include/zephyr/arch/arm64/scripts/linker.ld index 3475e5310e6e..93c8b2f5db64 100644 --- a/include/zephyr/arch/arm64/scripts/linker.ld +++ b/include/zephyr/arch/arm64/scripts/linker.ld @@ -26,23 +26,28 @@ #endif #define RAMABLE_REGION RAM -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) - #define ROM_ADDR RAM_ADDR -#else - #define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE * 1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS diff --git a/include/zephyr/arch/riscv/common/linker.ld b/include/zephyr/arch/riscv/common/linker.ld index f134d609f03b..2f87e4a828da 100644 --- a/include/zephyr/arch/riscv/common/linker.ld +++ b/include/zephyr/arch/riscv/common/linker.ld @@ -35,6 +35,10 @@ #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_BASE (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) */ #if defined(CONFIG_FLASH_LOAD_OFFSET) #define FLASH_LOAD_OFFSET CONFIG_FLASH_LOAD_OFFSET #else @@ -81,6 +85,7 @@ #define ROM_BASE CONFIG_SRAM_BASE_ADDRESS #define ROM_SIZE (KB(CONFIG_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) diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 497822f6cfc6..d0ce598b5f88 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5694,5 +5694,9 @@ #include #include #include +#include +#include +#include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/fixed-partitions.h b/include/zephyr/devicetree/fixed-partitions.h index 3a60f960013c..ff44e07ef644 100644 --- a/include/zephyr/devicetree/fixed-partitions.h +++ b/include/zephyr/devicetree/fixed-partitions.h @@ -5,7 +5,6 @@ /* * Copyright (c) 2020, Linaro Ltd. - * Copyright (c) 2026, Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ @@ -106,15 +105,9 @@ extern "C" { * &flash_controller { * flash@1000000 { * compatible = "soc-nv-flash"; - * reg = <0x1000000 0x50000> - * ranges = <0x0 0x1000000 0x50000> - * * partitions { * compatible = "fixed-partitions"; - * ranges; - * * storage_partition: partition@3a000 { - * reg = <0x3a000 0x8000> * label = "storage"; * }; * }; @@ -137,20 +130,8 @@ extern "C" { * @return the partition's offset plus the base address of the flash * node containing it. */ - -/* - * The COND_CODE_0 ranges part handles invalid devices where they wrongly do not inherit the - * parent's address and wrongly start at address 0x0 which was a bug that was fixed post Zephyr - * 4.3, this extra handling can be removed in Zephyr 4.6 or newer - */ -#define DT_FIXED_PARTITION_ADDR(node_id) \ - COND_CODE_0(DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_subpartitions), \ - (COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(node_id)), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))), \ - (DT_REG_ADDR(node_id)))), \ - (COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(DT_PARENT(node_id))), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))), \ - (DT_REG_ADDR(node_id))))) +#define DT_FIXED_PARTITION_ADDR(node_id) \ + (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))) /** * @brief Test if fixed-subpartitions compatible node exists @@ -189,12 +170,9 @@ extern "C" { * &flash_controller { * flash@1000000 { * compatible = "soc-nv-flash"; - * reg = <0x1000000 0x50000> - * ranges = <0x0 0x1000000 0x50000> * * partitions { * compatible = "fixed-partitions"; - * ranges; * * slot0_partition: partition@10000 { * compatible = "fixed-subpartitions"; @@ -228,16 +206,8 @@ extern "C" { * @return the subpartition's offset plus the base address of the flash * node containing it. */ - -/* - * The COND_CODE_0 part handles invalid devices where they wrongly do not inherit the parent's - * address and wrongly start at address 0x0 which was a bug that was fixed post Zephyr 4.3, this - * extra handling can be removed in Zephyr 4.6 or newer - */ -#define DT_FIXED_SUBPARTITION_ADDR(node_id) \ - COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(DT_PARENT(node_id))), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(DT_PARENT(node_id)))), \ - (DT_REG_ADDR(node_id))) +#define DT_FIXED_SUBPARTITION_ADDR(node_id) \ + (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(DT_PARENT(node_id)))) /** * @} diff --git a/include/zephyr/devicetree/map.h b/include/zephyr/devicetree/map.h new file mode 100644 index 000000000000..6560b3a223db --- /dev/null +++ b/include/zephyr/devicetree/map.h @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2025 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ + +/** + * @file + * @brief Map devicetree macro public API header file. + * + * This module provides helper macros that facilitate interrupt mapping and + * specifier mapping based on DeviceTree specifications. It enables the extraction + * and interpretation of mapping data represented as phandle-arrays. + * + * In a typical DeviceTree fragment, properties ending with "-map" specify: + * - The child specifier to be mapped. + * - The parent node (phandle) to which the mapping applies. + * - The parent specifier associated with the mapping. + * + * For example, when the following DeviceTree snippet is defined: + * + * @code{.dts} + * n: node { + * gpio-map = <0 1 &gpio0 2 3>, <4 5 &gpio0 6 7>; + * }; + * @endcode + * + * In the first mapping entry: + * - `0 1` are the child specifiers. + * - &gpio0 is the parent node. + * - `2 3` are the parent specifiers. + * + * The map API provides the following macros for access to specific parts of a mapping entry: + * - DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX() + * - DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX() + * - DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX() + * - DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX() + * - DT_MAP_ENTRY_PARENT_BY_IDX() + * + * These macros extract, respectively, the child specifier arguments, the parent specifier + * arguments, and the parent node argument from a mapping element identified by its node ID, + * property name, and index. + * + * For instance: + * + * @code{.c} + * #define SRC_AND_DST(node_id, map, entry_idx) \ + * { DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0), \ + * DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0) } + * + * int src_and_dst[][2] = { + * DT_FOREACH_MAP_ENTRY_SEP(DT_NODELABEL(n), gpio_map, SRC_AND_DST, (,)) + * }; + * @endcode + * + * The above expansion yields: + * + * @code{.c} + * int src_and_dst[][2] = {{0, 2}, {4, 6}}; + * @endcode + * + */ + +/** + * @defgroup devicetree-map Map helpers + * @ingroup devicetree + * @{ + */ + +/** + * @brief Returns the existence of map property. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @retval True if the map exists, otherwise 0. + * + * @see DT_NODE_HAS_PROP + */ +#define DT_NODE_HAS_MAP(node_id, prop) DT_NODE_HAS_PROP(node_id, prop) + +/** + * @brief Returns the number of maps for the given property. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return The total count of mapping entries. + * + * @see DT_PROP_LEN + */ +#define DT_MAP_LEN(node_id, prop) DT_PROP_LEN(node_id, prop) + +/** + * @brief Is index @p idx valid for an array type property? + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx index to check + * @return An expression which evaluates to 1 if @p idx is a valid index + * into the given property, and 0 otherwise. + */ +#define DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, entry_idx) \ + IS_ENABLED(DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _EXISTS)) + +/** + * @brief Checks if the map property has any entries. + * + * Equivalent to calling @ref DT_MAP_HAS_ENTRY_BY_IDX with @p entry_idx set to + * zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return An expression which evaluates to 1 if @p idx is a valid index + * into the given property, and 0 otherwise. + */ +#define DT_MAP_HAS_ENTRY(node_id, prop) DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, 0) + +/** + * @brief Get the number of child addresses. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_LEN) + +/** + * @brief Checks if the child address has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child addresses. + * @retval True if the child address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any child addresses. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the child address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the child address element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child addresses. + * @return The element of the specified position of the child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_IDX_, param_idx) + +/** + * @brief Get the first child address element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The element of the specified position of the child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the number of child specifiers. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_LEN) + +/** + * @brief Checks if the child specifier has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child specifiers. + * @retval True if the child specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any child specifiers. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the child specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the child specifier element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child specifiers. + * @return The element of the specified position of the child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_IDX_, param_idx) + +/** + * @brief Get the first child specifier element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The element of the specified position of the child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Extracts the parent node from a mapping entry. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The parent node id. + */ +#define DT_MAP_ENTRY_PARENT_BY_IDX(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT) + +/** + * @brief Extracts the parent node from the first mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_BY_IDX with @p entry_idx set + * to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return The parent node id. + */ +#define DT_MAP_ENTRY_PARENT(node_id, prop) \ + DT_MAP_ENTRY_PARENT_BY_IDX(node_id, prop, 0) + +/** + * @brief Get the number of parent addresses. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_LEN) + +/** + * @brief Checks if the parent address has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent addresses. + * @retval True if the parent address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any parent addresses. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the parent address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the parent address element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent addresses. + * @retval The element of the specified position of the parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_IDX_, param_idx) + +/** + * @brief Get the first parent address element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The element of the specified position of the parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the number of parent specifiers. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The number of parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_LEN) + +/** + * @brief Checks if the parent specifier has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent specifiers. + * @retval True if the parent specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any parent specifiers. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the parent specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the parent specifier element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent specifiers. + * @retval The element of the specified position of the parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_IDX_, param_idx) + +/** + * @brief Get the first parent specifier element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The element of the specified position of the parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Invokes @p fn for each map entry in the @p map. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * + * @see DT_FOREACH_PROP_ELEM + */ +#define DT_FOREACH_MAP_ENTRY(node_id, prop, fn) DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY)(fn) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param sep Separator (e.g. comma or semicolon). Must be in parentheses; + * this is required to enable providing a comma as separator. + * + * @see DT_FOREACH_PROP_ELEM_SEP + */ +#define DT_FOREACH_MAP_ENTRY_SEP(node_id, prop, fn, sep) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_SEP)(fn, sep) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param ... variable number of arguments to pass to fn + * + * @see DT_FOREACH_PROP_ELEM_VARGS + */ +#define DT_FOREACH_MAP_ENTRY_VARGS(node_id, prop, fn, ...) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_VARGS)(fn, __VA_ARGS__) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param sep Separator (e.g. comma or semicolon). Must be in parentheses; + * this is required to enable providing a comma as separator. + * @param ... variable number of arguments to pass to fn + * + * @see DT_FOREACH_PROP_ELEM_SEP_VARGS + */ +#define DT_FOREACH_MAP_ENTRY_SEP_VARGS(node_id, prop, fn, sep, ...) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_SEP_VARGS)(fn, sep, __VA_ARGS__) + +/** + * @} + */ + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ */ diff --git a/include/zephyr/devicetree/mapped-partition.h b/include/zephyr/devicetree/mapped-partition.h new file mode 100644 index 000000000000..bb58e65c6f51 --- /dev/null +++ b/include/zephyr/devicetree/mapped-partition.h @@ -0,0 +1,188 @@ +/** + * @file + * @brief Flash Devicetree macro public API header file, for memory-mapped partitions. + */ + +/* + * Copyright (c) 2020, Linaro Ltd. + * Copyright (c) 2026 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-mapped-partition Devicetree Mapped Partition API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get a node identifier for a mapped partition with a given label property + * + * Example devicetree fragment: + * + * flash@... { + * reg = <0x0 0x40000>; + * ranges = <0x0 0x0 0x40000>; + * + * partitions { + * ranges; + * + * boot_partition: partition@0 { + * compatible = "zephyr,mapped-partition"; + * reg = <0x0 0xc000>; + * label = "mcuboot"; + * }; + * + * slot0_partition: partition@c000 { + * compatible = "zephyr,mapped-partition"; + * reg = <0xc000 0x18000>; + * label = "image-0"; + * }; + * + * ... + * }; + * }; + * + * Example usage: + * + * DT_NODE_BY_MAPPED_PARTITION_LABEL(mcuboot) // Node identifier for boot_partition + * DT_NODE_BY_MAPPED_PARTITION_LABEL(image_0) // Node identifier for slot0_partition + * + * @param label lowercase-and-underscores label property value. + * @return a node identifier for the partition with that label property. + */ +#define DT_NODE_BY_MAPPED_PARTITION_LABEL(label) \ + DT_CAT(DT_COMPAT_zephyr_mapped_partition_LABEL_, label) + +/** + * @brief Test if a mapped partition with a given label property exists. + * @param label lowercase-and-underscores label property value. + * @return 1 if the device has a "zephyr,mapped-partition" compatible, 0 otherwise. + */ +#define DT_HAS_MAPPED_PARTITION_LABEL(label) \ + IS_ENABLED(DT_CAT3(DT_COMPAT_zephyr_mapped_partition_LABEL_, label, _EXISTS)) + +/** + * @brief Test if zephyr,mapped-partition compatible node exists. + * + * @param node_id DTS node to test. + * @return 1 if node exists and has a zephyr,mapped-partition compatible, 0 otherwise. + */ +#define DT_MAPPED_PARTITION_EXISTS(node_id) DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition) + +/** + * @brief Get a numeric identifier for a mapped partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @return the partition's ID, a unique zero-based index number. + */ +#define DT_MAPPED_PARTITION_ID(node_id) DT_CAT(node_id, _PARTITION_ID) + +/** + * @brief Get the node identifier of the NVM memory for a partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @return the node identifier of the internal memory that contains the zephyr,mapped-partition + * node, or @ref DT_INVALID_NODE if it doesn't exist. + */ +#define DT_MEM_FROM_MAPPED_PARTITION(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_CAT(node_id, _NVM_DEVICE), soc_nv_flash), \ + (DT_CAT(node_id, _NVM_DEVICE)), \ + (DT_INVALID_NODE)) + +/** + * @brief Get the node identifier of the NVM controller for a partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @return the node identifier of the memory technology device that contains the + * zephyr,mapped-partition node. + */ +#define DT_MTD_FROM_MAPPED_PARTITION(node_id) DT_PARENT(DT_MEM_FROM_MAPPED_PARTITION(node_id)) + +/** + * @brief Get the absolute address of a mapped partition + * + * Example devicetree fragment: + * + * flash@1000000 { + * compatible = "soc-nv-flash"; + * reg = <0x1000000 0x30000>; + * ranges = <0x0 0x1000000 0x30000>; + * + * partitions { + * ranges; + * + * storage_partition: partition@3a000 { + * compatible = "zephyr,mapped-partition"; + * label = "storage"; + * reg = <0x3a000 0x8000>; + * }; + * }; + * }; + * + * Here, the "storage" partition is seen to belong to flash memory starting at address 0x1000000. + * The partition's address of 0x3a000 represents an offset inside that flash memory. + * + * Example usage: + * + * DT_MAPPED_PARTITION_ADDR(DT_NODELABEL(storage_partition)) // 0x103a000 + * + * This macro can only be used with partitions of internal memory addressable by the CPU. + * Otherwise, it may produce a compile-time error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a zephyr,mapped-partition node + * @return the partition's unit address. + */ +#define DT_MAPPED_PARTITION_ADDR(node_id) DT_REG_ADDR(node_id) + +/** + * @brief Get the offset address of a mapped partition from the NVM node + * + * Example devicetree fragment: + * + * flash@1000000 { + * compatible = "soc-nv-flash"; + * reg = <0x1000000 0x30000>; + * ranges = <0x0 0x1000000 0x30000>; + * + * partitions { + * ranges; + * + * storage_partition: partition@3a000 { + * compatible = "zephyr,mapped-partition"; + * label = "storage"; + * reg = <0x3a000 0x8000>; + * }; + * }; + * }; + * + * Here, the "storage" partition is seen to belong to flash memory starting at address 0x1000000. + * The partition's address of 0x3a000 represents an offset inside that flash memory. + * + * Example usage: + * + * DT_MAPPED_PARTITION_OFFSET(DT_NODELABEL(storage_partition)) // 0x3a000 + * + * This macro can only be used with partitions of internal memory addressable by the CPU. + * Otherwise, it may produce a compile-time error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a zephyr,mapped-partition node + * @return the partition's offset from the memory device. + */ +#define DT_MAPPED_PARTITION_OFFSET(node_id) \ + (DT_REG_ADDR(node_id) - DT_REG_ADDR(DT_MEM_FROM_MAPPED_PARTITION(node_id))) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ */ diff --git a/include/zephyr/devicetree/partitions.h b/include/zephyr/devicetree/partitions.h new file mode 100644 index 000000000000..34738334d604 --- /dev/null +++ b/include/zephyr/devicetree/partitions.h @@ -0,0 +1,115 @@ +/** + * @file + * @brief Flash Devicetree macro public API header file, for partitions. + */ + +/* + * Copyright (c) 2026 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-partition Devicetree Partition API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get a node identifier for a partition with a given label property + * + * @param label lowercase-and-underscores label property value + * @return a node identifier for the partition with that label property + */ +#define DT_NODE_BY_PARTITION_LABEL(label) \ + COND_CODE_1(DT_HAS_MAPPED_PARTITION_LABEL(label), \ + (DT_NODE_BY_MAPPED_PARTITION_LABEL(label)), \ + (DT_NODE_BY_FIXED_PARTITION_LABEL(label))) + +/** + * @brief Test if a partition with a given label property exists + * @param label lowercase-and-underscores label property value + * @return 1 if the device has a "zephyr,mapped-partition" or "fixed-subpartitions" compatible, + * or parent has a "fixed-partitions" compatible, 0 otherwise. + */ +#define DT_HAS_PARTITION_LABEL(label) \ + UTIL_OR(DT_HAS_MAPPED_PARTITION_LABEL(label), DT_HAS_FIXED_PARTITION_LABEL(label)) + +/** + * @brief Test if zephyr,mapped-partition, fixed-partitions or fixed-subpartitions compatible + * node exists + * + * @param node_id DTS node to test + * @return 1 if node exists and has a "zephyr,mapped-partition" or "fixed-subpartitions" + * compatible, or if parent has a "fixed-partitions" compatible, 0 otherwise. + */ +#define DT_PARTITION_EXISTS(node_id) \ + UTIL_OR(DT_MAPPED_PARTITION_EXISTS(node_id), \ + UTIL_OR(DT_FIXED_PARTITION_EXISTS(node_id), \ + DT_FIXED_SUBPARTITION_EXISTS(node_id))) + +/** + * @brief Get a numeric identifier for a partition + * @param node_id node identifier for a partition node + * @return the partition's ID, a unique zero-based index number + */ +#define DT_PARTITION_ID(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ID(node_id)), \ + (DT_FIXED_PARTITION_ID(node_id))) + +/** + * @brief Get the node identifier of the NVM memory for a partition + * @param node_id node identifier for a partition node + * @return the node identifier of the internal memory that contains the partition node, or + * @ref DT_INVALID_NODE if it doesn't exist. + */ +#define DT_MEM_FROM_PARTITION(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MEM_FROM_MAPPED_PARTITION(node_id)), \ + (DT_MEM_FROM_FIXED_PARTITION(node_id))) + +/** + * @brief Get the node identifier of the NVM controller for a partition + * @param node_id node identifier for a partition node + * @return the node identifier of the memory technology device that contains the partition node. + */ +#define DT_MTD_FROM_PARTITION(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MTD_FROM_MAPPED_PARTITION(node_id)), \ + (DT_MTD_FROM_FIXED_PARTITION(node_id))) + +/** + * @brief Get the absolute address of a partition + * This macro can only be used with partitions of internal memory + * addressable by the CPU. Otherwise, it may produce a compile-time + * error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a partition node + * @return the partition's unit address. + */ +#define DT_PARTITION_ADDR(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ADDR(node_id)), \ + (DT_FIXED_PARTITION_ADDR(node_id))) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ */ diff --git a/include/zephyr/devicetree/wuc.h b/include/zephyr/devicetree/wuc.h new file mode 100644 index 000000000000..1e59c475a39c --- /dev/null +++ b/include/zephyr/devicetree/wuc.h @@ -0,0 +1,209 @@ +/** + * @file + * @brief Wakeup Controller Devicetree macro public API header file. + */ + +/* + * Copyright 2026 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-wakeup-controller Devicetree WUC Controller API + * @ingroup devicetree + * @ingroup wuc_interface + * @{ + */ + +/** + * @brief Get the node identifier for the controller phandle from a + * "wakeup-ctrls" phandle-array property at an index + * + * Example devicetree fragment: + * + * wuc1: wakeup-controller@... { ... }; + * + * wuc2: wakeup-controller@... { ... }; + * + * n: node { + * wakeup-ctrls = <&wuc1 10>, <&wuc2 20>; + * }; + * + * Example usage: + * + * DT_WUC_BY_IDX(DT_NODELABEL(n), 0) // DT_NODELABEL(wuc1) + * DT_WUC_BY_IDX(DT_NODELABEL(n), 1) // DT_NODELABEL(wuc2) + * + * @param node_id node identifier + * @param idx logical index into "wakeup-ctrls" + * @return the node identifier for the wakeup controller referenced at + * index "idx" + * @see DT_PHANDLE_BY_IDX() + */ +#define DT_WUC_BY_IDX(node_id, idx) DT_PHANDLE_BY_IDX(node_id, wakeup_ctrls, idx) + +/** + * @brief Equivalent to DT_WUC_BY_IDX(node_id, 0) + * @param node_id node identifier + * @return a node identifier for the wakeup controller at index 0 + * in "wakeup-ctrls" + * @see DT_WUC_BY_IDX() + */ +#define DT_WUC(node_id) DT_WUC_BY_IDX(node_id, 0) + +/** + * @brief Get a wakeup controller specifier's cell value at an index + * + * Example devicetree fragment: + * + * wuc: wakeup-controller@... { + * compatible = "vnd,wuc"; + * #wakeup-ctrl-cells = <1>; + * }; + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * }; + * + * Bindings fragment for the vnd,wuc compatible: + * + * wakeup-ctrl-cells: + * - id + * + * Example usage: + * + * DT_WUC_CELL_BY_IDX(DT_NODELABEL(n), 0, id) // 10 + * + * @param node_id node identifier for a node with a wakeup-ctrls property + * @param idx logical index into wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index "idx" + * @see DT_PHA_BY_IDX() + */ +#define DT_WUC_CELL_BY_IDX(node_id, idx, cell) DT_PHA_BY_IDX(node_id, wakeup_ctrls, idx, cell) + +/** + * @brief Equivalent to DT_WUC_CELL_BY_IDX(node_id, 0, cell) + * @param node_id node identifier for a node with a wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index 0 + * @see DT_WUC_CELL_BY_IDX() + */ +#define DT_WUC_CELL(node_id, cell) DT_WUC_CELL_BY_IDX(node_id, 0, cell) + +/** + * @brief Get the node identifier for the controller phandle from a + * "wakeup-ctrls" phandle-array property at an index + * + * @param inst instance number + * @param idx logical index into "wakeup-ctrls" + * @return the node identifier for the wakeup controller referenced at + * index "idx" + * @see DT_WUC_BY_IDX() + */ +#define DT_INST_WUC_BY_IDX(inst, idx) DT_WUC_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Equivalent to DT_INST_WUC_BY_IDX(inst, 0) + * @param inst instance number + * @return a node identifier for the wakeup controller at index 0 + * in "wakeup-ctrls" + * @see DT_WUC_BY_IDX() + */ +#define DT_INST_WUC(inst) DT_INST_WUC_BY_IDX(inst, 0) + +/** + * @brief Get a DT_DRV_COMPAT instance's wakeup controller specifier's cell value + * at an index + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index "idx" + * @see DT_WUC_CELL_BY_IDX() + */ +#define DT_INST_WUC_CELL_BY_IDX(inst, idx, cell) DT_WUC_CELL_BY_IDX(DT_DRV_INST(inst), idx, cell) + +/** + * @brief Equivalent to DT_INST_WUC_CELL_BY_IDX(inst, 0, cell) + * @param inst DT_DRV_COMPAT instance number + * @param cell lowercase-and-underscores cell name + * @return the value of the cell inside the specifier at index 0 + */ +#define DT_INST_WUC_CELL(inst, cell) DT_INST_WUC_CELL_BY_IDX(inst, 0, cell) + +/** + * @brief Get a Wakeup Controller specifier's id cell at an index + * + * This macro only works for Wakeup Controller specifiers with cells named "id". + * Refer to the node's binding to check if necessary. + * + * Example devicetree fragment: + * + * wuc: wakeup-controller@... { + * compatible = "vnd,wuc"; + * #wakeup-ctrl-cells = <1>; + * }; + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * }; + * + * Bindings fragment for the vnd,wuc compatible: + * + * wakeup-ctrl-cells: + * - id + * + * Example usage: + * + * DT_WUC_ID_BY_IDX(DT_NODELABEL(n), 0) // 10 + * + * @param node_id node identifier + * @param idx logical index into "wakeup-ctrls" + * @return the id cell value at index "idx" + * @see DT_PHA_BY_IDX() + */ +#define DT_WUC_ID_BY_IDX(node_id, idx) DT_PHA_BY_IDX(node_id, wakeup_ctrls, idx, id) + +/** + * @brief Equivalent to DT_WUC_ID_BY_IDX(node_id, 0) + * @param node_id node identifier + * @return the id cell value at index 0 + * @see DT_WUC_ID_BY_IDX() + */ +#define DT_WUC_ID(node_id) DT_WUC_ID_BY_IDX(node_id, 0) + +/** + * @brief Get a DT_DRV_COMPAT instance's Wakeup Controller specifier's id cell value + * at an index + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into "wakeup-ctrls" + * @return the id cell value at index "idx" + * @see DT_WUC_ID_BY_IDX() + */ +#define DT_INST_WUC_ID_BY_IDX(inst, idx) DT_WUC_ID_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Equivalent to DT_INST_WUC_ID_BY_IDX(inst, 0) + * @param inst DT_DRV_COMPAT instance number + * @return the id cell value at index 0 + * @see DT_INST_WUC_ID_BY_IDX() + */ +#define DT_INST_WUC_ID(inst) DT_INST_WUC_ID_BY_IDX(inst, 0) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ */ diff --git a/include/zephyr/drivers/wuc.h b/include/zephyr/drivers/wuc.h new file mode 100644 index 000000000000..d43103260865 --- /dev/null +++ b/include/zephyr/drivers/wuc.h @@ -0,0 +1,310 @@ +/* + * Copyright 2026 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @ingroup wuc_interface + * @brief Main header file for WUC (Wakeup Controller) driver API. + */ + +#ifndef ZEPHYR_INCLUDE_DRIVERS_WUC_H_ +#define ZEPHYR_INCLUDE_DRIVERS_WUC_H_ + +/** + * @brief Wakeup Controller (WUC) Driver APIs + * @defgroup wuc_interface WUC + * @since 4.4 + * @version 0.1.0 + * @ingroup io_interfaces + * @{ + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Wakeup controller device configuration. */ +struct wuc_dt_spec { + /** Wakeup controller device. */ + const struct device *dev; + /** Wakeup source identifier. */ + uint32_t id; +}; + +/** + * @brief Static initializer for a @p wuc_dt_spec + * + * This returns a static initializer for a @p wuc_dt_spec structure given a + * devicetree node identifier, a property specifying a Wakeup Controller and an index. + * + * Example devicetree fragment: + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * } + * + * Example usage: + * + * const struct wuc_dt_spec spec = WUC_DT_SPEC_GET_BY_IDX(DT_NODELABEL(n), 0); + * Initializes 'spec' to: + * { + * .dev = DEVICE_DT_GET(DT_NODELABEL(wuc)), + * .id = 10 + * } + * + * The 'wuc' field must still be checked for readiness, e.g. using + * device_is_ready(). It is an error to use this macro unless the node + * exists, has the given property, and that property specifies a wakeup + * controller wakeup source id as shown above. + * + * @param node_id devicetree node identifier + * @param idx logical index into "wakeup-ctrls" + * @return static initializer for a struct wuc_dt_spec for the property + */ +#define WUC_DT_SPEC_GET_BY_IDX(node_id, idx) \ + {.dev = DEVICE_DT_GET(DT_WUC_BY_IDX(node_id, idx)), .id = DT_WUC_ID_BY_IDX(node_id, idx)} + +/** + * @brief Like WUC_DT_SPEC_GET_BY_IDX(), with a fallback to a default value + * + * If the devicetree node identifier 'node_id' refers to a node with a + * 'wakeup-ctrls' property, this expands to + * WUC_DT_SPEC_GET_BY_IDX(node_id, idx). The @p + * default_value parameter is not expanded in this case. + * + * Otherwise, this expands to @p default_value. + * + * @param node_id devicetree node identifier + * @param idx logical index into the 'wakeup-ctrls' property + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, wakeup_ctrls), \ + (WUC_DT_SPEC_GET_BY_IDX(node_id, idx)), \ + (default_value)) + +/** + * @brief Equivalent to WUC_DT_SPEC_GET_BY_IDX(node_id, 0). + * + * @param node_id devicetree node identifier + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_GET_BY_IDX() + */ +#define WUC_DT_SPEC_GET(node_id) WUC_DT_SPEC_GET_BY_IDX(node_id, 0) + +/** + * @brief Equivalent to + * WUC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value). + * + * @param node_id devicetree node identifier + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_GET_OR(node_id, default_value) \ + WUC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value) + +/** + * @brief Static initializer for a @p wuc_dt_spec from a DT_DRV_COMPAT + * instance's Wakeup Controller property at an index. + * + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into "wakeup-ctrls" + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_GET_BY_IDX() + */ +#define WUC_DT_SPEC_INST_GET_BY_IDX(inst, idx) WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Static initializer for a @p wuc_dt_spec from a DT_DRV_COMPAT + * instance's 'wakeup-ctrls' property at an index, with fallback + * + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into the 'wakeup-ctrls' property + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) \ + COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), wakeup_ctrls, idx), \ + (WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)), \ + (default_value)) + +/** + * @brief Equivalent to WUC_DT_SPEC_INST_GET_BY_IDX(inst, 0). + * + * @param inst DT_DRV_COMPAT instance number + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_INST_GET_BY_IDX() + */ +#define WUC_DT_SPEC_INST_GET(inst) WUC_DT_SPEC_INST_GET_BY_IDX(inst, 0) + +/** + * @brief Equivalent to + * WUC_DT_SPEC_INST_GET_BY_IDX_OR(node_id, 0, default_value). + * + * @param inst DT_DRV_COMPAT instance number + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_INST_GET_OR(inst, default_value) \ + WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default_value) +/** + * @cond INTERNAL_HIDDEN + * + * For internal use only, skip these in public documentation. + */ +typedef int (*wuc_api_enable_wakeup_source)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_disable_wakeup_source)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_check_wakeup_source_triggered)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_clear_wakeup_source_triggered)(const struct device *dev, uint32_t id); + +__subsystem struct wuc_driver_api { + wuc_api_enable_wakeup_source enable; + wuc_api_disable_wakeup_source disable; + wuc_api_check_wakeup_source_triggered triggered; + wuc_api_clear_wakeup_source_triggered clear; +}; +/** @endcond */ + +/** + * @brief Enable a wakeup source + * + * @param dev Pointer to the WUC device structure + * @param id Wakeup source identifier + * + * @retval 0 If successful + * @retval -errno Negative errno code on failure + */ +static inline int wuc_enable_wakeup_source(const struct device *dev, uint32_t id) +{ + return DEVICE_API_GET(wuc, dev)->enable(dev, id); +} + +/** + * @brief Enable a wakeup source using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec) +{ + return wuc_enable_wakeup_source(spec->dev, spec->id); +} + +/** + * @brief Disable a wakeup source. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_disable_wakeup_source(const struct device *dev, uint32_t id) +{ + return DEVICE_API_GET(wuc, dev)->disable(dev, id); +} + +/** + * @brief Disable a wakeup source using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec) +{ + return wuc_disable_wakeup_source(spec->dev, spec->id); +} + +/** + * @brief Check if a wakeup source triggered. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 1 If wakeup was triggered by this source. + * @retval 0 If wakeup was not triggered by this source. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id) +{ + if (DEVICE_API_GET(wuc, dev)->triggered == NULL) { + return -ENOSYS; + } + return DEVICE_API_GET(wuc, dev)->triggered(dev, id); +} + +/** + * @brief Check if a wakeup source triggered using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 1 If wakeup was triggered by this source. + * @retval 0 If wakeup was not triggered by this source. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec) +{ + return wuc_check_wakeup_source_triggered(spec->dev, spec->id); +} + +/** + * @brief Clear a wakeup source triggered status. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id) +{ + if (DEVICE_API_GET(wuc, dev)->clear == NULL) { + return -ENOSYS; + } + return DEVICE_API_GET(wuc, dev)->clear(dev, id); +} + +/** + * @brief Clear a wakeup source triggered status using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec) +{ + return wuc_clear_wakeup_source_triggered(spec->dev, spec->id); +} + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* ZEPHYR_INCLUDE_DRIVERS_WUC_H_ */ diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index bfd86e7771f2..819f94182474 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -19,7 +19,7 @@ * * @defgroup flash_area_api flash area Interface * @since 1.11 - * @version 1.1.0 + * @version 1.1.1 * @ingroup storage_apis * @{ */ @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -139,7 +142,7 @@ void flash_area_close(const struct flash_area *fa); * Indicates whether the provided flash area has a device known to be * in a state where it can be used with Flash Map API. * - * This can be used with struct flash_area pointers captured from FIXED_PARTITION(). + * This can be used with struct flash_area pointers captured from PARTITION(). * At minimum this means that the device has been successfully initialized. * * @param fa pointer to flash_area object to check. @@ -353,97 +356,127 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #else /** - * Returns non-0 value if fixed-partition or fixed-subpartition of given - * DTS node label exists. + * Returns non-0 value if partition of given DTS node label exists. * * @param label DTS node label * - * @return non-0 if fixed-partition node exists and is enabled; - * 0 if node does not exist, is not enabled or is not fixed-partition. + * @return non-0 if partition node exists and is enabled; + * 0 if node does not exist, is not enabled or is not partition. */ -#define FIXED_PARTITION_EXISTS(label) \ - UTIL_OR(DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(label)), \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label))) +#define PARTITION_EXISTS(label) DT_PARTITION_EXISTS(DT_NODELABEL(label)) /** - * Get flash area ID from fixed-partition DTS node label + * Deprecated macro, replace with PARTITION_EXISTS(), this cannot use __DEPRECATED_MACRO as it + * causes usage of the macro to fail with compiler errors + */ +#define FIXED_PARTITION_EXISTS(label) PARTITION_EXISTS(label) + +/** + * Get flash area ID from partition DTS node label * * @param label DTS node label of a partition * * @return flash area ID */ -#define FIXED_PARTITION_ID(label) DT_FIXED_PARTITION_ID(DT_NODELABEL(label)) +#define PARTITION_ID(label) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ID(DT_NODELABEL(label))), \ + (DT_FIXED_PARTITION_ID(DT_NODELABEL(label)))) + +/** Deprecated macro, replace with PARTITION_ID() */ +#define FIXED_PARTITION_ID(label) PARTITION_ID(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition offset from DTS node label + * Get partition offset from DTS node label * * Note: This only works from a top level ``fixed-partitions`` node, top level * ``fixed-subpartitions`` node or ``fixed-partitions`` node inside of 1 layer of a * ``fixed-subpartitions`` node, it will not work for multiple layers of ``fixed-subpartitions`` - * nodes. + * nodes, though this works on all instances of ``zephyr,mapped-partition`` nodes. * * @param label DTS node label of a partition * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return offset, as defined for the partition in DTS. */ -#define FIXED_PARTITION_OFFSET(label) \ - COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_PROP_BY_IDX(DT_PARENT(DT_NODELABEL(label)), reg, 0) + \ - DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0)), \ - (DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0))) +#define PARTITION_OFFSET(label) PARTITION_NODE_OFFSET(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_OFFSET(label) PARTITION_OFFSET(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition address from DTS node label + * Get partition address from DTS node label * - * @param label DTS node label of a partition or subpartition + * @param label DTS node label of a partition * - * @return fixed-partition address, as defined for the partition in DTS. + * @return address, as defined for the partition in DTS. */ -#define FIXED_PARTITION_ADDRESS(label) DT_REG_ADDR(DT_NODELABEL(label)) +#define PARTITION_ADDRESS(label) PARTITION_NODE_ADDRESS(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_ADDRESS() */ +#define FIXED_PARTITION_ADDRESS(label) PARTITION_ADDRESS(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition address from DTS node + * Get partition address from DTS node * * @param node DTS node of a partition * - * @return fixed-partition address, as defined for the partition in DTS. + * @return address, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_ADDRESS(node) DT_REG_ADDR(node) +#define PARTITION_NODE_ADDRESS(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ADDR(node)), \ + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_FIXED_SUBPARTITION_ADDR(node)), \ + (DT_FIXED_PARTITION_ADDR(node))))) + +/** Deprecated macro, replace with PARTITION_NODE_ADDRESS() */ +#define FIXED_PARTITION_NODE_ADDRESS(node) PARTITION_NODE_ADDRESS(node) __DEPRECATED_MACRO /** - * Get fixed-partition offset from DTS node + * Get partition offset from DTS node * * Note: This only works from a top level ``fixed-partitions`` node, top level * ``fixed-subpartitions`` node or ``fixed-partitions`` node inside of 1 layer of a * ``fixed-subpartitions`` node, it will not work for multiple layers of ``fixed-subpartitions`` - * nodes. + * nodes, though this works on all instances of ``zephyr,mapped-partition`` nodes. * * @param node DTS node of a partition * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return offset, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_OFFSET(node) \ - COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + DT_PROP_BY_IDX(node, reg, 0)), \ - (DT_PROP_BY_IDX(node, reg, 0))) +#define PARTITION_NODE_OFFSET(node) \ + COND_CASE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_OFFSET(node)), \ + DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + DT_PROP_BY_IDX(node, reg, 0)), \ + ((DT_PROP_BY_IDX(node, reg, 0)))) + +/** Deprecated macro, replace with PARTITION_NODE_OFFSET() */ +#define FIXED_PARTITION_NODE_OFFSET(label) PARTITION_NODE_OFFSET(label) __DEPRECATED_MACRO /** - * Get fixed-partition size for DTS node label + * Get partition size for DTS node label * * @param label DTS node label * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return size, as defined for the partition in DTS. */ -#define FIXED_PARTITION_SIZE(label) DT_REG_SIZE(DT_NODELABEL(label)) +#define PARTITION_SIZE(label) DT_REG_SIZE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_SIZE() */ +#define FIXED_PARTITION_SIZE(label) PARTITION_SIZE(label) __DEPRECATED_MACRO /** * Get fixed-partition size for DTS node * * @param node DTS node of a partition * - * @return fixed-partition size, as defined for the partition in DTS. + * @return size, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_SIZE(node) DT_REG_SIZE(node) +#define PARTITION_NODE_SIZE(node) DT_REG_SIZE(node) + +/** Deprecated macro, replace with PARTITION_NODE_SIZE() */ +#define FIXED_PARTITION_NODE_SIZE(node) PARTITION_NODE_SIZE(node) __DEPRECATED_MACRO /** * Get device pointer for device the area/partition resides on @@ -452,8 +485,12 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return const struct device type pointer */ -#define FLASH_AREA_DEVICE(label) \ - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODE_BY_FIXED_PARTITION_LABEL(label))) +#define FLASH_AREA_DEVICE(label) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ + (DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION( \ + DT_NODE_BY_MAPPED_PARTITION_LABEL(label)))), \ + (DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION( \ + DT_NODE_BY_FIXED_PARTITION_LABEL(label))))) /** * Get device pointer for device the area/partition resides on @@ -462,11 +499,11 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_DEVICE(label) \ - DEVICE_DT_GET(COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(DT_NODELABEL(label))), \ - (DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label))))) +#define PARTITION_DEVICE(label) PARTITION_NODE_DEVICE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_DEVICE() */ +#define FIXED_PARTITION_DEVICE(label) PARTITION_DEVICE(label) __DEPRECATED_MACRO + /** * Get device pointer for device the area/partition resides on * @@ -474,11 +511,15 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_NODE_DEVICE(node) \ - DEVICE_DT_GET(COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ - (DT_MTD_FROM_FIXED_PARTITION(node)))) +#define PARTITION_NODE_DEVICE(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(node))), \ + (DEVICE_DT_GET(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ + (DT_MTD_FROM_FIXED_PARTITION(node)))))) + +/** Deprecated macro, replace with PARTITION_NODE_DEVICE() */ +#define FIXED_PARTITION_NODE_DEVICE(node) PARTITION_NODE_DEVICE(node) __DEPRECATED_MACRO /** * Get the node identifier of the flash controller the area/partition resides on @@ -487,11 +528,10 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_MTD(label) \ - COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(DT_NODELABEL(label))), \ - (DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label)))) +#define PARTITION_MTD(label) PARTITION_NODE_MTD(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_MTD(label) PARTITION_MTD(label) __DEPRECATED_MACRO /** * Get the node identifier of the flash controller the area/partition resides on @@ -500,11 +540,15 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_NODE_MTD(node) \ - COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ - (DT_MTD_FROM_FIXED_PARTITION(node))) +#define PARTITION_NODE_MTD(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MTD_FROM_MAPPED_PARTITION(node)), \ + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ + (DT_MTD_FROM_FIXED_PARTITION(node))))) + +/** Deprecated macro, replace with PARTITION_NODE_MTD() */ +#define FIXED_PARTITION_NODE_MTD(node) PARTITION_NODE_MTD(node) __DEPRECATED_MACRO /** * Get pointer to flash_area object by partition label @@ -513,7 +557,10 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to flash_area type object representing partition */ -#define FIXED_PARTITION(label) FIXED_PARTITION_1(DT_NODELABEL(label)) +#define PARTITION(label) PARTITION_BY_NODE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION() */ +#define FIXED_PARTITION(label) PARTITION(label) __DEPRECATED_MACRO /** * Get pointer to flash_area object by partition node in DTS @@ -522,7 +569,13 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to flash_area type object representing partition */ -#define FIXED_PARTITION_BY_NODE(node) FIXED_PARTITION_1(node) +#define PARTITION_BY_NODE(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (MAPPED_PARTITION_1(node)), \ + (FIXED_PARTITION_1(node))) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_BY_NODE(node) PARTITION_BY_NODE(node) __DEPRECATED_MACRO /** @cond INTERNAL_HIDDEN */ #define FIXED_PARTITION_1(node) FIXED_PARTITION_0(DT_DEP_ORD(node)) @@ -541,6 +594,19 @@ DT_FOREACH_STATUS_OKAY(fixed_partitions, FOR_EACH_PARTITION_TABLE) #undef DECLARE_PARTITION_0 #undef FOR_EACH_PARTITION_TABLE +#define MAPPED_PARTITION_1(node) MAPPED_PARTITION_0(DT_DEP_ORD(node)) +#define MAPPED_PARTITION_0(ord) \ + ((const struct flash_area *)&DT_CAT(global_zephyr_mapped_partition_ORD_, ord)) + +#define DECLARE_MAPPED_PARTITION(node) DECLARE_MAPPED_PARTITION_0(DT_DEP_ORD(node)) +#define DECLARE_MAPPED_PARTITION_0(ord) \ + extern const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord); + +DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DECLARE_MAPPED_PARTITION) + +#undef DECLARE_MAPPED_PARTITION +#undef DECLARE_MAPPED_PARTITION_0 + #define FIXED_SUBPARTITION_1(node) FIXED_SUBPARTITION_0(DT_DEP_ORD(node)) #define FIXED_SUBPARTITION_0(ord) \ ((const struct flash_area *)&DT_CAT(global_fixed_subpartition_ORD_, ord)) diff --git a/modules/canopennode/canopen_program.c b/modules/canopennode/canopen_program.c index 5ad99c376283..c40e57cc2b52 100644 --- a/modules/canopennode/canopen_program.c +++ b/modules/canopennode/canopen_program.c @@ -189,7 +189,7 @@ static inline CO_SDO_abortCode_t canopen_program_cmd_clear(void) if (!IS_ENABLED(CONFIG_IMG_ERASE_PROGRESSIVELY)) { LOG_DBG("erasing flash area"); - err = boot_erase_img_bank(FIXED_PARTITION_ID(slot1_partition)); + err = boot_erase_img_bank(PARTITION_ID(slot1_partition)); if (err) { LOG_ERR("failed to erase image bank (err %d)", err); CO_errorReport(ctx.em, CO_EM_NON_VOLATILE_MEMORY, @@ -344,9 +344,9 @@ static CO_SDO_abortCode_t canopen_odf_1f56(CO_ODF_arg_t *odf_arg) * started upon receiveing the next 'start' command. */ if (ctx.flash_written) { - fa_id = FIXED_PARTITION_ID(slot1_partition); + fa_id = PARTITION_ID(slot1_partition); } else { - fa_id = FIXED_PARTITION_ID(slot0_partition); + fa_id = PARTITION_ID(slot0_partition); } err = boot_read_bank_header(fa_id, &header, sizeof(header)); diff --git a/samples/boards/espressif/flash_encryption/src/main.c b/samples/boards/espressif/flash_encryption/src/main.c index 07799dfe21ac..431696f4df5e 100644 --- a/samples/boards/espressif/flash_encryption/src/main.c +++ b/samples/boards/espressif/flash_encryption/src/main.c @@ -25,7 +25,7 @@ int main(void) { uint8_t buffer[32]; const struct device *flash_device; - off_t address = FIXED_PARTITION_OFFSET(storage_partition); + off_t address = PARTITION_OFFSET(storage_partition); flash_device = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); if (!device_is_ready(flash_device)) { diff --git a/samples/boards/espressif/flash_ipm/remote/src/main.c b/samples/boards/espressif/flash_ipm/remote/src/main.c index 2e383ea19cb9..3b28831f3781 100644 --- a/samples/boards/espressif/flash_ipm/remote/src/main.c +++ b/samples/boards/espressif/flash_ipm/remote/src/main.c @@ -16,9 +16,9 @@ #define ASCII_PATTERN(i) ((uint8_t) i % 128) #define TEST_PARTITION storage_partition -#define TEST_PARTITION_DEVICE FIXED_PARTITION_DEVICE(TEST_PARTITION) -#define TEST_PARTITION_ADDRESS FIXED_PARTITION_ADDRESS(TEST_PARTITION) -#define TEST_PARTITION_SIZE FIXED_PARTITION_SIZE(TEST_PARTITION) +#define TEST_PARTITION_DEVICE PARTITION_DEVICE(TEST_PARTITION) +#define TEST_PARTITION_ADDRESS PARTITION_ADDRESS(TEST_PARTITION) +#define TEST_PARTITION_SIZE PARTITION_SIZE(TEST_PARTITION) #define PAGE_SIZE 0x1000 diff --git a/samples/boards/espressif/flash_memory_mapped/src/main.c b/samples/boards/espressif/flash_memory_mapped/src/main.c index f6124107bfe5..ec49a51a7a3d 100644 --- a/samples/boards/espressif/flash_memory_mapped/src/main.c +++ b/samples/boards/espressif/flash_memory_mapped/src/main.c @@ -22,8 +22,8 @@ int main(void) const struct device *flash_device; const void *mem_ptr; spi_flash_mmap_handle_t handle; - off_t address = FIXED_PARTITION_OFFSET(scratch_partition); - size_t size = FIXED_PARTITION_SIZE(scratch_partition); + off_t address = PARTITION_OFFSET(scratch_partition); + size_t size = PARTITION_SIZE(scratch_partition); flash_device = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); if (!device_is_ready(flash_device)) { diff --git a/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c b/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c index b7e71e06e5a1..9fed36185ac7 100644 --- a/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c +++ b/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c @@ -25,9 +25,9 @@ #include "board.h" #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_DEV FIXED_PARTITION_DEVICE(STORAGE_PARTITION) -#define STORAGE_PARTITION_OFFSET FIXED_PARTITION_OFFSET(STORAGE_PARTITION) -#define STORAGE_PARTITION_SIZE FIXED_PARTITION_SIZE(STORAGE_PARTITION) +#define STORAGE_PARTITION_DEV PARTITION_DEVICE(STORAGE_PARTITION) +#define STORAGE_PARTITION_OFFSET PARTITION_OFFSET(STORAGE_PARTITION) +#define STORAGE_PARTITION_SIZE PARTITION_SIZE(STORAGE_PARTITION) enum font_size { FONT_SMALL = 0, diff --git a/samples/drivers/soc_flash_nrf/src/main.c b/samples/drivers/soc_flash_nrf/src/main.c index e509deda044a..73332d4c6a24 100644 --- a/samples/drivers/soc_flash_nrf/src/main.c +++ b/samples/drivers/soc_flash_nrf/src/main.c @@ -14,8 +14,8 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_OFFSET FIXED_PARTITION_OFFSET(TEST_PARTITION) -#define TEST_PARTITION_DEVICE FIXED_PARTITION_DEVICE(TEST_PARTITION) +#define TEST_PARTITION_OFFSET PARTITION_OFFSET(TEST_PARTITION) +#define TEST_PARTITION_DEVICE PARTITION_DEVICE(TEST_PARTITION) #if defined(CONFIG_SOC_NRF54H20) #define FLASH_PAGE_SIZE 2048 diff --git a/samples/drivers/spi_flash/src/main.c b/samples/drivers/spi_flash/src/main.c index b8721386af00..31cde69c6af7 100644 --- a/samples/drivers/spi_flash/src/main.c +++ b/samples/drivers/spi_flash/src/main.c @@ -17,7 +17,7 @@ defined(CONFIG_BOARD_ARTY_A7_DESIGNSTART_FPGA_CORTEX_M3) /* The FPGA bitstream is stored in the lower 536 sectors of the flash. */ #define SPI_FLASH_TEST_REGION_OFFSET \ - DT_REG_SIZE(DT_NODE_BY_FIXED_PARTITION_LABEL(fpga_bitstream)) + DT_REG_SIZE(DT_NODE_BY_PARTITION_LABEL(fpga_bitstream)) #elif defined(CONFIG_BOARD_NPCX9M6F_EVB) || \ defined(CONFIG_BOARD_NPCX7M6FB_EVB) #define SPI_FLASH_TEST_REGION_OFFSET 0x7F000 diff --git a/samples/subsys/fs/format/src/main.c b/samples/subsys/fs/format/src/main.c index dabc795fc568..7df2aa7e8e0c 100644 --- a/samples/subsys/fs/format/src/main.c +++ b/samples/subsys/fs/format/src/main.c @@ -20,7 +20,7 @@ #include #define MKFS_FS_TYPE FS_LITTLEFS -#define MKFS_DEV_ID FIXED_PARTITION_ID(storage_partition) +#define MKFS_DEV_ID PARTITION_ID(storage_partition) #define MKFS_FLAGS 0 #elif defined(CONFIG_FAT_FILESYSTEM_ELM) diff --git a/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay b/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay index fe4e532b471c..25473f52ddec 100644 --- a/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay +++ b/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay @@ -17,19 +17,18 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; reg = <0x0000c000 0x00066000>; }; slot1_partition: partition@72000 { + compatible = "zephyr,mapped-partition"; reg = <0x00072000 0x00066000>; }; storage_partition: partition@d8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000d8000 0x00028000>; }; diff --git a/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index b44427b19b9d..49a3ace82730 100644 --- a/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay +++ b/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -14,19 +14,18 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; reg = <0x00010000 DT_SIZE_K(300)>; }; slot1_partition: partition@5b000 { + compatible = "zephyr,mapped-partition"; reg = <0x0005b000 DT_SIZE_K(300)>; }; storage_partition: partition@a6000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000a6000 DT_SIZE_K(128)>; }; diff --git a/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay b/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay index 1afd8bf74b46..e26399cd4c4e 100644 --- a/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay +++ b/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay @@ -1,45 +1 @@ -/* - * Copyright (c) 2025 Würth Elektronik eiSos GmbH & Co. KG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* Because FAT FS needs at least 64kiB partition and default - * storage_partition is 36kiB for this board, we need to reorganize - * partitions to get at least 64KiB. - */ -/delete-node/ &slot0_partition; -/delete-node/ &slot1_partition; -/delete-node/ &storage_partition; - -&cpuapp_rram { - partitions { - compatible = "fixed-partitions"; - - #address-cells = <1>; - #size-cells = <1>; - - slot0_partition: partition@10000 { - reg = <0x00010000 DT_SIZE_K(300)>; - }; - - slot1_partition: partition@5b000 { - reg = <0x0005b000 DT_SIZE_K(300)>; - }; - - storage_partition: partition@a6000 { - label = "storage"; - reg = <0x000a6000 DT_SIZE_K(128)>; - }; - }; -}; - -/ { - msc_disk0 { - status = "okay"; - compatible = "zephyr,flash-disk"; - partition = <&storage_partition>; - disk-name = "SD"; - cache-size = <512>; - }; -}; +#include "nrf54l15dk_nrf54l15_cpuapp.overlay" diff --git a/samples/subsys/fs/fs_sample/sample.yaml b/samples/subsys/fs/fs_sample/sample.yaml index e1b9b56e6e8f..c750cecc1f7f 100644 --- a/samples/subsys/fs/fs_sample/sample.yaml +++ b/samples/subsys/fs/fs_sample/sample.yaml @@ -58,12 +58,11 @@ tests: extra_args: - EXTRA_CONF_FILE=boards/nrf52840dk_nrf52840_ram_disk.conf - DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk_region.overlay - sample.filesystem.fat_fs.nrf54l15dk: + sample.filesystem.fat_fs.nrf54l15: build_only: true - platform_allow: nrf54l15dk/nrf54l15/cpuapp - sample.filesystem.fat_fs.ophelia4ev: - build_only: true - platform_allow: ophelia4ev/nrf54l15/cpuapp + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + - ophelia4ev/nrf54l15/cpuapp sample.filesystem.fat_fs.nrf52840dk_nrf52840.qspi: build_only: true platform_allow: nrf52840dk/nrf52840 diff --git a/samples/subsys/fs/littlefs/src/main.c b/samples/subsys/fs/littlefs/src/main.c index e228baad1fa6..7e565cada935 100644 --- a/samples/subsys/fs/littlefs/src/main.c +++ b/samples/subsys/fs/littlefs/src/main.c @@ -268,7 +268,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); static struct fs_mount_t lfs_storage_mnt = { .type = FS_LITTLEFS, .fs_data = &storage, - .storage_dev = (void *)FIXED_PARTITION_ID(storage_partition), + .storage_dev = (void *)PARTITION_ID(storage_partition), .mnt_point = "/lfs", }; #endif /* PARTITION_NODE */ diff --git a/samples/subsys/fs/zms/src/main.c b/samples/subsys/fs/zms/src/main.c index a17ffd68f72d..6790b786ac2a 100644 --- a/samples/subsys/fs/zms/src/main.c +++ b/samples/subsys/fs/zms/src/main.c @@ -18,8 +18,8 @@ static struct zms_fs fs; #define ZMS_PARTITION storage_partition -#define ZMS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(ZMS_PARTITION) -#define ZMS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(ZMS_PARTITION) +#define ZMS_PARTITION_DEVICE PARTITION_DEVICE(ZMS_PARTITION) +#define ZMS_PARTITION_OFFSET PARTITION_OFFSET(ZMS_PARTITION) #define IP_ADDRESS_ID 1 #define KEY_VALUE_ID COND_CODE_1(CONFIG_ZMS_ID_64BIT, (0xbeefdead00000002ULL), (0xbeefdeadULL)) diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c index 2f33b436fe0c..9c7f06be8665 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c +++ b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(smp_sample); #include "common.h" #define STORAGE_PARTITION_LABEL storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION_LABEL) /* Define an example stats group; approximates seconds since boot. */ STATS_SECT_START(smp_svr_stats) diff --git a/samples/subsys/nvs/src/main.c b/samples/subsys/nvs/src/main.c index 222ebe0ac95d..a2682ef79c5e 100644 --- a/samples/subsys/nvs/src/main.c +++ b/samples/subsys/nvs/src/main.c @@ -49,8 +49,8 @@ static struct nvs_fs fs; #define NVS_PARTITION storage_partition -#define NVS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(NVS_PARTITION) -#define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION) +#define NVS_PARTITION_DEVICE PARTITION_DEVICE(NVS_PARTITION) +#define NVS_PARTITION_OFFSET PARTITION_OFFSET(NVS_PARTITION) #define ADDRESS_ID 1 #define KEY_ID 2 diff --git a/samples/subsys/settings/src/main.c b/samples/subsys/settings/src/main.c index e1fb1cf299f3..4b0dce2a058a 100644 --- a/samples/subsys/settings/src/main.c +++ b/samples/subsys/settings/src/main.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -18,7 +19,7 @@ #endif #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) #define GAMMA_DEFAULT_VAl 0 #define FAIL_MSG "fail (err %d)\n" diff --git a/samples/subsys/usb/mass/src/main.c b/samples/subsys/usb/mass/src/main.c index 97b357e88b7e..64c1984a89dd 100644 --- a/samples/subsys/usb/mass/src/main.c +++ b/samples/subsys/usb/mass/src/main.c @@ -36,7 +36,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #endif #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) static struct fs_mount_t fs_mnt; diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py old mode 100755 new mode 100644 index 94c6d0e085ac..446a5d79e3e4 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -286,8 +286,9 @@ def write_special_props(node: edtlib.Node) -> None: # Macros that are special to bindings inherited from Linux, which # we can't capture with the current bindings language. write_pinctrls(node) - write_fixed_partitions(node) + write_partition_data(node) write_gpio_hogs(node) + write_maps(node) def write_ranges(node: edtlib.Node) -> None: @@ -564,10 +565,12 @@ def write_pinctrls(node: edtlib.Node) -> None: f"DT_{ph.z_path_id}") -def write_fixed_partitions(node: edtlib.Node) -> None: - # Macros for child nodes of each fixed-partitions node. +def write_partition_data(node: edtlib.Node) -> None: + # Macros for partition nodes (fixed-partitions, fixed-subpartitions, zephyr,mapped-partition) - if not (node.parent and ("fixed-partitions" in node.parent.compats or "fixed-subpartitions" in node.parent.compats)): + if not (node.parent and ("fixed-partitions" in node.parent.compats or + "zephyr,mapped-partition" in node.compats or + "fixed-subpartitions" in node.parent.compats)): return global flash_area_num @@ -592,6 +595,73 @@ def write_gpio_hogs(node: edtlib.Node) -> None: out_dt_define(macro, val) +def write_maps(node: edtlib.Node) -> None: + if len(node.maps.keys()) == 0: + return + + out_comment("Map properties:") + + macro2val = {} + + for bn, entries in node.maps.items(): + basename = str2ident(bn) + plen = len(entries) + prop_id = f"{basename}_map" + macro = f"{node.z_path_id}_P_{basename}_map" + + # _LEN and _EXISTS share the grammar with `prop` element. + + macro2val[f"{macro}_LEN"] = plen + macro2val[f"{macro}_EXISTS"] = 1 + + # Map node specific definitions + for i, mp in enumerate(entries): + macro2val[f"{macro}_MAP_ENTRY_{i}_EXISTS"] = 1 + + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_LEN"] = len(mp.child_addresses) + for n, addr in enumerate(mp.child_addresses): + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_IDX_{n}"] = addr + + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_LEN"] = len(mp.child_specifiers) + for n, sp in enumerate(mp.child_specifiers): + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_IDX_{n}"] = sp + + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT"] = "DT_" + node_z_path_id(mp.parent) + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_LEN"] = len(mp.parent_addresses) + for n, addr in enumerate(mp.parent_addresses): + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_IDX_{n}"] = addr + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_LEN"] = len(mp.parent_specifiers) + for n, sp in enumerate(mp.parent_specifiers): + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_IDX_{n}"] = sp + + macro2val[f"{macro}_FOREACH_MAP_ENTRY(fn)"] = ' \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i})' for i in range(plen) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_SEP(fn, sep)"] = ( + ' DT_DEBRACKET_INTERNAL sep \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i})' for i in range(plen) + ) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_VARGS(fn, ...)"] = ' \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)' for i in range(plen) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_SEP_VARGS(fn, sep, ...)"] = ( + ' DT_DEBRACKET_INTERNAL sep \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)' for i in range(plen) + ) + ) + + for mc, val in macro2val.items(): + out_dt_define(mc, val) + + def write_vanilla_props(node: edtlib.Node) -> None: # Writes macros for any and all properties defined in the # "properties" section of the binding for the node. @@ -998,6 +1068,25 @@ def write_global_macros(edt: edtlib.EDT): out_dt_define(macro, val) out_dt_define(macro + "_EXISTS", 1) + elif compat == "zephyr,mapped-partition": + parent = node.parent + + while parent and "soc-nv-flash" not in parent.compats: + parent = parent.parent + + if not parent: + err(f"zephyr,mapped-partition node lacks soc-nv-flash parent: {node.path}") + + out_comment("parent NVM identifier:") + out_dt_define(f"{node.z_path_id}_NVM_DEVICE", f"DT_{parent.z_path_id}") + + if "label" in node.props: + label = node.props["label"].val + macro = f"COMPAT_{str2ident(compat)}_LABEL_{str2ident(label)}" + val = f"DT_{node.z_path_id}" + + out_dt_define(macro, val) + out_dt_define(macro + "_EXISTS", 1) out_comment('Macros for compatibles with status "okay" nodes\n') for compat, okay_nodes in edt.compat2okay.items(): diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index 8151388a6df2..c9584e1d3aa5 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -915,6 +915,55 @@ def name_as_token(self): "See the class docstring" return str_as_token(self.name) if self.name is not None else None +@dataclass +class MapEntry: + """ + Represents a single entry parsed from a ``*-map`` property. For example, + the value '<0 0 &gpio0 14 0>' from 'gpio-map = <0 0 &gpio0 14 0>, <1 0 &gpio0 0 0>;' + becomes one ``MapEntry`` instance. + + These attributes are available on ``MapEntry`` objects: + + node: + The Node instance whose property contains the map entry. + + child_addresses: + A list of integers describing the unit address portion that precedes the + child specifier. ``interrupt-map`` entries, for example, begin with the + child unit address whose length is determined by ``#address-cells`` on the + nexus node or its parent. When no address cells are defined this list is + empty. + + child_specifiers: + A list of integers read from the child side of the map entry after any + address words. These are the specifier cells that precede the parent + phandle. + + parent: + The parent Node instance. + + parent_addresses: + The unit address portion that follows the parent phandle. Its length is + derived from the parent's ``#address-cells`` (with the same parent lookup + fallback as in the devicetree specification). Empty when no address cells + are provided. + + parent_specifiers: + A list of integers describing the parent side of the mapping after any + parent address cells. These values correspond to the ``*-cells`` + definition in the parent's binding. + + basename: + The base name of the ``*-map`` property, which also describes the + specifier space for the mapping. + """ + node: 'Node' + child_addresses: list[int] + child_specifiers: list[int] + parent: 'Node' + parent_addresses: list[int] + parent_specifiers: list[int] + basename: str class Node: """ @@ -1062,6 +1111,11 @@ class Node: list is empty if the node does not hog any GPIOs. Only relevant for GPIO hog nodes. + maps: + A dictionary that contains a list of MapEntry instances associated with each string key. + The key is the basename-part of the node property name, the value is + the entries of the property value. + is_pci_device: True if the node is a PCI device. """ @@ -1334,6 +1388,103 @@ def gpio_hogs(self) -> list[ControllerAndData]: return res + @property + def maps(self) -> dict[str, list[MapEntry]]: + "See the class docstring" + + res: dict[str, list[MapEntry]] = {} + + def count_specifier_cells(node: dtlib_Node, specifier: str) -> int: + """Return the number of specifier cells for *specifier* in *node*.""" + + cells_prop = f"#{specifier}-cells" + + if cells_prop not in node.props: + _err(f"{node!r} lacks required '{cells_prop}' property") + + return node.props[cells_prop].to_num() + + def count_address_cells(node: dtlib_Node) -> int: + """Return the number of interrupt address cells for *node*.""" + + if "#address-cells" in node.props: + return node.props["#address-cells"].to_num() + + if node.parent and "#address-cells" in node.parent.props: + return node.parent.props["#address-cells"].to_num() + + return 0 + + for prop in [v for k, v in self._node.props.items() if k.endswith("-map")]: + specifier_space = prop.name[:-4] # Strip '-map' + entries: list[MapEntry] = [] + raw = prop.value + while raw: + if len(raw) < 4: + # Not enough room for phandle + _err("bad value for " + repr(prop)) + + child_address_cells = 0 + if specifier_space == "interrupt": + child_address_cells = count_address_cells(prop.node) + + child_specifier_cells = count_specifier_cells(prop.node, specifier_space) + child_total_cells = child_address_cells + child_specifier_cells + + if len(raw) < 4 * child_total_cells: + _err("bad value for " + repr(prop)) + + child_cells = to_nums(raw[: 4 * child_total_cells]) + child_addresses = child_cells[:child_address_cells] + child_specifiers = child_cells[child_address_cells:] + + raw = raw[4 * child_total_cells :] + phandle = to_num(raw[:4]) + raw = raw[4:] + + parent_node = prop.node.dt.phandle2node.get(phandle) + if parent_node is None: + _err(f"parent node cannot be found from phandle:{phandle}") + + parent: Node = self.edt._node2enode[parent_node] + if parent is None: + _err("parent cannot be found from: " + repr(parent_node)) + + parent_address_cells = 0 + if specifier_space == "interrupt": + parent_address_cells = count_address_cells(parent_node) + + parent_specifier_cells = count_specifier_cells(parent_node, specifier_space) + parent_total_cells = parent_address_cells + parent_specifier_cells + + if len(raw) < 4 * parent_total_cells: + _err("bad value for " + repr(prop)) + + parent_cells = to_nums(raw[: 4 * parent_total_cells]) + parent_addresses = parent_cells[:parent_address_cells] + parent_specifiers = parent_cells[parent_address_cells:] + + raw = raw[4 * parent_total_cells :] + + entries.append( + MapEntry( + node=self, + child_addresses=child_addresses, + child_specifiers=child_specifiers, + parent=parent, + parent_addresses=parent_addresses, + parent_specifiers=parent_specifiers, + basename=specifier_space, + ) + ) + + if len(raw) != 0: + _err(f"unexpected prop.value remaining: {raw}") + + res[specifier_space] = entries + + return res + @property def has_child_binding(self) -> bool: """ diff --git a/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay b/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay index 74d9d477b19d..d3594b00aaaa 100644 --- a/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay +++ b/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay @@ -3,6 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ +&cpuapp_sram { + reg = <0x20000000 DT_SIZE_K(188)>; + ranges = <0x0 0x20000000 DT_SIZE_K(188)>; +}; + +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1428)>; + ranges = <0x0 0x0 DT_SIZE_K(1428)>; + + /delete-node/ partitions; +}; + &rram_controller { cpuflpr_rram: rram@165000 { compatible = "soc-nv-flash"; @@ -26,3 +38,6 @@ &cpuapp_vevif_tx { status = "okay"; }; + +#define WITH_FLPR_PARTITIONS +#include diff --git a/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay b/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay index f429def60040..318a60b3698d 100644 --- a/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay +++ b/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay @@ -25,6 +25,13 @@ ranges = <0x0 0x20000000 0x28000>; }; +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1428)>; + ranges = <0x0 0x0 DT_SIZE_K(1428)>; + + /delete-node/ partitions; +}; + &rram_controller { cpuflpr_rram: rram@165000 { compatible = "soc-nv-flash"; @@ -45,3 +52,6 @@ &cpuapp_vevif_tx { status = "okay"; }; + +#define WITH_FLPR_PARTITIONS +#include diff --git a/soc/adi/max32/mpu_regions.c b/soc/adi/max32/mpu_regions.c index 020b5cf19126..b1b1ac7ccc31 100644 --- a/soc/adi/max32/mpu_regions.c +++ b/soc/adi/max32/mpu_regions.c @@ -30,9 +30,9 @@ * flash. */ static const struct arm_mpu_region mpu_regions[] = { -#if FIXED_PARTITION_EXISTS(storage_partition) -#define STORAGE_ADDR (CONFIG_FLASH_BASE_ADDRESS + FIXED_PARTITION_OFFSET(storage_partition)) -#define STORAGE_SIZE (FIXED_PARTITION_SIZE(storage_partition) >> 10) +#if PARTITION_EXISTS(storage_partition) +#define STORAGE_ADDR (CONFIG_FLASH_BASE_ADDRESS + PARTITION_OFFSET(storage_partition)) +#define STORAGE_SIZE (PARTITION_SIZE(storage_partition) >> 10) MAX32_MPU_REGION("FLASH", CONFIG_FLASH_BASE_ADDRESS, REGION_FLASH_ATTR, KB(CONFIG_FLASH_SIZE - STORAGE_SIZE)), MAX32_MPU_REGION("STORAGE", STORAGE_ADDR, MAX32_FLASH_NON_CACHEABLE, KB(STORAGE_SIZE)), diff --git a/soc/espressif/common/loader.c b/soc/espressif/common/loader.c index 74a3c977a42e..d8f01606b718 100644 --- a/soc/espressif/common/loader.c +++ b/soc/espressif/common/loader.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,9 @@ #include #include +#ifdef CONFIG_XTENSA +#include +#endif #if CONFIG_SOC_SERIES_ESP32C6 #include @@ -81,9 +85,13 @@ #define HDR_ATTR __attribute__((section(".entry_addr"))) __attribute__((used)) #if !defined(CONFIG_SOC_ESP32_APPCPU) && !defined(CONFIG_SOC_ESP32S3_APPCPU) -#define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_partition) +#if DT_NODE_EXISTS(DT_CHOSEN(zephyr_code_partition)) +#define PART_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) +#else +#define PART_OFFSET PARTITION_OFFSET(slot0_partition) +#endif #else -#define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_appcpu_partition) +#define PART_OFFSET PARTITION_OFFSET(slot0_appcpu_partition) #endif void __start(void); @@ -118,7 +126,7 @@ void map_rom_segments(int core, struct rom_segments *map) /* Traverse segments to fix flash offset changes due to post-build processing */ #ifndef CONFIG_BOOTLOADER_MCUBOOT esp_image_segment_header_t WORD_ALIGNED_ATTR segment_hdr; - size_t offset = FIXED_PARTITION_OFFSET(boot_partition); + size_t offset = PARTITION_OFFSET(boot_partition); bool checksum = false; unsigned int segments = 0; unsigned int ram_segments = 0; @@ -302,10 +310,10 @@ void __start(void) __asm__ __volatile__("wsr %0, PS" : : "r"(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE)); /* Initialize the architecture CPU pointer. Some of the - * initialization code wants a valid arch_current_thread() before + * initialization code wants a valid arch_curr_cpu() before * arch_kernel_init() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[0])); #endif /* CONFIG_RISCV_GP */ diff --git a/soc/espressif/esp32/esp32-mp.c b/soc/espressif/esp32/esp32-mp.c index 55bc5fd028e4..f484440e4db3 100644 --- a/soc/espressif/esp32/esp32-mp.c +++ b/soc/espressif/esp32/esp32-mp.c @@ -18,6 +18,7 @@ #include "esp_mcuboot_image.h" #include "esp_memory_utils.h" +#include #ifdef CONFIG_SMP @@ -94,7 +95,7 @@ static void appcpu_entry2(void) */ _cpu_t *cpu = &_kernel.cpus[1]; - __asm__ volatile("wsr.MISC0 %0" : : "r"(cpu)); + __asm__ volatile("wsr %0, " ZSR_CPU_STR : : "r"(cpu)); smp_log("ESP32: APPCPU running"); @@ -350,9 +351,9 @@ static int load_segment(uint32_t src_addr, uint32_t src_len, uint32_t dst_addr) int IRAM_ATTR esp_appcpu_image_load(unsigned int hdr_offset, unsigned int *entry_addr) { - const uint32_t img_off = FIXED_PARTITION_OFFSET(slot0_appcpu_partition); - const uint32_t fa_size = FIXED_PARTITION_SIZE(slot0_appcpu_partition); - const uint8_t fa_id = FIXED_PARTITION_ID(slot0_appcpu_partition); + const uint32_t img_off = PARTITION_OFFSET(slot0_appcpu_partition); + const uint32_t fa_size = PARTITION_SIZE(slot0_appcpu_partition); + const uint8_t fa_id = PARTITION_ID(slot0_appcpu_partition); if (entry_addr == NULL) { ets_printf("Can't return the entry address. Aborting!\n"); diff --git a/soc/espressif/esp32/soc_appcpu.c b/soc/espressif/esp32/soc_appcpu.c index a682a87753c6..ec46501e5d33 100644 --- a/soc/espressif/esp32/soc_appcpu.c +++ b/soc/espressif/esp32/soc_appcpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -83,7 +84,7 @@ void IRAM_ATTR __appcpu_start(void) * initialization code wants a valid _current before * z_prep_c() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[1])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[1])); core_intr_matrix_clear(); diff --git a/soc/espressif/esp32s3/esp32s3-mp.c b/soc/espressif/esp32s3/esp32s3-mp.c index fadbd9224189..85e84b469807 100644 --- a/soc/espressif/esp32s3/esp32s3-mp.c +++ b/soc/espressif/esp32s3/esp32s3-mp.c @@ -68,9 +68,9 @@ static int load_segment(uint32_t src_addr, uint32_t src_len, uint32_t dst_addr) int IRAM_ATTR esp_appcpu_image_load(unsigned int hdr_offset, unsigned int *entry_addr) { - const uint32_t fa_offset = FIXED_PARTITION_OFFSET(slot0_appcpu_partition); - const uint32_t fa_size = FIXED_PARTITION_SIZE(slot0_appcpu_partition); - const uint8_t fa_id = FIXED_PARTITION_ID(slot0_appcpu_partition); + const uint32_t fa_offset = PARTITION_OFFSET(slot0_appcpu_partition); + const uint32_t fa_size = PARTITION_SIZE(slot0_appcpu_partition); + const uint8_t fa_id = PARTITION_ID(slot0_appcpu_partition); if (entry_addr == NULL) { ESP_EARLY_LOGE(TAG, "Can't return the entry address. Aborting!"); diff --git a/soc/espressif/esp32s3/soc_appcpu.c b/soc/espressif/esp32s3/soc_appcpu.c index 4cb0e404857e..fc7bb549b448 100644 --- a/soc/espressif/esp32s3/soc_appcpu.c +++ b/soc/espressif/esp32s3/soc_appcpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -68,7 +69,7 @@ void IRAM_ATTR __appcpu_start(void) * initialization code wants a valid _current before * arch_kernel_init() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[1])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[1])); core_intr_matrix_clear(); diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index 4f6c3b131a54..740d58d5a339 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -44,11 +44,11 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); #define FLASH_LOAD_ADDRESS (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) #endif -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && \ - (FIXED_PARTITION_ADDRESS(label) <= FLASH_LOAD_ADDRESS && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && \ + (PARTITION_ADDRESS(label) <= FLASH_LOAD_ADDRESS && \ + PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ FLASH_LOAD_ADDRESS) #define FICR_ADDR_GET(node_id, name) \ @@ -164,16 +164,16 @@ void soc_late_init_hook(void) void *radiocore_address = NULL; #if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition)) - if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) { - radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot1_partition) + + if (PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) { + radiocore_address = (void *)(PARTITION_ADDRESS(cpurad_slot1_partition) + CONFIG_ROM_START_OFFSET); } else { - radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + + radiocore_address = (void *)(PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); } #else radiocore_address = - (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); + (void *)(PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); #endif if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) && diff --git a/subsys/bluetooth/mesh/shell/dfu.c b/subsys/bluetooth/mesh/shell/dfu.c index 4ff050f3e59a..e5884a01897a 100644 --- a/subsys/bluetooth/mesh/shell/dfu.c +++ b/subsys/bluetooth/mesh/shell/dfu.c @@ -136,7 +136,7 @@ void bt_mesh_shell_dfu_cmds_init(void) #if defined(CONFIG_BT_MESH_SHELL_DFU_SRV) && defined(CONFIG_BOOTLOADER_MCUBOOT) struct mcuboot_img_header img_header; - int err = boot_read_bank_header(FIXED_PARTITION_ID(slot0_partition), + int err = boot_read_bank_header(PARTITION_ID(slot0_partition), &img_header, sizeof(img_header)); if (!err) { struct shell_dfu_fwid *fwid = diff --git a/subsys/debug/coredump/coredump_backend_flash_partition.c b/subsys/debug/coredump/coredump_backend_flash_partition.c index c23fe82fecc3..25ec9711ba3d 100644 --- a/subsys/debug/coredump/coredump_backend_flash_partition.c +++ b/subsys/debug/coredump/coredump_backend_flash_partition.c @@ -32,9 +32,9 @@ LOG_MODULE_REGISTER(coredump, CONFIG_DEBUG_COREDUMP_LOG_LEVEL); * aligned to flash write size. */ #define FLASH_PARTITION coredump_partition -#define FLASH_PARTITION_ID FIXED_PARTITION_ID(FLASH_PARTITION) +#define FLASH_PARTITION_ID PARTITION_ID(FLASH_PARTITION) -#if !FIXED_PARTITION_EXISTS(FLASH_PARTITION) +#if !PARTITION_EXISTS(FLASH_PARTITION) #error "Need a fixed partition named 'coredump-partition'!" #else @@ -632,4 +632,4 @@ struct coredump_backend_api coredump_backend_flash_partition = { .cmd = coredump_flash_backend_cmd, }; -#endif /* FIXED_PARTITION_EXISTS(coredump_partition) */ +#endif /* PARTITION_EXISTS(coredump_partition) */ diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index 3750e44ac6b0..d754acc8d939 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -121,7 +121,7 @@ enum IMAGE_INDEXES { #define INVALID_SLOT_ID 255 #else /* Get active partition. zephyr,code-partition chosen node must be defined */ -#define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) +#define ACTIVE_SLOT_FLASH_AREA_ID DT_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) #endif #endif /* USE_PARTITION_MANAGER */ @@ -168,81 +168,81 @@ uint8_t boot_fetch_active_slot(void) /* Map slot number back to flash area ID */ switch (slot) { case 0: - return FIXED_PARTITION_ID(SLOT0_PARTITION); + return PARTITION_ID(SLOT0_PARTITION); -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) case 1: - return FIXED_PARTITION_ID(SLOT1_PARTITION); + return PARTITION_ID(SLOT1_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT2_PARTITION) +#if PARTITION_EXISTS(SLOT2_PARTITION) case 2: - return FIXED_PARTITION_ID(SLOT2_PARTITION); + return PARTITION_ID(SLOT2_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT3_PARTITION) +#if PARTITION_EXISTS(SLOT3_PARTITION) case 3: - return FIXED_PARTITION_ID(SLOT3_PARTITION); + return PARTITION_ID(SLOT3_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT4_PARTITION) +#if PARTITION_EXISTS(SLOT4_PARTITION) case 4: - return FIXED_PARTITION_ID(SLOT4_PARTITION); + return PARTITION_ID(SLOT4_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT5_PARTITION) +#if PARTITION_EXISTS(SLOT5_PARTITION) case 5: - return FIXED_PARTITION_ID(SLOT5_PARTITION); + return PARTITION_ID(SLOT5_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT6_PARTITION) +#if PARTITION_EXISTS(SLOT6_PARTITION) case 6: - return FIXED_PARTITION_ID(SLOT6_PARTITION); + return PARTITION_ID(SLOT6_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT7_PARTITION) +#if PARTITION_EXISTS(SLOT7_PARTITION) case 7: - return FIXED_PARTITION_ID(SLOT7_PARTITION); + return PARTITION_ID(SLOT7_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT8_PARTITION) +#if PARTITION_EXISTS(SLOT8_PARTITION) case 8: - return FIXED_PARTITION_ID(SLOT8_PARTITION); + return PARTITION_ID(SLOT8_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT9_PARTITION) +#if PARTITION_EXISTS(SLOT9_PARTITION) case 9: - return FIXED_PARTITION_ID(SLOT9_PARTITION); + return PARTITION_ID(SLOT9_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT10_PARTITION) +#if PARTITION_EXISTS(SLOT10_PARTITION) case 10: - return FIXED_PARTITION_ID(SLOT10_PARTITION); + return PARTITION_ID(SLOT10_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT11_PARTITION) +#if PARTITION_EXISTS(SLOT11_PARTITION) case 11: - return FIXED_PARTITION_ID(SLOT11_PARTITION); + return PARTITION_ID(SLOT11_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT12_PARTITION) +#if PARTITION_EXISTS(SLOT12_PARTITION) case 12: - return FIXED_PARTITION_ID(SLOT12_PARTITION); + return PARTITION_ID(SLOT12_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT13_PARTITION) +#if PARTITION_EXISTS(SLOT13_PARTITION) case 13: - return FIXED_PARTITION_ID(SLOT13_PARTITION); + return PARTITION_ID(SLOT13_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT14_PARTITION) +#if PARTITION_EXISTS(SLOT14_PARTITION) case 14: - return FIXED_PARTITION_ID(SLOT14_PARTITION); + return PARTITION_ID(SLOT14_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT15_PARTITION) +#if PARTITION_EXISTS(SLOT15_PARTITION) case 15: - return FIXED_PARTITION_ID(SLOT15_PARTITION); + return PARTITION_ID(SLOT15_PARTITION); #endif default: @@ -268,34 +268,34 @@ size_t boot_get_image_start_offset(uint8_t area_id) size_t off = 0; int image = IMAGE_INDEX_INVALID; - if (area_id == FIXED_PARTITION_ID(slot1_partition)) { + if (area_id == PARTITION_ID(slot1_partition)) { image = IMAGE_INDEX_0; -#if FIXED_PARTITION_EXISTS(slot3_partition) - } else if (area_id == FIXED_PARTITION_ID(slot3_partition)) { +#if PARTITION_EXISTS(slot3_partition) + } else if (area_id == PARTITION_ID(slot3_partition)) { image = IMAGE_INDEX_1; #endif -#if FIXED_PARTITION_EXISTS(slot5_partition) - } else if (area_id == FIXED_PARTITION_ID(slot5_partition)) { +#if PARTITION_EXISTS(slot5_partition) + } else if (area_id == PARTITION_ID(slot5_partition)) { image = IMAGE_INDEX_2; #endif -#if FIXED_PARTITION_EXISTS(slot7_partition) - } else if (area_id == FIXED_PARTITION_ID(slot7_partition)) { +#if PARTITION_EXISTS(slot7_partition) + } else if (area_id == PARTITION_ID(slot7_partition)) { image = IMAGE_INDEX_3; #endif -#if FIXED_PARTITION_EXISTS(slot9_partition) - } else if (area_id == FIXED_PARTITION_ID(slot9_partition)) { +#if PARTITION_EXISTS(slot9_partition) + } else if (area_id == PARTITION_ID(slot9_partition)) { image = IMAGE_INDEX_4; #endif -#if FIXED_PARTITION_EXISTS(slot11_partition) - } else if (area_id == FIXED_PARTITION_ID(slot11_partition)) { +#if PARTITION_EXISTS(slot11_partition) + } else if (area_id == PARTITION_ID(slot11_partition)) { image = IMAGE_INDEX_5; #endif -#if FIXED_PARTITION_EXISTS(slot13_partition) - } else if (area_id == FIXED_PARTITION_ID(slot13_partition)) { +#if PARTITION_EXISTS(slot13_partition) + } else if (area_id == PARTITION_ID(slot13_partition)) { image = IMAGE_INDEX_6; #endif -#if FIXED_PARTITION_EXISTS(slot15_partition) - } else if (area_id == FIXED_PARTITION_ID(slot15_partition)) { +#if PARTITION_EXISTS(slot15_partition) + } else if (area_id == PARTITION_ID(slot15_partition)) { image = IMAGE_INDEX_7; #endif diff --git a/subsys/dfu/boot/mcuboot_priv.h b/subsys/dfu/boot/mcuboot_priv.h index 9f33c1bc5ec8..faeec105063c 100644 --- a/subsys/dfu/boot/mcuboot_priv.h +++ b/subsys/dfu/boot/mcuboot_priv.h @@ -18,10 +18,10 @@ #define SLOT1_LABEL slot1_partition #endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ -/* FIXED_PARTITION_ID() values used below are auto-generated by DT */ -#define FLASH_AREA_IMAGE_PRIMARY FIXED_PARTITION_ID(SLOT0_LABEL) -#if FIXED_PARTITION_EXISTS(SLOT1_LABEL) -#define FLASH_AREA_IMAGE_SECONDARY FIXED_PARTITION_ID(SLOT1_LABEL) +/* PARTITION_ID() values used below are auto-generated by DT */ +#define FLASH_AREA_IMAGE_PRIMARY PARTITION_ID(SLOT0_LABEL) +#if PARTITION_EXISTS(SLOT1_LABEL) +#define FLASH_AREA_IMAGE_SECONDARY PARTITION_ID(SLOT1_LABEL) #endif diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index e167bc1e39b8..06eb79baa92b 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -132,15 +132,15 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, } #endif #else -#if FIXED_PARTITION_EXISTS(boot_partition) - if (id == FIXED_PARTITION_ID(boot_partition)) { +#if PARTITION_EXISTS(boot_partition) + if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); return -EACCES; } #endif -#if DT_FIXED_PARTITION_EXISTS(DT_CHOSEN(zephyr_code_partition)) - if (id == DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))) { +#if DT_PARTITION_EXISTS(DT_CHOSEN(zephyr_code_partition)) + if (id == DT_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))) { shell_error(sh, "Cannot erase active partitions"); return -EACCES; } diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index 2e6a5e7485fb..75bf36a92eb3 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -23,18 +23,14 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); #include #endif -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && (FIXED_PARTITION_ADDRESS(label) <= \ - (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ - (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2) #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition #else -#if FIXED_PARTITION_EXISTS(slot1_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#if PARTITION_EXISTS(slot1_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) #define UPLOAD_FLASH_AREA_LABEL slot1_partition #else #define UPLOAD_FLASH_AREA_LABEL slot0_partition @@ -45,8 +41,8 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); /* For RAM LOAD mode, the active image must be fetched from the bootloader */ #define UPLOAD_FLASH_AREA_ID flash_img_get_upload_slot() #else -/* FIXED_PARTITION_ID() values used below are auto-generated by DT */ -#define UPLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(UPLOAD_FLASH_AREA_LABEL) +/* PARTITION_ID() values used below are auto-generated by DT */ +#define UPLOAD_FLASH_AREA_ID PARTITION_ID(UPLOAD_FLASH_AREA_LABEL) #endif /* CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD */ #define UPLOAD_FLASH_AREA_CONTROLLER \ DT_GPARENT(DT_NODELABEL(UPLOAD_FLASH_AREA_LABEL)) @@ -262,10 +258,10 @@ uint8_t flash_img_get_upload_slot(void) slot = boot_fetch_active_slot(); - if (slot == FIXED_PARTITION_ID(slot0_partition)) { - return FIXED_PARTITION_ID(slot1_partition); + if (slot == PARTITION_ID(slot0_partition)) { + return PARTITION_ID(slot1_partition); } - return FIXED_PARTITION_ID(slot0_partition); + return PARTITION_ID(slot0_partition); } #else /* CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD */ uint8_t flash_img_get_upload_slot(void) diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index a31e01836a9c..0bd75a349b76 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1135,9 +1135,9 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(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)))), \ + (COND_CODE_1(PARTITION_EXISTS(littlefs_storage), \ + (PARTITION_ID(littlefs_storage)), \ + (PARTITION_ID(storage)))), \ (DT_FIXED_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/fs/shell.c b/subsys/fs/shell.c index ebd33c2b7219..a93aabf0f926 100644 --- a/subsys/fs/shell.c +++ b/subsys/fs/shell.c @@ -63,11 +63,11 @@ static struct fs_mount_t littlefs_mnt = { #define STORAGE_PARTIION_NODE_ID DT_PHANDLE(DT_INST(0, zephyr_fstab_littlefs), partition) -#if DT_FIXED_PARTITION_EXISTS(STORAGE_PARTIION_NODE_ID) -#define STORAGE_PARTITION_ID DT_FIXED_PARTITION_ID(STORAGE_PARTIION_NODE_ID) +#if DT_PARTITION_EXISTS(STORAGE_PARTIION_NODE_ID) +#define STORAGE_PARTITION_ID DT_PARTITION_ID(STORAGE_PARTIION_NODE_ID) #else #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) #endif FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(lfs_data); diff --git a/subsys/lorawan/services/frag_flash.c b/subsys/lorawan/services/frag_flash.c index 71ea4adb9052..4e77f29dd4cb 100644 --- a/subsys/lorawan/services/frag_flash.c +++ b/subsys/lorawan/services/frag_flash.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(lorawan_frag_flash, CONFIG_LORAWAN_SERVICES_LOG_LEVEL); -#define TARGET_IMAGE_AREA FIXED_PARTITION_ID(slot1_partition) +#define TARGET_IMAGE_AREA PARTITION_ID(slot1_partition) struct frag_cache_entry { uint32_t addr; diff --git a/subsys/mgmt/hawkbit/hawkbit.c b/subsys/mgmt/hawkbit/hawkbit.c index c6493d95e463..028333bd925f 100644 --- a/subsys/mgmt/hawkbit/hawkbit.c +++ b/subsys/mgmt/hawkbit/hawkbit.c @@ -52,7 +52,7 @@ LOG_MODULE_REGISTER(hawkbit, CONFIG_HAWKBIT_LOG_LEVEL); #define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8" #define SLOT1_LABEL slot1_partition -#define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL) +#define SLOT1_SIZE PARTITION_SIZE(SLOT1_LABEL) static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * SEC_PER_MIN); diff --git a/subsys/mgmt/hawkbit/hawkbit_firmware.c b/subsys/mgmt/hawkbit/hawkbit_firmware.c index f070fa65ea53..81ab00389ed5 100644 --- a/subsys/mgmt/hawkbit/hawkbit_firmware.c +++ b/subsys/mgmt/hawkbit/hawkbit_firmware.c @@ -12,7 +12,7 @@ bool hawkbit_get_firmware_version(char *version, int version_len) { struct mcuboot_img_header header; - if (boot_read_bank_header(FIXED_PARTITION_ID(slot0_partition), &header, + if (boot_read_bank_header(PARTITION_ID(slot0_partition), &header, sizeof(header)) != 0) { return false; } diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index edcacd4cfd8c..410c5a2c61c0 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -43,72 +43,77 @@ #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) +#else #ifndef CONFIG_FLASH_LOAD_OFFSET #error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \ to be able to figure out application running slot. #endif -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && (FIXED_PARTITION_ADDRESS(label) <= \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && (PARTITION_ADDRESS(label) <= \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ + PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) +#endif BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE, "struct image_header not required size"); #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 2 -#if FIXED_PARTITION_EXISTS(slot0_ns_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition) +#if PARTITION_EXISTS(slot0_ns_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot0_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#elif PARTITION_EXISTS(slot0_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot1_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition) +#elif PARTITION_EXISTS(slot1_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot2_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot2_partition) +#elif PARTITION_EXISTS(slot2_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot2_partition) #define ACTIVE_IMAGE_IS 1 -#elif FIXED_PARTITION_EXISTS(slot3_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot3_partition) +#elif PARTITION_EXISTS(slot3_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot3_partition) #define ACTIVE_IMAGE_IS 1 -#elif FIXED_PARTITION_EXISTS(slot4_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot4_partition) +#elif PARTITION_EXISTS(slot4_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot4_partition) #define ACTIVE_IMAGE_IS 2 -#elif FIXED_PARTITION_EXISTS(slot5_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot5_partition) +#elif PARTITION_EXISTS(slot5_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot5_partition) #define ACTIVE_IMAGE_IS 2 -#elif FIXED_PARTITION_EXISTS(slot6_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot6_partition) +#elif PARTITION_EXISTS(slot6_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot6_partition) #define ACTIVE_IMAGE_IS 3 -#elif FIXED_PARTITION_EXISTS(slot7_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot7_partition) +#elif PARTITION_EXISTS(slot7_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot7_partition) #define ACTIVE_IMAGE_IS 3 -#elif FIXED_PARTITION_EXISTS(slot8_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot8_partition) +#elif PARTITION_EXISTS(slot8_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot8_partition) #define ACTIVE_IMAGE_IS 4 -#elif FIXED_PARTITION_EXISTS(slot9_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot9_partition) +#elif PARTITION_EXISTS(slot9_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot9_partition) #define ACTIVE_IMAGE_IS 4 -#elif FIXED_PARTITION_EXISTS(slot10_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot10_partition) +#elif PARTITION_EXISTS(slot10_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot10_partition) #define ACTIVE_IMAGE_IS 5 -#elif FIXED_PARTITION_EXISTS(slot11_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot11_partition) +#elif PARTITION_EXISTS(slot11_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot11_partition) #define ACTIVE_IMAGE_IS 5 -#elif FIXED_PARTITION_EXISTS(slot12_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot12_partition) +#elif PARTITION_EXISTS(slot12_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot12_partition) #define ACTIVE_IMAGE_IS 6 -#elif FIXED_PARTITION_EXISTS(slot13_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot13_partition) +#elif PARTITION_EXISTS(slot13_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot13_partition) #define ACTIVE_IMAGE_IS 6 -#elif FIXED_PARTITION_EXISTS(slot14_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot14_partition) +#elif PARTITION_EXISTS(slot14_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot14_partition) #define ACTIVE_IMAGE_IS 7 -#elif FIXED_PARTITION_EXISTS(slot15_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot15_partition) +#elif PARTITION_EXISTS(slot15_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot15_partition) #define ACTIVE_IMAGE_IS 7 #else #define ACTIVE_IMAGE_IS 0 @@ -251,7 +256,7 @@ int img_mgmt_active_slot(int image) slot = (int)temp_slot; #else /* This covers single image, including DirectXiP */ - if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { + if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { slot = 1; } #endif diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c index 39c3e06f65f4..e3a323b0b1b5 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c @@ -50,44 +50,44 @@ LOG_MODULE_DECLARE(mcumgr_img_grp, CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL); * properly. */ #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 2 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT2_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT3_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT2_PARTITION) && + PARTITION_EXISTS(SLOT3_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 3 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT4_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT5_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT4_PARTITION) && + PARTITION_EXISTS(SLOT5_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 4 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT6_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT7_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT6_PARTITION) && + PARTITION_EXISTS(SLOT7_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 5 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT8_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT9_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT8_PARTITION) && + PARTITION_EXISTS(SLOT9_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 6 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT10_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT11_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT10_PARTITION) && + PARTITION_EXISTS(SLOT11_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 7 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT12_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT13_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT12_PARTITION) && + PARTITION_EXISTS(SLOT13_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 8 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT14_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT15_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT14_PARTITION) && + PARTITION_EXISTS(SLOT15_PARTITION), "Missing partitions?"); #endif @@ -177,95 +177,95 @@ img_mgmt_flash_area_id(int slot) switch (slot) { case 0: - fa_id = FIXED_PARTITION_ID(SLOT0_PARTITION); + fa_id = PARTITION_ID(SLOT0_PARTITION); break; case 1: - fa_id = FIXED_PARTITION_ID(SLOT1_PARTITION); + fa_id = PARTITION_ID(SLOT1_PARTITION); break; #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) -#if FIXED_PARTITION_EXISTS(SLOT2_PARTITION) +#if PARTITION_EXISTS(SLOT2_PARTITION) case 2: - fa_id = FIXED_PARTITION_ID(SLOT2_PARTITION); + fa_id = PARTITION_ID(SLOT2_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT3_PARTITION) +#if PARTITION_EXISTS(SLOT3_PARTITION) case 3: - fa_id = FIXED_PARTITION_ID(SLOT3_PARTITION); + fa_id = PARTITION_ID(SLOT3_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT4_PARTITION) +#if PARTITION_EXISTS(SLOT4_PARTITION) case 4: - fa_id = FIXED_PARTITION_ID(SLOT4_PARTITION); + fa_id = PARTITION_ID(SLOT4_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT5_PARTITION) +#if PARTITION_EXISTS(SLOT5_PARTITION) case 5: - fa_id = FIXED_PARTITION_ID(SLOT5_PARTITION); + fa_id = PARTITION_ID(SLOT5_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT6_PARTITION) +#if PARTITION_EXISTS(SLOT6_PARTITION) case 6: - fa_id = FIXED_PARTITION_ID(SLOT6_PARTITION); + fa_id = PARTITION_ID(SLOT6_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT7_PARTITION) +#if PARTITION_EXISTS(SLOT7_PARTITION) case 7: - fa_id = FIXED_PARTITION_ID(SLOT7_PARTITION); + fa_id = PARTITION_ID(SLOT7_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT8_PARTITION) +#if PARTITION_EXISTS(SLOT8_PARTITION) case 8: - fa_id = FIXED_PARTITION_ID(SLOT8_PARTITION); + fa_id = PARTITION_ID(SLOT8_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT9_PARTITION) +#if PARTITION_EXISTS(SLOT9_PARTITION) case 9: - fa_id = FIXED_PARTITION_ID(SLOT9_PARTITION); + fa_id = PARTITION_ID(SLOT9_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT10_PARTITION) +#if PARTITION_EXISTS(SLOT10_PARTITION) case 10: - fa_id = FIXED_PARTITION_ID(SLOT10_PARTITION); + fa_id = PARTITION_ID(SLOT10_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT11_PARTITION) +#if PARTITION_EXISTS(SLOT11_PARTITION) case 11: - fa_id = FIXED_PARTITION_ID(SLOT11_PARTITION); + fa_id = PARTITION_ID(SLOT11_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT12_PARTITION) +#if PARTITION_EXISTS(SLOT12_PARTITION) case 12: - fa_id = FIXED_PARTITION_ID(SLOT12_PARTITION); + fa_id = PARTITION_ID(SLOT12_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT13_PARTITION) +#if PARTITION_EXISTS(SLOT13_PARTITION) case 13: - fa_id = FIXED_PARTITION_ID(SLOT13_PARTITION); + fa_id = PARTITION_ID(SLOT13_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT14_PARTITION) +#if PARTITION_EXISTS(SLOT14_PARTITION) case 14: - fa_id = FIXED_PARTITION_ID(SLOT14_PARTITION); + fa_id = PARTITION_ID(SLOT14_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT15_PARTITION) +#if PARTITION_EXISTS(SLOT15_PARTITION) case 15: - fa_id = FIXED_PARTITION_ID(SLOT15_PARTITION); + fa_id = PARTITION_ID(SLOT15_PARTITION); break; #endif diff --git a/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c b/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c index 9e9c17252e01..beacf91e3d7a 100644 --- a/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c @@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(mcumgr_zbasic_grp, CONFIG_MCUMGR_GRP_ZBASIC_LOG_LEVEL); #define ERASE_TARGET storage_partition -#define ERASE_TARGET_ID FIXED_PARTITION_ID(ERASE_TARGET) +#define ERASE_TARGET_ID PARTITION_ID(ERASE_TARGET) static int storage_erase(void) { diff --git a/subsys/mgmt/updatehub/updatehub_storage.h b/subsys/mgmt/updatehub/updatehub_storage.h index 081ad86d46b9..a158645a7670 100644 --- a/subsys/mgmt/updatehub/updatehub_storage.h +++ b/subsys/mgmt/updatehub/updatehub_storage.h @@ -13,8 +13,8 @@ extern "C" { #include #include -#define UPDATEHUB_SLOT_PARTITION_0 FIXED_PARTITION_ID(slot0_partition) -#define UPDATEHUB_SLOT_PARTITION_1 FIXED_PARTITION_ID(slot1_partition) +#define UPDATEHUB_SLOT_PARTITION_0 PARTITION_ID(slot0_partition) +#define UPDATEHUB_SLOT_PARTITION_1 PARTITION_ID(slot1_partition) struct updatehub_storage_context { struct flash_img_context flash_ctx; diff --git a/subsys/secure_storage/Kconfig.its_store b/subsys/secure_storage/Kconfig.its_store index c924def563fa..290111943495 100644 --- a/subsys/secure_storage/Kconfig.its_store +++ b/subsys/secure_storage/Kconfig.its_store @@ -8,12 +8,14 @@ DT_ITS_PARTITION := $(dt_chosen_path,secure_storage_its_partition) DT_CHOSEN_Z_SETTINGS_PARTITION := zephyr,settings-partition DT_SETTINGS_PARTITIION := $(dt_chosen_path,$(DT_CHOSEN_Z_SETTINGS_PARTITION)) DT_STORAGE_PARTITION := $(dt_nodelabel_path,storage_partition) +DT_COMPAT_Z_MAPPED_PARTITION := zephyr,mapped-partition config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS bool "ITS store module implementation using ZMS for storage" depends on FLASH_HAS_DRIVER_ENABLED \ - && $(dt_path_enabled,$(DT_ITS_PARTITION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_ITS_PARTITION)),fixed-partitions) + && $(dt_path_enabled,$(DT_ITS_PARTITION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_ITS_PARTITION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_ITS_PARTITION),$(DT_COMPAT_Z_MAPPED_PARTITION))) depends on ZMS help This implementation of the ITS store module makes direct use of ZMS for storage. @@ -27,11 +29,13 @@ config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS bool "ITS store module implementation using the settings subsystem for storage" depends on FLASH_HAS_DRIVER_ENABLED \ - && (($(dt_path_enabled,$(DT_SETTINGS_PARTITIION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions))\ - || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions))) - depends on SETTINGS + && ($(dt_path_enabled,$(DT_SETTINGS_PARTITIION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_SETTINGS_PARTITIION),$(DT_COMPAT_Z_MAPPED_PARTITION))) \ + || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_STORAGE_PARTITION),$(DT_COMPAT_Z_MAPPED_PARTITION))))) + depends on SETTINGS && !SETTINGS_NONE config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_NONE bool "No ITS store module implementation" diff --git a/subsys/secure_storage/src/its/store/zms.c b/subsys/secure_storage/src/its/store/zms.c index 4778e0365e91..2e48444215f5 100644 --- a/subsys/secure_storage/src/its/store/zms.c +++ b/subsys/secure_storage/src/its/store/zms.c @@ -14,8 +14,8 @@ BUILD_ASSERT(CONFIG_SECURE_STORAGE_ITS_STORE_ZMS_SECTOR_SIZE #define PARTITION_DT_NODE DT_CHOSEN(secure_storage_its_partition) static struct zms_fs s_zms = { - .flash_device = FIXED_PARTITION_NODE_DEVICE(PARTITION_DT_NODE), - .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_DT_NODE), + .flash_device = PARTITION_NODE_DEVICE(PARTITION_DT_NODE), + .offset = PARTITION_NODE_OFFSET(PARTITION_DT_NODE), .sector_size = CONFIG_SECURE_STORAGE_ITS_STORE_ZMS_SECTOR_SIZE, }; @@ -23,7 +23,7 @@ static int init_zms(void) { int ret; - s_zms.sector_count = FIXED_PARTITION_NODE_SIZE(PARTITION_DT_NODE) / s_zms.sector_size; + s_zms.sector_count = PARTITION_NODE_SIZE(PARTITION_DT_NODE) / s_zms.sector_size; ret = zms_mount(&s_zms); if (ret) { diff --git a/subsys/settings/src/settings_fcb.c b/subsys/settings/src/settings_fcb.c index f58e4e3700b3..3c8e6ef31a20 100644 --- a/subsys/settings/src/settings_fcb.c +++ b/subsys/settings/src/settings_fcb.c @@ -18,9 +18,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif #define SETTINGS_FCB_VERS 1 diff --git a/subsys/settings/src/settings_nvs.c b/subsys/settings/src/settings_nvs.c index 6764c7587a3b..a6539984d2f8 100644 --- a/subsys/settings/src/settings_nvs.c +++ b/subsys/settings/src/settings_nvs.c @@ -18,9 +18,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif struct settings_nvs_read_fn_arg { diff --git a/subsys/settings/src/settings_zms.c b/subsys/settings/src/settings_zms.c index 485c2a68b086..b2ea12c42520 100644 --- a/subsys/settings/src/settings_zms.c +++ b/subsys/settings/src/settings_zms.c @@ -19,9 +19,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif struct settings_zms_read_fn_arg { diff --git a/subsys/storage/flash_map/flash_map_default.c b/subsys/storage/flash_map/flash_map_default.c index c5ba79af2340..3dbdc0367bce 100644 --- a/subsys/storage/flash_map/flash_map_default.c +++ b/subsys/storage/flash_map/flash_map_default.c @@ -9,29 +9,49 @@ #include #include #include +#include +#include #if CONFIG_FLASH_MAP_LABELS -#define FLASH_AREA_FOO(part, mtd_from_partition) \ - {.fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define FLASH_AREA_FOO(part, mtd_from_partition) \ + {.fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ + .fa_size = DT_REG_SIZE(part), \ + .fa_label = DT_PROP_OR(part, label, NULL), }, + +#define MAPPED_AREA(part) \ + {.fa_id = DT_MAPPED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ .fa_label = DT_PROP_OR(part, label, NULL), }, #else -#define FLASH_AREA_FOO(part, mtd_from_partition) \ - {.fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ +#define FLASH_AREA_FOO(part, mtd_from_partition) \ + {.fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ + .fa_size = DT_REG_SIZE(part), }, + +#define MAPPED_AREA(part) \ + {.fa_id = DT_MAPPED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ .fa_size = DT_REG_SIZE(part), }, #endif #define FLASH_AREA_FOOO(part) \ - COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(part), fixed_partitions), (\ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ - (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_PARTITION)), ())), ( \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(part), fixed_partitions), ( \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ + (FLASH_AREA_FOO(part, DT_MTD_FROM_PARTITION)), ())), ( \ COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_SUBPARTITION)), ()))) +#define MAPPED_AREA_FOREACH(part) \ + COND_CODE_1(UTIL_AND(DT_NODE_HAS_STATUS_OKAY(part), \ + DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_MAPPED_PARTITION(part))), \ + (MAPPED_AREA(part)), ()) + #define FOREACH_PARTITION(n) DT_FOREACH_CHILD(n, FLASH_AREA_FOOO) /* We iterate over all compatible 'fixed-partitions' nodes and @@ -39,6 +59,7 @@ * 'fixed-partitions' node. This way we build a global partition map */ const struct flash_area default_flash_map[] = { + DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, MAPPED_AREA_FOREACH) DT_FOREACH_STATUS_OKAY(fixed_partitions, FOREACH_PARTITION) DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOREACH_PARTITION) }; @@ -50,30 +71,48 @@ const struct flash_area *flash_map = default_flash_map; * objects referenced by code will be included into build. */ #define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) -#define DEFINE_PARTITION_1(part, ord) \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ +#define DEFINE_PARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ + (DEFINE_PARTITION_0(part, ord)), ()) +#define DEFINE_PARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord) = { \ + .fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ + }; + +DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DEFINE_PARTITION) + +#undef DEFINE_PARTITION +#undef DEFINE_PARTITION_1 +#undef DEFINE_PARTITION_0 + +#define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) +#define DEFINE_PARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ (DEFINE_PARTITION_0(part, ord)), ()) -#define DEFINE_PARTITION_0(part, ord) \ - const struct flash_area DT_CAT(global_fixed_partition_ORD_, ord) = { \ - .fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define DEFINE_PARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_fixed_partition_ORD_, ord) = { \ + .fa_id = DT_FIXED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ }; #define FOR_EACH_PARTITION_TABLE(table) DT_FOREACH_CHILD(table, DEFINE_PARTITION) DT_FOREACH_STATUS_OKAY(fixed_partitions, FOR_EACH_PARTITION_TABLE) #define DEFINE_SUBPARTITION(part) DEFINE_SUBPARTITION_1(part, DT_DEP_ORD(part)) -#define DEFINE_SUBPARTITION_1(part, ord) \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ +#define DEFINE_SUBPARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ (DEFINE_SUBPARTITION_0(part, ord)), ()) -#define DEFINE_SUBPARTITION_0(part, ord) \ - const struct flash_area DT_CAT(global_fixed_subpartition_ORD_, ord) = { \ - .fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define DEFINE_SUBPARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_fixed_subpartition_ORD_, ord) = { \ + .fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ }; #define FOR_EACH_SUBPARTITION_TABLE(table) DT_FOREACH_CHILD(table, DEFINE_SUBPARTITION) diff --git a/subsys/usb/device/class/dfu/usb_dfu.c b/subsys/usb/device/class/dfu/usb_dfu.c index 3961e78531dc..e7c40abd4bd0 100644 --- a/subsys/usb/device/class/dfu/usb_dfu.c +++ b/subsys/usb/device/class/dfu/usb_dfu.c @@ -141,7 +141,7 @@ struct dev_dfu_mode_descriptor { struct usb_cfg_descriptor cfg_descr; struct usb_sec_dfu_config { struct usb_if_descriptor if0; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) struct usb_if_descriptor if1; #endif struct dfu_runtime_descriptor dfu_descr; @@ -197,7 +197,7 @@ struct dev_dfu_mode_descriptor dfu_mode_desc = { .bInterfaceProtocol = DFU_MODE_PROTOCOL, .iInterface = 4, }, -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) .if1 = { .bLength = sizeof(struct usb_if_descriptor), .bDescriptorType = USB_DESC_INTERFACE, @@ -251,7 +251,7 @@ struct usb_string_desription { uint8_t bString[USB_BSTRING_LENGTH(FIRMWARE_IMAGE_0_LABEL)]; } __packed utf16le_image0; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) struct image_1_descriptor { uint8_t bLength; uint8_t bDescriptorType; @@ -294,7 +294,7 @@ struct usb_string_desription string_descr = { .bDescriptorType = USB_DESC_STRING, .bString = FIRMWARE_IMAGE_0_LABEL, }, -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) /* Image 1 String Descriptor */ .utf16le_image1 = { .bLength = USB_STRING_DESCRIPTOR_LENGTH( @@ -327,10 +327,10 @@ struct dfu_data_t { uint16_t bwPollTimeout; }; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) - #define DOWNLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) + #define DOWNLOAD_FLASH_AREA_ID PARTITION_ID(SLOT1_PARTITION) #else - #define DOWNLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(SLOT0_PARTITION) + #define DOWNLOAD_FLASH_AREA_ID PARTITION_ID(SLOT0_PARTITION) #endif @@ -813,9 +813,9 @@ static int dfu_custom_handle_req(struct usb_setup_packet *setup, switch (setup->wValue) { case 0: dfu_data.flash_area_id = - FIXED_PARTITION_ID(SLOT0_PARTITION); + PARTITION_ID(SLOT0_PARTITION); break; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) case 1: dfu_data.flash_area_id = DOWNLOAD_FLASH_AREA_ID; break; diff --git a/subsys/usb/device_next/class/usbd_dfu_flash.c b/subsys/usb/device_next/class/usbd_dfu_flash.c index fea438bf3b26..c9130e820d15 100644 --- a/subsys/usb/device_next/class/usbd_dfu_flash.c +++ b/subsys/usb/device_next/class/usbd_dfu_flash.c @@ -136,18 +136,18 @@ static bool dfu_flash_next(void *const priv, return true; } -#if FIXED_PARTITION_EXISTS(slot0_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT0) +#if PARTITION_EXISTS(slot0_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT0) static struct usbd_dfu_flash_data slot0_data = { - .id = FIXED_PARTITION_ID(slot0_partition), + .id = PARTITION_ID(slot0_partition), }; USBD_DFU_DEFINE_IMG(slot0_image, "slot0_image", &slot0_data, dfu_flash_read, dfu_flash_write, dfu_flash_next); #endif -#if FIXED_PARTITION_EXISTS(slot1_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT1) +#if PARTITION_EXISTS(slot1_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT1) static struct usbd_dfu_flash_data slot1_data = { - .id = FIXED_PARTITION_ID(slot1_partition), + .id = PARTITION_ID(slot1_partition), }; USBD_DFU_DEFINE_IMG(slot1_image, "slot1_image", &slot1_data, diff --git a/tests/bluetooth/mesh/blob_io_flash/src/main.c b/tests/bluetooth/mesh/blob_io_flash/src/main.c index aa04ae2dd9dd..36b1afbe977b 100644 --- a/tests/bluetooth/mesh/blob_io_flash/src/main.c +++ b/tests/bluetooth/mesh/blob_io_flash/src/main.c @@ -11,8 +11,8 @@ #include "mesh/blob.h" #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_SIZE FIXED_PARTITION_SIZE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_SIZE PARTITION_SIZE(SLOT1_PARTITION) /* Chunk size is set to value that is not multiple of 4, to verify that chunks are written correctly * even if they are not aligned with word length used in flash */ diff --git a/tests/boards/nrf/rram_throttling/src/main.c b/tests/boards/nrf/rram_throttling/src/main.c index 9984f26787d0..a7cf0f028fd6 100644 --- a/tests/boards/nrf/rram_throttling/src/main.c +++ b/tests/boards/nrf/rram_throttling/src/main.c @@ -16,9 +16,9 @@ * fixed-partition nodes. */ #if defined(TEST_AREA) -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #else #error "Unsupported configuration" #endif diff --git a/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay b/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay index 307d2b890fb0..69d15c05e194 100644 --- a/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay @@ -42,21 +42,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00022000>; }; slot1_partition: partition@42000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00042000 0x00023000>; }; diff --git a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay index 89843ccf6875..ab88f44fb404 100644 --- a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay @@ -16,21 +16,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00020000>; }; slot1_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00040000 0x00020000>; }; diff --git a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay index a61ee5db8746..812cba932723 100644 --- a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay +++ b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay @@ -45,21 +45,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00020000>; }; slot1_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00040000 0x00020000>; }; diff --git a/tests/drivers/flash/common/src/main.c b/tests/drivers/flash/common/src/main.c index 9c176f47d2a8..5e7b1c22e59a 100644 --- a/tests/drivers/flash/common/src/main.c +++ b/tests/drivers/flash/common/src/main.c @@ -38,10 +38,10 @@ */ #ifdef TEST_AREA -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) #define TEST_AREA_MAX (TEST_AREA_OFFSET + TEST_AREA_SIZE) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #elif defined(TEST_AREA_DEV_NODE) diff --git a/tests/drivers/flash/erase_blocks/src/main.c b/tests/drivers/flash/erase_blocks/src/main.c index d44eed15e4de..2f40e769117c 100644 --- a/tests/drivers/flash/erase_blocks/src/main.c +++ b/tests/drivers/flash/erase_blocks/src/main.c @@ -27,7 +27,7 @@ LOG_MODULE_REGISTER(test_flash); #endif #define TEST_FLASH_PART_OFFSET \ - FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) + PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE \ DT_REG_SIZE(TEST_FLASH_PART_NODE) @@ -36,7 +36,7 @@ LOG_MODULE_REGISTER(test_flash); (TEST_FLASH_PART_OFFSET + TEST_FLASH_PART_SIZE) #define TEST_FLASH_CONTROLLER_NODE \ - DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) + DT_MTD_FROM_PARTITION(TEST_FLASH_PART_NODE) static const struct device *flash_controller = DEVICE_DT_GET(TEST_FLASH_CONTROLLER_NODE); static uint8_t test_write_block[512]; diff --git a/tests/drivers/flash/interface_test/src/main.c b/tests/drivers/flash/interface_test/src/main.c index 8b2627b4f787..4b37e86ca8b5 100644 --- a/tests/drivers/flash/interface_test/src/main.c +++ b/tests/drivers/flash/interface_test/src/main.c @@ -15,10 +15,10 @@ #define TEST_FLASH_PART_NODE DT_NODELABEL(slot1_partition) #endif -#define TEST_FLASH_PART_OFFSET FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) +#define TEST_FLASH_PART_OFFSET PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE DT_REG_SIZE(TEST_FLASH_PART_NODE) -#define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) +#define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_PARTITION(TEST_FLASH_PART_NODE) #define PATTERN_SIZE 256 diff --git a/tests/drivers/flash/negative_tests/src/main.c b/tests/drivers/flash/negative_tests/src/main.c index fa3723b52312..076f4d1e0b86 100644 --- a/tests/drivers/flash/negative_tests/src/main.c +++ b/tests/drivers/flash/negative_tests/src/main.c @@ -22,13 +22,13 @@ * fixed-partition nodes. */ #if defined(TEST_AREA) -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #if defined(CONFIG_SOC_SERIES_NRF54L) || defined(CONFIG_SOC_FAMILY_MICROCHIP_SAM_D5X_E5X) -#define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA)))) -#define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA)))) +#define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) +#define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) #elif defined(CONFIG_SOC_NRF54H20) #define TEST_FLASH_START (DT_REG_ADDR(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) #define TEST_FLASH_SIZE (DT_REG_SIZE(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) diff --git a/tests/drivers/flash/stm32/src/main.c b/tests/drivers/flash/stm32/src/main.c index 4fd8de9b44dd..d23bbe3e561a 100644 --- a/tests/drivers/flash/stm32/src/main.c +++ b/tests/drivers/flash/stm32/src/main.c @@ -13,11 +13,11 @@ #include #define TEST_AREA storage_partition -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) #define TEST_AREA_MAX (TEST_AREA_OFFSET + TEST_AREA_SIZE) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) -#define TEST_AREA_DEVICE_REG DT_REG_ADDR(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA))) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_DEVICE_REG DT_REG_ADDR(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_AREA))) #define EXPECTED_SIZE 512 diff --git a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c index 95dd3d92d92a..43ab17c7599b 100644 --- a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c +++ b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c @@ -19,7 +19,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) #define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) #define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) #define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) @@ -453,6 +453,36 @@ ZTEST(flash_sim_api, test_get_erase_value) FLASH_SIMULATOR_ERASE_VALUE); } +ZTEST(flash_sim_api, test_erase_capability) +{ + /* Verify that the runtime device capability matches the build configuration. + * This is the test that was missing and resulted in issue #100352 not being caught: + * the driver was incorrectly setting no_explicit_erase for all instances based + * on a global Kconfig rather than per-instance properties. + */ + const struct flash_parameters *fp = flash_get_parameters(flash_dev); + int erase_cap; + + zassert_not_null(fp, "flash_get_parameters() returned NULL"); + + erase_cap = flash_params_get_erase_cap(fp); + +#if defined(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE) + /* Erase-type (classic Flash) device: must report explicit erase required */ + zassert_false(fp->caps.no_explicit_erase, + "Device is configured as explicit-erase but caps.no_explicit_erase=true"); + zassert_equal(FLASH_ERASE_C_EXPLICIT, erase_cap, + "Expected FLASH_ERASE_C_EXPLICIT (0x%x), got 0x%x", + FLASH_ERASE_C_EXPLICIT, erase_cap); +#else + /* RAM-like device: must report no explicit erase required */ + zassert_true(fp->caps.no_explicit_erase, + "Device is configured as RAM-like but caps.no_explicit_erase=false"); + zassert_equal(0, erase_cap, + "Expected erase capability 0 for RAM-like device, got 0x%x", erase_cap); +#endif +} + ZTEST(flash_sim_api, test_flash_fill) { off_t i; diff --git a/tests/lib/devicetree/api/app.overlay b/tests/lib/devicetree/api/app.overlay index ecbe17df3e78..49ec63b96891 100644 --- a/tests/lib/devicetree/api/app.overlay +++ b/tests/lib/devicetree/api/app.overlay @@ -883,70 +883,53 @@ test-mtd@ffeeddcc { reg = <0xffeeddcc 0x1000>; + ranges = <0x0 0x0 0x100000>; #address-cells = <1>; #size-cells = <1>; - /* - * The below specifies an invalid setup whereby partitions wrongly do not - * inherit the parent node's address space and specify that the partitions - * start at absolute address 0x0 onwards, this has been fixed post Zephyr - * 4.3 and is only here to ensure macros do not break for out of tree - * users so that they have time to fix their DTS files, it will be removed - * in Zephyr 4.6 or newer. - */ - flash@20000000 { + flash@0 { compatible = "soc-nv-flash"; - reg = <0x20000000 0x100>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - reg = <0x0 0xc0>; - label = "test-partition-0-deprecated"; - }; + reg = <0x0 0x100000>; + ranges; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; - partition@c0 { - reg = <0xc0 0x40>; - label = "test-partition-1-deprecated"; - }; + /* Purposely not using a partitions {} grouping node */ + partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-1"; + reg = <0x00000000 0x0000c000>; + }; - partition@100 { - compatible = "fixed-subpartitions"; - label = "test-subpartitions-deprecated"; - reg = <0x00000100 0x100>; - ranges = <0x0 0x100 0x100>; - #address-cells = <1>; - #size-cells = <1>; + partition@c000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-2"; + reg = <0x0000c000 0x00076000>; + }; - partition@0 { - label = "test-subpartition-0-deprecated"; - reg = <0x00000000 0x40>; - }; + partition@82000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-3"; + reg = <0x00082000 0x00007000>; + }; - partition@40 { - label = "test-subpartition-1-deprecated"; - reg = <0x00000040 0xc0>; - }; - }; + partition@89000 { + compatible = "zephyr,mapped-partition"; + label = "disabled-mapped-partition"; + status = "disabled"; + reg = <0x00089000 0x00007000>; }; }; - /* The below device correctly inherits the parent's address space */ - flash@20001000 { + flash@20000000 { compatible = "soc-nv-flash"; - reg = <0x20001000 0x200>; - ranges = <0x0 0x20001000 0x200>; - #address-cells = <1>; - #size-cells = <1>; + reg = <0x20000000 0x100>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; partition@0 { reg = <0x0 0xc0>; @@ -980,33 +963,8 @@ }; }; - /* - * The below specifies an invalid setup whereby partitions wrongly do not - * inherit the parent node's address space and specify that the partitions - * start at absolute address 0x0 onwards, this has been fixed post Zephyr - * 4.3 and is only here to ensure macros do not break for out of tree - * users so that they have time to fix their DTS files, it will be removed - * in Zephyr 4.6 or newer. - */ test-mtd@33221100 { - reg = <0x33221100 0x70000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@6ff80 { - reg = <0x6ff80 0x80>; - label = "test-partition-2-deprecated"; - }; - }; - }; - - /* The below device correctly inherits the parent's address space */ - test-mtd@33291100 { - reg = <0x33291100 0x70000>; - ranges = <0x0 0x33291100 0x70000>; + reg = <0x33221100 0x1000>; #address-cells = <1>; #size-cells = <1>; @@ -1014,7 +972,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; partition@6ff80 { reg = <0x6ff80 0x80>; @@ -1065,4 +1022,112 @@ compatible = "vnd,non-deprecated-label"; label = "FOO"; }; + + gpio-map-test { + connector { + compatible = "vnd,gpio-nexus"; + #gpio-cells = <2>; + gpio-map = <1 2 &{/gpio-map-test/parent} 3 + 4 5 &{/gpio-map-test/parent} 6>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0x0 0x3f>; + }; + + parent { + compatible = "gpio-dst"; + gpio-controller; + #gpio-cells = <1>; + }; + }; + + /* Node purposely not put in test area due to lines being too long for compliance CI */ + test-mtd@12830 { + reg = <0x13830 0x1000>; + ranges = <0x10000000 0x10000000 0x100000>; + #address-cells = <1>; + #size-cells = <1>; + + flash@10000000 { + compatible = "soc-nv-flash"; + reg = <0x10000000 0x100000>; + ranges = <0x0 0x10000000 0x100000>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + + partitions { + ranges; + #address-cells = <1>; + #size-cells = <1>; + + partition@f8000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-4"; + reg = <0x000f8000 0x00008000>; + ranges = <0x0 0x000f8000 0x00008000>; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-5"; + reg = <0x00000000 0x00003000>; + ranges = <0x0 0x00000000 0x00003000>; + #address-cells = <1>; + #size-cells = <1>; + + partition@1000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-6"; + reg = <0x00001000 0x00001000>; + }; + }; + + partition@3000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-7"; + reg = <0x00003000 0x00002000>; + }; + }; + }; + }; + }; + + interrupt-map-test { + #address-cells = <2>; + #size-cells = <0>; + + controller-0@0 { + compatible = "vnd,cpu-intc"; + reg = <0x0 0x0>; + #address-cells = <1>; + #interrupt-cells = <1>; + interrupt-controller; + }; + + controller-1@1 { + compatible = "vnd,intc"; + reg = <0x0 0x1>; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-controller; + }; + + nexus { + compatible = "vnd,intr-nexus"; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-map = <0 0 1 2 &{/interrupt-map-test/controller-0@0} 3 4 + 0 0 5 6 &{/interrupt-map-test/controller-1@1} 7 8 9 0 + 0 1 9 8 &{/interrupt-map-test/controller-0@0} 7 6 + 0 1 5 4 &{/interrupt-map-test/controller-1@1} 3 2 1 0>; + }; + + empty { + compatible = "vnd,intr-nexus"; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-map = <>; + }; + }; }; diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index eb06c570e116..3ead4a70351c 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -97,39 +98,42 @@ #define TEST_RANGES_EMPTY DT_NODELABEL(test_ranges_empty) #define TEST_MTD_0 DT_PATH(test, test_mtd_ffeeddcc) +#define TEST_MTD_1 DT_PATH(test, test_mtd_33221100) +#define TEST_MTD_2 DT_PATH(test_mtd_12830) -#define TEST_MTD_1_DEPRECATED DT_PATH(test, test_mtd_33221100) +#define TEST_MEM_0 DT_CHILD(TEST_MTD_0, flash_20000000) -#define TEST_MEM_0_DEPRECATED DT_CHILD(TEST_MTD_0, flash_20000000) +#define TEST_PARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, partition_0) +#define TEST_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, partition_c0) +#define TEST_PARTITION_2 DT_PATH(test, test_mtd_33221100, partitions, partition_6ff80) -#define TEST_PARTITION_0_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ - partition_0) -#define TEST_PARTITION_1_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ - partition_c0) -#define TEST_PARTITION_2_DEPRECATED DT_PATH(test, test_mtd_33221100, partitions, partition_6ff80) - -#define TEST_SUBPARTITION_COMBINED_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100) -#define TEST_SUBPARTITION_0_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100, partition_0) -#define TEST_SUBPARTITION_1_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100, partition_40) - -#define TEST_MTD_1 DT_PATH(test, test_mtd_33291100) - -#define TEST_MEM_0 DT_CHILD(TEST_MTD_0, flash_20001000) - -#define TEST_PARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, partition_0) -#define TEST_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, partition_c0) -#define TEST_PARTITION_2 DT_PATH(test, test_mtd_33291100, partitions, partition_6ff80) - -#define TEST_SUBPARTITION_COMBINED DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_COMBINED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100) -#define TEST_SUBPARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100, partition_0) -#define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100, partition_40) +#define TEST_FLASH_0 DT_PATH(test, test_mtd_ffeeddcc, flash_0) +#define TEST_FLASH_1 DT_PATH(test_mtd_12830, flash_10000000) + +#define TEST_MAPPED_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_0) +#define TEST_MAPPED_PARTITION_2 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_c000) +#define TEST_MAPPED_PARTITION_3 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_82000) +#define TEST_MAPPED_PARTITION_4 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000) +#define TEST_MAPPED_PARTITION_5 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_0) +#define TEST_MAPPED_PARTITION_6 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_0, partition_1000) +#define TEST_MAPPED_PARTITION_7 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_3000) +#define TEST_DISABLED_MAPPED_PARTITION DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_89000) + +#define TEST_GPIO_CONNECTOR DT_PATH(gpio_map_test, connector) +#define TEST_INTERRUPT_NEXUS DT_PATH(interrupt_map_test, nexus) +#define TEST_INTERRUPT_NEXUS_EMPTY DT_PATH(interrupt_map_test, empty) + #define ZEPHYR_USER DT_PATH(zephyr_user) #define TA_HAS_COMPAT(compat) DT_NODE_HAS_COMPAT(TEST_ARRAYS, compat) @@ -3296,199 +3300,322 @@ ZTEST(devicetree_api, test_mbox) DT_NODELABEL(test_mbox_zero_cell)), ""); } -/* - * Tests that invalid but accidentally working behaviour does not break out of tree users, to be - * removed in Zephyr 4.6 or newer - */ -ZTEST(devicetree_api, test_fixed_partitions_deprecated) -{ - /* Test finding fixed partitions by the 'label' property. */ - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_0_deprecated)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_1_deprecated)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_2_deprecated)); - zassert_true(DT_SAME_NODE(TEST_PARTITION_0_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_0_deprecated))); - zassert_true(DT_SAME_NODE(TEST_PARTITION_1_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_1_deprecated))); - zassert_true(DT_SAME_NODE(TEST_PARTITION_2_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_2_deprecated))); - - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_0_DEPRECATED)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_1_DEPRECATED)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_2_DEPRECATED)); - - /* There should not be a node with `label = "test_partition_3_deprecated"`. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(test_partition_3_deprecated)); - zassert_false(DT_NODE_EXISTS( - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_3_deprecated))); - - /* Test DT_MTD_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2_DEPRECATED))); - - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_1_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MTD_1_DEPRECATED, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_2_DEPRECATED))); - - /* Test DT_MEM_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1_DEPRECATED))); - zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_2_DEPRECATED))); - - zassert_true(DT_SAME_NODE(TEST_MEM_0_DEPRECATED, DT_MEM_FROM_FIXED_PARTITION( - TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MEM_0_DEPRECATED, DT_MEM_FROM_FIXED_PARTITION( - TEST_PARTITION_1_DEPRECATED))); - - /* Test DT_FIXED_PARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0_DEPRECATED), 0x20000000); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1_DEPRECATED), 0x200000c0); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2_DEPRECATED), 0x33291080); -} - -ZTEST(devicetree_api, test_fixed_subpartitions_deprecated) -{ - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED_DEPRECATED)); - zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_0_DEPRECATED)); - zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_1_DEPRECATED)); - - /* Test DT_MEM_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION( - TEST_SUBPARTITION_COMBINED_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_1_DEPRECATED))); - - /* Test DT_MTD_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION( - TEST_SUBPARTITION_COMBINED_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_1_DEPRECATED))); - zassert_true(DT_SAME_NODE( - DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED_DEPRECATED), - DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1_DEPRECATED))); - - /* Test DT_FIXED_SUBPARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED_DEPRECATED), 0x20000100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0_DEPRECATED), - DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED_DEPRECATED)); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0_DEPRECATED), 0x20000100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1_DEPRECATED), 0x20000140); - - /* Check sizes match */ - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED_DEPRECATED), - (DT_REG_SIZE(TEST_SUBPARTITION_0_DEPRECATED) + - DT_REG_SIZE(TEST_SUBPARTITION_1_DEPRECATED))); - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED_DEPRECATED), - (DT_REG_SIZE(TEST_SUBPARTITION_0_DEPRECATED) + - DT_REG_SIZE(TEST_SUBPARTITION_1_DEPRECATED))); -} - ZTEST(devicetree_api, test_fixed_partitions) { /* Test finding fixed partitions by the 'label' property. */ - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_0)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_1)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_2)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_0)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_2)); + zassert_true(DT_SAME_NODE(TEST_PARTITION_0, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_0))); + DT_NODE_BY_PARTITION_LABEL(test_partition_0))); zassert_true(DT_SAME_NODE(TEST_PARTITION_1, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_1))); + DT_NODE_BY_PARTITION_LABEL(test_partition_1))); zassert_true(DT_SAME_NODE(TEST_PARTITION_2, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_2))); + DT_NODE_BY_PARTITION_LABEL(test_partition_2))); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_0)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_1)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_2)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_0)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_1)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_2)); /* There should not be a node with `label = "test_partition_3"`. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(test_partition_3)); - zassert_false(DT_NODE_EXISTS(DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_3))); + zassert_false(DT_HAS_PARTITION_LABEL(test_partition_3)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(test_partition_3))); /* There is a node with `label = "FOO"`, but it is not a fixed partition. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(FOO)); - zassert_false(DT_NODE_EXISTS(DT_NODE_BY_FIXED_PARTITION_LABEL(FOO))); - - /* Test DT_MTD_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_true(DT_SAME_NODE(TEST_MTD_1, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - /* Test DT_MEM_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - - /* Test DT_FIXED_PARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0), 0x20001000); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1), 0x200010c0); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2), 0x33301080); - - /* Test that all DT_FIXED_PARTITION_ID are defined and unique. */ -#define FIXED_PARTITION_ID_COMMA(node_id) DT_FIXED_PARTITION_ID(node_id), - - static const int ids[] = { - DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) - DT_FOREACH_STATUS_OKAY_VARGS(fixed_subpartitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) - }; - bool found[ARRAY_SIZE(ids)] = { false }; - - for (int i = 0; i < ARRAY_SIZE(ids); i++) { - zassert_between_inclusive(ids[i], 0, ARRAY_SIZE(ids) - 1, ""); - zassert_false(found[ids[i]]); - found[ids[i]] = true; - } - -#undef FIXED_PARTITION_ID_COMMA + zassert_false(DT_HAS_PARTITION_LABEL(FOO)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(FOO))); + + /* Test DT_MTD_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_2))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION(TEST_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_1, DT_MTD_FROM_PARTITION(TEST_PARTITION_2))); + + /* Test DT_MEM_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_1))); + zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_2))); + + zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_PARTITION(TEST_PARTITION_1))); + + /* Test DT_PARTITION_ADDR. */ + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_0), 0x20000000); + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_1), 0x200000c0); + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_2), 0x33291080); } ZTEST(devicetree_api, test_fixed_subpartitions) { - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED)); + zassert_true(DT_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED)); zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_0)); zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_1)); /* Test DT_MEM_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_SUBPARTITION_COMBINED))); zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_0))); zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); /* Test DT_MTD_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_SUBPARTITION_COMBINED))); zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_0))); zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); zassert_true(DT_SAME_NODE( - DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED), + DT_MTD_FROM_PARTITION(TEST_SUBPARTITION_COMBINED), DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); /* Test DT_FIXED_SUBPARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20001100); + zassert_equal(DT_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20000100); zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), - DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED)); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), 0x20001100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1), 0x20001140); + DT_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED)); + zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), 0x20000100); + zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1), 0x20000140); /* Check sizes match */ zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED), (DT_REG_SIZE(TEST_SUBPARTITION_0) + DT_REG_SIZE(TEST_SUBPARTITION_1))); - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED), - (DT_REG_SIZE(TEST_SUBPARTITION_0) + DT_REG_SIZE(TEST_SUBPARTITION_1))); +} + +ZTEST(devicetree_api, test_mapped_partition) +{ + /* Test finding fixed partitions by the 'label' property. */ + zassert_false(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_0)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_2)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_3)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_4)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_5)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_6)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_7)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(disabled_mapped_partition)); + + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_1, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_1))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_2, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_2))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_3, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_3))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_4, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_4))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_5, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_5))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_6, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_6))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_7, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_7))); + zassert_true(DT_SAME_NODE(TEST_DISABLED_MAPPED_PARTITION, + DT_NODE_BY_MAPPED_PARTITION_LABEL(disabled_mapped_partition))); + + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_1)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_2)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_3)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_4)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_5)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_6)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_7)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_DISABLED_MAPPED_PARTITION)); + + /* There should not be a node with `label = "mapped-partition-8"`. */ + zassert_false(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_8)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_8))); + + /* Test DT_MTD_FROM_MAPPED_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MEM_FROM_MAPPED_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MAPPED_PARTITION_ADDR. */ + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_1), 0x0); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_2), 0xc000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_3), 0x82000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_4), 0x100f8000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_5), 0x100f8000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_6), 0x100f9000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_7), 0x100fb000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_DISABLED_MAPPED_PARTITION), 0x89000); +} + +ZTEST(devicetree_api, test_partition) +{ + zassert_false(DT_HAS_PARTITION_LABEL(mapped_partition_0)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_2)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_3)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_4)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_5)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_6)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_7)); + zassert_true(DT_HAS_PARTITION_LABEL(disabled_mapped_partition)); + + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_1, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_1))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_2, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_2))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_3, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_3))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_4, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_4))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_5, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_5))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_6, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_6))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_7, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_7))); + zassert_true(DT_SAME_NODE(TEST_DISABLED_MAPPED_PARTITION, + DT_NODE_BY_PARTITION_LABEL(disabled_mapped_partition))); + + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_1)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_2)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_3)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_4)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_5)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_6)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_7)); + zassert_true(DT_PARTITION_EXISTS(TEST_DISABLED_MAPPED_PARTITION)); + + /* There should not be a node with `label = "mapped-partition-8"`. */ + zassert_false(DT_HAS_PARTITION_LABEL(mapped_partition_8)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(mapped_partition_8))); + + /* Test DT_MTD_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MEM_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_PARTITION_ADDR. */ + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_1), 0x0); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_2), 0xc000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_3), 0x82000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_4), 0x100f8000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_5), 0x100f8000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_6), 0x100f9000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_7), 0x100fb000); + zassert_equal(DT_PARTITION_ADDR(TEST_DISABLED_MAPPED_PARTITION), 0x89000); + + /* Test that all DT_PARTITION_ID are defined and unique. */ +#define PARTITION_ID_COMMA(node_id) DT_PARTITION_ID(node_id), + + static const int ids[] = { + DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, + PARTITION_ID_COMMA) + DT_FOREACH_STATUS_OKAY_VARGS(fixed_subpartitions, DT_FOREACH_CHILD, + PARTITION_ID_COMMA) + DT_FOREACH_STATUS_OKAY_VARGS(zephyr_mapped_partitions, DT_FOREACH_CHILD, + PARTITION_ID_COMMA) + }; + bool found[20] = { false }; + + for (int i = 0; i < ARRAY_SIZE(ids); i++) { + zassert_between_inclusive(ids[i], 0, ARRAY_SIZE(found) - 1, ""); + zassert_false(found[ids[i]]); + found[ids[i]] = true; + } + +#undef PARTITION_ID_COMMA } ZTEST(devicetree_api, test_string_token) @@ -4117,4 +4244,140 @@ ZTEST(devicetree_api, test_nvmem_devictree_inst) "/test/test-nvmem-provider"); } +#define INTERRUPT_NEXUS_CHECK_0(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 3); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 4); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT(n, p)), \ + "DT_N_S_interrupt_map_test_S_controller_0_0"); + +#define INTERRUPT_NEXUS_CHECK_1(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS(n, p, i), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER(n, p, i), 5); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 6); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS(n, p, i), 7); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 1), 8); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER(n, p, i), 9); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 1), 0); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_1_1"); + +#define INTERRUPT_NEXUS_CHECK_2(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 9); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 8); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 7); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 6); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_0_0"); + +#define INTERRUPT_NEXUS_CHECK_3(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 5); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 4); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 3); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 1), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 1), 0); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_1_1"); + +#define INTERRUPT_NEXUS_CHECK(n, p, i) UTIL_CAT(INTERRUPT_NEXUS_CHECK_, i)(n, p, i) +#define INTERRUPT_NEXUS_CHECK_VARGS(n, p, i, ...) UTIL_CAT(INTERRUPT_NEXUS_CHECK_, i)(n, p, i) + +#define EMPTY_MAP_SHOULD_NOT_RUN(...) zassert_unreachable("map should be empty") + +ZTEST(devicetree_api, test_map) +{ + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map_mask), 2); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_mask, 0), 0xffffffff); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_mask, 1), 0xffffffc0); + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map_pass_thru), 2); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_pass_thru, 0), 0x0); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_pass_thru, 1), 0x3f); + + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map), 2); + + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 0); + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 2); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 2), + 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), 1); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), 2); + + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0)), + "DT_N_S_gpio_map_test_S_parent"); + + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 1), 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), + 0); + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), 3); + + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 1), 2); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 2), + 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), 4); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), 5); + + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1)), + "DT_N_S_gpio_map_test_S_parent"); + + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), + 0); + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), 6); + + zassert_true(DT_NODE_HAS_MAP(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), ""); + zassert_equal(DT_MAP_LEN(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), 0); + zassert_equal(DT_MAP_HAS_ENTRY(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), 0); + + DT_FOREACH_MAP_ENTRY(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, EMPTY_MAP_SHOULD_NOT_RUN); + DT_FOREACH_MAP_ENTRY_SEP(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, ()); + DT_FOREACH_MAP_ENTRY_VARGS(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, 1234); + DT_FOREACH_MAP_ENTRY_SEP_VARGS(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, (), 1234); + + zassert_equal(DT_MAP_HAS_ENTRY_BY_IDX(TEST_INTERRUPT_NEXUS, interrupt_map, 3), 1); + zassert_equal(DT_MAP_HAS_ENTRY_BY_IDX(TEST_INTERRUPT_NEXUS, interrupt_map, 4), 0); + DT_FOREACH_MAP_ENTRY(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK) + DT_FOREACH_MAP_ENTRY_SEP(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK, ()) + DT_FOREACH_MAP_ENTRY_VARGS(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK_VARGS, + 9999); + DT_FOREACH_MAP_ENTRY_SEP_VARGS(TEST_INTERRUPT_NEXUS, interrupt_map, + INTERRUPT_NEXUS_CHECK_VARGS, (), 9999); +} + ZTEST_SUITE(devicetree_api, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/lib/devicetree/api/testcase.yaml b/tests/lib/devicetree/api/testcase.yaml index ded886833ac8..2759a047ab7d 100644 --- a/tests/lib/devicetree/api/testcase.yaml +++ b/tests/lib/devicetree/api/testcase.yaml @@ -5,6 +5,7 @@ tests: # will mostly likely be the fastest. platform_allow: - native_sim + - native_sim/native/64 - qemu_x86 - qemu_x86_64 - qemu_cortex_m3 diff --git a/tests/lib/gui/lvgl/src/main.c b/tests/lib/gui/lvgl/src/main.c index 18b9f22c68c8..6b595d35f79e 100644 --- a/tests/lib/gui/lvgl/src/main.c +++ b/tests/lib/gui/lvgl/src/main.c @@ -44,7 +44,7 @@ static struct fs_mount_t mnt = { #define IMG_FILE_PATH "/mnt/img.bin" #define LVGL_PARTITION storage_partition -#define LVGL_PARTITION_ID FIXED_PARTITION_ID(LVGL_PARTITION) +#define LVGL_PARTITION_ID PARTITION_ID(LVGL_PARTITION) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage); diff --git a/tests/net/lib/http_server/core/src/main.c b/tests/net/lib/http_server/core/src/main.c index c372f6c8b702..8fca6a80b6b1 100644 --- a/tests/net/lib/http_server/core/src/main.c +++ b/tests/net/lib/http_server/core/src/main.c @@ -2525,7 +2525,7 @@ ZTEST(server_function_tests_no_init, test_parse_http_frames) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) #define LFS_MNTP "/littlefs" #define TEST_FILE "static_file.html" diff --git a/tests/subsys/dfu/img_util/src/main.c b/tests/subsys/dfu/img_util/src/main.c index c0b5d96daeb1..039954f14d57 100644 --- a/tests/subsys/dfu/img_util/src/main.c +++ b/tests/subsys/dfu/img_util/src/main.c @@ -13,18 +13,15 @@ #define SLOT0_PARTITION slot0_partition #define SLOT1_PARTITION slot1_partition -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && \ - (FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \ - FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET) - -#if FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) -#define UPLOAD_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define RUNNING_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) + +#if PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#define UPLOAD_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define RUNNING_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) #else -#define UPLOAD_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) -#define RUNNING_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#define UPLOAD_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) +#define RUNNING_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) #endif diff --git a/tests/subsys/dfu/mcuboot/src/main.c b/tests/subsys/dfu/mcuboot/src/main.c index de40526dfc3e..8c42d23563a5 100644 --- a/tests/subsys/dfu/mcuboot/src/main.c +++ b/tests/subsys/dfu/mcuboot/src/main.c @@ -12,8 +12,8 @@ #define SLOT0_PARTITION slot0_partition #define SLOT1_PARTITION slot1_partition -#define SLOT0_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#define SLOT0_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) #define BOOT_MAGIC_VAL_W0 0xf395c277 #define BOOT_MAGIC_VAL_W1 0x7fefd260 diff --git a/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay b/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay index e46c6318792c..90628e17dbc7 100644 --- a/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay @@ -10,31 +10,36 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00010000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x0000a000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0x0000a000>; }; slot2_partition: partition@24000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00024000 0x0000a000>; }; slot3_partition: partition@2e000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x0002e000 0x0000a000>; }; diff --git a/tests/subsys/dfu/mcuboot_multi/src/main.c b/tests/subsys/dfu/mcuboot_multi/src/main.c index d99a6a74e899..47dd360f23e9 100644 --- a/tests/subsys/dfu/mcuboot_multi/src/main.c +++ b/tests/subsys/dfu/mcuboot_multi/src/main.c @@ -76,8 +76,8 @@ static void _test_request_upgrade_n(uint8_t fa_id, int img_index, int confirmed) ZTEST(mcuboot_multi, test_request_upgrade_multi) { - _test_request_upgrade_n(FIXED_PARTITION_ID(slot1_partition), 0, 0); - _test_request_upgrade_n(FIXED_PARTITION_ID(slot3_partition), 1, 1); + _test_request_upgrade_n(PARTITION_ID(slot1_partition), 0, 0); + _test_request_upgrade_n(PARTITION_ID(slot3_partition), 1, 1); } static void _test_write_confirm_n(uint8_t fa_id, int img_index) @@ -122,8 +122,8 @@ static void _test_write_confirm_n(uint8_t fa_id, int img_index) ZTEST(mcuboot_multi, test_write_confirm_multi) { - _test_write_confirm_n(FIXED_PARTITION_ID(slot0_partition), 0); - _test_write_confirm_n(FIXED_PARTITION_ID(slot2_partition), 1); + _test_write_confirm_n(PARTITION_ID(slot0_partition), 0); + _test_write_confirm_n(PARTITION_ID(slot2_partition), 1); } ZTEST_SUITE(mcuboot_multi, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/subsys/fs/fcb/src/fcb_test.h b/tests/subsys/fs/fcb/src/fcb_test.h index 9ae833991b66..cd7f2cc6804c 100644 --- a/tests/subsys/fs/fcb/src/fcb_test.h +++ b/tests/subsys/fs/fcb/src/fcb_test.h @@ -21,7 +21,7 @@ extern "C" { #endif #define TEST_FCB_FLASH_AREA slot1_partition -#define TEST_FCB_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_FCB_FLASH_AREA) +#define TEST_FCB_FLASH_AREA_ID PARTITION_ID(TEST_FCB_FLASH_AREA) extern struct fcb test_fcb; #if defined(CONFIG_FCB_ALLOW_FIXED_ENDMARKER) diff --git a/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index d7b166fa1e02..e99eb4091da9 100644 --- a/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay +++ b/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -4,17 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -/delete-node/ &slot1_partition; - -&cpuapp_rram { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - small_partition: partition@b6000 { - label = "small"; - reg = <0x000b6000 0x00010000>; - }; - }; +small_partition: &slot1_partition { + label = "small"; + reg = <0xc2000 0x10000>; }; diff --git a/tests/subsys/fs/littlefs/src/testfs_lfs.c b/tests/subsys/fs/littlefs/src/testfs_lfs.c index bde73b87caa1..bb6a2eaa21c3 100644 --- a/tests/subsys/fs/littlefs/src/testfs_lfs.c +++ b/tests/subsys/fs/littlefs/src/testfs_lfs.c @@ -10,13 +10,13 @@ #include "testfs_lfs.h" #define SMALL_PARTITION small_partition -#define SMALL_PARTITION_ID FIXED_PARTITION_ID(SMALL_PARTITION) +#define SMALL_PARTITION_ID PARTITION_ID(SMALL_PARTITION) #define MEDIUM_PARTITION medium_partition -#define MEDIUM_PARTITION_ID FIXED_PARTITION_ID(MEDIUM_PARTITION) +#define MEDIUM_PARTITION_ID PARTITION_ID(MEDIUM_PARTITION) #define LARGE_PARTITION large_partition -#define LARGE_PARTITION_ID FIXED_PARTITION_ID(LARGE_PARTITION) +#define LARGE_PARTITION_ID PARTITION_ID(LARGE_PARTITION) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(small); struct fs_mount_t testfs_small_mnt = { diff --git a/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c b/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c index c92bebd7f9fc..4fb397a5d2ee 100644 --- a/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c +++ b/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c @@ -16,7 +16,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) struct fs_mount_t littlefs_mnt = { .type = FS_LITTLEFS, diff --git a/tests/subsys/fs/multi-fs/src/test_ram_backend.c b/tests/subsys/fs/multi-fs/src/test_ram_backend.c index d391412512cb..0f3b9ca59993 100644 --- a/tests/subsys/fs/multi-fs/src/test_ram_backend.c +++ b/tests/subsys/fs/multi-fs/src/test_ram_backend.c @@ -13,8 +13,8 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) -#define TEST_PARTITION_SIZE FIXED_PARTITION_SIZE(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_SIZE PARTITION_SIZE(TEST_PARTITION) static uint8_t rambuf[TEST_PARTITION_SIZE]; diff --git a/tests/subsys/fs/multi-fs/src/test_utils.c b/tests/subsys/fs/multi-fs/src/test_utils.c index 579007ab8ff2..05b7ab38b04d 100644 --- a/tests/subsys/fs/multi-fs/src/test_utils.c +++ b/tests/subsys/fs/multi-fs/src/test_utils.c @@ -11,7 +11,7 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) int check_file_dir_exists(const char *fpath) { diff --git a/tests/subsys/fs/nvs/src/main.c b/tests/subsys/fs/nvs/src/main.c index 3d2254ada929..87963bf06c45 100644 --- a/tests/subsys/fs/nvs/src/main.c +++ b/tests/subsys/fs/nvs/src/main.c @@ -16,10 +16,10 @@ #include "nvs_priv.h" #define TEST_NVS_FLASH_AREA storage_partition -#define TEST_NVS_FLASH_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_NVS_FLASH_AREA) -#define TEST_NVS_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_NVS_FLASH_AREA) +#define TEST_NVS_FLASH_AREA_OFFSET PARTITION_OFFSET(TEST_NVS_FLASH_AREA) +#define TEST_NVS_FLASH_AREA_ID PARTITION_ID(TEST_NVS_FLASH_AREA) #define TEST_NVS_FLASH_AREA_DEV \ - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_NVS_FLASH_AREA))) + DEVICE_DT_GET(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_NVS_FLASH_AREA))) #define TEST_DATA_ID 1 #define TEST_SECTOR_COUNT 5U diff --git a/tests/subsys/fs/zms/src/main.c b/tests/subsys/fs/zms/src/main.c index 06d20f6153b6..fd58f42fb4c8 100644 --- a/tests/subsys/fs/zms/src/main.c +++ b/tests/subsys/fs/zms/src/main.c @@ -17,9 +17,9 @@ #include "zms_priv.h" #define TEST_ZMS_AREA storage_partition -#define TEST_ZMS_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_ZMS_AREA) -#define TEST_ZMS_AREA_ID FIXED_PARTITION_ID(TEST_ZMS_AREA) -#define TEST_ZMS_AREA_DEV DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_ZMS_AREA))) +#define TEST_ZMS_AREA_OFFSET PARTITION_OFFSET(TEST_ZMS_AREA) +#define TEST_ZMS_AREA_ID PARTITION_ID(TEST_ZMS_AREA) +#define TEST_ZMS_AREA_DEV DEVICE_DT_GET(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_ZMS_AREA))) #define TEST_DATA_ID 1 #define TEST_SECTOR_COUNT 5U diff --git a/tests/subsys/llext/src/test_llext.c b/tests/subsys/llext/src/test_llext.c index a7cf0032059f..81cb60772901 100644 --- a/tests/subsys/llext/src/test_llext.c +++ b/tests/subsys/llext/src/test_llext.c @@ -627,7 +627,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); static struct fs_mount_t mp = { .type = FS_LITTLEFS, .fs_data = &storage, - .storage_dev = (void *)FIXED_PARTITION_ID(storage_partition), + .storage_dev = (void *)PARTITION_ID(storage_partition), .mnt_point = "/lfs", }; diff --git a/tests/subsys/lorawan/frag_decoder/src/main.c b/tests/subsys/lorawan/frag_decoder/src/main.c index 34beb61e2b35..aaf4910c39f8 100644 --- a/tests/subsys/lorawan/frag_decoder/src/main.c +++ b/tests/subsys/lorawan/frag_decoder/src/main.c @@ -28,7 +28,7 @@ #define FRAG_TRANSPORT_PORT (201) #define FRAG_SESSION_INDEX (1) -#define TARGET_IMAGE_AREA FIXED_PARTITION_ID(slot1_partition) +#define TARGET_IMAGE_AREA PARTITION_ID(slot1_partition) /* below array would normally hold the actual firmware binary */ static uint8_t fw_uncoded[FIRMWARE_SIZE]; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay index 4d5de021baa4..f4d4ff21d4c8 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay @@ -10,31 +10,32 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x40000>; }; slot1_partition: partition@50000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00050000 0x40000>; }; slot2_partition: partition@90000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00090000 0x30000>; }; slot3_partition: partition@c0000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x000c0000 0x30000>; }; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay index 4d5de021baa4..f4d4ff21d4c8 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay @@ -10,31 +10,32 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x40000>; }; slot1_partition: partition@50000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00050000 0x40000>; }; slot2_partition: partition@90000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00090000 0x30000>; }; slot3_partition: partition@c0000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x000c0000 0x30000>; }; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c index c3cdc4d11343..a676c4b83ae2 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c @@ -38,13 +38,13 @@ struct partition_entries_t { }; struct partition_entries_t partition_entries[] = { - { FIXED_PARTITION_ID(slot0_partition), 0 }, - { FIXED_PARTITION_ID(slot1_partition), 0 }, -#if FIXED_PARTITION_EXISTS(slot2_partition) - { FIXED_PARTITION_ID(slot2_partition), 0 }, + { PARTITION_ID(slot0_partition), 0 }, + { PARTITION_ID(slot1_partition), 0 }, +#if PARTITION_EXISTS(slot2_partition) + { PARTITION_ID(slot2_partition), 0 }, #endif -#if FIXED_PARTITION_EXISTS(slot3_partition) - { FIXED_PARTITION_ID(slot3_partition), 0 }, +#if PARTITION_EXISTS(slot3_partition) + { PARTITION_ID(slot3_partition), 0 }, #endif }; diff --git a/tests/subsys/secure_storage/psa/its/src/main.c b/tests/subsys/secure_storage/psa/its/src/main.c index 712be32c7606..aeca82fdd6f3 100644 --- a/tests/subsys/secure_storage/psa/its/src/main.c +++ b/tests/subsys/secure_storage/psa/its/src/main.c @@ -9,15 +9,14 @@ /* The flash must be erased after this test suite is run for the write-once entry test to pass. */ #if !defined(CONFIG_BUILD_WITH_TFM) && defined(CONFIG_FLASH_PAGE_LAYOUT) && \ - DT_HAS_CHOSEN(zephyr_flash_controller) && \ - DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(storage_partition)) + PARTITION_EXISTS(DT_NODELABEL(storage_partition)) static int erase_flash(void) { - const struct device *const fdev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); + const struct device *const fdev = PARTITION_MTD(storage_partition); int rc; - rc = flash_flatten(fdev, FIXED_PARTITION_OFFSET(storage_partition), - FIXED_PARTITION_SIZE(storage_partition)); + rc = flash_flatten(fdev, PARTITION_OFFSET(storage_partition), + PARTITION_SIZE(storage_partition)); if (rc < 0) { TC_PRINT("Failed to flatten the storage partition (%d) !", rc); return rc; @@ -29,7 +28,7 @@ static int erase_flash(void) /* Low priority to ensure we run after any flash drivers are initialized */ SYS_INIT(erase_flash, POST_KERNEL, 100); -#endif /* !CONFIG_BUILD_WITH_TFM && CONFIG_FLASH_PAGE_LAYOUT */ +#endif /* !CONFIG_BUILD_WITH_TFM && CONFIG_FLASH_PAGE_LAYOUT && storage_partition */ ZTEST_SUITE(secure_storage_psa_its, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay index dada2d62ce14..41f6de157b30 100644 --- a/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay @@ -8,11 +8,8 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay b/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/fcb/src/settings_test_fcb.c b/tests/subsys/settings/fcb/src/settings_test_fcb.c index 1b3097c6f8b3..0710d1b16469 100644 --- a/tests/subsys/settings/fcb/src/settings_test_fcb.c +++ b/tests/subsys/settings/fcb/src/settings_test_fcb.c @@ -12,7 +12,7 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) uint8_t val8; uint8_t val8_un; diff --git a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c index 8e3be17c4b35..9c5bc5463841 100644 --- a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c +++ b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c @@ -12,17 +12,18 @@ #include #include +#include #include #include #define TEST_PARTITION storage_partition #define CODE_PARTITION slot0_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) #define CODE_PARTITION_NODE DT_NODELABEL(CODE_PARTITION) -#define CODE_PARTITION_ID FIXED_PARTITION_ID(CODE_PARTITION) -#define CODE_PARTITION_EXISTS FIXED_PARTITION_EXISTS(CODE_PARTITION) +#define CODE_PARTITION_ID PARTITION_ID(CODE_PARTITION) +#define CODE_PARTITION_EXISTS PARTITION_EXISTS(CODE_PARTITION) static uint32_t val32; @@ -34,16 +35,20 @@ static uint32_t val32; /* leverage that this area has to be embedded flash part */ #if CODE_PARTITION_EXISTS -#if DT_NODE_HAS_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) +#if DT_NODE_HAS_COMPAT(CODE_PARTITION_NODE, zephyr_mapped_partition) && \ + DT_NODE_HAS_PROP(DT_MEM_FROM_PARTITION(CODE_PARTITION_NODE), write_block_size) +#define FLASH_WRITE_BLOCK_SIZE \ + DT_PROP(DT_MEM_FROM_PARTITION(CODE_PARTITION_NODE), write_block_size) +#elif DT_NODE_HAS_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) #define FLASH_WRITE_BLOCK_SIZE \ DT_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) +#endif static const volatile __attribute__((section(".rodata"))) __aligned(FLASH_WRITE_BLOCK_SIZE) uint8_t prepared_mark[FLASH_WRITE_BLOCK_SIZE] = {ERASED_VAL}; #else #error "Test not prepared to run from flash with no write-block-size property in DTS" #endif -#endif static int c1_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) diff --git a/tests/subsys/settings/file/src/settings_setup_littlefs.c b/tests/subsys/settings/file/src/settings_setup_littlefs.c index 5e1705b876bf..9f88a503a9b6 100644 --- a/tests/subsys/settings/file/src/settings_setup_littlefs.c +++ b/tests/subsys/settings/file/src/settings_setup_littlefs.c @@ -10,7 +10,7 @@ #include #define LITTLEFS_PARTITION settings_file_partition -#define LITTLEFS_PARTITION_ID FIXED_PARTITION_ID(LITTLEFS_PARTITION) +#define LITTLEFS_PARTITION_ID PARTITION_ID(LITTLEFS_PARTITION) /* LittleFS work area struct */ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage); diff --git a/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay index dada2d62ce14..9e7fe1185124 100644 --- a/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay @@ -8,11 +8,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay b/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay index dada2d62ce14..9e7fe1185124 100644 --- a/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay @@ -8,11 +8,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay b/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/functional/src/settings_basic_test.c b/tests/subsys/settings/functional/src/settings_basic_test.c index da00b1e7237d..a495b188f94a 100644 --- a/tests/subsys/settings/functional/src/settings_basic_test.c +++ b/tests/subsys/settings/functional/src/settings_basic_test.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(settings_basic_test); #if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS) || defined(CONFIG_SETTINGS_ZMS) #include #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define TEST_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define TEST_FLASH_AREA_ID DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #endif #elif defined(CONFIG_SETTINGS_FILE) #include @@ -56,7 +56,7 @@ LOG_MODULE_REGISTER(settings_basic_test); #ifndef TEST_FLASH_AREA_ID #define TEST_FLASH_AREA storage_partition -#define TEST_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_FLASH_AREA) +#define TEST_FLASH_AREA_ID PARTITION_ID(TEST_FLASH_AREA) #endif /* The standard test expects a cleared flash area. Make sure it has diff --git a/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay index 37bae45ab120..53049260d6f7 100644 --- a/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay @@ -22,6 +22,7 @@ #size-cells = <1>; settings_partition0: settings_partition@0 { + compatible = "zephyr,mapped-partition"; compatible = "zephyr,retention"; status = "okay"; reg = <0x0 0x1000>; diff --git a/tests/subsys/shell/shell_flash/src/shell_flash_test.c b/tests/subsys/shell/shell_flash/src/shell_flash_test.c index ff8d1bb0db93..f4c51f595146 100644 --- a/tests/subsys/shell/shell_flash/src/shell_flash_test.c +++ b/tests/subsys/shell/shell_flash/src/shell_flash_test.c @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -24,7 +23,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) /* Test 'flash read' shell command */ ZTEST(shell_flash, test_flash_read) diff --git a/tests/subsys/storage/flash_map/src/main.c b/tests/subsys/storage/flash_map/src/main.c index aa47c9e0c70c..b44499ec8340 100644 --- a/tests/subsys/storage/flash_map/src/main.c +++ b/tests/subsys/storage/flash_map/src/main.c @@ -12,11 +12,11 @@ #include #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_DEV FIXED_PARTITION_DEVICE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_DEV PARTITION_DEVICE(SLOT1_PARTITION) #define SLOT1_PARTITION_NODE DT_NODELABEL(SLOT1_PARTITION) -#define SLOT1_PARTITION_OFFSET FIXED_PARTITION_OFFSET(SLOT1_PARTITION) -#define SLOT1_PARTITION_SIZE FIXED_PARTITION_SIZE(SLOT1_PARTITION) +#define SLOT1_PARTITION_OFFSET PARTITION_OFFSET(SLOT1_PARTITION) +#define SLOT1_PARTITION_SIZE PARTITION_SIZE(SLOT1_PARTITION) #define FLASH_AREA_COPY_SIZE MIN((SLOT1_PARTITION_SIZE / 2), 128) @@ -37,20 +37,20 @@ ZTEST(flash_map, test_flash_area_disabled_device) int rc; /* Test that attempting to open a disabled flash area fails */ - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - /* Note lack of tests for FIXED_PARTITION(...) instantiation, + /* Note lack of tests for PARTITION(...) instantiation, * because this macro will fail, at compile time, if node does not * exist or is disabled. */ @@ -71,7 +71,7 @@ ZTEST(flash_map, test_flash_area_device_is_ready) * all devices are already initialized and ready. */ zassert_true(flash_area_device_is_ready( - FIXED_PARTITION(SLOT1_PARTITION))); + PARTITION(SLOT1_PARTITION))); } static void layout_match(const struct device *flash_dev, uint32_t sec_cnt) @@ -104,7 +104,7 @@ ZTEST(flash_map, test_flash_area_get_sectors) uint32_t sec_cnt; int rc; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); zassert_true(flash_area_device_is_ready(fa)); @@ -129,7 +129,7 @@ ZTEST(flash_map, test_flash_area_sectors) int rc; const struct device *flash_dev_a = SLOT1_PARTITION_DEV; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); zassert_true(flash_area_device_is_ready(fa)); @@ -151,7 +151,7 @@ ZTEST(flash_map, test_flash_area_erased_val) const struct flash_area *fa; uint8_t val; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); val = flash_area_erased_val(fa); @@ -169,25 +169,16 @@ ZTEST(flash_map, test_fixed_partition_node_macros) */ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS) /* Test against changes in API */ -#if DT_REG_ADDR(DT_PARENT(SLOT1_PARTITION_NODE)) - /* Sub-partition handling */ - zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), - (DT_REG_ADDR(SLOT1_PARTITION_NODE) - DT_REG_ADDR(DT_PARENT(SLOT1_PARTITION_NODE)))); -#else - /* Partition handling */ - zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), - (DT_REG_ADDR(SLOT1_PARTITION_NODE) - DT_REG_ADDR(DT_PARENT( - DT_PARENT(SLOT1_PARTITION_NODE))))); -#endif - - zassert_equal(FIXED_PARTITION_NODE_SIZE(SLOT1_PARTITION_NODE), + zassert_equal(PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), + DT_REG_ADDR(SLOT1_PARTITION_NODE)); + zassert_equal(PARTITION_NODE_SIZE(SLOT1_PARTITION_NODE), DT_REG_SIZE(SLOT1_PARTITION_NODE)); - zassert_equal(FIXED_PARTITION_NODE_DEVICE(SLOT1_PARTITION_NODE), - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(SLOT1_PARTITION_NODE))); + zassert_equal(PARTITION_NODE_DEVICE(SLOT1_PARTITION_NODE), + DEVICE_DT_GET(DT_MTD_FROM_PARTITION(SLOT1_PARTITION_NODE))); /* Taking by node and taking by label should give same device */ - zassert_equal(FIXED_PARTITION_BY_NODE(DT_NODELABEL(SLOT1_PARTITION)), - FIXED_PARTITION(SLOT1_PARTITION)); + zassert_equal(PARTITION_BY_NODE(DT_NODELABEL(SLOT1_PARTITION)), + PARTITION(SLOT1_PARTITION)); #else ztest_test_skip(); #endif @@ -201,31 +192,31 @@ ZTEST(flash_map, test_fixed_subpartition_node_macros) */ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS) /* Test that both partitions and subpartitions exist */ - zassert_true(FIXED_PARTITION_EXISTS(disabled_a)); - zassert_true(FIXED_PARTITION_EXISTS(disabled_a_a)); - zassert_true(FIXED_PARTITION_EXISTS(disabled_a_b)); + zassert_true(PARTITION_EXISTS(disabled_a)); + zassert_true(PARTITION_EXISTS(disabled_a_a)); + zassert_true(PARTITION_EXISTS(disabled_a_b)); /* Test that the subpartition offset is relative to the parent */ - zassert_equal(FIXED_PARTITION_OFFSET(disabled_b), - FIXED_PARTITION_OFFSET(disabled_b_a)); - zassert_equal(FIXED_PARTITION_OFFSET(disabled_b) + 0x100, - FIXED_PARTITION_OFFSET(disabled_b_b)); - zassert_equal(FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)), - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_a))); + zassert_equal(PARTITION_OFFSET(disabled_b), + PARTITION_OFFSET(disabled_b_a)); + zassert_equal(PARTITION_OFFSET(disabled_b) + 0x100, + PARTITION_OFFSET(disabled_b_b)); + zassert_equal(PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)), + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_a))); zassert_equal( - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)) + 0x100, - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_b))); + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)) + 0x100, + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_b))); /* Test that the subpartition address is relative to the parent */ - zassert_equal(FIXED_PARTITION_ADDRESS(disabled_b), - FIXED_PARTITION_ADDRESS(disabled_b_a)); - zassert_equal(FIXED_PARTITION_ADDRESS(disabled_b) + 0x100, - FIXED_PARTITION_ADDRESS(disabled_b_b)); - zassert_equal(FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)), - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_a))); + zassert_equal(PARTITION_ADDRESS(disabled_b), + PARTITION_ADDRESS(disabled_b_a)); + zassert_equal(PARTITION_ADDRESS(disabled_b) + 0x100, + PARTITION_ADDRESS(disabled_b_b)); + zassert_equal(PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)), + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_a))); zassert_equal( - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)) + 0x100, - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_b))); + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)) + 0x100, + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_b))); #else ztest_test_skip(); #endif @@ -239,7 +230,7 @@ ZTEST(flash_map, test_flash_area_erase_and_flatten) const struct flash_area *fa; const struct device *flash_dev; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* First erase the area so it's ready for use. */ flash_dev = flash_area_get_device(fa); @@ -308,7 +299,7 @@ ZTEST(flash_map, test_flash_area_copy) int rc; /* Get source and destination flash areas */ - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* First erase the area so it's ready for use. */ rc = flash_area_erase(fa, 0, fa->fa_size); @@ -336,7 +327,7 @@ ZTEST(flash_map, test_parameter_overflows) uint8_t dst_buf[FLASH_AREA_COPY_SIZE]; int rc; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* -1 cast to size_t gives us max size_t value, added to offset of 1, * it will overflow to 0. */ diff --git a/tests/subsys/storage/flash_map/src/main_sha.c b/tests/subsys/storage/flash_map/src/main_sha.c index ae2dc6b2acf4..3cc9945f2cf3 100644 --- a/tests/subsys/storage/flash_map/src/main_sha.c +++ b/tests/subsys/storage/flash_map/src/main_sha.c @@ -12,10 +12,10 @@ #include #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_DEV FIXED_PARTITION_DEVICE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_DEV PARTITION_DEVICE(SLOT1_PARTITION) #define SLOT1_PARTITION_NODE DT_NODELABEL(SLOT1_PARTITION) -#define SLOT1_PARTITION_OFFSET FIXED_PARTITION_OFFSET(SLOT1_PARTITION) +#define SLOT1_PARTITION_OFFSET PARTITION_OFFSET(SLOT1_PARTITION) ZTEST(flash_map_sha, test_flash_area_check_int_sha256) { diff --git a/west.yml b/west.yml index ee24d08a3da9..2b1b71c435f0 100644 --- a/west.yml +++ b/west.yml @@ -326,7 +326,7 @@ manifest: groups: - crypto - name: mcuboot - revision: 9ac72969f281491d677e669d053281fc2d538ed4 + revision: 9eac8cb5f4fedb3500986c5877277ef80606c4b0 path: bootloader/mcuboot groups: - bootloader