blob: f421ee69449836f2e9c0da9fc077112dfb8f763e [file] [log] [blame]
David Vincze54d05552019-08-05 12:58:47 +02001#-------------------------------------------------------------------------------
David Vinczec3e313a2020-01-06 17:31:11 +01002# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
David Vincze54d05552019-08-05 12:58:47 +02003#
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 Vinczec3e313a2020-01-06 17:31:11 +010016 set(MCUBOOT_REPO "TF-M" CACHE STRING "Configure which repository use the MCUBoot from")
17 set_property(CACHE MCUBOOT_REPO PROPERTY STRINGS "TF-M;UPSTREAM")
18 validate_cache_value(MCUBOOT_REPO)
19
David Vincze7384ee72019-07-23 17:00:42 +020020 set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "Configure the number of separately updatable firmware images")
21 set_property(CACHE MCUBOOT_IMAGE_NUMBER PROPERTY STRINGS "1;2")
David Vincze63eda7a2019-08-09 17:42:51 +020022 validate_cache_value(MCUBOOT_IMAGE_NUMBER STRINGS)
23
David Vincze54d05552019-08-05 12:58:47 +020024 set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Configure BL2 which upgrade strategy to use")
25 set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING")
26 validate_cache_value(MCUBOOT_UPGRADE_STRATEGY)
27
28 set(MCUBOOT_SIGNATURE_TYPE "RSA-3072" CACHE STRING "Algorithm used by MCUBoot to validate signatures.")
29 set_property(CACHE MCUBOOT_SIGNATURE_TYPE PROPERTY STRINGS "RSA-3072;RSA-2048")
30 validate_cache_value(MCUBOOT_SIGNATURE_TYPE)
31
David Vinczec3e313a2020-01-06 17:31:11 +010032 if (MCUBOOT_REPO STREQUAL "TF-M")
33 set(MCUBOOT_HW_KEY On CACHE BOOL "Configure to use HW key for image verification. Otherwise key is embedded in MCUBoot image.")
34 else() #Using upstream MCUBoot
35 if (MCUBOOT_HW_KEY)
36 message(WARNING "Cannot use HW key for image verification when building against upstream MCUBoot."
37 " Your choice was overriden (MCUBOOT_HW_KEY=Off).")
38 endif()
39 set(MCUBOOT_HW_KEY Off)
40 endif()
Tamas Band0f4e1d2019-07-11 09:39:03 +010041
David Vincze73dfbc52019-10-11 13:54:58 +020042 set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_INFO" CACHE STRING "Configure the level of logging in MCUBoot.")
43 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 +010044 if (NOT CMAKE_BUILD_TYPE STREQUAL "debug")
David Vincze73dfbc52019-10-11 13:54:58 +020045 set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_OFF")
46 endif()
47 validate_cache_value(MCUBOOT_LOG_LEVEL)
48
David Vincze63eda7a2019-08-09 17:42:51 +020049 if ((${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
50 ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING") AND
51 NOT (MCUBOOT_IMAGE_NUMBER EQUAL 1))
52 message(WARNING "The number of separately updatable images with the NO_SWAP or the RAM_LOADING"
53 " upgrade strategy can be only '1'. Your choice was overriden.")
54 set(MCUBOOT_IMAGE_NUMBER 1)
55 endif()
56
David Vinczec3e313a2020-01-06 17:31:11 +010057 if (MCUBOOT_REPO STREQUAL "UPSTREAM")
58 set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP")
59 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
60 ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
61 message(WARNING "The ${MCUBOOT_UPGRADE_STRATEGY} upgrade strategy cannot be used when building against"
62 " upstream MCUBoot. Your choice was overriden.")
63 mcuboot_override_upgrade_strategy("OVERWRITE_ONLY")
64 endif()
65
66 if (DEFINED SECURITY_COUNTER OR
67 DEFINED SECURITY_COUNTER_S OR
68 DEFINED SECURITY_COUNTER_NS)
69 message(WARNING "Ignoring the values of SECURITY_COUNTER and/or SECURITY_COUNTER_* variables as"
70 " upstream MCUBoot does not support rollback protection.")
71 set(SECURITY_COUNTER "")
72 set(SECURITY_COUNTER_S "")
73 set(SECURITY_COUNTER_NS "")
74 endif()
75
76 endif()
77
David Vincze54d05552019-08-05 12:58:47 +020078else() #BL2 is turned off
David Vincze63eda7a2019-08-09 17:42:51 +020079
80 if (DEFINED MCUBOOT_IMAGE_NUMBER OR
81 DEFINED MCUBOOT_UPGRADE_STRATEGY OR
Tamas Band0f4e1d2019-07-11 09:39:03 +010082 DEFINED MCUBOOT_SIGNATURE_TYPE OR
David Vincze73dfbc52019-10-11 13:54:58 +020083 DEFINED MCUBOOT_HW_KEY OR
84 DEFINED MCUBOOT_LOG_LEVEL)
David Vinczec3e313a2020-01-06 17:31:11 +010085 message(WARNING "Ignoring the values of MCUBOOT_* variables as BL2 option is set to False.")
86 set(MCUBOOT_IMAGE_NUMBER "")
87 set(MCUBOOT_UPGRADE_STRATEGY "")
88 set(MCUBOOT_SIGNATURE_TYPE "")
89 set(MCUBOOT_HW_KEY "")
90 set(MCUBOOT_LOG_LEVEL "")
David Vincze54d05552019-08-05 12:58:47 +020091 endif()
92
David Vinczed8fbe0e2019-08-12 15:58:57 +020093 if (DEFINED SECURITY_COUNTER OR
94 DEFINED SECURITY_COUNTER_S OR
95 DEFINED SECURITY_COUNTER_NS)
David Vinczec3e313a2020-01-06 17:31:11 +010096 message(WARNING "Ignoring the values of SECURITY_COUNTER and/or SECURITY_COUNTER_* variables as BL2 option is set to False.")
97 set(SECURITY_COUNTER "")
98 set(SECURITY_COUNTER_S "")
99 set(SECURITY_COUNTER_NS "")
David Vinczed8fbe0e2019-08-12 15:58:57 +0200100 endif()
101
102 if (DEFINED IMAGE_VERSION OR
103 DEFINED IMAGE_VERSION_S OR
104 DEFINED IMAGE_VERSION_NS)
David Vinczec3e313a2020-01-06 17:31:11 +0100105 message(WARNING "Ignoring the values of IMAGE_VERSION and/or IMAGE_VERSION_* variables as BL2 option is set to False.")
106 set(IMAGE_VERSION "")
107 set(IMAGE_VERSION_S "")
108 set(IMAGE_VERSION_NS "")
David Vincze54d05552019-08-05 12:58:47 +0200109 endif()
David Vincze9ec0f542019-07-03 18:09:47 +0200110 if (DEFINED S_IMAGE_MIN_VER OR
111 DEFINED NS_IMAGE_MIN_VER)
David Vinczec3e313a2020-01-06 17:31:11 +0100112 message(WARNING "Ignoring the values of *_IMAGE_MIN_VER variables as BL2 option is set to False.")
113 set(S_IMAGE_MIN_VER "")
114 set(NS_IMAGE_MIN_VER "")
David Vincze9ec0f542019-07-03 18:09:47 +0200115 endif()
David Vincze54d05552019-08-05 12:58:47 +0200116endif()