Skip to content

Commit d5d3359

Browse files
taltenbachnordicjm
authored andcommitted
zephyr: Fix trailer size computation for swap-scratch
When swap-scratch is used, the trailer size doesn't have to be rounded up to the next multiple of the sector size. Indeed, the trailer only need to be sector-aligned for swap-move and swap-offset. Signed-off-by: Thomas Altenbach <[email protected]>
1 parent f9e4e52 commit d5d3359

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

boot/zephyr/CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -678,15 +678,21 @@ if(SYSBUILD)
678678
endif()
679679

680680
math(EXPR trailer_size "${key_size} + ${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size}")
681-
align_up(${trailer_size} ${erase_size} trailer_size)
681+
682+
if(CONFIG_BOOT_SWAP_USING_MOVE OR CONFIG_BOOT_SWAP_USING_OFFSET)
683+
align_up(${trailer_size} ${erase_size} trailer_size)
684+
endif()
682685

683686
math(EXPR required_size "${trailer_size} + ${boot_tlv_estimate}")
684687

685688
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
686689
set(required_upgrade_size "0")
687690
else()
688691
math(EXPR required_upgrade_size "${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size}")
689-
align_up(${required_upgrade_size} ${erase_size} required_upgrade_size)
692+
693+
if(CONFIG_BOOT_SWAP_USING_MOVE OR CONFIG_BOOT_SWAP_USING_OFFSET)
694+
align_up(${required_upgrade_size} ${erase_size} required_upgrade_size)
695+
endif()
690696
endif()
691697

692698
if(CONFIG_BOOT_SWAP_USING_MOVE)

0 commit comments

Comments
 (0)