Bug? Partition manager does not use device tree sizes for bootloader/settings partitions.

When compiling without a pm_static.yml in my project and using the dynamic partition resolver with mcuboot I noticed that I get an overflow error.

The current accepted fix in examples seems to be increasing CONFIG_PM_PARTITION_SIZE_MCUBOOT to the size in the device tree rather than the hardcoded value of 0xc000. However this isn't ideal since changes in device tree do not get automatically propagated.

I was able to extract the values from the device tree for both mcuboot and settings storage with the following diff.

diff --git a/modules/mcuboot/boot/zephyr/Kconfig b/modules/mcuboot/boot/zephyr/Kconfig
index ef150f0d8..674a13e5d 100644
--- a/modules/mcuboot/boot/zephyr/Kconfig
+++ b/modules/mcuboot/boot/zephyr/Kconfig
@@ -29,8 +29,10 @@ config PM_PARTITION_SIZE_MCUBOOT
        default 0x7c00
        depends on BOOT_USE_MIN_PARTITION_SIZE && !BOOT_NRF_EXTERNAL_CRYPTO
 
+DT_PARTITION_MCUBOOT_PATH := $(dt_nodelabel_path,boot_partition)
 config PM_PARTITION_SIZE_MCUBOOT
        hex "Flash space allocated for the MCUboot partition." if !BOOT_USE_MIN_PARTITION_SIZE
+       default $(dt_node_reg_size_hex,$(DT_PARTITION_MCUBOOT_PATH)) if $(dt_nodelabel_enabled,boot_partition)
        default 0xc000
        help
          Flash space set aside for the MCUboot partition.
diff --git a/subsys/partition_manager/Kconfig b/subsys/partition_manager/Kconfig
index df38d3500..bb1fcd35d 100644
--- a/subsys/partition_manager/Kconfig
+++ b/subsys/partition_manager/Kconfig
@@ -51,16 +51,22 @@ partition-size=0x6000
 rsource "Kconfig.template.partition_size"
 endif
 
+DT_PARTITION_STORAGE_PATH := $(dt_nodelabel_path,storage_partition)
+config PARTITION_SIZE_STORAGE
+       hex
+       default $(dt_node_reg_size_hex,$(DT_PARTITION_STORAGE_PATH)) if $(dt_nodelabel_enabled,storage_partition)
+       default 0x2000 if (SETTINGS_FCB || SETTINGS_NVS)
+       default 0x6000 if (NVS && !SETTINGS_NVS)
 
 if SETTINGS_FCB || SETTINGS_NVS
 partition=SETTINGS_STORAGE
-partition-size=0x2000
+partition-size=PARTITION_SIZE_STORAGE
 rsource "Kconfig.template.partition_size"
 endif
 
 if NVS && !SETTINGS_NVS
 partition=NVS_STORAGE
-partition-size=0x6000
+partition-size=PARTITION_SIZE_STORAGE
 rsource "Kconfig.template.partition_size"
 endif

Parents Reply Children
No Data
Related