-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zephyr: Add estimated image footer size to cache in sysbuild
Adds MCUboot's estimated overhead footer size to the application's cache when using sysbuild, this allows that information to be propagated to applications which can use the information to reduce the available size for an application, preventing the MCUboot error of image too large to swap. Signed-off-by: Jamie McCrae <[email protected]>
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function(mathup num align result) | ||
math(EXPR out "(((${num}) + ((${align}) - 1)) & ~((${align}) - 1))") | ||
set(${result} "${out}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_image_cmake) | ||
cmake_parse_arguments(POST_IMAGE_CMAKE "" "IMAGE" "IMAGES" ${ARGN}) | ||
|
||
if(NOT "${POST_IMAGE_CMAKE_IMAGE}" STREQUAL "mcuboot") | ||
return() | ||
endif() | ||
|
||
set_property( | ||
DIRECTORY APPEND PROPERTY | ||
CMAKE_CONFIGURE_DEPENDS | ||
${CMAKE_BINARY_DIR}/mcuboot/CMakeCache.txt | ||
${CMAKE_BINARY_DIR}/mcuboot/zephyr/.config | ||
) | ||
endfunction(${SYSBUILD_CURRENT_MODULE_NAME}_pre_image_cmake) | ||
|
||
function(${SYSBUILD_CURRENT_MODULE_NAME}_post_image_cmake) | ||
cmake_parse_arguments(POST_IMAGE_CMAKE "" "IMAGE" "IMAGES" ${ARGN}) | ||
|
||
if(NOT "${POST_IMAGE_CMAKE_IMAGE}" STREQUAL "mcuboot") | ||
return() | ||
endif() | ||
|
||
foreach(image ${IMAGES}) | ||
set(app_type) | ||
get_property(app_type TARGET ${image} PROPERTY APP_TYPE) | ||
|
||
if("${app_type}" STREQUAL "MAIN") | ||
sysbuild_get(mcuboot_image_footer_size IMAGE mcuboot CACHE) | ||
math(EXPR mcuboot_image_footer_size "${mcuboot_image_footer_size}" OUTPUT_FORMAT HEXADECIMAL) | ||
|
||
set_property(TARGET ${image} APPEND_STRING PROPERTY CONFIG "CONFIG_FLASH_LOAD_OVERHEAD_SIZE=${mcuboot_image_footer_size}\n") | ||
return() | ||
endif() | ||
endforeach() | ||
endfunction(${SYSBUILD_CURRENT_MODULE_NAME}_post_image_cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ samples: | |
- boot/zephyr | ||
build: | ||
cmake: ./boot/bootutil/zephyr | ||
sysbuild-cmake: boot/zephyr/sysbuild |