cmake: flash signed binaries for mcuboot

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 <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-08-26 16:26:07 -07:00 committed by Maureen Helm
commit 003d30b6f0
2 changed files with 12 additions and 4 deletions

View file

@ -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("")

View file

@ -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)