blob: 10cd885579f0d7e0dad5c364fa97a2c096653c2c [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
Emanuele Di Santo865777d2018-11-08 11:28:15 +010017
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040018config BOOT_USE_MBEDTLS
19 bool
20 # Hidden option
21 default n
22 help
23 Use mbedTLS for crypto primitives.
24
25config BOOT_USE_TINYCRYPT
26 bool
27 # Hidden option
28 default n
Sebastian Bøe913a3852019-01-22 13:53:12 +010029 # When building for ECDSA, we use our own copy of mbedTLS, so the
30 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
31 # will collide.
32 depends on ! MBEDTLS
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040033 help
34 Use TinyCrypt for crypto primitives.
35
Sigvart Hovlandebd05032019-03-21 10:47:32 +010036config BOOT_USE_CC310
37 bool
38 # Hidden option
39 default n
40 # When building for ECDSA, we use our own copy of mbedTLS, so the
41 # Zephyr one must not be enabled or the MBEDTLS_CONFIG_FILE macros
42 # will collide.
43 depends on ! MBEDTLS
44 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
Dominik Ermel4dc3f442020-05-26 08:45:14 +000061config SINGLE_IMAGE_DFU
62 bool "Single image application"
63 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
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040069choice
70 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
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040081
Fabio Utzig105b59a2019-05-13 15:08:12 -070082if BOOT_SIGNATURE_TYPE_RSA
83config BOOT_SIGNATURE_TYPE_RSA_LEN
84 int "RSA signature length"
85 range 2048 3072
86 default 2048
87endif
88
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040089config BOOT_SIGNATURE_TYPE_ECDSA_P256
90 bool "Elliptic curve digital signatures with curve P-256"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040091
Sigvart Hovlandebd05032019-03-21 10:47:32 +010092if BOOT_SIGNATURE_TYPE_ECDSA_P256
93choice
94 prompt "Ecdsa implementation"
Fabio Utzig34e93a52020-02-03 09:59:53 -030095 default BOOT_ECDSA_TINYCRYPT
96config BOOT_ECDSA_TINYCRYPT
Sigvart Hovlandebd05032019-03-21 10:47:32 +010097 bool "Use tinycrypt"
98 select BOOT_USE_TINYCRYPT
99config BOOT_CC310
100 bool "Use CC310"
101 select BOOT_USE_NRF_CC310_BL if HAS_HW_NRF_CC310
102 select NRF_CC310_BL if HAS_HW_NRF_CC310
103 select NRFXLIB_CRYPTO if SOC_FAMILY_NRF
104 select BOOT_USE_CC310
105endchoice
106endif
Fabio Utzig34e93a52020-02-03 09:59:53 -0300107
108config BOOT_SIGNATURE_TYPE_ED25519
109 bool "Edwards curve digital signatures using ed25519"
110
111if BOOT_SIGNATURE_TYPE_ED25519
112choice
113 prompt "Ecdsa implementation"
114 default BOOT_ED25519_TINYCRYPT
115config BOOT_ED25519_TINYCRYPT
116 bool "Use tinycrypt"
117 select BOOT_USE_TINYCRYPT
118config BOOT_ED25519_MBEDTLS
119 bool "Use mbedTLS"
120 select BOOT_USE_MBEDTLS
121 select MBEDTLS
122endchoice
123endif
124
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400125endchoice
126
Fabio Utzigc690c762018-04-26 10:51:09 -0300127config BOOT_SIGNATURE_KEY_FILE
128 string "PEM key file"
129 default ""
130 help
131 The key file will be parsed by imgtool's getpub command and a .c source
132 with the public key information will be written in a format expected by
133 MCUboot.
134
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100135config MCUBOOT_CLEANUP_ARM_CORE
136 bool "Perform core cleanup before chain-load the application"
137 depends on CPU_CORTEX_M
138 default y
139
Marti Bolivara4818a52018-04-12 13:02:38 -0400140config MBEDTLS_CFG_FILE
141 default "mcuboot-mbedtls-cfg.h"
142
David Vincze03368b82020-04-01 12:53:53 +0200143config BOOT_HW_KEY
144 bool "Use HW key for image verification"
145 default n
146 help
147 Use HW key for image verification, otherwise the public key is embedded
148 in MCUBoot. If enabled the public key is appended to the signed image
149 and requires the hash of the public key to be provisioned to the device
150 beforehand.
151
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400152config BOOT_VALIDATE_SLOT0
David Vincze2d736ad2019-02-18 11:50:22 +0100153 bool "Validate image in the primary slot on every boot"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400154 default y
155 help
David Vincze2d736ad2019-02-18 11:50:22 +0100156 If y, the bootloader attempts to validate the signature of the
157 primary slot every boot. This adds the signature check time to
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400158 every boot, but can mitigate against some changes that are
159 able to modify the flash image itself.
160
Dominik Ermel4dc3f442020-05-26 08:45:14 +0000161if !SINGLE_IMAGE_DFU
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400162config BOOT_UPGRADE_ONLY
163 bool "Overwrite image updates instead of swapping"
164 default n
165 help
David Vincze2d736ad2019-02-18 11:50:22 +0100166 If y, overwrite the primary slot with the upgrade image instead
167 of swapping them. This prevents the fallback recovery, but
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400168 uses a much simpler code path.
169
Fabio Utzigc58842e2019-11-28 10:30:01 -0300170config BOOT_SWAP_USING_MOVE
Fabio Utzigdd2b6802020-01-06 09:10:45 -0300171 bool "Swap mode that can run without a scratch partition"
Håkon Øye Amundsen09be7832020-01-24 14:34:49 +0000172 default y if SOC_FAMILY_NRF
Fabio Utzigc58842e2019-11-28 10:30:01 -0300173 default n
174 help
175 If y, the swap upgrade is done in two steps, where first every
176 sector of the primary slot is moved up one sector, then for
177 each sector X in the secondary slot, it is moved to index X in
178 the primary slot, then the sector at X+1 in the primary is
179 moved to index X in the secondary.
180 This allows a swap upgrade without using a scratch partition,
181 but is currently limited to all sectors in both slots being of
182 the same size.
Dominik Ermel4dc3f442020-05-26 08:45:14 +0000183endif
Fabio Utzigc58842e2019-11-28 10:30:01 -0300184
Dominik Ermel4dc3f442020-05-26 08:45:14 +0000185if !SINGLE_IMAGE_DFU
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200186config BOOT_BOOTSTRAP
Sam Bristowd0ca0ff2019-10-30 20:51:35 +1300187 bool "Bootstrap erased the primary slot from the secondary slot"
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200188 default n
189 help
190 If y, enables bootstraping support. Bootstrapping allows an erased
David Vincze2d736ad2019-02-18 11:50:22 +0100191 primary slot to be initialized from a valid image in the secondary slot.
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200192 If unsure, leave at the default value.
193
Fabio Utzigca8ead22019-12-20 07:06:04 -0300194config BOOT_SWAP_SAVE_ENCTLV
195 bool "Save encrypted key TLVs instead of plaintext keys in swap metadata"
196 default n
197 help
198 If y, instead of saving the encrypted image keys in plaintext in the
199 swap resume metadata, save the encrypted image TLVs. This should be used
200 when there is no security mechanism protecting the data in the primary
201 slot from being dumped. If n is selected (default), the keys are written
202 after being decrypted from the image TLVs and could be read by an
203 attacker who has access to the flash contents of the primary slot (eg
204 JTAG/SWD or primary slot in external flash).
205 If unsure, leave at the default value.
206
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300207config BOOT_ENCRYPT_RSA
Fabio Utzig42cc29a2019-11-05 07:54:41 -0300208 bool "Support for encrypted upgrade images using RSA"
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300209 default n
210 help
David Vincze2d736ad2019-02-18 11:50:22 +0100211 If y, images in the secondary slot can be encrypted and are decrypted
212 on the fly when upgrading to the primary slot, as well as encrypted
Fabio Utzig42cc29a2019-11-05 07:54:41 -0300213 back when swapping from the primary slot to the secondary slot. The
214 encryption mechanism used in this case is RSA-OAEP (2048 bits).
215
216config BOOT_ENCRYPT_EC256
217 bool "Support for encrypted upgrade images using ECIES-P256"
218 default n
219 help
220 If y, images in the secondary slot can be encrypted and are decrypted
221 on the fly when upgrading to the primary slot, as well as encrypted
222 back when swapping from the primary slot to the secondary slot. The
223 encryption mechanism used in this case is ECIES using primitives
224 described under "ECIES-P256 encryption" in docs/encrypted_images.md.
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300225
Fabio Utzigb6f014c2020-04-02 13:25:01 -0300226config BOOT_ENCRYPT_X25519
227 bool "Support for encrypted upgrade images using ECIES-X25519"
228 default n
229 help
230 If y, images in the secondary slot can be encrypted and are decrypted
231 on the fly when upgrading to the primary slot, as well as encrypted
232 back when swapping from the primary slot to the secondary slot. The
233 encryption mechanism used in this case is ECIES using primitives
234 described under "ECIES-X25519 encryption" in docs/encrypted_images.md.
Dominik Ermel4dc3f442020-05-26 08:45:14 +0000235endif
Fabio Utzigb6f014c2020-04-02 13:25:01 -0300236
Marti Bolivar0e091c92018-04-12 11:23:16 -0400237config BOOT_MAX_IMG_SECTORS
238 int "Maximum number of sectors per image slot"
239 default 128
240 help
241 This option controls the maximum number of sectors that each of
242 the two image areas can contain. Smaller values reduce MCUboot's
243 memory usage; larger values allow it to support larger images.
244 If unsure, leave at the default value.
245
Emanuele Di Santo205c8c62018-07-20 11:42:31 +0200246config BOOT_ERASE_PROGRESSIVELY
247 bool "Erase flash progressively when receiving new firmware"
248 default y if SOC_NRF52840
249 help
250 If enabled, flash is erased as necessary when receiving new firmware,
251 instead of erasing the whole image slot at once. This is necessary
252 on some hardware that has long erase times, to prevent long wait
253 times at the beginning of the DFU process.
254
David Vincze1cf11b52020-03-24 07:51:09 +0100255config MEASURED_BOOT
256 bool "Store the boot state/measurements in shared memory"
257 default n
258 help
259 If enabled, the bootloader will store certain boot measurements such as
260 the hash of the firmware image in a shared memory area. This data can
261 be used later by runtime services (e.g. by a device attestation service).
262
263config BOOT_SHARE_DATA
264 bool "Save application specific data in shared memory area"
265 default n
266
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530267config BOOT_WAIT_FOR_USB_DFU
268 bool "Wait for a prescribed duration to see if USB DFU is invoked"
269 default n
270 select USB
271 select USB_DFU_CLASS
272 select IMG_MANAGER
273 help
274 If y, MCUboot waits for a prescribed duration of time to allow
275 for USB DFU to be invoked. Please note DFU always updates the
276 slot1 image.
277
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400278config ZEPHYR_TRY_MASS_ERASE
279 bool "Try to mass erase flash when flashing MCUboot image"
280 default y
281 help
282 If y, attempt to configure the Zephyr build system's "flash"
283 target to mass-erase the flash device before flashing the
284 MCUboot image. This ensures the scratch and other partitions
285 are in a consistent state.
286
287 This is not available for all targets.
288
David Brownf6d14c22019-12-10 15:36:36 -0700289config BOOT_USE_BENCH
290 bool "Enable benchmark code"
291 default n
292 help
293 If y, adds support for simple benchmarking that can record
294 time intervals between two calls. The time printed depends
295 on the particular Zephyr target, and is generally ticks of a
296 specific board-specific timer.
297
Michael Scott74ceae52019-02-01 14:01:09 -0800298module = MCUBOOT
Piotr Mienkowski15aa6ef2019-04-08 22:48:15 +0200299module-str = MCUBoot bootloader
Michael Scott74ceae52019-02-01 14:01:09 -0800300source "subsys/logging/Kconfig.template.log_config"
Michael Scott74ceae52019-02-01 14:01:09 -0800301
Andrzej Puzdrowskiaf148532020-02-25 12:51:26 +0100302config MCUBOOT_LOG_THREAD_STACK_SIZE
303 int "Stack size for the MCUBoot log processing thread"
304 depends on LOG && !LOG_IMMEDIATE
305 default 2048 if COVERAGE_GCOV
306 default 1024 if NO_OPTIMIZATIONS
307 default 1024 if XTENSA
308 default 4096 if (X86 && X86_64)
309 default 4096 if ARM64
310 default 768
311 help
312 Set the internal stack size for MCUBoot log processing thread.
313
Marti Bolivar0e091c92018-04-12 11:23:16 -0400314menuconfig MCUBOOT_SERIAL
315 bool "MCUboot serial recovery"
316 default n
317 select REBOOT
Emanuele Di Santo30a92652019-01-16 14:01:08 +0100318 select GPIO
Marti Bolivar0e091c92018-04-12 11:23:16 -0400319 select SERIAL
Emanuele Di Santo30a92652019-01-16 14:01:08 +0100320 select UART_INTERRUPT_DRIVEN
Marti Bolivar0e091c92018-04-12 11:23:16 -0400321 select BASE64
322 select TINYCBOR
323 help
324 If y, enables a serial-port based update mode. This allows
325 MCUboot itself to load update images into flash over a UART.
326 If unsure, leave at the default value.
327
328if MCUBOOT_SERIAL
329
Emanuele Di Santoc4bf7802018-07-20 11:39:57 +0200330choice
331 prompt "Serial device"
Andrzej Puzdrowskif4a9a9d2020-04-24 12:31:51 +0200332 default BOOT_SERIAL_UART if !BOARD_NRF52840DONGLE_NRF52840
333 default BOOT_SERIAL_CDC_ACM if BOARD_NRF52840DONGLE_NRF52840
Emanuele Di Santoc4bf7802018-07-20 11:39:57 +0200334
335config BOOT_SERIAL_UART
336 bool "UART"
337 # SERIAL and UART_INTERRUPT_DRIVEN already selected
338
339config BOOT_SERIAL_CDC_ACM
340 bool "CDC ACM"
341 select USB
342 select USB_DEVICE_STACK
343 select USB_CDC_ACM
344
345endchoice
346
Marti Bolivar0e091c92018-04-12 11:23:16 -0400347config BOOT_MAX_LINE_INPUT_LEN
348 int "Maximum command line length"
349 default 512
350 help
351 Maximum length of commands transported over the serial port.
352
353config BOOT_SERIAL_DETECT_PORT
354 string "GPIO device to trigger serial recovery mode"
355 default GPIO_0 if SOC_FAMILY_NRF
356 help
357 Zephyr GPIO device which contains the pin used to trigger
358 serial recovery mode.
359
360config BOOT_SERIAL_DETECT_PIN
361 int "Pin to trigger serial recovery mode"
Andrzej Puzdrowskif4a9a9d2020-04-24 12:31:51 +0200362 default 6 if BOARD_NRF9160DK_NRF9160
Andrzej Puzdrowskifefdea22020-03-27 09:41:14 +0100363 default 11 if BOARD_NRF52840DK_NRF52840
Andrzej Puzdrowskif4a9a9d2020-04-24 12:31:51 +0200364 default 13 if BOARD_NRF52DK_NRF52832
Håkon Øye Amundsen6fc25952020-01-02 15:15:42 +0000365 default 23 if BOARD_NRF5340_DK_NRF5340_CPUAPP || BOARD_NRF5340_DK_NRF5340_CPUAPPNS
Marti Bolivar0e091c92018-04-12 11:23:16 -0400366 help
367 Pin on the serial detect port which triggers serial recovery mode.
368
369config BOOT_SERIAL_DETECT_PIN_VAL
370 int "Serial detect pin trigger value"
371 default 0
372 range 0 1
373 help
374 Logic value of the detect pin which triggers serial recovery
375 mode.
376
Andrzej Puzdrowskif0004802019-10-01 14:13:35 +0200377# Workaround for not being able to have commas in macro arguments
378DT_CHOSEN_Z_CONSOLE := zephyr,console
379
380config RECOVERY_UART_DEV_NAME
381 string "UART Device Name for Recovery UART"
382 default "$(dt_chosen_label,$(DT_CHOSEN_Z_CONSOLE))" if HAS_DTS
383 default "UART_0"
384 depends on BOOT_SERIAL_UART
385 help
386 This option specifies the name of UART device to be used for
387 serial recovery.
388
Marti Bolivar0e091c92018-04-12 11:23:16 -0400389endif # MCUBOOT_SERIAL
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200390
Rafał Kuźniad854bb62020-06-17 15:06:47 +0200391config BOOT_INTR_VEC_RELOC
392 bool "Relocate the interrupt vector to the application"
393 default n
394 depends on SW_VECTOR_RELAY || CPU_CORTEX_M_HAS_VTOR
395 help
396 Relocate the interrupt vector to the application before it is started.
397 Select this option if application requires vector relocation,
398 but it doesn't relocate vector in its reset handler.
399
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200400config UPDATEABLE_IMAGE_NUMBER
401 int "Number of updateable images"
402 default 1
Dominik Ermel4dc3f442020-05-26 08:45:14 +0000403 range 1 1 if SINGLE_IMAGE_DFU
Andrzej Puzdrowski16b6d152020-06-01 14:16:54 +0200404 help
405 Enables support of multi image update.
406
407choice
408 prompt "Downgrade prevention"
409 optional
410
411config MCUBOOT_DOWNGRADE_PREVENTION
412 bool "SW based downgrade prevention"
413 depends on BOOT_UPGRADE_ONLY
414 help
415 Prevent downgrades by enforcing incrementing version numbers.
416 When this option is set, any upgrade must have greater major version
417 or greater minor version with equal major version. This mechanism
418 only protects against some attacks against version downgrades (for
419 example, a JTAG could be used to write an older version).
420
421config MCUBOOT_HW_DOWNGRADE_PREVENTION
422 bool "HW based downgrade prevention"
423 help
424 Prevent undesirable/malicious software downgrades. When this option is
425 set, any upgrade must have greater or equal security counter value.
426 Because of the acceptance of equal values it allows for software
427 downgrade to some extent.
428
429endchoice
430
Andrzej Puzdrowski97543282018-04-12 15:16:56 +0200431endmenu
432
Carles Cufi84ede582018-01-29 15:12:00 +0100433config MCUBOOT_DEVICE_SETTINGS
434 # Hidden selector for device-specific settings
435 bool
436 default y
437 # CPU options
438 select MCUBOOT_DEVICE_CPU_CORTEX_M0 if CPU_CORTEX_M0
Carles Cufi67c792e2018-01-29 15:14:31 +0100439 # Enable flash page layout if available
440 select FLASH_PAGE_LAYOUT if FLASH_HAS_PAGE_LAYOUT
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +0200441 # Enable flash_map module as flash I/O back-end
442 select FLASH_MAP
Carles Cufi84ede582018-01-29 15:12:00 +0100443
444config MCUBOOT_DEVICE_CPU_CORTEX_M0
445 # Hidden selector for Cortex-M0 settings
446 bool
447 default n
448 select SW_VECTOR_RELAY if !CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
449
Marti Bolivar0e091c92018-04-12 11:23:16 -0400450comment "Zephyr configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200451
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700452# Disabling MULTITHREADING provides a code size advantage, but
453# it requires peripheral drivers (particularly a flash driver)
454# that works properly with the option enabled.
455#
456# If you know for sure that your hardware will work, you can default
457# it to n here. Otherwise, having it on by default makes the most
458# hardware work.
459config MULTITHREADING
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100460 default y if BOOT_SERIAL_CDC_ACM #usb driver requires MULTITHREADING
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700461 default n if SOC_FAMILY_NRF
462 default y
463
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100464config LOG_IMMEDIATE
465 default n if MULTITHREADING
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100466 default y
467
468config LOG_PROCESS_THREAD
469 default n # mcuboot has its own log processing thread
470
471# override USB device name
472config USB_DEVICE_PRODUCT
473 default "MCUBOOT"
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100474
Robert Lubos1b19d2a2020-01-31 14:05:35 +0100475source "Kconfig.zephyr"