blob: 64e23ac6d9e48ce33309105acc5636b97574e0ad [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
Mateusz Michalekc3a72e92024-01-09 08:30:58 +01003# Copyright (c) 2023 Nordic Semiconductor ASA
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +02004#
5# SPDX-License-Identifier: Apache-2.0
6#
7
Marti Bolivar0e091c92018-04-12 11:23:16 -04008mainmenu "MCUboot configuration"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +02009
Marti Bolivar0e091c92018-04-12 11:23:16 -040010comment "MCUboot-specific configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +020011
Emanuele Di Santo865777d2018-11-08 11:28:15 +010012# Hidden option to mark a project as MCUboot
13config MCUBOOT
14 default y
15 bool
Rajavardhan Gundi07ba28f2018-12-10 15:44:48 +053016 select MPU_ALLOW_FLASH_WRITE if ARM_MPU
Marcin Niestrojc6be76a2020-03-22 14:39:35 +010017 select USE_DT_CODE_PARTITION if HAS_FLASH_LOAD_OFFSET
Andrzej Puzdrowskif573b392020-11-10 14:35:15 +010018 select MCUBOOT_BOOTUTIL_LIB
Emanuele Di Santo865777d2018-11-08 11:28:15 +010019
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040020config BOOT_USE_MBEDTLS
21 bool
22 # Hidden option
23 default n
24 help
25 Use mbedTLS for crypto primitives.
26
27config BOOT_USE_TINYCRYPT
28 bool
29 # Hidden option
30 default n
Sebastian Bøe913a3852019-01-22 13:53:12 +010031 # When building for ECDSA, we use our own copy of mbedTLS, so the
32 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
33 # will collide.
Xudong Zheng8cee3552023-12-26 21:28:38 -050034 select MBEDTLS_PROMPTLESS if ZEPHYR_MBEDTLS_MODULE
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040035 help
36 Use TinyCrypt for crypto primitives.
37
Sigvart Hovlandebd05032019-03-21 10:47:32 +010038config BOOT_USE_CC310
39 bool
40 # Hidden option
41 default n
42 # When building for ECDSA, we use our own copy of mbedTLS, so the
43 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
44 # will collide.
Sigvart Hovlandebd05032019-03-21 10:47:32 +010045 help
46 Use cc310 for crypto primitives.
47
48config BOOT_USE_NRF_CC310_BL
49 bool
50 default n
51
52config NRFXLIB_CRYPTO
53 bool
54 default n
55
56config NRF_CC310_BL
57 bool
58 default n
59
Andrzej Puzdrowski97543282018-04-12 15:16:56 +020060menu "MCUBoot settings"
61
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020062config SINGLE_APPLICATION_SLOT
63 bool "Single slot bootloader"
Dominik Ermel4dc3f442020-05-26 08:45:14 +000064 default n
65 help
66 Single image area is used for application which means that
67 uploading a new application overwrites the one that previously
68 occupied the area.
69
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +000070choice BOOT_SIGNATURE_TYPE
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040071 prompt "Signature type"
72 default BOOT_SIGNATURE_TYPE_RSA
73
Arvin Farahmandfb5ec182020-05-05 11:44:12 -040074config BOOT_SIGNATURE_TYPE_NONE
75 bool "No signature; use only hash check"
76 select BOOT_USE_TINYCRYPT
77
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040078config BOOT_SIGNATURE_TYPE_RSA
79 bool "RSA signatures"
80 select BOOT_USE_MBEDTLS
Marti Bolivara4818a52018-04-12 13:02:38 -040081 select MBEDTLS
Jamie McCrae25d2f2c2023-07-17 14:17:53 +010082 select BOOT_ENCRYPTION_SUPPORT
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040083
Fabio Utzig105b59a2019-05-13 15:08:12 -070084if BOOT_SIGNATURE_TYPE_RSA
85config BOOT_SIGNATURE_TYPE_RSA_LEN
86 int "RSA signature length"
87 range 2048 3072
88 default 2048
89endif
90
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040091config BOOT_SIGNATURE_TYPE_ECDSA_P256
92 bool "Elliptic curve digital signatures with curve P-256"
Jamie McCrae25d2f2c2023-07-17 14:17:53 +010093 select BOOT_ENCRYPTION_SUPPORT
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040094
Sigvart Hovlandebd05032019-03-21 10:47:32 +010095if BOOT_SIGNATURE_TYPE_ECDSA_P256
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +000096choice BOOT_ECDSA_IMPLEMENTATION
Sigvart Hovlandebd05032019-03-21 10:47:32 +010097 prompt "Ecdsa implementation"
Fabio Utzig34e93a52020-02-03 09:59:53 -030098 default BOOT_ECDSA_TINYCRYPT
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +000099
Fabio Utzig34e93a52020-02-03 09:59:53 -0300100config BOOT_ECDSA_TINYCRYPT
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100101 bool "Use tinycrypt"
102 select BOOT_USE_TINYCRYPT
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000103
104config BOOT_ECDSA_CC310
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100105 bool "Use CC310"
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000106 depends on HAS_HW_NRF_CC310
107 select BOOT_USE_NRF_CC310_BL
108 select NRF_CC310_BL
109 select NRFXLIB_CRYPTO
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100110 select BOOT_USE_CC310
Håkon Øye Amundsenee7282d2020-09-28 09:48:29 +0000111endchoice # Ecdsa implementation
Sigvart Hovlandebd05032019-03-21 10:47:32 +0100112endif
Fabio Utzig34e93a52020-02-03 09:59:53 -0300113
114config BOOT_SIGNATURE_TYPE_ED25519
115 bool "Edwards curve digital signatures using ed25519"
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100116 select BOOT_ENCRYPTION_SUPPORT
Fabio Utzig34e93a52020-02-03 09:59:53 -0300117
118if BOOT_SIGNATURE_TYPE_ED25519
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000119choice BOOT_ED25519_IMPLEMENTATION
Fabio Utzig34e93a52020-02-03 09:59:53 -0300120 prompt "Ecdsa implementation"
121 default BOOT_ED25519_TINYCRYPT
122config BOOT_ED25519_TINYCRYPT
123 bool "Use tinycrypt"
124 select BOOT_USE_TINYCRYPT
125config BOOT_ED25519_MBEDTLS
126 bool "Use mbedTLS"
127 select BOOT_USE_MBEDTLS
128 select MBEDTLS
129endchoice
130endif
131
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400132endchoice
133
Fabio Utzigc690c762018-04-26 10:51:09 -0300134config BOOT_SIGNATURE_KEY_FILE
135 string "PEM key file"
Håkon Øye Amundsen705c6c22020-09-28 09:45:40 +0000136 default "root-ec-p256.pem" if BOOT_SIGNATURE_TYPE_ECDSA_P256
137 default "root-ed25519.pem" if BOOT_SIGNATURE_TYPE_ED25519
138 default "root-rsa-3072.pem" if BOOT_SIGNATURE_TYPE_RSA && BOOT_SIGNATURE_TYPE_RSA_LEN=3072
139 default "root-rsa-2048.pem" if BOOT_SIGNATURE_TYPE_RSA && BOOT_SIGNATURE_TYPE_RSA_LEN=2048
Fabio Utzigc690c762018-04-26 10:51:09 -0300140 default ""
141 help
Marek Pietabdcfc852020-08-04 02:22:55 -0700142 You can use either absolute or relative path.
143 In case relative path is used, the build system assumes that it starts
144 from the directory where the MCUBoot KConfig configuration file is
145 located. If the key file is not there, the build system uses relative
146 path that starts from the MCUBoot repository root directory.
Fabio Utzigc690c762018-04-26 10:51:09 -0300147 The key file will be parsed by imgtool's getpub command and a .c source
148 with the public key information will be written in a format expected by
149 MCUboot.
150
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100151config MCUBOOT_CLEANUP_ARM_CORE
152 bool "Perform core cleanup before chain-load the application"
153 depends on CPU_CORTEX_M
Jamie McCrae9e8eddc2023-02-27 12:51:09 +0000154 default y
Ioannis Glaropoulos518d93a2020-10-22 14:22:14 +0200155 help
156 This option instructs MCUboot to perform a clean-up of a set of
Marcin Niestroj9ced4592023-05-17 14:50:57 +0200157 architecture core HW registers before jumping to the application
Ioannis Glaropoulos518d93a2020-10-22 14:22:14 +0200158 firmware. The clean-up sets these registers to their warm-reset
159 values as specified by the architecture.
160
Jamie McCrae9e8eddc2023-02-27 12:51:09 +0000161 This option is enabled by default to prevent possible problems when
162 booting zephyr (or other) applications whereby e.g. a MPU stack guard
163 may be initialised in RAM which is then used by the application
164 start-up code which can cause a module fault and potentially make the
165 module irrecoverable.
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100166
Marti Bolivara4818a52018-04-12 13:02:38 -0400167config MBEDTLS_CFG_FILE
168 default "mcuboot-mbedtls-cfg.h"
169
David Vincze03368b82020-04-01 12:53:53 +0200170config BOOT_HW_KEY
171 bool "Use HW key for image verification"
172 default n
173 help
174 Use HW key for image verification, otherwise the public key is embedded
175 in MCUBoot. If enabled the public key is appended to the signed image
176 and requires the hash of the public key to be provisioned to the device
177 beforehand.
178
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400179config BOOT_VALIDATE_SLOT0
David Vincze2d736ad2019-02-18 11:50:22 +0100180 bool "Validate image in the primary slot on every boot"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400181 default y
182 help
David Vincze2d736ad2019-02-18 11:50:22 +0100183 If y, the bootloader attempts to validate the signature of the
184 primary slot every boot. This adds the signature check time to
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400185 every boot, but can mitigate against some changes that are
186 able to modify the flash image itself.
187
Wouter Cappellebb7a39d2021-05-03 16:44:44 +0200188config BOOT_VALIDATE_SLOT0_ONCE
189 bool "Validate image in the primary slot just once after after upgrade"
190 depends on !BOOT_VALIDATE_SLOT0 && SINGLE_APPLICATION_SLOT
191 default n
192 help
193 If y, the bootloader attempts to validate the signature of the
194 primary slot only once after an upgrade of the main slot.
195 It caches the result in the magic area, which makes it an unsecure
196 method. This option is usefull for lowering the boot up time for
197 low end devices with as a compromise lowering the security level.
198 If unsure, leave at the default value.
199
David Brown08a30a42022-04-26 14:49:51 -0600200config BOOT_PREFER_SWAP_MOVE
201 bool "Prefer the newer swap move algorithm"
Jamie McCrae8b4c70a2024-03-07 07:51:55 +0000202 default y if SOC_FAMILY_NORDIC_NRF
Thomas Strangeraa217e22022-10-28 21:17:55 +0200203 default y if !$(dt_nodelabel_enabled,scratch_partition)
David Brown08a30a42022-04-26 14:49:51 -0600204 help
205 If y, the BOOT_IMAGE_UPGRADE_MODE will default to using
206 "move" instead of "scratch". This is a separate bool config
207 option, because Kconfig doesn't allow defaults to be
208 overridden in choice options. Most devices should be using
209 swap move.
210
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +0200211if !SINGLE_APPLICATION_SLOT
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000212choice BOOT_IMAGE_UPGRADE_MODE
David Vincze5a6e1812020-06-29 13:34:42 +0200213 prompt "Image upgrade modes"
David Brown08a30a42022-04-26 14:49:51 -0600214 default BOOT_SWAP_USING_MOVE if BOOT_PREFER_SWAP_MOVE
David Vincze5a6e1812020-06-29 13:34:42 +0200215 default BOOT_SWAP_USING_SCRATCH
216
217config BOOT_SWAP_USING_SCRATCH
218 bool "Swap mode that run with the scratch partition"
219 help
220 This is the most conservative swap mode but it can work even on
221 devices with heterogeneous flash page layout.
222
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400223config BOOT_UPGRADE_ONLY
224 bool "Overwrite image updates instead of swapping"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400225 help
David Vincze2d736ad2019-02-18 11:50:22 +0100226 If y, overwrite the primary slot with the upgrade image instead
227 of swapping them. This prevents the fallback recovery, but
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400228 uses a much simpler code path.
229
Fabio Utzigc58842e2019-11-28 10:30:01 -0300230config BOOT_SWAP_USING_MOVE
Fabio Utzigdd2b6802020-01-06 09:10:45 -0300231 bool "Swap mode that can run without a scratch partition"
Fabio Utzigc58842e2019-11-28 10:30:01 -0300232 help
233 If y, the swap upgrade is done in two steps, where first every
234 sector of the primary slot is moved up one sector, then for
235 each sector X in the secondary slot, it is moved to index X in
236 the primary slot, then the sector at X+1 in the primary is
237 moved to index X in the secondary.
238 This allows a swap upgrade without using a scratch partition,
239 but is currently limited to all sectors in both slots being of
240 the same size.
David Vincze5a6e1812020-06-29 13:34:42 +0200241
242config BOOT_DIRECT_XIP
243 bool "Run the latest image directly from its slot"
244 help
245 If y, mcuboot selects the newest valid image based on the image version
246 numbers, thereafter the selected image can run directly from its slot
247 without having to move/copy it into the primary slot. For this reason the
248 images must be linked to be executed from the given image slot. Using this
249 mode results in a simpler code path and smaller code size.
250
Johan Öhmanb5889072022-04-01 09:10:28 +0200251config BOOT_RAM_LOAD
252 bool "RAM load"
253 help
254 If y, mcuboot selects the newest valid image based on the image version
255 numbers, thereafter the selected image is copied to RAM and executed from
256 there. For this reason, the image has to be linked to be executed from RAM.
257 The address that the image is copied to is specified using the load-addr
258 argument to the imgtool.py script which writes it to the image header.
259
Jamie McCrae215345f2023-08-16 07:37:18 +0100260config BOOT_FIRMWARE_LOADER
261 bool "Firmware loader"
262 help
263 If y, mcuboot will have a single application slot, and the secondary
264 slot will be for a non-upgradeable firmware loaded image (e.g. for
265 loading firmware via Bluetooth). The main application will boot by
266 default unless there is an error with it or the boot mode has been
267 forced to the firmware loader.
268
269 Note: The firmware loader image must be signed with the same signing
270 key as the primary image.
271
David Vincze5a6e1812020-06-29 13:34:42 +0200272endchoice
Fabio Utzigc58842e2019-11-28 10:30:01 -0300273
Johan Öhmanb5889072022-04-01 09:10:28 +0200274# Workaround for not being able to have commas in macro arguments
275DT_CHOSEN_Z_SRAM := zephyr,sram
276
277if BOOT_RAM_LOAD
278config BOOT_IMAGE_EXECUTABLE_RAM_START
279 hex "Boot image executable ram start"
280 default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))
281
282config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
283 int "Boot image executable base size"
284 default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
285endif
286
David Vincze505fba22020-10-22 13:53:29 +0200287config BOOT_DIRECT_XIP_REVERT
288 bool "Enable the revert mechanism in direct-xip mode"
Andrzej Puzdrowski32342e72020-11-18 17:04:44 +0100289 depends on BOOT_DIRECT_XIP
David Vincze505fba22020-10-22 13:53:29 +0200290 default n
291 help
292 If y, enables the revert mechanism in direct-xip similar to the one in
293 swap mode. It requires the trailer magic to be added to the signed image.
294 When a reboot happens without the image being confirmed at runtime, the
295 bootloader considers the image faulty and erases it. After this it will
296 attempt to boot the previous image. The images can also be made permanent
297 (marked as confirmed in advance) just like in swap mode.
298
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200299config BOOT_BOOTSTRAP
Sam Bristowd0ca0ff2019-10-30 20:51:35 +1300300 bool "Bootstrap erased the primary slot from the secondary slot"
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200301 default n
302 help
303 If y, enables bootstraping support. Bootstrapping allows an erased
David Vincze2d736ad2019-02-18 11:50:22 +0100304 primary slot to be initialized from a valid image in the secondary slot.
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200305 If unsure, leave at the default value.
306
Fabio Utzigca8ead22019-12-20 07:06:04 -0300307config BOOT_SWAP_SAVE_ENCTLV
308 bool "Save encrypted key TLVs instead of plaintext keys in swap metadata"
309 default n
Jamie McCraee9131ee2023-10-31 09:54:35 +0000310 depends on BOOT_ENCRYPT_IMAGE
Fabio Utzigca8ead22019-12-20 07:06:04 -0300311 help
312 If y, instead of saving the encrypted image keys in plaintext in the
313 swap resume metadata, save the encrypted image TLVs. This should be used
314 when there is no security mechanism protecting the data in the primary
315 slot from being dumped. If n is selected (default), the keys are written
316 after being decrypted from the image TLVs and could be read by an
317 attacker who has access to the flash contents of the primary slot (eg
318 JTAG/SWD or primary slot in external flash).
319 If unsure, leave at the default value.
320
David Vincze505fba22020-10-22 13:53:29 +0200321endif # !SINGLE_APPLICATION_SLOT
Fabio Utzigb6f014c2020-04-02 13:25:01 -0300322
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100323config BOOT_ENCRYPTION_SUPPORT
324 bool
325 help
326 Hidden option used to check if image encryption is supported.
327
328config BOOT_ENCRYPT_IMAGE
329 bool "Support for encrypted image updates"
330 depends on BOOT_ENCRYPTION_SUPPORT
331 select BOOT_ENCRYPT_RSA if BOOT_SIGNATURE_TYPE_RSA
332 select BOOT_ENCRYPT_EC256 if BOOT_SIGNATURE_TYPE_ECDSA_P256
333 select BOOT_ENCRYPT_X25519 if BOOT_SIGNATURE_TYPE_ED25519
334 depends on !SINGLE_APPLICATION_SLOT || MCUBOOT_SERIAL
335 help
336 If y, images in the secondary slot can be encrypted and are decrypted
337 on the fly when upgrading to the primary slot, as well as encrypted
338 back when swapping from the primary slot to the secondary slot. The
339 encryption mechanism must match the same type as the signature type,
340 supported types include:
341 - RSA-OAEP (2048 bits).
342 - ECIES using primitives described under "ECIES-P256 encryption" in
343 docs/encrypted_images.md.
344 - ECIES using primitives described under "ECIES-X25519 encryption"
345 in docs/encrypted_images.md.
346
347 Note that for single slot operation, this can still be used to allow
348 loading encrypted images via serial recovery which are then
349 decrypted on-the-fly without needing a second slot.
350
351config BOOT_ENCRYPT_RSA
352 bool
353 help
354 Hidden option selecting RSA encryption.
355
356config BOOT_ENCRYPT_EC256
357 bool
358 help
359 Hidden option selecting EC256 encryption.
360
361config BOOT_ENCRYPT_X25519
362 bool
363 help
364 Hidden option selecting x25519 encryption.
365
Wouter Cappelle953a7612021-05-03 16:53:05 +0200366config BOOT_ENCRYPTION_KEY_FILE
Jamie McCrae25d2f2c2023-07-17 14:17:53 +0100367 string "Encryption key file"
368 depends on BOOT_ENCRYPT_IMAGE
369 default "enc-rsa2048-priv.pem" if BOOT_ENCRYPT_RSA
370 default "enc-ec256-priv.pem" if BOOT_ENCRYPT_EC256
371 default "enc-x25519-priv.pem" if BOOT_ENCRYPT_X25519
Wouter Cappelle953a7612021-05-03 16:53:05 +0200372 default ""
373 help
374 You can use either absolute or relative path.
375 In case relative path is used, the build system assumes that it starts
376 from the directory where the MCUBoot KConfig configuration file is
377 located. If the key file is not there, the build system uses relative
378 path that starts from the MCUBoot repository root directory.
379 The key file will be parsed by imgtool's getpriv command and a .c source
380 with the public key information will be written in a format expected by
381 MCUboot.
382
Jamie McCraeeaae6502024-07-25 14:36:46 +0100383config BOOT_MAX_IMG_SECTORS_AUTO
384 bool "Calculate maximum sectors automatically"
385 default y
386 help
387 If this option is enabled then the maximum number of supported sectors per image will
388 be calculated automatically from the flash erase sizes and size of each partition for
389 the first image.
390
391 If this information is not available, or multiple images are used, then this option
392 should be disabled and BOOT_MAX_IMG_SECTORS should be set instead
393
Marti Bolivar0e091c92018-04-12 11:23:16 -0400394config BOOT_MAX_IMG_SECTORS
395 int "Maximum number of sectors per image slot"
396 default 128
Jamie McCraeeaae6502024-07-25 14:36:46 +0100397 depends on !BOOT_MAX_IMG_SECTORS_AUTO
Marti Bolivar0e091c92018-04-12 11:23:16 -0400398 help
399 This option controls the maximum number of sectors that each of
400 the two image areas can contain. Smaller values reduce MCUboot's
401 memory usage; larger values allow it to support larger images.
402 If unsure, leave at the default value.
403
Jamie McCrae4da51012023-08-03 16:23:02 +0100404config BOOT_SHARE_BACKEND_AVAILABLE
405 bool
David Vincze1cf11b52020-03-24 07:51:09 +0100406 default n
407 help
Jamie McCrae4da51012023-08-03 16:23:02 +0100408 Hidden open which indicates if there is a sharing backend available.
409
410# Workaround for not being able to have commas in macro arguments
411DT_CHOSEN_BOOTLOADER_INFO := zephyr,bootloader-info
412
413config BOOT_SHARE_BACKEND_AVAILABLE
414 bool
415 default n
416 help
417 Hidden open which indicates if there is a sharing backend available.
418
419choice BOOT_SHARE_BACKEND
420 prompt "Shared data backend"
421 default BOOT_SHARE_BACKEND_DISABLED
422
423config BOOT_SHARE_BACKEND_DISABLED
424 bool "Disabled"
425 help
426 No data sharing support.
427
428config BOOT_SHARE_BACKEND_RETENTION
429 bool "Retention"
430 depends on RETENTION
431 depends on $(dt_chosen_enabled,$(DT_CHOSEN_BOOTLOADER_INFO))
432 select BOOT_SHARE_BACKEND_AVAILABLE
433 help
434 Use retention to share data with application. Requires:
435 - Retained memory area
436 - Retention partition of retained memory area
437 - Chosen node "zephyr,bootloader-info" to be set to the retention
438 partition
439
440config BOOT_SHARE_BACKEND_EXTERNAL
441 bool "External (user-provided code)"
442 select BOOT_SHARE_BACKEND_AVAILABLE
443 help
444 Use a custom user-specified storage.
445
446endchoice
447
448menuconfig BOOT_SHARE_DATA
449 bool "Save application specific data"
450 default n
451 depends on BOOT_SHARE_BACKEND_AVAILABLE
452 help
453 This will allow data to be shared between MCUboot and an application,
454 it does not include any informatiom by default.
455
456 Note: This requires a backend to function, see
457 BOOT_SHARE_BACKEND_RETENTION for details on using the retention
458 subsystem as a backend.
459
460config BOOT_SHARE_DATA_BOOTINFO
461 bool "Save boot information data"
462 default n
463 depends on BOOT_SHARE_DATA
464 help
465 This will place information about the MCUboot configuration and
466 running application into a shared memory area.
467
468menuconfig MEASURED_BOOT
469 bool "Store the boot state/measurements in shared memory area"
470 default n
471 depends on BOOT_SHARE_BACKEND_AVAILABLE
472 help
David Vincze1cf11b52020-03-24 07:51:09 +0100473 If enabled, the bootloader will store certain boot measurements such as
474 the hash of the firmware image in a shared memory area. This data can
475 be used later by runtime services (e.g. by a device attestation service).
476
Jamie McCrae4da51012023-08-03 16:23:02 +0100477 Note: This requires a backend to function, see
478 BOOT_SHARE_BACKEND_RETENTION for details on using the retention
479 subsystem as a backend.
480
481config MEASURED_BOOT_MAX_CBOR_SIZE
482 int "Maximum CBOR size of boot state/measurements"
483 default 64
484 range 0 256
485 depends on MEASURED_BOOT
486 help
487 The maximum size of the CBOR message which stores boot
488 state/measurements.
David Vincze1cf11b52020-03-24 07:51:09 +0100489
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000490choice BOOT_FAULT_INJECTION_HARDENING_PROFILE
Tamas Banfce87332020-07-10 12:40:11 +0100491 prompt "Fault injection hardening profile"
492 default BOOT_FIH_PROFILE_OFF
493
494config BOOT_FIH_PROFILE_OFF
495 bool "No hardening against hardware level fault injection"
496 help
497 No hardening in SW against hardware level fault injection: power or
498 clock glitching, etc.
499
500config BOOT_FIH_PROFILE_LOW
501 bool "Moderate level hardening against hardware level fault injection"
502 help
503 Moderate level hardening: Long global fail loop to avoid break out,
504 control flow integrity check to discover discrepancy in expected code
505 flow.
506
507config BOOT_FIH_PROFILE_MEDIUM
508 bool "Medium level hardening against hardware level fault injection"
509 help
510 Medium level hardening: Long global fail loop to avoid break out,
511 control flow integrity check to discover discrepancy in expected code
512 flow, double variables to discover register or memory corruption.
513
514config BOOT_FIH_PROFILE_HIGH
515 bool "Maximum level hardening against hardware level fault injection"
516 select MBEDTLS
517 help
518 Maximum level hardening: Long global fail loop to avoid break out,
519 control flow integrity check to discover discrepancy in expected code
520 flow, double variables to discover register or memory corruption, random
521 delays to make code execution less predictable. Random delays requires an
522 entropy source.
523
524endchoice
525
Josh Gao837cf882020-11-13 18:51:27 -0800526choice BOOT_USB_DFU
527 prompt "USB DFU"
528 default BOOT_USB_DFU_NO
529
530config BOOT_USB_DFU_NO
531 prompt "Disabled"
532
533config BOOT_USB_DFU_WAIT
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530534 bool "Wait for a prescribed duration to see if USB DFU is invoked"
Johann Fischer25852972021-08-02 13:20:09 +0200535 select USB_DEVICE_STACK
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530536 select USB_DFU_CLASS
537 select IMG_MANAGER
Dominik Ermel143485e2023-03-17 11:33:42 +0000538 select STREAM_FLASH
539 select MULTITHREADING
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530540 help
541 If y, MCUboot waits for a prescribed duration of time to allow
542 for USB DFU to be invoked. Please note DFU always updates the
543 slot1 image.
544
Josh Gao837cf882020-11-13 18:51:27 -0800545config BOOT_USB_DFU_GPIO
546 bool "Use GPIO to detect whether to trigger DFU mode"
Johann Fischer25852972021-08-02 13:20:09 +0200547 select USB_DEVICE_STACK
Josh Gao837cf882020-11-13 18:51:27 -0800548 select USB_DFU_CLASS
549 select IMG_MANAGER
Dominik Ermel143485e2023-03-17 11:33:42 +0000550 select STREAM_FLASH
551 select MULTITHREADING
Josh Gao837cf882020-11-13 18:51:27 -0800552 help
553 If y, MCUboot uses GPIO to detect whether to invoke USB DFU.
554
555endchoice
556
557config BOOT_USB_DFU_WAIT_DELAY_MS
558 int "USB DFU wait duration"
559 depends on BOOT_USB_DFU_WAIT
560 default 12000
561 help
562 Milliseconds to wait for USB DFU to be invoked.
563
564if BOOT_USB_DFU_GPIO
565
Josh Gao837cf882020-11-13 18:51:27 -0800566config BOOT_USB_DFU_DETECT_DELAY
567 int "Serial detect pin detection delay time [ms]"
568 default 0
569 help
570 Used to prevent the bootloader from loading on button press.
571 Useful for powering on when using the same button as
572 the one used to place the device in bootloader mode.
573
574endif # BOOT_USB_DFU_GPIO
575
David Brownf6d14c22019-12-10 15:36:36 -0700576config BOOT_USE_BENCH
577 bool "Enable benchmark code"
578 default n
579 help
580 If y, adds support for simple benchmarking that can record
581 time intervals between two calls. The time printed depends
582 on the particular Zephyr target, and is generally ticks of a
583 specific board-specific timer.
584
Michael Scott74ceae52019-02-01 14:01:09 -0800585module = MCUBOOT
Piotr Mienkowski15aa6ef2019-04-08 22:48:15 +0200586module-str = MCUBoot bootloader
Michael Scott74ceae52019-02-01 14:01:09 -0800587source "subsys/logging/Kconfig.template.log_config"
Michael Scott74ceae52019-02-01 14:01:09 -0800588
Andrzej Puzdrowskiaf148532020-02-25 12:51:26 +0100589config MCUBOOT_LOG_THREAD_STACK_SIZE
590 int "Stack size for the MCUBoot log processing thread"
591 depends on LOG && !LOG_IMMEDIATE
592 default 2048 if COVERAGE_GCOV
593 default 1024 if NO_OPTIMIZATIONS
594 default 1024 if XTENSA
595 default 4096 if (X86 && X86_64)
596 default 4096 if ARM64
597 default 768
598 help
599 Set the internal stack size for MCUBoot log processing thread.
600
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200601config MCUBOOT_INDICATION_LED
602 bool "Turns on LED indication when device is in DFU"
Jamie McCrae2c867552023-07-27 14:18:47 +0100603 select GPIO
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200604 help
605 Device device activates the LED while in bootloader mode.
Jeppe Odgaard1dbe0cf2023-05-17 11:09:10 +0200606 mcuboot-led0 alias must be set in the device's .dts
Andrzej Puzdrowski6c00b5e2022-04-01 16:51:27 +0200607 definitions for this to work.
608
Andrzej Puzdrowski35f61d32022-04-01 17:00:08 +0200609rsource "Kconfig.serial_recovery"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200610
Jamie McCrae215345f2023-08-16 07:37:18 +0100611rsource "Kconfig.firmware_loader"
612
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200613config BOOT_INTR_VEC_RELOC
614 bool "Relocate the interrupt vector to the application"
615 default n
616 depends on SW_VECTOR_RELAY || CPU_CORTEX_M_HAS_VTOR
617 help
618 Relocate the interrupt vector to the application before it is started.
619 Select this option if application requires vector relocation,
620 but it doesn't relocate vector in its reset handler.
621
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200622config UPDATEABLE_IMAGE_NUMBER
623 int "Number of updateable images"
624 default 1
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +0200625 range 1 1 if SINGLE_APPLICATION_SLOT
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200626 help
627 Enables support of multi image update.
628
Marek Pietaa95a41b2023-04-21 14:03:19 +0200629config BOOT_VERSION_CMP_USE_BUILD_NUMBER
630 bool "Use build number while comparing image version"
631 depends on (UPDATEABLE_IMAGE_NUMBER > 1) || BOOT_DIRECT_XIP || \
632 BOOT_RAM_LOAD || MCUBOOT_DOWNGRADE_PREVENTION
633 help
634 By default, the image version comparison relies only on version major,
635 minor and revision. Enable this option to take into account the build
636 number as well.
637
Håkon Øye Amundsen21f03762021-11-12 08:21:31 +0000638choice BOOT_DOWNGRADE_PREVENTION_CHOICE
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200639 prompt "Downgrade prevention"
640 optional
641
642config MCUBOOT_DOWNGRADE_PREVENTION
643 bool "SW based downgrade prevention"
Jerzy Kasenbergb8801fc2022-06-29 15:54:37 +0200644 depends on !BOOT_DIRECT_XIP
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200645 help
646 Prevent downgrades by enforcing incrementing version numbers.
647 When this option is set, any upgrade must have greater major version
648 or greater minor version with equal major version. This mechanism
649 only protects against some attacks against version downgrades (for
650 example, a JTAG could be used to write an older version).
651
Jerzy Kasenbergb8801fc2022-06-29 15:54:37 +0200652config MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER
653 bool "Use image security counter instead of version number"
654 depends on MCUBOOT_DOWNGRADE_PREVENTION
655 depends on (BOOT_SWAP_USING_MOVE || BOOT_SWAP_USING_SCRATCH)
656 help
657 Security counter is used for version eligibility check instead of pure
658 version. When this option is set, any upgrade must have greater or
659 equal security counter value.
660 Because of the acceptance of equal values it allows for software
661 downgrades to some extent.
662
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200663config MCUBOOT_HW_DOWNGRADE_PREVENTION
664 bool "HW based downgrade prevention"
665 help
666 Prevent undesirable/malicious software downgrades. When this option is
667 set, any upgrade must have greater or equal security counter value.
668 Because of the acceptance of equal values it allows for software
669 downgrade to some extent.
670
671endchoice
672
Andrzej Puzdrowskid21442a2020-10-12 16:47:28 +0200673config BOOT_WATCHDOG_FEED
674 bool "Feed the watchdog while doing swap"
Andrzej Puzdrowskib25ba4b2022-09-28 15:58:19 +0200675 default y if WATCHDOG
Jamie McCrae8b4c70a2024-03-07 07:51:55 +0000676 default y if SOC_FAMILY_NORDIC_NRF
Andrzej Puzdrowskib25ba4b2022-09-28 15:58:19 +0200677 # for nRF nrfx based implementation is available
Jamie McCrae8b4c70a2024-03-07 07:51:55 +0000678 imply NRFX_WDT if SOC_FAMILY_NORDIC_NRF
679 imply NRFX_WDT0 if SOC_FAMILY_NORDIC_NRF
680 imply NRFX_WDT1 if SOC_FAMILY_NORDIC_NRF
681 imply NRFX_WDT30 if SOC_FAMILY_NORDIC_NRF
682 imply NRFX_WDT31 if SOC_FAMILY_NORDIC_NRF
Andrzej Puzdrowskid21442a2020-10-12 16:47:28 +0200683 help
684 Enables implementation of MCUBOOT_WATCHDOG_FEED() macro which is
685 used to feed watchdog while doing time consuming operations.
686
Andrzej Puzdrowski914204d2021-07-09 19:20:46 +0200687config BOOT_IMAGE_ACCESS_HOOKS
688 bool "Enable hooks for overriding MCUboot's native routines"
689 help
690 Allow to provide procedures for override or extend native
691 MCUboot's routines required for access the image data and the image
Andrzej Puzdrowski1c150c62022-07-07 14:55:22 +0200692 update. It is up to the project customization to add required source
693 files to the build.
Andrzej Puzdrowski914204d2021-07-09 19:20:46 +0200694
Jamie McCrae56cb6102022-03-23 11:57:03 +0000695config MCUBOOT_ACTION_HOOKS
696 bool "Enable hooks for responding to MCUboot status changes"
697 help
698 This will call a handler when the MCUboot status changes which allows
699 for some level of user feedback, for instance to change LED status to
700 indicate a failure, using the callback:
701 'void mcuboot_status_change(mcuboot_status_type_t status)' where
702 'mcuboot_status_type_t' is listed in
703 boot/bootutil/include/bootutil/mcuboot_status.h
704
Jamie McCrae24ac8cc2024-03-19 08:18:44 +0000705config BOOT_DISABLE_CACHES
706 bool "Disable I/D caches before chain-loading application"
707 depends on CPU_HAS_ICACHE || CPU_HAS_DCACHE
708 default y
709 help
710 Will flush and disable the instruction and data caches on the CPU prior to
711 booting an application, this is required on some ARM Cortex devices and
712 increases protection against data leakage from MCUboot to applications via
713 these caches.
714
Jamie McCrae14961292024-04-18 09:12:09 +0100715config MCUBOOT_BOOT_BANNER
716 bool "Use MCUboot boot banner"
717 depends on BOOT_BANNER
718 depends on "$(APP_VERSION_EXTENDED_STRING)" != ""
719 default y
720 help
721 Uses a MCUboot boot banner instead of the default zephyr one, which will output the
722 MCUboot name and version, followed by the zephyr name and version.
723
724 For example:
725
726 *** Booting MCUboot v2.0.0-72-g8c0e36c88663 ***
727 *** Using Zephyr OS build v3.6.0-2607-gd0be2010c31f ***
728
729config BOOT_BANNER_STRING
730 default "Using Zephyr OS build" if MCUBOOT_BOOT_BANNER
731
Jamie McCrae0c1ddf72024-08-23 08:13:00 +0100732config BOOT_DECOMPRESSION_SUPPORT
733 bool
734 help
735 Hidden symbol which should be selected if a system provided decompression support.
736
737if BOOT_DECOMPRESSION_SUPPORT
738
739menuconfig BOOT_DECOMPRESSION
740 bool "Decompression"
741 help
742 If enabled, will include support for compressed images being loaded to the secondary slot
743 which then get decompressed into the primary slot. This mode allows the secondary slot to
744 be smaller than primary slot which otherwise would not be allowed.
745
746if BOOT_DECOMPRESSION
747
748config BOOT_DECOMPRESSION_BUFFER_SIZE
749 int "Write buffer size"
750 range 16 16384
751 default 4096
752 help
753 The size of a secondary buffer used for writing decompressed data to the storage device.
754
755endif # BOOT_DECOMPRESSION
756
757endif # BOOT_DECOMPRESSION_SUPPORT
758
Andrzej Puzdrowski97543282018-04-12 15:16:56 +0200759endmenu
760
Carles Cufi84ede582018-01-29 15:12:00 +0100761config MCUBOOT_DEVICE_SETTINGS
762 # Hidden selector for device-specific settings
763 bool
764 default y
765 # CPU options
766 select MCUBOOT_DEVICE_CPU_CORTEX_M0 if CPU_CORTEX_M0
Carles Cufi67c792e2018-01-29 15:14:31 +0100767 # Enable flash page layout if available
768 select FLASH_PAGE_LAYOUT if FLASH_HAS_PAGE_LAYOUT
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +0200769 # Enable flash_map module as flash I/O back-end
770 select FLASH_MAP
Carles Cufi84ede582018-01-29 15:12:00 +0100771
772config MCUBOOT_DEVICE_CPU_CORTEX_M0
773 # Hidden selector for Cortex-M0 settings
774 bool
775 default n
776 select SW_VECTOR_RELAY if !CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
777
Marti Bolivar0e091c92018-04-12 11:23:16 -0400778comment "Zephyr configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200779
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700780# Disabling MULTITHREADING provides a code size advantage, but
781# it requires peripheral drivers (particularly a flash driver)
782# that works properly with the option enabled.
783#
784# If you know for sure that your hardware will work, you can default
785# it to n here. Otherwise, having it on by default makes the most
786# hardware work.
787config MULTITHREADING
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100788 default y if BOOT_SERIAL_CDC_ACM #usb driver requires MULTITHREADING
Josh Gao837cf882020-11-13 18:51:27 -0800789 default y if BOOT_USB_DFU_GPIO || BOOT_USB_DFU_WAIT
Jamie McCrae8b4c70a2024-03-07 07:51:55 +0000790 default n if SOC_FAMILY_NORDIC_NRF
Sylvio Alvesb794d332024-03-04 10:08:30 -0300791 default n if SOC_FAMILY_ESPRESSIF_ESP32 && MCUBOOT
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700792 default y
793
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100794config LOG_PROCESS_THREAD
795 default n # mcuboot has its own log processing thread
796
797# override USB device name
798config USB_DEVICE_PRODUCT
799 default "MCUBOOT"
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100800
Andrzej Puzdrowskif573b392020-11-10 14:35:15 +0100801# use MCUboot's own log configuration
802config MCUBOOT_BOOTUTIL_LIB_OWN_LOG
803 bool
804 default n
805
Håkon Øye Amundsene829e9d2021-11-12 14:01:01 +0000806config MCUBOOT_VERIFY_IMG_ADDRESS
807 bool "Verify reset address of image in secondary slot"
808 depends on UPDATEABLE_IMAGE_NUMBER > 1
809 depends on !BOOT_ENCRYPT_IMAGE
810 depends on ARM
811 default y if BOOT_UPGRADE_ONLY
812 help
813 Verify that the reset address in the image located in the secondary slot
814 is contained within the corresponding primary slot. This is recommended
815 if swapping is not used (that is, BOOT_UPGRADE_ONLY is set). If a user
816 incorrectly uploads an update for image 1 to image 0's secondary slot
817 MCUboot will overwrite image 0's primary slot with this image even
818 though it will not boot. If swapping is enabled this will be handled
819 since the image will not confirm itself. If, however, swapping is not
820 enabled then the only mitigation is serial recovery. This feature can
821 also be useful when BOOT_DIRECT_XIP is enabled, to ensure that the image
822 linked at the correct address is loaded.
823
Robert Lubos1b19d2a2020-01-31 14:05:35 +0100824source "Kconfig.zephyr"