Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
David Vincze | db32b21 | 2019-04-16 17:43:57 +0200 | [diff] [blame] | 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
| 10 | function(mcuboot_create_boot_payload) |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 11 | set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 12 | set( _ONE_VALUE_ARGS S_BIN NS_BIN FULL_BIN SIGN_BIN POSTFIX) #Single option arguments (e.g. PATH "./foo/bar") |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 13 | set( _MULTI_VALUE_ARGS) #List arguments (e.g. LANGUAGES C ASM CXX) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 14 | cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN}) |
| 15 | |
| 16 | if (NOT DEFINED _MY_PARAMS_S_BIN) |
| 17 | message(FATAL_ERROR "mcuboot_create_boot_payload(): mandatory parameter 'S_BIN' missing.") |
| 18 | endif() |
| 19 | |
| 20 | if (NOT DEFINED _MY_PARAMS_NS_BIN) |
| 21 | message(FATAL_ERROR "mcuboot_create_boot_payload(): mandatory parameter 'NS_BIN' missing.") |
| 22 | endif() |
| 23 | |
| 24 | if (NOT DEFINED _MY_PARAMS_FULL_BIN) |
| 25 | message(FATAL_ERROR "mcuboot_create_boot_payload(): mandatory parameter 'FULL_BIN' missing.") |
| 26 | endif() |
| 27 | |
| 28 | if (NOT DEFINED _MY_PARAMS_SIGN_BIN) |
| 29 | message(FATAL_ERROR "mcuboot_create_boot_payload(): mandatory parameter 'SIGN_BIN' missing.") |
| 30 | endif() |
| 31 | |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 32 | if (DEFINED _MY_PARAMS_POSTFIX) |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 33 | if (${_MY_PARAMS_POSTFIX} STREQUAL "_1") |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 34 | set(MY_POSTFIX "1") |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 35 | else() |
| 36 | message(FATAL_ERROR "Unknown artefacts postfix: ${_MY_PARAMS_POSTFIX}") |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 37 | endif() |
| 38 | endif() |
| 39 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 40 | #Find Python3.x interpreter |
| 41 | find_package(PythonInterp 3) |
| 42 | if (NOT PYTHONINTERP_FOUND) |
| 43 | message(FATAL_ERROR "Failed to find Python3.x interpreter. Pyhton3 must be installed and available on the PATH.") |
| 44 | endif() |
| 45 | |
| 46 | if(NOT DEFINED FLASH_LAYOUT) |
| 47 | message(FATAL_ERROR "ERROR: Incomplete Configuration: FLASH_LAYOUT is not defined.") |
| 48 | endif() |
| 49 | |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 50 | if (MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-3072") |
Tamas Ban | 78676ac | 2019-07-11 09:05:54 +0100 | [diff] [blame^] | 51 | set(KEY_FILE "${MCUBOOT_DIR}/root-rsa-3072.pem") |
| 52 | set(KEY_FILE_S "${MCUBOOT_DIR}/root-rsa-3072.pem") |
| 53 | set(KEY_FILE_NS "${MCUBOOT_DIR}/root-rsa-3072_1.pem") |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 54 | elseif(MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-2048") |
Tamas Ban | 78676ac | 2019-07-11 09:05:54 +0100 | [diff] [blame^] | 55 | set(KEY_FILE "${MCUBOOT_DIR}/root-rsa-2048.pem") |
| 56 | set(KEY_FILE_S "${MCUBOOT_DIR}/root-rsa-2048.pem") |
| 57 | set(KEY_FILE_NS "${MCUBOOT_DIR}/root-rsa-2048_1.pem") |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 58 | else() |
| 59 | message(FATAL_ERROR "${MCUBOOT_SIGNATURE_TYPE} is not supported as firmware signing algorithm") |
| 60 | endif() |
| 61 | |
Tamas Ban | d0f4e1d | 2019-07-11 09:39:03 +0100 | [diff] [blame] | 62 | #Configure in which format (full or hash) include the public key to the image manifest |
| 63 | # |
| 64 | #|-----------------------|-----------------------|-------------------|--------------------| |
| 65 | #| |Key format in manifest |Key in MCUBoot code| Key in HW | |
| 66 | #|-----------------------|-----------------------|-------------------|--------------------| |
| 67 | #|MCUBOOT_HW_KEY == On | Full public key | No key embedded | Hash of public key | |
| 68 | #|-----------------------|-----------------------|-------------------|--------------------| |
| 69 | #|MCUBOOT_HW_KEY == Off | Hash of public key | Full public key | No key in HW | |
| 70 | #|-----------------------|-----------------------|-------------------|--------------------| |
| 71 | if (MCUBOOT_HW_KEY) |
| 72 | set(PUBLIC_KEY_FORMAT "full") |
| 73 | else() |
| 74 | set(PUBLIC_KEY_FORMAT "hash") |
| 75 | endif() |
| 76 | |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 77 | set(PARTIAL_CONTENT_FOR_PREPROCESSING "#include \"${FLASH_LAYOUT}\"\n\n" |
Sverteczky, Marcell | 7d069e8 | 2019-07-04 18:17:33 +0200 | [diff] [blame] | 78 | "/* Enumeration that is used by the assemble.py and imgtool.py scripts\n" |
| 79 | " * for correct binary generation when nested macros are used\n" |
| 80 | " */\n" |
Sverteczky, Marcell | 4b78a4b | 2019-06-03 14:17:10 +0200 | [diff] [blame] | 81 | "enum image_attributes {\n" |
| 82 | "\tRE_SECURE_IMAGE_OFFSET = SECURE_IMAGE_OFFSET,\n" |
| 83 | "\tRE_SECURE_IMAGE_MAX_SIZE = SECURE_IMAGE_MAX_SIZE,\n" |
| 84 | "\tRE_NON_SECURE_IMAGE_OFFSET = NON_SECURE_IMAGE_OFFSET,\n" |
Sverteczky, Marcell | 7d069e8 | 2019-07-04 18:17:33 +0200 | [diff] [blame] | 85 | "\tRE_NON_SECURE_IMAGE_MAX_SIZE = NON_SECURE_IMAGE_MAX_SIZE,\n" |
| 86 | "#ifdef IMAGE_LOAD_ADDRESS\n" |
| 87 | "\tRE_IMAGE_LOAD_ADDRESS = IMAGE_LOAD_ADDRESS,\n" |
| 88 | "#endif\n" |
Sverteczky, Marcell | 4b78a4b | 2019-06-03 14:17:10 +0200 | [diff] [blame] | 89 | ) |
| 90 | |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 91 | if (MCUBOOT_IMAGE_NUMBER GREATER 1) |
| 92 | if (SECURITY_COUNTER_S) |
| 93 | set(ADD_SECURITY_COUNTER_S "-s ${SECURITY_COUNTER_S}") |
| 94 | else() |
| 95 | set(ADD_SECURITY_COUNTER_S "") |
| 96 | endif() |
| 97 | if (SECURITY_COUNTER_NS) |
| 98 | set(ADD_SECURITY_COUNTER_NS "-s ${SECURITY_COUNTER_NS}") |
| 99 | else() |
| 100 | set(ADD_SECURITY_COUNTER_NS "") |
| 101 | endif() |
| 102 | if (DEFINED SECURITY_COUNTER) |
| 103 | message(WARNING "In case of multiple updatable images the security counter value can be specified" |
| 104 | " for the Secure and Non-secure images separately with the SECURITY_COUNTER_S and SECURITY_COUNTER_NS" |
| 105 | " defines. The value of SECURITY_COUNTER was ignored.") |
| 106 | set(SECURITY_COUNTER "") |
| 107 | endif() |
| 108 | |
| 109 | if (NOT IMAGE_VERSION_S) |
| 110 | set(IMAGE_VERSION_S 0.0.0+0) |
| 111 | endif() |
| 112 | if (NOT IMAGE_VERSION_NS) |
| 113 | set(IMAGE_VERSION_NS 0.0.0+0) |
| 114 | endif() |
| 115 | if (DEFINED IMAGE_VERSION) |
| 116 | message(WARNING "In case of multiple updatable images the image version can be specified" |
| 117 | " for the Secure and Non-secure images separately with the IMAGE_VERSION_S and IMAGE_VERSION_NS" |
| 118 | " defines. The value of IMAGE_VERSION was ignored.") |
| 119 | set(IMAGE_VERSION "") |
| 120 | endif() |
| 121 | |
David Vincze | 9ec0f54 | 2019-07-03 18:09:47 +0200 | [diff] [blame] | 122 | if (S_IMAGE_MIN_VER) |
| 123 | set(ADD_S_IMAGE_MIN_VER "-d \"(0,${S_IMAGE_MIN_VER})\"") |
| 124 | else() |
| 125 | set(ADD_S_IMAGE_MIN_VER "") |
| 126 | endif() |
| 127 | if (NS_IMAGE_MIN_VER) |
| 128 | set(ADD_NS_IMAGE_MIN_VER "-d \"(1,${NS_IMAGE_MIN_VER})\"") |
| 129 | else() |
| 130 | set(ADD_NS_IMAGE_MIN_VER "") |
| 131 | endif() |
| 132 | |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 133 | set(FILE_TO_PREPROCESS ${CMAKE_BINARY_DIR}/image_macros_to_preprocess) |
| 134 | set(PREPROCESSED_FILE ${CMAKE_BINARY_DIR}/image_macros_preprocessed) |
| 135 | |
| 136 | #Create files that will be preprocessed later in order to be able to handle |
| 137 | # nested macros in header files for certain macros |
| 138 | string(CONCAT CONTENT_FOR_PREPROCESSING ${PARTIAL_CONTENT_FOR_PREPROCESSING} |
| 139 | "\tRE_SIGN_BIN_SIZE = FLASH_AREA_0_SIZE,\n}\;") |
| 140 | file(WRITE ${FILE_TO_PREPROCESS}_s.c ${CONTENT_FOR_PREPROCESSING}) |
| 141 | string(CONCAT CONTENT_FOR_PREPROCESSING ${PARTIAL_CONTENT_FOR_PREPROCESSING} |
| 142 | "\tRE_SIGN_BIN_SIZE = FLASH_AREA_1_SIZE,\n}\;") |
| 143 | file(WRITE ${FILE_TO_PREPROCESS}_ns.c ${CONTENT_FOR_PREPROCESSING}) |
| 144 | |
| 145 | #Preprocess the _s.c file that contains the secure image related macros |
| 146 | compiler_preprocess_file(SRC ${FILE_TO_PREPROCESS}_s.c |
| 147 | DST ${PREPROCESSED_FILE}_s.c |
| 148 | BEFORE_TARGET ${_MY_PARAMS_S_BIN} |
| 149 | TARGET_PREFIX ${_MY_PARAMS_S_BIN} |
| 150 | DEFINES "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}") |
| 151 | |
| 152 | #Preprocess the _ns.c file that contains the non-secure image related macros |
| 153 | compiler_preprocess_file(SRC ${FILE_TO_PREPROCESS}_ns.c |
| 154 | DST ${PREPROCESSED_FILE}_ns.c |
| 155 | BEFORE_TARGET ${_MY_PARAMS_NS_BIN} |
| 156 | TARGET_PREFIX ${_MY_PARAMS_NS_BIN} |
| 157 | DEFINES "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}") |
| 158 | |
| 159 | add_custom_command(TARGET ${_MY_PARAMS_NS_BIN} |
| 160 | POST_BUILD |
| 161 | |
| 162 | #Sign secure binary image with default public key in mcuboot folder |
| 163 | COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/imgtool.py |
| 164 | ARGS sign |
| 165 | --layout ${PREPROCESSED_FILE}_s.c |
Tamas Ban | 78676ac | 2019-07-11 09:05:54 +0100 | [diff] [blame^] | 166 | -k ${KEY_FILE_S} |
Tamas Ban | d0f4e1d | 2019-07-11 09:39:03 +0100 | [diff] [blame] | 167 | --public-key-format ${PUBLIC_KEY_FORMAT} |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 168 | --align 1 |
| 169 | -v ${IMAGE_VERSION_S} |
David Vincze | 9ec0f54 | 2019-07-03 18:09:47 +0200 | [diff] [blame] | 170 | ${ADD_NS_IMAGE_MIN_VER} |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 171 | ${ADD_SECURITY_COUNTER_S} |
| 172 | -H 0x400 |
| 173 | $<TARGET_FILE_DIR:${_MY_PARAMS_S_BIN}>/${_MY_PARAMS_S_BIN}.bin |
| 174 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_S_BIN}_signed.bin |
| 175 | |
| 176 | #Sign non-secure binary image with default public key in mcuboot folder |
| 177 | COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/imgtool.py |
| 178 | ARGS sign |
| 179 | --layout ${PREPROCESSED_FILE}_ns.c |
Tamas Ban | 78676ac | 2019-07-11 09:05:54 +0100 | [diff] [blame^] | 180 | -k ${KEY_FILE_NS} |
Tamas Ban | d0f4e1d | 2019-07-11 09:39:03 +0100 | [diff] [blame] | 181 | --public-key-format ${PUBLIC_KEY_FORMAT} |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 182 | --align 1 |
| 183 | -v ${IMAGE_VERSION_NS} |
David Vincze | 9ec0f54 | 2019-07-03 18:09:47 +0200 | [diff] [blame] | 184 | ${ADD_S_IMAGE_MIN_VER} |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 185 | ${ADD_SECURITY_COUNTER_NS} |
| 186 | -H 0x400 |
| 187 | $<TARGET_FILE_DIR:${_MY_PARAMS_NS_BIN}>/${_MY_PARAMS_NS_BIN}.bin |
| 188 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_NS_BIN}_signed.bin |
| 189 | |
| 190 | #Create concatenated binary image from the two independently signed binary file |
| 191 | COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/assemble.py |
| 192 | ARGS --layout ${PREPROCESSED_FILE}_s.c |
| 193 | -s ${CMAKE_BINARY_DIR}/${_MY_PARAMS_S_BIN}_signed.bin |
| 194 | -n ${CMAKE_BINARY_DIR}/${_MY_PARAMS_NS_BIN}_signed.bin |
| 195 | -o ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin) |
| 196 | |
| 197 | else() # MCUBOOT_IMAGE_NUMBER = 1 |
| 198 | if (SECURITY_COUNTER) |
| 199 | set(ADD_SECURITY_COUNTER "-s ${SECURITY_COUNTER}") |
| 200 | else() |
| 201 | set(ADD_SECURITY_COUNTER "") |
| 202 | endif() |
| 203 | if (DEFINED SECURITY_COUNTER_S OR |
| 204 | DEFINED SECURITY_COUNTER_NS) |
| 205 | message(WARNING "In case of a single updatable image the security counter value can be specified with" |
| 206 | " the SECURITY_COUNTER define. The values of SECURITY_COUNTER_S and/or SECURITY_COUNTER_NS were ignored.") |
| 207 | set(SECURITY_COUNTER_S "") |
| 208 | set(SECURITY_COUNTER_NS "") |
| 209 | endif() |
| 210 | |
| 211 | if (NOT IMAGE_VERSION) |
| 212 | set(IMAGE_VERSION 0.0.0+0) |
| 213 | endif() |
| 214 | if (DEFINED IMAGE_VERSION_S OR |
| 215 | DEFINED IMAGE_VERSION_NS) |
| 216 | message(WARNING "In case of a single updatable image the image version can be specified with" |
| 217 | " the IMAGE_VERSION define. The values of IMAGE_VERSION_S and/or IMAGE_VERSION_NS were ignored.") |
| 218 | set(IMAGE_VERSION_S "") |
| 219 | set(IMAGE_VERSION_NS "") |
| 220 | endif() |
| 221 | |
David Vincze | 9ec0f54 | 2019-07-03 18:09:47 +0200 | [diff] [blame] | 222 | if (DEFINED S_IMAGE_MIN_VER OR |
| 223 | DEFINED NS_IMAGE_MIN_VER) |
| 224 | message(WARNING "WARNING: In case of a single updatable image a dependency cannot be specified between" |
| 225 | " the S and NS images. The S_IMAGE_MIN_VER and/or NS_IMAGE_MIN_VER defines were ignored.") |
| 226 | set(S_IMAGE_MIN_VER "") |
| 227 | set(NS_IMAGE_MIN_VER "") |
| 228 | endif() |
| 229 | |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 230 | set(FILE_TO_PREPROCESS ${CMAKE_BINARY_DIR}/image_macros_to_preprocess.c) |
| 231 | set(PREPROCESSED_FILE ${CMAKE_BINARY_DIR}/image_macros_preprocessed.c) |
| 232 | string(CONCAT CONTENT_FOR_PREPROCESSING ${PARTIAL_CONTENT_FOR_PREPROCESSING} |
| 233 | "\tRE_SIGN_BIN_SIZE = FLASH_AREA_0_SIZE,\n}\;") |
| 234 | |
Sverteczky, Marcell | 4b78a4b | 2019-06-03 14:17:10 +0200 | [diff] [blame] | 235 | #Create a file that will be preprocessed later in order to be able to handle nested macros |
Sverteczky, Marcell | 7d069e8 | 2019-07-04 18:17:33 +0200 | [diff] [blame] | 236 | #in header files for certain macros |
Sverteczky, Marcell | 4b78a4b | 2019-06-03 14:17:10 +0200 | [diff] [blame] | 237 | file(WRITE ${FILE_TO_PREPROCESS} ${CONTENT_FOR_PREPROCESSING}) |
| 238 | |
| 239 | #Preprocess the .c file that contains the image related macros |
| 240 | compiler_preprocess_file(SRC ${FILE_TO_PREPROCESS} |
| 241 | DST ${PREPROCESSED_FILE} |
| 242 | BEFORE_TARGET ${_MY_PARAMS_NS_BIN} |
David Vincze | 63eda7a | 2019-08-09 17:42:51 +0200 | [diff] [blame] | 243 | TARGET_PREFIX ${_MY_PARAMS_NS_BIN} |
| 244 | DEFINES "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}") |
Sverteczky, Marcell | 4b78a4b | 2019-06-03 14:17:10 +0200 | [diff] [blame] | 245 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 246 | add_custom_command(TARGET ${_MY_PARAMS_NS_BIN} |
| 247 | POST_BUILD |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 248 | #Create concatenated binary image from the two binary file |
| 249 | COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/assemble.py |
Sverteczky, Marcell | 7d069e8 | 2019-07-04 18:17:33 +0200 | [diff] [blame] | 250 | ARGS --layout ${PREPROCESSED_FILE} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 251 | -s $<TARGET_FILE_DIR:${_MY_PARAMS_S_BIN}>/${_MY_PARAMS_S_BIN}.bin |
| 252 | -n $<TARGET_FILE_DIR:${_MY_PARAMS_NS_BIN}>/${_MY_PARAMS_NS_BIN}.bin |
| 253 | -o ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin |
| 254 | |
| 255 | #Sign concatenated binary image with default public key in mcuboot folder |
| 256 | COMMAND ${PYTHON_EXECUTABLE} ${MCUBOOT_DIR}/scripts/imgtool.py |
| 257 | ARGS sign |
Sverteczky, Marcell | 7d069e8 | 2019-07-04 18:17:33 +0200 | [diff] [blame] | 258 | --layout ${PREPROCESSED_FILE} |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 259 | -k ${KEY_FILE} |
Tamas Ban | d0f4e1d | 2019-07-11 09:39:03 +0100 | [diff] [blame] | 260 | --public-key-format ${PUBLIC_KEY_FORMAT} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 261 | --align 1 |
Oliver Swede | 2144044 | 2018-07-10 09:31:32 +0100 | [diff] [blame] | 262 | -v ${IMAGE_VERSION} |
David Vincze | db32b21 | 2019-04-16 17:43:57 +0200 | [diff] [blame] | 263 | ${ADD_SECURITY_COUNTER} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 264 | -H 0x400 |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 265 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin |
| 266 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin) |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 267 | endif() |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 268 | |
| 269 | #Collect executables to common location: build/install/outputs/ |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 270 | set(TFM_SIGN_NAME tfm_s_ns_signed) |
| 271 | |
| 272 | if (DEFINED MY_POSTFIX) |
| 273 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin |
| 274 | RENAME tfm_sig${MY_POSTFIX}.bin |
| 275 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 276 | else() |
| 277 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin |
| 278 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 279 | endif() |
| 280 | |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 281 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_SIGN_BIN}.bin |
| 282 | RENAME ${TFM_SIGN_NAME}${_MY_PARAMS_POSTFIX}.bin |
| 283 | DESTINATION outputs/fvp/) |
David Vincze | d8fbe0e | 2019-08-12 15:58:57 +0200 | [diff] [blame] | 284 | |
| 285 | if (MCUBOOT_IMAGE_NUMBER GREATER 1) |
| 286 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_S_BIN}_signed.bin |
| 287 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_NS_BIN}_signed.bin |
| 288 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 289 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_S_BIN}_signed.bin |
| 290 | ${CMAKE_BINARY_DIR}/${_MY_PARAMS_NS_BIN}_signed.bin |
| 291 | DESTINATION outputs/fvp/) |
| 292 | |
| 293 | else() # MCUBOOT_IMAGE_NUMBER = 1 |
| 294 | set(TFM_FULL_NAME tfm_s_ns_concatenated) |
| 295 | |
| 296 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin |
| 297 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 298 | install(FILES ${CMAKE_BINARY_DIR}/${_MY_PARAMS_FULL_BIN}.bin |
| 299 | RENAME ${TFM_FULL_NAME}${_MY_PARAMS_POSTFIX}.bin |
| 300 | DESTINATION outputs/fvp/) |
| 301 | endif() |
David Vincze | db32b21 | 2019-04-16 17:43:57 +0200 | [diff] [blame] | 302 | endfunction() |
David Vincze | 63eda7a | 2019-08-09 17:42:51 +0200 | [diff] [blame] | 303 | |
| 304 | #Validate and override the upgrade strategy to be used by the bootloader. |
| 305 | # |
| 306 | # If the given upgrade strategy is not supported with the current value |
| 307 | # of the MCUBOOT_IMAGE_NUMBER variable then the function will override its |
| 308 | # previously set value. |
| 309 | # |
| 310 | #Examples: |
| 311 | # mcuboot_override_upgrade_strategy("SWAP") |
| 312 | # |
| 313 | #INPUTS: |
| 314 | # strategy - (mandatory) - Upgrade strategy to be used. |
| 315 | # |
| 316 | #OUTPUTS: |
| 317 | # MCUBOOT_UPGRADE_STRATEGY variable is set to the new strategy. |
| 318 | # |
| 319 | function(mcuboot_override_upgrade_strategy strategy) |
| 320 | if ((${strategy} STREQUAL "NO_SWAP" OR |
| 321 | ${strategy} STREQUAL "RAM_LOADING") AND |
| 322 | NOT (MCUBOOT_IMAGE_NUMBER EQUAL 1)) |
| 323 | message(WARNING "The number of separately updatable images with the NO_SWAP or the RAM_LOADING" |
| 324 | " upgrade strategy can be only '1'. Your choice was overriden.") |
| 325 | set(MCUBOOT_IMAGE_NUMBER 1 PARENT_SCOPE) |
| 326 | endif() |
| 327 | get_property(_validation_list CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS) |
| 328 | #Check if validation list is set. |
| 329 | if (NOT _validation_list) |
| 330 | #Set the default upgrade strategy if the CACHE variable has not been set yet. |
| 331 | set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Configure BL2 which upgrade strategy to use") |
| 332 | set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING") |
| 333 | endif() |
| 334 | set(MCUBOOT_UPGRADE_STRATEGY ${strategy} PARENT_SCOPE) |
| 335 | validate_cache_value(MCUBOOT_UPGRADE_STRATEGY STRINGS) |
| 336 | endfunction() |