boot: zephyr: Fix estimated size calculation
Fixes an issue with the estimated size calculation which wrongly
used the maximum align size for some multiplications, this would
mean that in some instances the estimated maximum image size was
smaller than the actual allowed size
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt
index 9156ad2..f6c4b7e 100644
--- a/boot/zephyr/CMakeLists.txt
+++ b/boot/zephyr/CMakeLists.txt
@@ -433,8 +433,12 @@
if(NOT DEFINED write_size)
message(WARNING "Unable to determine write size of slot0 or slot1 partition, setting to 8 (this is probably wrong)")
set(write_size 8)
- elseif(write_size LESS 8)
- set(write_size 8)
+ endif()
+
+ if(${write_size} LESS 8)
+ set(max_align_size 8)
+ else()
+ set(max_align_size ${write_size})
endif()
set(key_size 0)
@@ -473,7 +477,7 @@
set(key_size "${boot_enc_key_size}")
endif()
- align_up(${key_size} ${write_size} key_size)
+ align_up(${key_size} ${max_align_size} key_size)
math(EXPR key_size "${key_size} * 2")
endif()
@@ -482,7 +486,7 @@
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
set(boot_swap_data_size 0)
else()
- math(EXPR boot_swap_data_size "${write_size} * 4")
+ math(EXPR boot_swap_data_size "${max_align_size} * 4")
endif()
if(CONFIG_BOOT_SWAP_USING_SCRATCH OR CONFIG_BOOT_SWAP_USING_MOVE)