Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: Add estimated size of update trailer to sysbuild #1896

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,24 @@ if(SYSBUILD)
endif()

math(EXPR required_size "${key_size} + ${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size} + ${boot_tlv_estimate}")

align_up(${required_size} ${erase_size} required_size)

if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
set(required_upgrade_size "0")
else()
math(EXPR required_upgrade_size "${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size}")
align_up(${required_upgrade_size} ${erase_size} required_upgrade_size)
endif()

if(CONFIG_BOOT_SWAP_USING_MOVE)
math(EXPR required_size "${required_size} + ${erase_size}")
math(EXPR required_upgrade_size "${required_upgrade_size} + ${erase_size}")
endif()
else()
set(required_size 0)
set(required_upgrade_size 0)
endif()

set(mcuboot_image_footer_size ${required_size} CACHE INTERNAL "Estimated MCUboot image trailer size" FORCE)
set(mcuboot_image_upgrade_footer_size ${required_upgrade_size} CACHE INTERNAL "Estimated MCUboot update image trailer size" FORCE)
endif()
3 changes: 3 additions & 0 deletions boot/zephyr/sysbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_post_image_cmake)

if("${app_type}" STREQUAL "MAIN")
sysbuild_get(mcuboot_image_footer_size IMAGE mcuboot CACHE)
sysbuild_get(mcuboot_image_upgrade_footer_size IMAGE mcuboot CACHE)
math(EXPR mcuboot_image_footer_size "${mcuboot_image_footer_size}" OUTPUT_FORMAT HEXADECIMAL)
math(EXPR mcuboot_image_upgrade_footer_size "${mcuboot_image_upgrade_footer_size}" OUTPUT_FORMAT HEXADECIMAL)

set_property(TARGET ${image} APPEND_STRING PROPERTY CONFIG "CONFIG_ROM_END_OFFSET=${mcuboot_image_footer_size}\n")
set_property(TARGET ${image} APPEND_STRING PROPERTY CONFIG "CONFIG_MCUBOOT_UPDATE_FOOTER_SIZE=${mcuboot_image_upgrade_footer_size}\n")
return()
endif()
endforeach()
Expand Down
Loading