blob: 02c68a3ffedd53287fe6a129e4107782875c738e [file] [log] [blame]
David Vincze54d05552019-08-05 12:58:47 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2019, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
David Vincze63eda7a2019-08-09 17:42:51 +02008#Include BL2 bootloader related functions
9include("${CMAKE_CURRENT_LIST_DIR}/MCUBoot.cmake")
10
David Vincze54d05552019-08-05 12:58:47 +020011set(BL2 True CACHE BOOL "Configure TF-M to use BL2 and enable building BL2")
12
13if (BL2)
14 add_definitions(-DBL2)
15
David Vincze7384ee72019-07-23 17:00:42 +020016 set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "Configure the number of separately updatable firmware images")
17 set_property(CACHE MCUBOOT_IMAGE_NUMBER PROPERTY STRINGS "1;2")
David Vincze63eda7a2019-08-09 17:42:51 +020018 validate_cache_value(MCUBOOT_IMAGE_NUMBER STRINGS)
19
David Vincze54d05552019-08-05 12:58:47 +020020 set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Configure BL2 which upgrade strategy to use")
21 set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING")
22 validate_cache_value(MCUBOOT_UPGRADE_STRATEGY)
23
24 set(MCUBOOT_SIGNATURE_TYPE "RSA-3072" CACHE STRING "Algorithm used by MCUBoot to validate signatures.")
25 set_property(CACHE MCUBOOT_SIGNATURE_TYPE PROPERTY STRINGS "RSA-3072;RSA-2048")
26 validate_cache_value(MCUBOOT_SIGNATURE_TYPE)
27
Tamas Ban1d37c342019-07-11 08:55:55 +010028 set(MCUBOOT_HW_KEY On CACHE BOOL "Configure to use HW key for image verification. Otherwise key is embedded in MCUBoot image.")
Tamas Band0f4e1d2019-07-11 09:39:03 +010029
David Vincze73dfbc52019-10-11 13:54:58 +020030 set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_INFO" CACHE STRING "Configure the level of logging in MCUBoot.")
31 set_property(CACHE MCUBOOT_LOG_LEVEL PROPERTY STRINGS "LOG_LEVEL_OFF;LOG_LEVEL_ERROR;LOG_LEVEL_WARNING;LOG_LEVEL_INFO;LOG_LEVEL_DEBUG")
Raef Colesb321c0b2019-10-15 08:49:17 +010032 if (NOT CMAKE_BUILD_TYPE STREQUAL "debug")
David Vincze73dfbc52019-10-11 13:54:58 +020033 set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_OFF")
34 endif()
35 validate_cache_value(MCUBOOT_LOG_LEVEL)
36
David Vincze63eda7a2019-08-09 17:42:51 +020037 if ((${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
38 ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING") AND
39 NOT (MCUBOOT_IMAGE_NUMBER EQUAL 1))
40 message(WARNING "The number of separately updatable images with the NO_SWAP or the RAM_LOADING"
41 " upgrade strategy can be only '1'. Your choice was overriden.")
42 set(MCUBOOT_IMAGE_NUMBER 1)
43 endif()
44
David Vincze54d05552019-08-05 12:58:47 +020045else() #BL2 is turned off
David Vincze63eda7a2019-08-09 17:42:51 +020046
47 if (DEFINED MCUBOOT_IMAGE_NUMBER OR
48 DEFINED MCUBOOT_UPGRADE_STRATEGY OR
Tamas Band0f4e1d2019-07-11 09:39:03 +010049 DEFINED MCUBOOT_SIGNATURE_TYPE OR
David Vincze73dfbc52019-10-11 13:54:58 +020050 DEFINED MCUBOOT_HW_KEY OR
51 DEFINED MCUBOOT_LOG_LEVEL)
David Vincze54d05552019-08-05 12:58:47 +020052 message(WARNING "Ignoring the values of MCUBOOT_* variables as BL2 option is set to False.")
David Vincze63eda7a2019-08-09 17:42:51 +020053 set(MCUBOOT_IMAGE_NUMBER "")
David Vincze54d05552019-08-05 12:58:47 +020054 set(MCUBOOT_UPGRADE_STRATEGY "")
55 set(MCUBOOT_SIGNATURE_TYPE "")
Tamas Band0f4e1d2019-07-11 09:39:03 +010056 set(MCUBOOT_HW_KEY "")
David Vincze73dfbc52019-10-11 13:54:58 +020057 set(MCUBOOT_LOG_LEVEL "")
David Vincze54d05552019-08-05 12:58:47 +020058 endif()
59
David Vinczed8fbe0e2019-08-12 15:58:57 +020060 if (DEFINED SECURITY_COUNTER OR
61 DEFINED SECURITY_COUNTER_S OR
62 DEFINED SECURITY_COUNTER_NS)
63 message(WARNING "Ignoring the values of SECURITY_COUNTER and/or SECURITY_COUNTER_* variables as BL2 option is set to False.")
David Vincze54d05552019-08-05 12:58:47 +020064 set(SECURITY_COUNTER "")
David Vinczed8fbe0e2019-08-12 15:58:57 +020065 set(SECURITY_COUNTER_S "")
66 set(SECURITY_COUNTER_NS "")
67 endif()
68
69 if (DEFINED IMAGE_VERSION OR
70 DEFINED IMAGE_VERSION_S OR
71 DEFINED IMAGE_VERSION_NS)
72 message(WARNING "Ignoring the values of IMAGE_VERSION and/or IMAGE_VERSION_* variables as BL2 option is set to False.")
73 set(IMAGE_VERSION "")
74 set(IMAGE_VERSION_S "")
75 set(IMAGE_VERSION_NS "")
David Vincze54d05552019-08-05 12:58:47 +020076 endif()
David Vincze9ec0f542019-07-03 18:09:47 +020077 if (DEFINED S_IMAGE_MIN_VER OR
78 DEFINED NS_IMAGE_MIN_VER)
79 message(WARNING "Ignoring the values of *_IMAGE_MIN_VER variables as BL2 option is set to False.")
80 set(S_IMAGE_MIN_VER "")
81 set(NS_IMAGE_MIN_VER "")
82 endif()
David Vincze54d05552019-08-05 12:58:47 +020083endif()