From 51177e064a3a485dc6b1c1107f7a53a84ceede86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 12 Dec 2018 08:59:47 +0100 Subject: [PATCH] dump: dump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dump Signed-off-by: Sebastian Bøe --- boot/zephyr/CMakeLists.txt | 18 ++++++++++++++++++ boot/zephyr/Kconfig | 8 -------- zephyr/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ zephyr/Kconfig | 19 +++++++++++++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 zephyr/CMakeLists.txt create mode 100644 zephyr/Kconfig diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt index 470103cf04..20e91de876 100644 --- a/boot/zephyr/CMakeLists.txt +++ b/boot/zephyr/CMakeLists.txt @@ -161,6 +161,14 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "") else() set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}) endif() + + set_property( + GLOBAL + PROPERTY + KEY_FILE + ${KEY_FILE} + ) + set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c) add_custom_command( OUTPUT ${GENERATED_PUBKEY} @@ -175,3 +183,13 @@ if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "") ) zephyr_library_sources(${GENERATED_PUBKEY}) endif() + +# TODO: Configurable? +set_property(GLOBAL APPEND PROPERTY + HEX_FILES_TO_MERGE + ${PROJECT_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME} + ) +set_property(GLOBAL APPEND PROPERTY + HEX_FILES_TO_MERGE_TARGET + ${logical_target_for_zephyr_elf} + ) diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index 77c5b6300f..25088ddb51 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -60,14 +60,6 @@ config BOOT_SIGNATURE_TYPE_ECDSA_P256 endchoice -config BOOT_SIGNATURE_KEY_FILE - string "PEM key file" - default "" - 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. - config MBEDTLS_CFG_FILE default "mcuboot-mbedtls-cfg.h" diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt new file mode 100644 index 0000000000..38206b9877 --- /dev/null +++ b/zephyr/CMakeLists.txt @@ -0,0 +1,36 @@ +if(CONFIG_BOOTLOADER_MCUBOOT) + # Build a second bootloader image + + set(MCUBOOT_BASE ${CMAKE_CURRENT_LIST_DIR}/..) + + zephyr_add_executable(mcuboot) + 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() diff --git a/zephyr/Kconfig b/zephyr/Kconfig new file mode 100644 index 0000000000..dc0d584250 --- /dev/null +++ b/zephyr/Kconfig @@ -0,0 +1,19 @@ +if BOOTLOADER_MCUBOOT + +config MCUBOOT_CMAKELISTS_DIR + string "Path to the directory of the MCUBoot CMakeLists.txt file" + default "$MCUBOOT_BASE/boot/zephyr/" + +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