1#-------------------------------------------------------------------------------
2# Copyright (c) 2023-2024, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8menuconfig BL2
9    bool "BL2"
10    default y
11
12if BL2
13
14config DEFAULT_MCUBOOT_SECURITY_COUNTERS
15    bool "Use the default security counter configuration"
16    default y
17    help
18      Use the default security counter configuration defined by TF-M project
19
20config DEFAULT_MCUBOOT_FLASH_MAP
21    bool "Use the default flash map"
22    default y
23    help
24      Whether to use the default flash map defined by TF-M project
25
26config MCUBOOT_S_IMAGE_FLASH_AREA_NUM
27    int "ID of the flash area containing the primary Secure image"
28    default 0
29    help
30      ID of the flash area containing the primary Secure image
31
32config MCUBOOT_NS_IMAGE_FLASH_AREA_NUM
33    int "ID of the flash area containing the primary Non-Secure image"
34    default 1
35
36config MCUBOOT_IMAGE_NUMBER
37    int "Whether to combine S and NS into either 1 image, or sign each seperately"
38    default 2
39    range 1 9
40
41config MCUBOOT_EXECUTION_SLOT
42    int "Slot from which to execute the image, used for XIP mode"
43    default 1
44
45config MCUBOOT_USE_PSA_CRYPTO
46    bool "Enable cryptography through PSA Crypto APIs"
47    default n
48
49choice
50    prompt "Hardware key options for signature verification"
51    optional
52
53config MCUBOOT_HW_KEY
54    bool "Embed the entire public key"
55    default y
56    help
57      Whether to embed the entire public key in the image metadata instead of
58      the hash only
59
60config MCUBOOT_BUILTIN_KEY
61    bool "Use builtin key(s) for verification"
62    default n
63    help
64      No public key data is in the image metadata or boot code, key IDs
65      are used instead to select a builtin key for signature verification.
66endchoice
67
68choice
69    prompt "Upgrade strategy for images"
70    default MCUBOOT_UPGRADE_STRATEGY_OVERWRITE_ONLY
71
72    config MCUBOOT_UPGRADE_STRATEGY_OVERWRITE_ONLY
73        bool "Overwrite only"
74
75    config MCUBOOT_UPGRADE_STRATEGY_SWAP_USING_SCRATCH
76        bool "Swap using scratch"
77        imply FWU_SUPPORT_TRIAL_STATE
78
79    config MCUBOOT_UPGRADE_STRATEGY_SWAP_USING_MOVE
80        bool "Swap using move"
81        imply FWU_SUPPORT_TRIAL_STATE
82
83    config MCUBOOT_UPGRADE_STRATEGY_DIRECT_XIP
84        bool "Direct xip"
85        depends on !TFM_PARTITION_FIRMWARE_UPDATE
86
87    config MCUBOOT_UPGRADE_STRATEGY_RAM_LOAD
88        bool "Ram load"
89        depends on !TFM_PARTITION_FIRMWARE_UPDATE
90endchoice
91
92config MCUBOOT_UPGRADE_STRATEGY
93    string "Upgrade strategy for images"
94    default "OVERWRITE_ONLY" if MCUBOOT_UPGRADE_STRATEGY_OVERWRITE_ONLY
95    default "SWAP_USING_SCRATCH" if MCUBOOT_UPGRADE_STRATEGY_SWAP_USING_SCRATCH
96    default "SWAP_USING_MOVE" if MCUBOOT_UPGRADE_STRATEGY_SWAP_USING_MOVE
97    default "DIRECT_XIP" if MCUBOOT_UPGRADE_STRATEGY_DIRECT_XIP
98    default "RAM_LOAD" if MCUBOOT_UPGRADE_STRATEGY_RAM_LOAD
99
100config BL2_HEADER_SIZE
101    hex "BL2 Header size"
102    default 0x400
103
104config BL2_TRAILER_SIZE
105    hex "BL2 Trailer size"
106    default 0x400
107
108choice
109    prompt "Align option for mcuboot and build image with imgtool"
110    config MCUBOOT_ALIGN_VAL_1
111        bool "1"
112    config MCUBOOT_ALIGN_VAL_2
113        bool "2"
114    config MCUBOOT_ALIGN_VAL_4
115        bool "4"
116    config MCUBOOT_ALIGN_VAL_8
117        bool "8"
118    config MCUBOOT_ALIGN_VAL_16
119        bool "16"
120    config MCUBOOT_ALIGN_VAL_32
121        bool "32"
122endchoice
123
124config MCUBOOT_ALIGN_VAL
125    int
126    default 1 if MCUBOOT_ALIGN_VAL_1
127    default 2 if MCUBOOT_ALIGN_VAL_2
128    default 4 if MCUBOOT_ALIGN_VAL_4
129    default 8 if MCUBOOT_ALIGN_VAL_8
130    default 16 if MCUBOOT_ALIGN_VAL_16
131    default 32 if MCUBOOT_ALIGN_VAL_32
132
133config MCUBOOT_CONFIRM_IMAGE
134    bool "Whether to confirm the image if REVERT is supported in MCUboot"
135    default n
136
137config MCUBOOT_DIRECT_XIP_REVERT
138    bool "Enable the revert mechanism in direct-xip mode"
139    default y
140
141config MCUBOOT_HW_ROLLBACK_PROT
142    bool "Enable security counter validation against non-volatile HW counters"
143    default y
144
145config MCUBOOT_ENC_IMAGES
146    bool "Enable encrypted image upgrade support"
147    default n
148
149config MCUBOOT_BOOTSTRAP
150    bool "Support initial state with empty primary slot and images installed from secondary slots"
151    default n
152
153config MCUBOOT_ENCRYPT_RSA
154    bool "Use RSA for encrypted image upgrade support"
155    default n
156
157choice
158    prompt "Fault injection hardening profile"
159    default MCUBOOT_FIH_PROFILE_OFF
160
161    config MCUBOOT_FIH_PROFILE_OFF
162        bool "OFF"
163
164    config MCUBOOT_FIH_PROFILE_LOW
165        bool "LOW"
166
167    config MCUBOOT_FIH_PROFILE_MEDIUM
168        bool "MEDIUM"
169
170    config MCUBOOT_FIH_PROFILE_HIGH
171        bool "HIGH"
172endchoice
173
174config MCUBOOT_FIH_PROFILE
175    string
176    default "OFF" if MCUBOOT_FIH_PROFILE_OFF
177    default "LOW" if MCUBOOT_FIH_PROFILE_LOW
178    default "MEDIUM" if MCUBOOT_FIH_PROFILE_MEDIUM
179    default "HIGH" if MCUBOOT_FIH_PROFILE_HIGH
180
181config MCUBOOT_SIGNATURE_TYPE
182    string "Algorithm to use for signature validation [RSA-2048, RSA-3072, EC-P256, EC-P384]"
183    default "RSA-3072"
184    help
185      Note - If either SIGNATURE_TYPE or KEY_LEN are changed, the entries for KEY_S
186      and KEY_NS will either have to be updated manually or removed from the cache.
187      `cmake .. -UMCUBOOT_KEY_S -UMCUBOOT_KEY_NS`. Once removed from the cache it
188      will be set to default again.
189
190config MCUBOOT_GENERATE_SIGNING_KEYPAIR
191    bool "Generate new keypair or use MCUBOOT_KEY_S and MCUBOOT_KEY_NS for signing"
192    default n
193
194config MCUBOOT_KEY_S
195    string "Path to key with which to sign secure binary"
196    default "$(TFM_SOURCE_DIR)/bl2/ext/mcuboot/root-${MCUBOOT_SIGNATURE_TYPE}.pem"
197
198config MCUBOOT_KEY_NS
199    string "Path to key with which to sign non-secure binary"
200    default "$(TFM_SOURCE_DIR)/bl2/ext/mcuboot/root-${MCUBOOT_SIGNATURE_TYPE}_1.pem"
201
202config MCUBOOT_IMAGE_VERSION_S
203    string "Version number of S image"
204    default "${TFM_VERSION}"
205
206config MCUBOOT_IMAGE_VERSION_NS
207    string "Version number of NS image"
208    default "0.0.0"
209
210config MCUBOOT_SECURITY_COUNTER_S
211    int "Security counter for S image. auto sets it to IMAGE_VERSION_S"
212    default 1
213
214config MCUBOOT_SECURITY_COUNTER_NS
215    int "Security counter for NS image. auto sets it to IMAGE_VERSION_NS"
216    default 1
217
218config MCUBOOT_S_IMAGE_MIN_VER
219    string "Minimum version of secure image"
220    default "0.0.0+0"
221    help
222      Minimum version of secure image required by the non-secure image for
223      upgrade to this non-secure image. If MCUBOOT_IMAGE_NUMBER == 1 this
224      option has no effect
225
226config MCUBOOT_NS_IMAGE_MIN_VER
227    string "Minimum version of non-secure image"
228    default "0.0.0+0"
229    help
230      Minimum version of non-secure image required by the secure image for
231      upgrade to this secure image. If MCUBOOT_IMAGE_NUMBER == 1 this option
232      has no effect
233
234config MCUBOOT_ENC_KEY_LEN
235    int "Length of the AES key for encrypting images"
236    default 128
237
238config MCUBOOT_MBEDCRYPTO_CONFIG_FILEPATH
239    string "Mbedtls config file to use with MCUboot"
240    default "$(TFM_SOURCE_DIR)/bl2/ext/mcuboot/config/mcuboot-mbedtls-cfg.h"
241
242choice
243    prompt "MCUBoot Log Level"
244    default MCUBOOT_LOG_LEVEL_INFO
245
246    config MCUBOOT_LOG_LEVEL_DEBUG
247        bool "Debug"
248    config MCUBOOT_LOG_LEVEL_INFO
249        bool "Info"
250    config MCUBOOT_LOG_LEVEL_WARNING
251        bool "Warning"
252    config MCUBOOT_LOG_LEVEL_ERROR
253        bool "Error"
254    config MCUBOOT_LOG_LEVEL_OFF
255        bool "Off"
256endchoice
257
258config MCUBOOT_LOG_LEVEL
259    string
260    default "DEBUG" if MCUBOOT_LOG_LEVEL_DEBUG
261    default "INFO" if MCUBOOT_LOG_LEVEL_INFO
262    default "WARNING" if MCUBOOT_LOG_LEVEL_WARNING
263    default "ERROR" if MCUBOOT_LOG_LEVEL_ERROR
264    default "OFF" if MCUBOOT_LOG_LEVEL_OFF
265endif
266