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