1# Copyright 2022 NXP
2# SPDX-License-Identifier: Apache-2.0
3
4# Add the mcuboot key file to the secondary swapped app
5# This must be done here to ensure that the same key file is used for signing
6# both the primary and secondary apps
7set(swapped_app_CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
8    \"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}\" CACHE STRING
9    "Signature key file for signing" FORCE)
10
11# Add the swapped app to the build
12ExternalZephyrProject_Add(
13  APPLICATION swapped_app
14  SOURCE_DIR ${APP_DIR}/swapped_app
15)
16
17# Add the swapped app to the list of images to flash
18# Ensure the flashing order of images is as follows:
19# - mcuboot
20# - swapped app
21# - primary app (test_mcuboot)
22# This order means that if the debugger resets the MCU in between flash
23# iterations, the MCUBoot swap won't be triggered until the secondary app
24# is actually present in flash.
25sysbuild_add_dependencies(FLASH test_mcuboot swapped_app)
26sysbuild_add_dependencies(FLASH swapped_app mcuboot)
27