Skip to content

Commit b0bedd7

Browse files
committed
dump: dump
dump Signed-off-by: Sebastian Bøe <[email protected]>
1 parent ad0e9b8 commit b0bedd7

File tree

4 files changed

+104
-9
lines changed

4 files changed

+104
-9
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ if(CONFIG_MCUBOOT_SERIAL)
134134

135135
zephyr_link_libraries_ifdef(
136136
CONFIG_TINYCBOR
137-
TINYCBOR
137+
${IMAGE}TINYCBOR
138138
)
139139

140140
zephyr_include_directories_ifdef(
@@ -149,6 +149,14 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
149149
else()
150150
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
151151
endif()
152+
153+
set_property(
154+
GLOBAL
155+
PROPERTY
156+
KEY_FILE
157+
${KEY_FILE}
158+
)
159+
152160
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
153161
add_custom_command(
154162
OUTPUT ${GENERATED_PUBKEY}
@@ -163,3 +171,13 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
163171
)
164172
zephyr_library_sources(${GENERATED_PUBKEY})
165173
endif()
174+
175+
# TODO: Configurable?
176+
set_property(GLOBAL APPEND PROPERTY
177+
HEX_FILES_TO_MERGE
178+
${PROJECT_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME}
179+
)
180+
set_property(GLOBAL APPEND PROPERTY
181+
HEX_FILES_TO_MERGE_TARGET
182+
${logical_target_for_zephyr_elf}
183+
)

boot/zephyr/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ config BOOT_SIGNATURE_TYPE_ECDSA_P256
6060

6161
endchoice
6262

63-
config BOOT_SIGNATURE_KEY_FILE
64-
string "PEM key file"
65-
default ""
66-
help
67-
The key file will be parsed by imgtool's getpub command and a .c source
68-
with the public key information will be written in a format expected by
69-
MCUboot.
70-
7163
config MBEDTLS_CFG_FILE
7264
default "mcuboot-mbedtls-cfg.h"
7365

zephyr/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if(CONFIG_BOOTLOADER_MCUBOOT)
2+
# Build a second bootloader image
3+
4+
set(MCUBOOT_BASE ${CMAKE_CURRENT_LIST_DIR}/..)
5+
6+
zephyr_add_executable(mcuboot require_build)
7+
8+
if (${require_build})
9+
add_subdirectory(${MCUBOOT_BASE}/boot/zephyr ${CMAKE_CURRENT_BINARY_DIR}/mcuboot)
10+
11+
# TODO: Assert that the bootloader and image use the same key.
12+
13+
set(SIGNED_IMAGE signed.hex)
14+
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}
39+
endif()

zephyr/Kconfig

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
if BOOTLOADER_MCUBOOT
2+
3+
config MCUBOOT_CMAKELISTS_DIR
4+
string "Path to the directory of the MCUBoot CMakeLists.txt file"
5+
default "$MCUBOOT_BASE/boot/zephyr/"
6+
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+
34+
endif # BOOTLOADER_MCUBOOT
35+
36+
if MCUBOOT || BOOTLOADER_MCUBOOT
37+
# TODO: Support sharing Kconfig configuration between images
38+
config BOOT_SIGNATURE_KEY_FILE
39+
string "PEM key file"
40+
default "root-rsa-2048.pem"
41+
help
42+
The key file will be parsed by imgtool's getpub command and a .c source
43+
with the public key information will be written in a format expected by
44+
MCUboot.
45+
46+
endif # MCUBOOT || BOOTLOADER_MCUBOOT

0 commit comments

Comments
 (0)