Skip to content

Commit 640c107

Browse files
committed
cmake: kconfig: support skipping build of mcuboot
Signed-off-by: Håkon Øye Amundsen <[email protected]>
1 parent 8fd86ad commit 640c107

File tree

2 files changed

+56
-26
lines changed

2 files changed

+56
-26
lines changed

zephyr/CMakeLists.txt

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,37 @@ if(CONFIG_BOOTLOADER_MCUBOOT)
33

44
set(MCUBOOT_BASE ${CMAKE_CURRENT_LIST_DIR}/..)
55

6-
zephyr_add_executable(mcuboot)
7-
add_subdirectory(${MCUBOOT_BASE}/boot/zephyr ${CMAKE_CURRENT_BINARY_DIR}/mcuboot)
6+
zephyr_add_executable(mcuboot require_build)
87

9-
# TODO: Assert that the bootloader and image use the same key.
8+
if (${require_build})
9+
add_subdirectory(${MCUBOOT_BASE}/boot/zephyr ${CMAKE_CURRENT_BINARY_DIR}/mcuboot)
1010

11-
set(SIGNED_IMAGE signed.hex)
11+
# TODO: Assert that the bootloader and image use the same key.
1212

13-
set_property(GLOBAL APPEND PROPERTY
14-
extra_post_build_commands
15-
COMMAND
16-
${PYTHON_EXECUTABLE}
17-
${MCUBOOT_BASE}/scripts/imgtool.py
18-
sign
19-
--key ${MCUBOOT_BASE}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}
20-
--header-size ${CONFIG_TEXT_SECTION_OFFSET}
21-
--align ${DT_FLASH_WRITE_BLOCK_SIZE}
22-
--version 0.1 # TODO: Configurable?
23-
--slot-size 0x32000 # TODO: Configurable?
24-
${KERNEL_HEX_NAME} # TODO: Enforce that this will be present through Kconfig
25-
${SIGNED_IMAGE}
26-
)
13+
set(SIGNED_IMAGE signed.hex)
2714

28-
set_property(GLOBAL APPEND PROPERTY
29-
HEX_FILES_TO_MERGE
30-
${SIGNED_IMAGE}
31-
)
32-
set_property(GLOBAL APPEND PROPERTY
33-
HEX_FILES_TO_MERGE_TARGET
34-
${logical_target_for_zephyr_elf}
35-
)
15+
set_property(GLOBAL APPEND PROPERTY
16+
extra_post_build_commands
17+
COMMAND
18+
${PYTHON_EXECUTABLE}
19+
${MCUBOOT_BASE}/scripts/imgtool.py
20+
sign
21+
--key ${MCUBOOT_BASE}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}
22+
--header-size ${CONFIG_TEXT_SECTION_OFFSET}
23+
--align ${DT_FLASH_WRITE_BLOCK_SIZE}
24+
--version 0.1 # TODO: Configurable?
25+
--slot-size 0x32000 # TODO: Configurable?
26+
${KERNEL_HEX_NAME} # TODO: Enforce that this will be present through Kconfig
27+
${SIGNED_IMAGE}
28+
)
29+
30+
set_property(GLOBAL APPEND PROPERTY
31+
HEX_FILES_TO_MERGE
32+
${SIGNED_IMAGE}
33+
)
34+
set_property(GLOBAL APPEND PROPERTY
35+
HEX_FILES_TO_MERGE_TARGET
36+
${logical_target_for_zephyr_elf}
37+
)
38+
endif() # ${require_build}
3639
endif()

zephyr/Kconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@ config MCUBOOT_CMAKELISTS_DIR
44
string "Path to the directory of the MCUBoot CMakeLists.txt file"
55
default "$MCUBOOT_BASE/boot/zephyr/"
66

7+
8+
choice
9+
prompt "MCUBoot build strategy"
10+
default MCUBOOT_BUILD_STRATEGY_FROM_SOURCE
11+
12+
config MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE
13+
# Mandatory option when being built through 'zephyr_add_executable'
14+
bool "Use hex file instead of building MCUBoot"
15+
16+
if MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE
17+
18+
config MCUBOOT_HEX_FILE
19+
# Mandatory option when being built through 'zephyr_add_executable'
20+
string "MCUBoot hex file"
21+
22+
endif # MCUBOOT_USE_HEX_FILE
23+
24+
config MCUBOOT_BUILD_STRATEGY_SKIP_BUILD
25+
# Mandatory option when being built through 'zephyr_add_executable'
26+
bool "Skip building MCUBoot"
27+
28+
config MCUBOOT_BUILD_STRATEGY_FROM_SOURCE
29+
# Mandatory option when being built through 'zephyr_add_executable'
30+
bool "Build from source"
31+
32+
endchoice
33+
734
endif # BOOTLOADER_MCUBOOT
835

936
if MCUBOOT || BOOTLOADER_MCUBOOT

0 commit comments

Comments
 (0)