From 003d30b6f028705e7eefe7cec29669da1594d6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 26 Aug 2020 16:26:07 -0700 Subject: [PATCH] cmake: flash signed binaries for mcuboot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When CONFIG_MCUBOOT_SIGNATURE_KEY_FILE is set and the build system successfully creates signed outputs, use them as the default artifacts to flash. This flashes the non-confirmed variant regardless of CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE, allowing POST code in the application to confirm the image or not. Since this is used primarily from development, I'd hesitate to assume the confirmed image is good. Signed-off-by: Martí Bolívar --- cmake/flash/CMakeLists.txt | 8 ++++---- cmake/mcuboot.cmake | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/flash/CMakeLists.txt b/cmake/flash/CMakeLists.txt index 6fe6aa015ef..3f2c0592553 100644 --- a/cmake/flash/CMakeLists.txt +++ b/cmake/flash/CMakeLists.txt @@ -45,16 +45,16 @@ function(runners_yaml_append_config) runners_yaml_append(" bin_file: ${bin}") endif() - if (DEFINED CMAKE_GDB OR DEFINED OPENOCD OR DEFINED OPENOCD_DEFAULT_PATH) + if(CMAKE_GDB OR OPENOCD OR OPENOCD_DEFAULT_PATH) runners_yaml_append(" # Host tools:") endif() - if (DEFINED CMAKE_GDB) + if(CMAKE_GDB) runners_yaml_append(" gdb: ${CMAKE_GDB}") endif() - if (DEFINED OPENOCD) + if(OPENOCD) runners_yaml_append(" openocd: ${OPENOCD}") endif() - if(DEFINED OPENOCD_DEFAULT_PATH) + if(OPENOCD_DEFAULT_PATH) runners_yaml_append(" openocd_search: ${OPENOCD_DEFAULT_PATH}") endif() runners_yaml_append("") diff --git a/cmake/mcuboot.cmake b/cmake/mcuboot.cmake index 318091c13b6..0981f979fd7 100644 --- a/cmake/mcuboot.cmake +++ b/cmake/mcuboot.cmake @@ -10,6 +10,12 @@ # Since this file is brought in via include(), we do the work in a # function to avoid polluting the top-level scope. +function(zephyr_runner_file type path) + # Property magic which makes west flash choose the signed build + # output of a given type. + set_target_properties(runners_yaml_props_target PROPERTIES "${type}_file" "${path}") +endfunction() + function(zephyr_mcuboot_tasks) set(keyfile "${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}") @@ -97,6 +103,7 @@ function(zephyr_mcuboot_tasks) if(CONFIG_BUILD_OUTPUT_BIN) list(APPEND unconfirmed_args --bin --sbin ${output}.signed.bin) list(APPEND byproducts ${output}.signed.bin) + zephyr_runner_file(bin ${output}.signed.bin) if(CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE) list(APPEND confirmed_args --bin --sbin ${output}.signed.confirmed.bin) @@ -108,6 +115,7 @@ function(zephyr_mcuboot_tasks) if(CONFIG_BUILD_OUTPUT_HEX) list(APPEND unconfirmed_args --hex --shex ${output}.signed.hex) list(APPEND byproducts ${output}.signed.hex) + zephyr_runner_file(hex ${output}.signed.hex) if(CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE) list(APPEND confirmed_args --hex --shex ${output}.signed.confirmed.hex)