blob: 183bb500ea18ce5d536afcea995a85420e7f4011 [file] [log] [blame]
David Vincze03368b82020-04-01 12:53:53 +02001# Copyright (c) 2017-2020 Linaro Limited
David Vinczec3084132020-02-18 14:50:47 +01002# Copyright (c) 2020 Arm Limited
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +02003#
4# SPDX-License-Identifier: Apache-2.0
5#
6
Marti Bolivar0e091c92018-04-12 11:23:16 -04007mainmenu "MCUboot configuration"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +02008
Marti Bolivar0e091c92018-04-12 11:23:16 -04009comment "MCUboot-specific configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +020010
Emanuele Di Santo865777d2018-11-08 11:28:15 +010011# Hidden option to mark a project as MCUboot
12config MCUBOOT
13 default y
14 bool
Rajavardhan Gundi07ba28f2018-12-10 15:44:48 +053015 select MPU_ALLOW_FLASH_WRITE if ARM_MPU
Marcin Niestrojc6be76a2020-03-22 14:39:35 +010016 select USE_DT_CODE_PARTITION if HAS_FLASH_LOAD_OFFSET
Andrzej Puzdrowskif573b392020-11-10 14:35:15 +010017 select MCUBOOT_BOOTUTIL_LIB
Emanuele Di Santo865777d2018-11-08 11:28:15 +010018
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040019config BOOT_USE_MBEDTLS
20 bool
21 # Hidden option
22 default n
23 help
24 Use mbedTLS for crypto primitives.
25
26config BOOT_USE_TINYCRYPT
27 bool
28 # Hidden option
29 default n
Sebastian Bøe913a3852019-01-22 13:53:12 +010030 # When building for ECDSA, we use our own copy of mbedTLS, so the
31 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
32 # will collide.
Jamie McCrae47b34362023-11-21 10:38:41 +000033 select MBEDTLS_PROMPTLESS
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040034 help
35 Use TinyCrypt for crypto primitives.
36
Sigvart Hovlandebd05032019-03-21 10:47:32 +010037config BOOT_USE_CC310
38 bool
39 # Hidden option
40 default n
41 # When building for ECDSA, we use our own copy of mbedTLS, so the
42 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
43 # will collide.
Sigvart Hovlandebd05032019-03-21 10:47:32 +010044 help
45 Use cc310 for crypto primitives.
46
47config BOOT_USE_NRF_CC310_BL
48 bool
49 default n
50
51config NRFXLIB_CRYPTO
52 bool
53 default n
54
55config NRF_CC310_BL
56 bool
57 default n
58
Andrzej Puzdrowski97543282018-04-12 15:16:56 +020059menu "MCUBoot settings"
60
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020061config SINGLE_APPLICATION_SLOT
62 bool "Single slot bootloader"
Dominik Ermel4dc3f442020-05-26 08:45:14 +000063 default n
64 help
65 Single image area is used for application which means that
66 uploading a new application overwrites the one that previously
67 occupied the area.
68
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +000069choice BOOT_SIGNATURE_TYPE
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040070 prompt "Signature type"
71 default BOOT_SIGNATURE_TYPE_RSA
72
Arvin Farahmandfb5ec182020-05-05 11:44:12 -040073config BOOT_SIGNATURE_TYPE_NONE
74 bool "No signature; use only hash check"
75 select BOOT_USE_TINYCRYPT
76
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040077config BOOT_SIGNATURE_TYPE_RSA
78 bool "RSA signatures"
79 select BOOT_USE_MBEDTLS
Marti Bolivara4818a52018-04-12 13:02:38 -040080 select MBEDTLS
Jamie McCrae25d2f2c2023-07-17 14:17:53 +010081 select BOOT_ENCRYPTION_SUPPORT
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040082
Fabio Utzig105b59a2019-05-13 15:08:12 -070083if BOOT_SIGNATURE_TYPE_RSA
84config BOOT_SIGNATURE_TYPE_RSA_LEN
85 int "RSA signature length"
86 range 2048 3072
87 default 2048
88endif
89
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040090config BOOT_SIGNATURE_TYPE_ECDSA_P256
91 bool "Elliptic curve digital signatures with curve P-256"
Jamie McCrae25d2f2c2023-07-17 14:17:53 +010092 select BOOT_ENCRYPTION_SUPPORT
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040093
Sigvart Hovlandebd05032019-03-21 10:47:32 +010094if BOOT_SIGNATURE_TYPE_ECDSA_P256
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +000095choice BOOT_ECDSA_IMPLEMENTATION
Sigvart Hovlandebd05032019-03-21 10:47:32 +010096 prompt "Ecdsa implementation"
Fabio Utzig34e93a52020-02-03 09:59:53 -030097 default BOOT_ECDSA_TINYCRYPT
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +000098
Fabio Utzig34e93a52020-02-03 09:59:53 -030099config BOOT_ECDSA_TINYCRYPT
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100100 bool "Use tinycrypt"
101 select BOOT_USE_TINYCRYPT
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000102
103config BOOT_ECDSA_CC310
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100104 bool "Use CC310"
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000105 depends on HAS_HW_NRF_CC310
106 select BOOT_USE_NRF_CC310_BL
107 select NRF_CC310_BL
108 select NRFXLIB_CRYPTO
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100109 select BOOT_USE_CC310
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000110endchoice # Ecdsa implementation
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100111endif
Fabio Utzig34e93a52020-02-03 09:59:53 -0300112
113config BOOT_SIGNATURE_TYPE_ED25519
114 bool "Edwards curve digital signatures using ed25519"
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100115 select BOOT_ENCRYPTION_SUPPORT
Fabio Utzig34e93a52020-02-03 09:59:53 -0300116
117if BOOT_SIGNATURE_TYPE_ED25519
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000118choice BOOT_ED25519_IMPLEMENTATION
Fabio Utzig34e93a52020-02-03 09:59:53 -0300119 prompt "Ecdsa implementation"
120 default BOOT_ED25519_TINYCRYPT
121config BOOT_ED25519_TINYCRYPT
122 bool "Use tinycrypt"
123 select BOOT_USE_TINYCRYPT
124config BOOT_ED25519_MBEDTLS
125 bool "Use mbedTLS"
126 select BOOT_USE_MBEDTLS
127 select MBEDTLS
128endchoice
129endif
130
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400131endchoice
132
Fabio Utzigc690c762018-04-26 10:51:09 -0300133config BOOT_SIGNATURE_KEY_FILE
134 string "PEM key file"
Håkon Øye Amundsen705c6c22020-09-28 09:45:40 +0000135 default "root-ec-p256.pem" if BOOT_SIGNATURE_TYPE_ECDSA_P256
136 default "root-ed25519.pem" if BOOT_SIGNATURE_TYPE_ED25519
137 default "root-rsa-3072.pem" if BOOT_SIGNATURE_TYPE_RSA && BOOT_SIGNATURE_TYPE_RSA_LEN=3072
138 default "root-rsa-2048.pem" if BOOT_SIGNATURE_TYPE_RSA && BOOT_SIGNATURE_TYPE_RSA_LEN=2048
Fabio Utzigc690c762018-04-26 10:51:09 -0300139 default ""
140 help
Marek Pietabdcfc852020-08-04 02:22:55 -0700141 You can use either absolute or relative path.
142 In case relative path is used, the build system assumes that it starts
143 from the directory where the MCUBoot KConfig configuration file is
144 located. If the key file is not there, the build system uses relative
145 path that starts from the MCUBoot repository root directory.
Fabio Utzigc690c762018-04-26 10:51:09 -0300146 The key file will be parsed by imgtool's getpub command and a .c source
147 with the public key information will be written in a format expected by
148 MCUboot.
149
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100150config MCUBOOT_CLEANUP_ARM_CORE
151 bool "Perform core cleanup before chain-load the application"
152 depends on CPU_CORTEX_M
Jamie McCrae9e8eddc2023-02-27 12:51:09 +0000153 default y
Ioannis Glaropoulos518d93a2020-10-22 14:22:14 +0200154 help
155 This option instructs MCUboot to perform a clean-up of a set of
Marcin Niestroj9ced4592023-05-17 14:50:57 +0200156 architecture core HW registers before jumping to the application
Ioannis Glaropoulos518d93a2020-10-22 14:22:14 +0200157 firmware. The clean-up sets these registers to their warm-reset
158 values as specified by the architecture.
159
Jamie McCrae9e8eddc2023-02-27 12:51:09 +0000160 This option is enabled by default to prevent possible problems when
161 booting zephyr (or other) applications whereby e.g. a MPU stack guard
162 may be initialised in RAM which is then used by the application
163 start-up code which can cause a module fault and potentially make the
164 module irrecoverable.
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100165
Marti Bolivara4818a52018-04-12 13:02:38 -0400166config MBEDTLS_CFG_FILE
167 default "mcuboot-mbedtls-cfg.h"
168
David Vincze03368b82020-04-01 12:53:53 +0200169config BOOT_HW_KEY
170 bool "Use HW key for image verification"
171 default n
172 help
173 Use HW key for image verification, otherwise the public key is embedded
174 in MCUBoot. If enabled the public key is appended to the signed image
175 and requires the hash of the public key to be provisioned to the device
176 beforehand.
177
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400178config BOOT_VALIDATE_SLOT0
David Vincze2d736ad2019-02-18 11:50:22 +0100179 bool "Validate image in the primary slot on every boot"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400180 default y
181 help
David Vincze2d736ad2019-02-18 11:50:22 +0100182 If y, the bootloader attempts to validate the signature of the
183 primary slot every boot. This adds the signature check time to
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400184 every boot, but can mitigate against some changes that are
185 able to modify the flash image itself.
186
Wouter Cappellebb7a39d2021-05-03 16:44:44 +0200187config BOOT_VALIDATE_SLOT0_ONCE
188 bool "Validate image in the primary slot just once after after upgrade"
189 depends on !BOOT_VALIDATE_SLOT0 && SINGLE_APPLICATION_SLOT
190 default n
191 help
192 If y, the bootloader attempts to validate the signature of the
193 primary slot only once after an upgrade of the main slot.
194 It caches the result in the magic area, which makes it an unsecure
195 method. This option is usefull for lowering the boot up time for
196 low end devices with as a compromise lowering the security level.
197 If unsure, leave at the default value.
198
David Brown08a30a42022-04-26 14:49:51 -0600199config BOOT_PREFER_SWAP_MOVE
200 bool "Prefer the newer swap move algorithm"
201 default y if SOC_FAMILY_NRF
Thomas Strangeraa217e22022-10-28 21:17:55 +0200202 default y if !$(dt_nodelabel_enabled,scratch_partition)
David Brown08a30a42022-04-26 14:49:51 -0600203 help
204 If y, the BOOT_IMAGE_UPGRADE_MODE will default to using
205 "move" instead of "scratch". This is a separate bool config
206 option, because Kconfig doesn't allow defaults to be
207 overridden in choice options. Most devices should be using
208 swap move.
209
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +0200210if !SINGLE_APPLICATION_SLOT
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000211choice BOOT_IMAGE_UPGRADE_MODE
David Vincze5a6e1812020-06-29 13:34:42 +0200212 prompt "Image upgrade modes"
David Brown08a30a42022-04-26 14:49:51 -0600213 default BOOT_SWAP_USING_MOVE if BOOT_PREFER_SWAP_MOVE
David Vincze5a6e1812020-06-29 13:34:42 +0200214 default BOOT_SWAP_USING_SCRATCH
215
216config BOOT_SWAP_USING_SCRATCH
217 bool "Swap mode that run with the scratch partition"
218 help
219 This is the most conservative swap mode but it can work even on
220 devices with heterogeneous flash page layout.
221
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400222config BOOT_UPGRADE_ONLY
223 bool "Overwrite image updates instead of swapping"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400224 help
David Vincze2d736ad2019-02-18 11:50:22 +0100225 If y, overwrite the primary slot with the upgrade image instead
226 of swapping them. This prevents the fallback recovery, but
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400227 uses a much simpler code path.
228
Fabio Utzigc58842e2019-11-28 10:30:01 -0300229config BOOT_SWAP_USING_MOVE
Fabio Utzigdd2b6802020-01-06 09:10:45 -0300230 bool "Swap mode that can run without a scratch partition"
Fabio Utzigc58842e2019-11-28 10:30:01 -0300231 help
232 If y, the swap upgrade is done in two steps, where first every
233 sector of the primary slot is moved up one sector, then for
234 each sector X in the secondary slot, it is moved to index X in
235 the primary slot, then the sector at X+1 in the primary is
236 moved to index X in the secondary.
237 This allows a swap upgrade without using a scratch partition,
238 but is currently limited to all sectors in both slots being of
239 the same size.
David Vincze5a6e1812020-06-29 13:34:42 +0200240
241config BOOT_DIRECT_XIP
242 bool "Run the latest image directly from its slot"
243 help
244 If y, mcuboot selects the newest valid image based on the image version
245 numbers, thereafter the selected image can run directly from its slot
246 without having to move/copy it into the primary slot. For this reason the
247 images must be linked to be executed from the given image slot. Using this
248 mode results in a simpler code path and smaller code size.
249
Johan Öhmanb5889072022-04-01 09:10:28 +0200250config BOOT_RAM_LOAD
251 bool "RAM load"
252 help
253 If y, mcuboot selects the newest valid image based on the image version
254 numbers, thereafter the selected image is copied to RAM and executed from
255 there. For this reason, the image has to be linked to be executed from RAM.
256 The address that the image is copied to is specified using the load-addr
257 argument to the imgtool.py script which writes it to the image header.
258
David Vincze5a6e1812020-06-29 13:34:42 +0200259endchoice
Fabio Utzigc58842e2019-11-28 10:30:01 -0300260
Johan Öhmanb5889072022-04-01 09:10:28 +0200261# Workaround for not being able to have commas in macro arguments
262DT_CHOSEN_Z_SRAM := zephyr,sram
263
264if BOOT_RAM_LOAD
265config BOOT_IMAGE_EXECUTABLE_RAM_START
266 hex "Boot image executable ram start"
267 default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))
268
269config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
270 int "Boot image executable base size"
271 default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
272endif
273
David Vincze505fba22020-10-22 13:53:29 +0200274config BOOT_DIRECT_XIP_REVERT
275 bool "Enable the revert mechanism in direct-xip mode"
Andrzej Puzdrowski32342e72020-11-18 17:04:44 +0100276 depends on BOOT_DIRECT_XIP
David Vincze505fba22020-10-22 13:53:29 +0200277 default n
278 help
279 If y, enables the revert mechanism in direct-xip similar to the one in
280 swap mode. It requires the trailer magic to be added to the signed image.
281 When a reboot happens without the image being confirmed at runtime, the
282 bootloader considers the image faulty and erases it. After this it will
283 attempt to boot the previous image. The images can also be made permanent
284 (marked as confirmed in advance) just like in swap mode.
285
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200286config BOOT_BOOTSTRAP
Sam Bristowd0ca0ff2019-10-30 20:51:35 +1300287 bool "Bootstrap erased the primary slot from the secondary slot"
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200288 default n
289 help
290 If y, enables bootstraping support. Bootstrapping allows an erased
David Vincze2d736ad2019-02-18 11:50:22 +0100291 primary slot to be initialized from a valid image in the secondary slot.
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200292 If unsure, leave at the default value.
293
Fabio Utzigca8ead22019-12-20 07:06:04 -0300294config BOOT_SWAP_SAVE_ENCTLV
295 bool "Save encrypted key TLVs instead of plaintext keys in swap metadata"
296 default n
297 help
298 If y, instead of saving the encrypted image keys in plaintext in the
299 swap resume metadata, save the encrypted image TLVs. This should be used
300 when there is no security mechanism protecting the data in the primary
301 slot from being dumped. If n is selected (default), the keys are written
302 after being decrypted from the image TLVs and could be read by an
303 attacker who has access to the flash contents of the primary slot (eg
304 JTAG/SWD or primary slot in external flash).
305 If unsure, leave at the default value.
306
David Vincze505fba22020-10-22 13:53:29 +0200307endif # !SINGLE_APPLICATION_SLOT
Fabio Utzigb6f014c2020-04-02 13:25:01 -0300308
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100309config BOOT_ENCRYPTION_SUPPORT
310 bool
311 help
312 Hidden option used to check if image encryption is supported.
313
314config BOOT_ENCRYPT_IMAGE
315 bool "Support for encrypted image updates"
316 depends on BOOT_ENCRYPTION_SUPPORT
317 select BOOT_ENCRYPT_RSA if BOOT_SIGNATURE_TYPE_RSA
318 select BOOT_ENCRYPT_EC256 if BOOT_SIGNATURE_TYPE_ECDSA_P256
319 select BOOT_ENCRYPT_X25519 if BOOT_SIGNATURE_TYPE_ED25519
320 depends on !SINGLE_APPLICATION_SLOT || MCUBOOT_SERIAL
321 help
322 If y, images in the secondary slot can be encrypted and are decrypted
323 on the fly when upgrading to the primary slot, as well as encrypted
324 back when swapping from the primary slot to the secondary slot. The
325 encryption mechanism must match the same type as the signature type,
326 supported types include:
327 - RSA-OAEP (2048 bits).
328 - ECIES using primitives described under "ECIES-P256 encryption" in
329 docs/encrypted_images.md.
330 - ECIES using primitives described under "ECIES-X25519 encryption"
331 in docs/encrypted_images.md.
332
333 Note that for single slot operation, this can still be used to allow
334 loading encrypted images via serial recovery which are then
335 decrypted on-the-fly without needing a second slot.
336
337config BOOT_ENCRYPT_RSA
338 bool
339 help
340 Hidden option selecting RSA encryption.
341
342config BOOT_ENCRYPT_EC256
343 bool
344 help
345 Hidden option selecting EC256 encryption.
346
347config BOOT_ENCRYPT_X25519
348 bool
349 help
350 Hidden option selecting x25519 encryption.
351
Wouter Cappelle953a7612021-05-03 16:53:05 +0200352config BOOT_ENCRYPTION_KEY_FILE
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100353 string "Encryption key file"
354 depends on BOOT_ENCRYPT_IMAGE
355 default "enc-rsa2048-priv.pem" if BOOT_ENCRYPT_RSA
356 default "enc-ec256-priv.pem" if BOOT_ENCRYPT_EC256
357 default "enc-x25519-priv.pem" if BOOT_ENCRYPT_X25519
Wouter Cappelle953a7612021-05-03 16:53:05 +0200358 default ""
359 help
360 You can use either absolute or relative path.
361 In case relative path is used, the build system assumes that it starts
362 from the directory where the MCUBoot KConfig configuration file is
363 located. If the key file is not there, the build system uses relative
364 path that starts from the MCUBoot repository root directory.
365 The key file will be parsed by imgtool's getpriv command and a .c source
366 with the public key information will be written in a format expected by
367 MCUboot.
368
Marti Bolivar0e091c92018-04-12 11:23:16 -0400369config BOOT_MAX_IMG_SECTORS
370 int "Maximum number of sectors per image slot"
371 default 128
372 help
373 This option controls the maximum number of sectors that each of
374 the two image areas can contain. Smaller values reduce MCUboot's
375 memory usage; larger values allow it to support larger images.
376 If unsure, leave at the default value.
377
Jamie McCrae4da51012023-08-03 16:23:02 +0100378config BOOT_SHARE_BACKEND_AVAILABLE
379 bool
David Vincze1cf11b52020-03-24 07:51:09 +0100380 default n
381 help
Jamie McCrae4da51012023-08-03 16:23:02 +0100382 Hidden open which indicates if there is a sharing backend available.
383
384# Workaround for not being able to have commas in macro arguments
385DT_CHOSEN_BOOTLOADER_INFO := zephyr,bootloader-info
386
387config BOOT_SHARE_BACKEND_AVAILABLE
388 bool
389 default n
390 help
391 Hidden open which indicates if there is a sharing backend available.
392
393choice BOOT_SHARE_BACKEND
394 prompt "Shared data backend"
395 default BOOT_SHARE_BACKEND_DISABLED
396
397config BOOT_SHARE_BACKEND_DISABLED
398 bool "Disabled"
399 help
400 No data sharing support.
401
402config BOOT_SHARE_BACKEND_RETENTION
403 bool "Retention"
404 depends on RETENTION
405 depends on $(dt_chosen_enabled,$(DT_CHOSEN_BOOTLOADER_INFO))
406 select BOOT_SHARE_BACKEND_AVAILABLE
407 help
408 Use retention to share data with application. Requires:
409 - Retained memory area
410 - Retention partition of retained memory area
411 - Chosen node "zephyr,bootloader-info" to be set to the retention
412 partition
413
414config BOOT_SHARE_BACKEND_EXTERNAL
415 bool "External (user-provided code)"
416 select BOOT_SHARE_BACKEND_AVAILABLE
417 help
418 Use a custom user-specified storage.
419
420endchoice
421
422menuconfig BOOT_SHARE_DATA
423 bool "Save application specific data"
424 default n
425 depends on BOOT_SHARE_BACKEND_AVAILABLE
426 help
427 This will allow data to be shared between MCUboot and an application,
428 it does not include any informatiom by default.
429
430 Note: This requires a backend to function, see
431 BOOT_SHARE_BACKEND_RETENTION for details on using the retention
432 subsystem as a backend.
433
434config BOOT_SHARE_DATA_BOOTINFO
435 bool "Save boot information data"
436 default n
437 depends on BOOT_SHARE_DATA
438 help
439 This will place information about the MCUboot configuration and
440 running application into a shared memory area.
441
442menuconfig MEASURED_BOOT
443 bool "Store the boot state/measurements in shared memory area"
444 default n
445 depends on BOOT_SHARE_BACKEND_AVAILABLE
446 help
David Vincze1cf11b52020-03-24 07:51:09 +0100447 If enabled, the bootloader will store certain boot measurements such as
448 the hash of the firmware image in a shared memory area. This data can
449 be used later by runtime services (e.g. by a device attestation service).
450
Jamie McCrae4da51012023-08-03 16:23:02 +0100451 Note: This requires a backend to function, see
452 BOOT_SHARE_BACKEND_RETENTION for details on using the retention
453 subsystem as a backend.
454
455config MEASURED_BOOT_MAX_CBOR_SIZE
456 int "Maximum CBOR size of boot state/measurements"
457 default 64
458 range 0 256
459 depends on MEASURED_BOOT
460 help
461 The maximum size of the CBOR message which stores boot
462 state/measurements.
David Vincze1cf11b52020-03-24 07:51:09 +0100463
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000464choice BOOT_FAULT_INJECTION_HARDENING_PROFILE
Tamas Banfce87332020-07-10 12:40:11 +0100465 prompt "Fault injection hardening profile"
466 default BOOT_FIH_PROFILE_OFF
467
468config BOOT_FIH_PROFILE_OFF
469 bool "No hardening against hardware level fault injection"
470 help
471 No hardening in SW against hardware level fault injection: power or
472 clock glitching, etc.
473
474config BOOT_FIH_PROFILE_LOW
475 bool "Moderate level hardening against hardware level fault injection"
476 help
477 Moderate level hardening: Long global fail loop to avoid break out,
478 control flow integrity check to discover discrepancy in expected code
479 flow.
480
481config BOOT_FIH_PROFILE_MEDIUM
482 bool "Medium level hardening against hardware level fault injection"
483 help
484 Medium level hardening: Long global fail loop to avoid break out,
485 control flow integrity check to discover discrepancy in expected code
486 flow, double variables to discover register or memory corruption.
487
488config BOOT_FIH_PROFILE_HIGH
489 bool "Maximum level hardening against hardware level fault injection"
490 select MBEDTLS
491 help
492 Maximum level hardening: Long global fail loop to avoid break out,
493 control flow integrity check to discover discrepancy in expected code
494 flow, double variables to discover register or memory corruption, random
495 delays to make code execution less predictable. Random delays requires an
496 entropy source.
497
498endchoice
499
Josh Gao837cf882020-11-13 18:51:27 -0800500choice BOOT_USB_DFU
501 prompt "USB DFU"
502 default BOOT_USB_DFU_NO
503
504config BOOT_USB_DFU_NO
505 prompt "Disabled"
506
507config BOOT_USB_DFU_WAIT
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530508 bool "Wait for a prescribed duration to see if USB DFU is invoked"
Johann Fischer25852972021-08-02 13:20:09 +0200509 select USB_DEVICE_STACK
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530510 select USB_DFU_CLASS
511 select IMG_MANAGER
Dominik Ermel143485e2023-03-17 11:33:42 +0000512 select STREAM_FLASH
513 select MULTITHREADING
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530514 help
515 If y, MCUboot waits for a prescribed duration of time to allow
516 for USB DFU to be invoked. Please note DFU always updates the
517 slot1 image.
518
Josh Gao837cf882020-11-13 18:51:27 -0800519config BOOT_USB_DFU_GPIO
520 bool "Use GPIO to detect whether to trigger DFU mode"
Johann Fischer25852972021-08-02 13:20:09 +0200521 select USB_DEVICE_STACK
Josh Gao837cf882020-11-13 18:51:27 -0800522 select USB_DFU_CLASS
523 select IMG_MANAGER
Dominik Ermel143485e2023-03-17 11:33:42 +0000524 select STREAM_FLASH
525 select MULTITHREADING
Josh Gao837cf882020-11-13 18:51:27 -0800526 help
527 If y, MCUboot uses GPIO to detect whether to invoke USB DFU.
528
529endchoice
530
531config BOOT_USB_DFU_WAIT_DELAY_MS
532 int "USB DFU wait duration"
533 depends on BOOT_USB_DFU_WAIT
534 default 12000
535 help
536 Milliseconds to wait for USB DFU to be invoked.
537
538if BOOT_USB_DFU_GPIO
539
Josh Gao837cf882020-11-13 18:51:27 -0800540config BOOT_USB_DFU_DETECT_DELAY
541 int "Serial detect pin detection delay time [ms]"
542 default 0
543 help
544 Used to prevent the bootloader from loading on button press.
545 Useful for powering on when using the same button as
546 the one used to place the device in bootloader mode.
547
548endif # BOOT_USB_DFU_GPIO
549
David Brownf6d14c22019-12-10 15:36:36 -0700550config BOOT_USE_BENCH
551 bool "Enable benchmark code"
552 default n
553 help
554 If y, adds support for simple benchmarking that can record
555 time intervals between two calls. The time printed depends
556 on the particular Zephyr target, and is generally ticks of a
557 specific board-specific timer.
558
Michael Scott74ceae52019-02-01 14:01:09 -0800559module = MCUBOOT
Piotr Mienkowski15aa6ef2019-04-08 22:48:15 +0200560module-str = MCUBoot bootloader
Michael Scott74ceae52019-02-01 14:01:09 -0800561source "subsys/logging/Kconfig.template.log_config"
Michael Scott74ceae52019-02-01 14:01:09 -0800562
Andrzej Puzdrowskiaf148532020-02-25 12:51:26 +0100563config MCUBOOT_LOG_THREAD_STACK_SIZE
564 int "Stack size for the MCUBoot log processing thread"
565 depends on LOG && !LOG_IMMEDIATE
566 default 2048 if COVERAGE_GCOV
567 default 1024 if NO_OPTIMIZATIONS
568 default 1024 if XTENSA
569 default 4096 if (X86 && X86_64)
570 default 4096 if ARM64
571 default 768
572 help
573 Set the internal stack size for MCUBoot log processing thread.
574
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200575config MCUBOOT_INDICATION_LED
576 bool "Turns on LED indication when device is in DFU"
Jamie McCrae2c867552023-07-27 14:18:47 +0100577 select GPIO
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200578 help
579 Device device activates the LED while in bootloader mode.
Jeppe Odgaard1dbe0cf2023-05-17 11:09:10 +0200580 mcuboot-led0 alias must be set in the device's .dts
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200581 definitions for this to work.
582
Andrzej Puzdrowski35f61d32022-04-01 17:00:08 +0200583rsource "Kconfig.serial_recovery"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200584
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200585config BOOT_INTR_VEC_RELOC
586 bool "Relocate the interrupt vector to the application"
587 default n
588 depends on SW_VECTOR_RELAY || CPU_CORTEX_M_HAS_VTOR
589 help
590 Relocate the interrupt vector to the application before it is started.
591 Select this option if application requires vector relocation,
592 but it doesn't relocate vector in its reset handler.
593
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200594config UPDATEABLE_IMAGE_NUMBER
595 int "Number of updateable images"
596 default 1
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +0200597 range 1 1 if SINGLE_APPLICATION_SLOT
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200598 help
599 Enables support of multi image update.
600
Marek Pietaa95a41b2023-04-21 14:03:19 +0200601config BOOT_VERSION_CMP_USE_BUILD_NUMBER
602 bool "Use build number while comparing image version"
603 depends on (UPDATEABLE_IMAGE_NUMBER > 1) || BOOT_DIRECT_XIP || \
604 BOOT_RAM_LOAD || MCUBOOT_DOWNGRADE_PREVENTION
605 help
606 By default, the image version comparison relies only on version major,
607 minor and revision. Enable this option to take into account the build
608 number as well.
609
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000610choice BOOT_DOWNGRADE_PREVENTION_CHOICE
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200611 prompt "Downgrade prevention"
612 optional
613
614config MCUBOOT_DOWNGRADE_PREVENTION
615 bool "SW based downgrade prevention"
Jerzy Kasenbergb8801fc2022-06-29 15:54:37 +0200616 depends on !BOOT_DIRECT_XIP
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200617 help
618 Prevent downgrades by enforcing incrementing version numbers.
619 When this option is set, any upgrade must have greater major version
620 or greater minor version with equal major version. This mechanism
621 only protects against some attacks against version downgrades (for
622 example, a JTAG could be used to write an older version).
623
Jerzy Kasenbergb8801fc2022-06-29 15:54:37 +0200624config MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER
625 bool "Use image security counter instead of version number"
626 depends on MCUBOOT_DOWNGRADE_PREVENTION
627 depends on (BOOT_SWAP_USING_MOVE || BOOT_SWAP_USING_SCRATCH)
628 help
629 Security counter is used for version eligibility check instead of pure
630 version. When this option is set, any upgrade must have greater or
631 equal security counter value.
632 Because of the acceptance of equal values it allows for software
633 downgrades to some extent.
634
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200635config MCUBOOT_HW_DOWNGRADE_PREVENTION
636 bool "HW based downgrade prevention"
637 help
638 Prevent undesirable/malicious software downgrades. When this option is
639 set, any upgrade must have greater or equal security counter value.
640 Because of the acceptance of equal values it allows for software
641 downgrade to some extent.
642
643endchoice
644
Andrzej Puzdrowskid21442a2020-10-12 16:47:28 +0200645config BOOT_WATCHDOG_FEED
646 bool "Feed the watchdog while doing swap"
Andrzej Puzdrowskib25ba4b2022-09-28 15:58:19 +0200647 default y if WATCHDOG
648 default y if SOC_FAMILY_NRF
649 # for nRF nrfx based implementation is available
Bartosz Bilasa1c8c8e2022-08-30 21:50:28 +0200650 imply NRFX_WDT if SOC_FAMILY_NRF
651 imply NRFX_WDT0 if SOC_FAMILY_NRF
652 imply NRFX_WDT1 if SOC_FAMILY_NRF
Andrzej Puzdrowskid21442a2020-10-12 16:47:28 +0200653 help
654 Enables implementation of MCUBOOT_WATCHDOG_FEED() macro which is
655 used to feed watchdog while doing time consuming operations.
656
Andrzej Puzdrowski914204d2021-07-09 19:20:46 +0200657config BOOT_IMAGE_ACCESS_HOOKS
658 bool "Enable hooks for overriding MCUboot's native routines"
659 help
660 Allow to provide procedures for override or extend native
661 MCUboot's routines required for access the image data and the image
Andrzej Puzdrowski1c150c62022-07-07 14:55:22 +0200662 update. It is up to the project customization to add required source
663 files to the build.
Andrzej Puzdrowski914204d2021-07-09 19:20:46 +0200664
Jamie McCrae56cb6102022-03-23 11:57:03 +0000665config MCUBOOT_ACTION_HOOKS
666 bool "Enable hooks for responding to MCUboot status changes"
667 help
668 This will call a handler when the MCUboot status changes which allows
669 for some level of user feedback, for instance to change LED status to
670 indicate a failure, using the callback:
671 'void mcuboot_status_change(mcuboot_status_type_t status)' where
672 'mcuboot_status_type_t' is listed in
673 boot/bootutil/include/bootutil/mcuboot_status.h
674
Andrzej Puzdrowski97543282018-04-12 15:16:56 +0200675endmenu
676
Carles Cufi84ede582018-01-29 15:12:00 +0100677config MCUBOOT_DEVICE_SETTINGS
678 # Hidden selector for device-specific settings
679 bool
680 default y
681 # CPU options
682 select MCUBOOT_DEVICE_CPU_CORTEX_M0 if CPU_CORTEX_M0
Carles Cufi67c792e2018-01-29 15:14:31 +0100683 # Enable flash page layout if available
684 select FLASH_PAGE_LAYOUT if FLASH_HAS_PAGE_LAYOUT
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +0200685 # Enable flash_map module as flash I/O back-end
686 select FLASH_MAP
Carles Cufi84ede582018-01-29 15:12:00 +0100687
688config MCUBOOT_DEVICE_CPU_CORTEX_M0
689 # Hidden selector for Cortex-M0 settings
690 bool
691 default n
692 select SW_VECTOR_RELAY if !CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
693
Marti Bolivar0e091c92018-04-12 11:23:16 -0400694comment "Zephyr configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200695
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700696# Disabling MULTITHREADING provides a code size advantage, but
697# it requires peripheral drivers (particularly a flash driver)
698# that works properly with the option enabled.
699#
700# If you know for sure that your hardware will work, you can default
701# it to n here. Otherwise, having it on by default makes the most
702# hardware work.
703config MULTITHREADING
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100704 default y if BOOT_SERIAL_CDC_ACM #usb driver requires MULTITHREADING
Josh Gao837cf882020-11-13 18:51:27 -0800705 default y if BOOT_USB_DFU_GPIO || BOOT_USB_DFU_WAIT
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700706 default n if SOC_FAMILY_NRF
Marek Matej67693442023-01-23 17:54:36 +0100707 default n if SOC_FAMILY_ESP32 && MCUBOOT
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700708 default y
709
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100710config LOG_PROCESS_THREAD
711 default n # mcuboot has its own log processing thread
712
713# override USB device name
714config USB_DEVICE_PRODUCT
715 default "MCUBOOT"
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100716
Andrzej Puzdrowskif573b392020-11-10 14:35:15 +0100717# use MCUboot's own log configuration
718config MCUBOOT_BOOTUTIL_LIB_OWN_LOG
719 bool
720 default n
721
Håkon Øye Amundsene829e9d2021-11-12 14:01:01 +0000722config MCUBOOT_VERIFY_IMG_ADDRESS
723 bool "Verify reset address of image in secondary slot"
724 depends on UPDATEABLE_IMAGE_NUMBER > 1
725 depends on !BOOT_ENCRYPT_IMAGE
726 depends on ARM
727 default y if BOOT_UPGRADE_ONLY
728 help
729 Verify that the reset address in the image located in the secondary slot
730 is contained within the corresponding primary slot. This is recommended
731 if swapping is not used (that is, BOOT_UPGRADE_ONLY is set). If a user
732 incorrectly uploads an update for image 1 to image 0's secondary slot
733 MCUboot will overwrite image 0's primary slot with this image even
734 though it will not boot. If swapping is enabled this will be handled
735 since the image will not confirm itself. If, however, swapping is not
736 enabled then the only mitigation is serial recovery. This feature can
737 also be useful when BOOT_DIRECT_XIP is enabled, to ensure that the image
738 linked at the correct address is loaded.
739
Robert Lubos1b19d2a2020-01-31 14:05:35 +0100740source "Kconfig.zephyr"