1# Copyright (c) 2023 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 Zephyr images.
7
8get_target_property(image_board ${image} BOARD)
9if((NOT image_board) OR ("${image_BOARD}" STREQUAL "${BOARD}"))
10  get_target_property(${image}_APP_TYPE ${image} APP_TYPE)
11  if(NOT "${${image}_APP_TYPE}" STREQUAL "BOOTLOADER")
12    set_config_bool(${image} CONFIG_BOOTLOADER_MCUBOOT "${SB_CONFIG_BOOTLOADER_MCUBOOT}")
13    set_config_string(${image} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
14                               "${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}"
15    )
16  else()
17    set(keytypes CONFIG_BOOT_SIGNATURE_TYPE_NONE
18                 CONFIG_BOOT_SIGNATURE_TYPE_RSA
19                 CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256
20                 CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
21
22    if(SB_CONFIG_BOOT_SIGNATURE_TYPE_NONE)
23      set(keytype CONFIG_BOOT_SIGNATURE_TYPE_NONE)
24    elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA)
25      set(keytype CONFIG_BOOT_SIGNATURE_TYPE_RSA)
26    elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
27      set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
28    elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
29      set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
30    endif()
31
32    foreach(loopkeytype ${keytypes})
33      if("${loopkeytype}" STREQUAL "${keytype}")
34        set_config_bool(${image} ${loopkeytype} y)
35      else()
36        set_config_bool(${image} ${loopkeytype} n)
37      endif()
38    endforeach()
39  endif()
40
41  if(SB_CONFIG_BOOTLOADER_MCUBOOT)
42    if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
43      set_config_bool(${image} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
44    else()
45      set_config_bool(${image} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
46    endif()
47  endif()
48endif()
49