Skip to content

Commit a4eda30

Browse files
committed
zephyr: Add estimated size of update trailer to sysbuild
Adds a new field which is set to the estimated size of the upgrade slot data, this is used to know how much space should be reserved in an update image to determine if an update will fit or not Signed-off-by: Jamie McCrae <[email protected]>
1 parent 205d7e5 commit a4eda30

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,24 @@ if(SYSBUILD)
492492
endif()
493493

494494
math(EXPR required_size "${key_size} + ${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size} + ${boot_tlv_estimate}")
495-
496495
align_up(${required_size} ${erase_size} required_size)
497496

497+
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
498+
set(required_upgrade_size "0")
499+
else()
500+
math(EXPR required_upgrade_size "${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size}")
501+
align_up(${required_upgrade_size} ${erase_size} required_upgrade_size)
502+
endif()
503+
498504
if(CONFIG_BOOT_SWAP_USING_MOVE)
499505
math(EXPR required_size "${required_size} + ${erase_size}")
506+
math(EXPR required_upgrade_size "${required_upgrade_size} + ${erase_size}")
500507
endif()
501508
else()
502509
set(required_size 0)
510+
set(required_upgrade_size 0)
503511
endif()
504512

505513
set(mcuboot_image_footer_size ${required_size} CACHE INTERNAL "Estimated MCUboot image trailer size" FORCE)
514+
set(mcuboot_image_upgrade_footer_size ${required_upgrade_size} CACHE INTERNAL "Estimated MCUboot update image trailer size" FORCE)
506515
endif()

boot/zephyr/sysbuild/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_image_cmake)
3131

3232
if("${app_type}" STREQUAL "MAIN")
3333
sysbuild_get(mcuboot_image_footer_size IMAGE mcuboot CACHE)
34+
sysbuild_get(mcuboot_image_upgrade_footer_size IMAGE mcuboot CACHE)
3435
math(EXPR mcuboot_image_footer_size "${mcuboot_image_footer_size}" OUTPUT_FORMAT HEXADECIMAL)
36+
math(EXPR mcuboot_image_upgrade_footer_size "${mcuboot_image_upgrade_footer_size}" OUTPUT_FORMAT HEXADECIMAL)
3537

3638
set_property(TARGET ${image} APPEND_STRING PROPERTY CONFIG "CONFIG_ROM_END_OFFSET=${mcuboot_image_footer_size}\n")
39+
set_property(TARGET ${image} APPEND_STRING PROPERTY CONFIG "CONFIG_MCUBOOT_UPDATE_FOOTER_SIZE=${mcuboot_image_upgrade_footer_size}\n")
3740
return()
3841
endif()
3942
endforeach()

0 commit comments

Comments
 (0)