1# Copyright (c) 2023-2024 Nordic Semiconductor
2#
3# SPDX-License-Identifier: Apache-2.0
4
5# This sysbuild CMake file sets the sysbuild controlled settings as properties
6# on the main Zephyr image.
7
8set_config_bool(${ZCMAKE_APPLICATION} CONFIG_BOOTLOADER_MCUBOOT "${SB_CONFIG_BOOTLOADER_MCUBOOT}")
9set_config_string(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
10                  "${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}"
11)
12set_config_string(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_ENCRYPTION_KEY_FILE
13                  "${SB_CONFIG_BOOT_ENCRYPTION_KEY_FILE}"
14)
15
16if(SB_CONFIG_BOOTLOADER_MCUBOOT)
17  if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
18    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
19  else()
20    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
21  endif()
22
23  if(SB_CONFIG_MCUBOOT_MODE_SINGLE_APP)
24    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP y)
25  elseif(SB_CONFIG_MCUBOOT_MODE_SWAP_WITHOUT_SCRATCH)
26    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH y)
27  elseif(SB_CONFIG_MCUBOOT_MODE_SWAP_SCRATCH)
28    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_SCRATCH y)
29  elseif(SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY)
30    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY y)
31  elseif(SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP)
32    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP y)
33  elseif(SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT)
34    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT y)
35  elseif(SB_CONFIG_MCUBOOT_MODE_RAM_LOAD)
36    # RAM load mode requires XIP be disabled and flash size be set to 0
37    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD y)
38    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_XIP n)
39    set_config_int(${ZCMAKE_APPLICATION} CONFIG_FLASH_SIZE 0)
40  elseif(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER)
41    set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER y)
42  endif()
43endif()
44