-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: Migrate to support multi-image building
Migrate to support multi-image building. Must be applied simultaneously with zephyrproject-rtos/zephyr#13672 See the Zephyr PR for details. Signed-off-by: Sebastian Bøe <[email protected]>
- Loading branch information
1 parent
ad0e9b8
commit 083b331
Showing
4 changed files
with
104 additions
and
9 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
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,39 @@ | ||
if(CONFIG_BOOTLOADER_MCUBOOT) | ||
# Build a second bootloader image | ||
|
||
set(MCUBOOT_BASE ${CMAKE_CURRENT_LIST_DIR}/..) | ||
|
||
zephyr_add_executable(mcuboot require_build) | ||
|
||
if (${require_build}) | ||
add_subdirectory(${MCUBOOT_BASE}/boot/zephyr ${CMAKE_CURRENT_BINARY_DIR}/mcuboot) | ||
|
||
# TODO: Assert that the bootloader and image use the same key. | ||
|
||
set(SIGNED_IMAGE signed.hex) | ||
|
||
set_property(GLOBAL APPEND PROPERTY | ||
extra_post_build_commands | ||
COMMAND | ||
${PYTHON_EXECUTABLE} | ||
${MCUBOOT_BASE}/scripts/imgtool.py | ||
sign | ||
--key ${MCUBOOT_BASE}/${CONFIG_BOOT_SIGNATURE_KEY_FILE} | ||
--header-size ${CONFIG_TEXT_SECTION_OFFSET} | ||
--align ${DT_FLASH_WRITE_BLOCK_SIZE} | ||
--version 0.1 # TODO: Configurable? | ||
--slot-size 0x32000 # TODO: Configurable? | ||
${KERNEL_HEX_NAME} # TODO: Enforce that this will be present through Kconfig | ||
${SIGNED_IMAGE} | ||
) | ||
|
||
set_property(GLOBAL APPEND PROPERTY | ||
HEX_FILES_TO_MERGE | ||
${SIGNED_IMAGE} | ||
) | ||
set_property(GLOBAL APPEND PROPERTY | ||
HEX_FILES_TO_MERGE_TARGET | ||
${logical_target_for_zephyr_elf} | ||
) | ||
endif() # ${require_build} | ||
endif() |
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,46 @@ | ||
if BOOTLOADER_MCUBOOT | ||
|
||
config MCUBOOT_CMAKELISTS_DIR | ||
string "Path to the directory of the MCUBoot CMakeLists.txt file" | ||
default "$MCUBOOT_BASE/boot/zephyr/" | ||
|
||
|
||
choice | ||
prompt "MCUBoot build strategy" | ||
default MCUBOOT_BUILD_STRATEGY_FROM_SOURCE | ||
|
||
config MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE | ||
# Mandatory option when being built through 'zephyr_add_executable' | ||
bool "Use hex file instead of building MCUBoot" | ||
|
||
if MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE | ||
|
||
config MCUBOOT_HEX_FILE | ||
# Mandatory option when being built through 'zephyr_add_executable' | ||
string "MCUBoot hex file" | ||
|
||
endif # MCUBOOT_USE_HEX_FILE | ||
|
||
config MCUBOOT_BUILD_STRATEGY_SKIP_BUILD | ||
# Mandatory option when being built through 'zephyr_add_executable' | ||
bool "Skip building MCUBoot" | ||
|
||
config MCUBOOT_BUILD_STRATEGY_FROM_SOURCE | ||
# Mandatory option when being built through 'zephyr_add_executable' | ||
bool "Build from source" | ||
|
||
endchoice | ||
|
||
endif # BOOTLOADER_MCUBOOT | ||
|
||
if MCUBOOT || BOOTLOADER_MCUBOOT | ||
# TODO: Support sharing Kconfig configuration between images | ||
config BOOT_SIGNATURE_KEY_FILE | ||
string "PEM key file" | ||
default "root-rsa-2048.pem" | ||
help | ||
The key file will be parsed by imgtool's getpub command and a .c source | ||
with the public key information will be written in a format expected by | ||
MCUboot. | ||
|
||
endif # MCUBOOT || BOOTLOADER_MCUBOOT |