Skip to content

Commit 9fb7ce5

Browse files
committed
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 <[email protected]>
1 parent 7ace8bd commit 9fb7ce5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,12 @@ if(SYSBUILD)
433433
if(NOT DEFINED write_size)
434434
message(WARNING "Unable to determine write size of slot0 or slot1 partition, setting to 8 (this is probably wrong)")
435435
set(write_size 8)
436-
elseif(write_size LESS 8)
437-
set(write_size 8)
436+
endif()
437+
438+
if(${write_size} LESS 8)
439+
set(max_align_size 8)
440+
else()
441+
set(max_align_size ${write_size})
438442
endif()
439443

440444
set(key_size 0)
@@ -473,7 +477,7 @@ if(SYSBUILD)
473477
set(key_size "${boot_enc_key_size}")
474478
endif()
475479

476-
align_up(${key_size} ${write_size} key_size)
480+
align_up(${key_size} ${max_align_size} key_size)
477481
math(EXPR key_size "${key_size} * 2")
478482
endif()
479483

@@ -482,7 +486,7 @@ if(SYSBUILD)
482486
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
483487
set(boot_swap_data_size 0)
484488
else()
485-
math(EXPR boot_swap_data_size "${write_size} * 4")
489+
math(EXPR boot_swap_data_size "${max_align_size} * 4")
486490
endif()
487491

488492
if(CONFIG_BOOT_SWAP_USING_SCRATCH OR CONFIG_BOOT_SWAP_USING_MOVE)

0 commit comments

Comments
 (0)