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