blob: 26c97d5cc6df9d887925d30d00a371e83189ade4 [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
Balint Matyif0873cd2020-06-09 14:03:47 +010016 set(MCUBOOT_REPO "UPSTREAM" CACHE STRING "Configure which repository use the MCUBoot from")
David Vinczec3e313a2020-01-06 17:31:11 +010017 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
Balint Matyif0873cd2020-06-09 14:03:47 +010032 #FixMe: These checks can be removed when the upgrade strategies in question are upstreamed to the original MCUBoot repo.
33 if (TARGET_PLATFORM STREQUAL "MUSCA_A" OR TARGET_PLATFORM STREQUAL "AN524")
34 if (MCUBOOT_REPO STREQUAL "UPSTREAM")
35 message(WARNING "The 'UPSTREAM' MCUBoot repository cannot be used when building for ${TARGET_PLATFORM}. Your choice was overridden.")
36 endif()
37 set(MCUBOOT_REPO "TF-M")
38 endif()
39
David Vinczef5c1e062020-03-31 17:05:34 +020040 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 +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()
Balint Matyi2fe04922020-02-18 12:27:38 +000047
David Vincze73dfbc52019-10-11 13:54:58 +020048 validate_cache_value(MCUBOOT_LOG_LEVEL)
49
David Vincze63eda7a2019-08-09 17:42:51 +020050 if ((${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
51 ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING") AND
52 NOT (MCUBOOT_IMAGE_NUMBER EQUAL 1))
53 message(WARNING "The number of separately updatable images with the NO_SWAP or the RAM_LOADING"
54 " upgrade strategy can be only '1'. Your choice was overriden.")
55 set(MCUBOOT_IMAGE_NUMBER 1)
56 endif()
57
David Vinczec3e313a2020-01-06 17:31:11 +010058 if (MCUBOOT_REPO STREQUAL "UPSTREAM")
59 set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP")
60 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
61 ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
62 message(WARNING "The ${MCUBOOT_UPGRADE_STRATEGY} upgrade strategy cannot be used when building against"
63 " upstream MCUBoot. Your choice was overriden.")
64 mcuboot_override_upgrade_strategy("OVERWRITE_ONLY")
65 endif()
David Vinczec3e313a2020-01-06 17:31:11 +010066 endif()
67
David Vincze54d05552019-08-05 12:58:47 +020068else() #BL2 is turned off
David Vincze63eda7a2019-08-09 17:42:51 +020069
70 if (DEFINED MCUBOOT_IMAGE_NUMBER OR
71 DEFINED MCUBOOT_UPGRADE_STRATEGY OR
Tamas Band0f4e1d2019-07-11 09:39:03 +010072 DEFINED MCUBOOT_SIGNATURE_TYPE OR
David Vincze73dfbc52019-10-11 13:54:58 +020073 DEFINED MCUBOOT_HW_KEY OR
74 DEFINED MCUBOOT_LOG_LEVEL)
David Vinczec3e313a2020-01-06 17:31:11 +010075 message(WARNING "Ignoring the values of MCUBOOT_* variables as BL2 option is set to False.")
76 set(MCUBOOT_IMAGE_NUMBER "")
77 set(MCUBOOT_UPGRADE_STRATEGY "")
78 set(MCUBOOT_SIGNATURE_TYPE "")
79 set(MCUBOOT_HW_KEY "")
80 set(MCUBOOT_LOG_LEVEL "")
David Vincze54d05552019-08-05 12:58:47 +020081 endif()
82
David Vinczed8fbe0e2019-08-12 15:58:57 +020083 if (DEFINED SECURITY_COUNTER OR
84 DEFINED SECURITY_COUNTER_S OR
85 DEFINED SECURITY_COUNTER_NS)
David Vinczec3e313a2020-01-06 17:31:11 +010086 message(WARNING "Ignoring the values of SECURITY_COUNTER and/or SECURITY_COUNTER_* variables as BL2 option is set to False.")
87 set(SECURITY_COUNTER "")
88 set(SECURITY_COUNTER_S "")
89 set(SECURITY_COUNTER_NS "")
David Vinczed8fbe0e2019-08-12 15:58:57 +020090 endif()
91
92 if (DEFINED IMAGE_VERSION OR
93 DEFINED IMAGE_VERSION_S OR
94 DEFINED IMAGE_VERSION_NS)
David Vinczec3e313a2020-01-06 17:31:11 +010095 message(WARNING "Ignoring the values of IMAGE_VERSION and/or IMAGE_VERSION_* variables as BL2 option is set to False.")
96 set(IMAGE_VERSION "")
97 set(IMAGE_VERSION_S "")
98 set(IMAGE_VERSION_NS "")
David Vincze54d05552019-08-05 12:58:47 +020099 endif()
David Vincze9ec0f542019-07-03 18:09:47 +0200100 if (DEFINED S_IMAGE_MIN_VER OR
101 DEFINED NS_IMAGE_MIN_VER)
David Vinczec3e313a2020-01-06 17:31:11 +0100102 message(WARNING "Ignoring the values of *_IMAGE_MIN_VER variables as BL2 option is set to False.")
103 set(S_IMAGE_MIN_VER "")
104 set(NS_IMAGE_MIN_VER "")
David Vincze9ec0f542019-07-03 18:09:47 +0200105 endif()
David Vincze54d05552019-08-05 12:58:47 +0200106endif()