Skip to content

Commit

Permalink
boot: zephyr: Fix estimated size calculation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nordicjm committed Mar 13, 2024
1 parent 7ace8bd commit 9fb7ce5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,12 @@ if(SYSBUILD)
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)
Expand Down Expand Up @@ -473,7 +477,7 @@ if(SYSBUILD)
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()

Expand All @@ -482,7 +486,7 @@ if(SYSBUILD)
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)
Expand Down

0 comments on commit 9fb7ce5

Please sign in to comment.