blob: 252093ab7db85abd9493d62c0f1b044bdb38c05e [file] [log] [blame]
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +02001# Copyright (c) 2017 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
Andrzej Puzdrowski23d3c662019-03-18 14:12:22 +010016 select USE_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
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040061choice
62 prompt "Signature type"
63 default BOOT_SIGNATURE_TYPE_RSA
64
65config BOOT_SIGNATURE_TYPE_RSA
66 bool "RSA signatures"
67 select BOOT_USE_MBEDTLS
Marti Bolivara4818a52018-04-12 13:02:38 -040068 select MBEDTLS
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040069
Fabio Utzig105b59a2019-05-13 15:08:12 -070070if BOOT_SIGNATURE_TYPE_RSA
71config BOOT_SIGNATURE_TYPE_RSA_LEN
72 int "RSA signature length"
73 range 2048 3072
74 default 2048
75endif
76
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040077config BOOT_SIGNATURE_TYPE_ECDSA_P256
78 bool "Elliptic curve digital signatures with curve P-256"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -040079
Sigvart Hovlandebd05032019-03-21 10:47:32 +010080if BOOT_SIGNATURE_TYPE_ECDSA_P256
81choice
82 prompt "Ecdsa implementation"
Fabio Utzig34e93a52020-02-03 09:59:53 -030083 default BOOT_ECDSA_TINYCRYPT
84config BOOT_ECDSA_TINYCRYPT
Sigvart Hovlandebd05032019-03-21 10:47:32 +010085 bool "Use tinycrypt"
86 select BOOT_USE_TINYCRYPT
87config BOOT_CC310
88 bool "Use CC310"
89 select BOOT_USE_NRF_CC310_BL if HAS_HW_NRF_CC310
90 select NRF_CC310_BL if HAS_HW_NRF_CC310
91 select NRFXLIB_CRYPTO if SOC_FAMILY_NRF
92 select BOOT_USE_CC310
93endchoice
94endif
Fabio Utzig34e93a52020-02-03 09:59:53 -030095
96config BOOT_SIGNATURE_TYPE_ED25519
97 bool "Edwards curve digital signatures using ed25519"
98
99if BOOT_SIGNATURE_TYPE_ED25519
100choice
101 prompt "Ecdsa implementation"
102 default BOOT_ED25519_TINYCRYPT
103config BOOT_ED25519_TINYCRYPT
104 bool "Use tinycrypt"
105 select BOOT_USE_TINYCRYPT
106config BOOT_ED25519_MBEDTLS
107 bool "Use mbedTLS"
108 select BOOT_USE_MBEDTLS
109 select MBEDTLS
110endchoice
111endif
112
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400113endchoice
114
Fabio Utzigc690c762018-04-26 10:51:09 -0300115config BOOT_SIGNATURE_KEY_FILE
116 string "PEM key file"
117 default ""
118 help
119 The key file will be parsed by imgtool's getpub command and a .c source
120 with the public key information will be written in a format expected by
121 MCUboot.
122
Andrzej Puzdrowski9a605b62020-03-16 13:34:30 +0100123config MCUBOOT_CLEANUP_ARM_CORE
124 bool "Perform core cleanup before chain-load the application"
125 depends on CPU_CORTEX_M
126 default y
127
Marti Bolivara4818a52018-04-12 13:02:38 -0400128config MBEDTLS_CFG_FILE
129 default "mcuboot-mbedtls-cfg.h"
130
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400131config BOOT_VALIDATE_SLOT0
David Vincze2d736ad2019-02-18 11:50:22 +0100132 bool "Validate image in the primary slot on every boot"
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400133 default y
134 help
David Vincze2d736ad2019-02-18 11:50:22 +0100135 If y, the bootloader attempts to validate the signature of the
136 primary slot every boot. This adds the signature check time to
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400137 every boot, but can mitigate against some changes that are
138 able to modify the flash image itself.
139
140config BOOT_UPGRADE_ONLY
141 bool "Overwrite image updates instead of swapping"
142 default n
143 help
David Vincze2d736ad2019-02-18 11:50:22 +0100144 If y, overwrite the primary slot with the upgrade image instead
145 of swapping them. This prevents the fallback recovery, but
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400146 uses a much simpler code path.
147
Fabio Utzigc58842e2019-11-28 10:30:01 -0300148config BOOT_SWAP_USING_MOVE
Fabio Utzigdd2b6802020-01-06 09:10:45 -0300149 bool "Swap mode that can run without a scratch partition"
Håkon Øye Amundsen09be7832020-01-24 14:34:49 +0000150 default y if SOC_FAMILY_NRF
Fabio Utzigc58842e2019-11-28 10:30:01 -0300151 default n
152 help
153 If y, the swap upgrade is done in two steps, where first every
154 sector of the primary slot is moved up one sector, then for
155 each sector X in the secondary slot, it is moved to index X in
156 the primary slot, then the sector at X+1 in the primary is
157 moved to index X in the secondary.
158 This allows a swap upgrade without using a scratch partition,
159 but is currently limited to all sectors in both slots being of
160 the same size.
161
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200162config BOOT_BOOTSTRAP
Sam Bristowd0ca0ff2019-10-30 20:51:35 +1300163 bool "Bootstrap erased the primary slot from the secondary slot"
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200164 default n
165 help
166 If y, enables bootstraping support. Bootstrapping allows an erased
David Vincze2d736ad2019-02-18 11:50:22 +0100167 primary slot to be initialized from a valid image in the secondary slot.
Fabio Utzigd0533ed2018-12-19 07:56:33 -0200168 If unsure, leave at the default value.
169
Fabio Utzigca8ead22019-12-20 07:06:04 -0300170config BOOT_SWAP_SAVE_ENCTLV
171 bool "Save encrypted key TLVs instead of plaintext keys in swap metadata"
172 default n
173 help
174 If y, instead of saving the encrypted image keys in plaintext in the
175 swap resume metadata, save the encrypted image TLVs. This should be used
176 when there is no security mechanism protecting the data in the primary
177 slot from being dumped. If n is selected (default), the keys are written
178 after being decrypted from the image TLVs and could be read by an
179 attacker who has access to the flash contents of the primary slot (eg
180 JTAG/SWD or primary slot in external flash).
181 If unsure, leave at the default value.
182
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300183config BOOT_ENCRYPT_RSA
Fabio Utzig42cc29a2019-11-05 07:54:41 -0300184 bool "Support for encrypted upgrade images using RSA"
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300185 default n
186 help
David Vincze2d736ad2019-02-18 11:50:22 +0100187 If y, images in the secondary slot can be encrypted and are decrypted
188 on the fly when upgrading to the primary slot, as well as encrypted
Fabio Utzig42cc29a2019-11-05 07:54:41 -0300189 back when swapping from the primary slot to the secondary slot. The
190 encryption mechanism used in this case is RSA-OAEP (2048 bits).
191
192config BOOT_ENCRYPT_EC256
193 bool "Support for encrypted upgrade images using ECIES-P256"
194 default n
195 help
196 If y, images in the secondary slot can be encrypted and are decrypted
197 on the fly when upgrading to the primary slot, as well as encrypted
198 back when swapping from the primary slot to the secondary slot. The
199 encryption mechanism used in this case is ECIES using primitives
200 described under "ECIES-P256 encryption" in docs/encrypted_images.md.
Fabio Utzig5fe874c2018-08-31 07:41:50 -0300201
Marti Bolivar0e091c92018-04-12 11:23:16 -0400202config BOOT_MAX_IMG_SECTORS
203 int "Maximum number of sectors per image slot"
204 default 128
205 help
206 This option controls the maximum number of sectors that each of
207 the two image areas can contain. Smaller values reduce MCUboot's
208 memory usage; larger values allow it to support larger images.
209 If unsure, leave at the default value.
210
Emanuele Di Santo205c8c62018-07-20 11:42:31 +0200211config BOOT_ERASE_PROGRESSIVELY
212 bool "Erase flash progressively when receiving new firmware"
213 default y if SOC_NRF52840
214 help
215 If enabled, flash is erased as necessary when receiving new firmware,
216 instead of erasing the whole image slot at once. This is necessary
217 on some hardware that has long erase times, to prevent long wait
218 times at the beginning of the DFU process.
219
Rajavardhan Gundi51c9d702019-02-20 14:08:52 +0530220config BOOT_WAIT_FOR_USB_DFU
221 bool "Wait for a prescribed duration to see if USB DFU is invoked"
222 default n
223 select USB
224 select USB_DFU_CLASS
225 select IMG_MANAGER
226 help
227 If y, MCUboot waits for a prescribed duration of time to allow
228 for USB DFU to be invoked. Please note DFU always updates the
229 slot1 image.
230
Marti Bolivarbc2fa4e2018-04-12 12:18:32 -0400231config ZEPHYR_TRY_MASS_ERASE
232 bool "Try to mass erase flash when flashing MCUboot image"
233 default y
234 help
235 If y, attempt to configure the Zephyr build system's "flash"
236 target to mass-erase the flash device before flashing the
237 MCUboot image. This ensures the scratch and other partitions
238 are in a consistent state.
239
240 This is not available for all targets.
241
David Brownf6d14c22019-12-10 15:36:36 -0700242config BOOT_USE_BENCH
243 bool "Enable benchmark code"
244 default n
245 help
246 If y, adds support for simple benchmarking that can record
247 time intervals between two calls. The time printed depends
248 on the particular Zephyr target, and is generally ticks of a
249 specific board-specific timer.
250
Michael Scott74ceae52019-02-01 14:01:09 -0800251module = MCUBOOT
Piotr Mienkowski15aa6ef2019-04-08 22:48:15 +0200252module-str = MCUBoot bootloader
Michael Scott74ceae52019-02-01 14:01:09 -0800253source "subsys/logging/Kconfig.template.log_config"
Michael Scott74ceae52019-02-01 14:01:09 -0800254
Andrzej Puzdrowskiaf148532020-02-25 12:51:26 +0100255config MCUBOOT_LOG_THREAD_STACK_SIZE
256 int "Stack size for the MCUBoot log processing thread"
257 depends on LOG && !LOG_IMMEDIATE
258 default 2048 if COVERAGE_GCOV
259 default 1024 if NO_OPTIMIZATIONS
260 default 1024 if XTENSA
261 default 4096 if (X86 && X86_64)
262 default 4096 if ARM64
263 default 768
264 help
265 Set the internal stack size for MCUBoot log processing thread.
266
Marti Bolivar0e091c92018-04-12 11:23:16 -0400267menuconfig MCUBOOT_SERIAL
268 bool "MCUboot serial recovery"
269 default n
270 select REBOOT
Emanuele Di Santo30a92652019-01-16 14:01:08 +0100271 select GPIO
Marti Bolivar0e091c92018-04-12 11:23:16 -0400272 select SERIAL
Emanuele Di Santo30a92652019-01-16 14:01:08 +0100273 select UART_INTERRUPT_DRIVEN
Marti Bolivar0e091c92018-04-12 11:23:16 -0400274 select BASE64
275 select TINYCBOR
276 help
277 If y, enables a serial-port based update mode. This allows
278 MCUboot itself to load update images into flash over a UART.
279 If unsure, leave at the default value.
280
281if MCUBOOT_SERIAL
282
Emanuele Di Santoc4bf7802018-07-20 11:39:57 +0200283choice
284 prompt "Serial device"
285 default BOOT_SERIAL_UART if !BOARD_NRF52840_PCA10059
286 default BOOT_SERIAL_CDC_ACM if BOARD_NRF52840_PCA10059
287
288config BOOT_SERIAL_UART
289 bool "UART"
290 # SERIAL and UART_INTERRUPT_DRIVEN already selected
291
292config BOOT_SERIAL_CDC_ACM
293 bool "CDC ACM"
294 select USB
295 select USB_DEVICE_STACK
296 select USB_CDC_ACM
297
298endchoice
299
Marti Bolivar0e091c92018-04-12 11:23:16 -0400300config BOOT_MAX_LINE_INPUT_LEN
301 int "Maximum command line length"
302 default 512
303 help
304 Maximum length of commands transported over the serial port.
305
306config BOOT_SERIAL_DETECT_PORT
307 string "GPIO device to trigger serial recovery mode"
308 default GPIO_0 if SOC_FAMILY_NRF
309 help
310 Zephyr GPIO device which contains the pin used to trigger
311 serial recovery mode.
312
313config BOOT_SERIAL_DETECT_PIN
314 int "Pin to trigger serial recovery mode"
Andreas Vibeto704b8ba2019-04-25 10:51:23 +0200315 default 6 if BOARD_NRF9160_PCA10090
Marti Bolivar0e091c92018-04-12 11:23:16 -0400316 default 11 if BOARD_NRF52840_PCA10056
317 default 13 if BOARD_NRF52_PCA10040
Håkon Øye Amundsen6fc25952020-01-02 15:15:42 +0000318 default 23 if BOARD_NRF5340_DK_NRF5340_CPUAPP || BOARD_NRF5340_DK_NRF5340_CPUAPPNS
Marti Bolivar0e091c92018-04-12 11:23:16 -0400319 help
320 Pin on the serial detect port which triggers serial recovery mode.
321
322config BOOT_SERIAL_DETECT_PIN_VAL
323 int "Serial detect pin trigger value"
324 default 0
325 range 0 1
326 help
327 Logic value of the detect pin which triggers serial recovery
328 mode.
329
Andrzej Puzdrowskif0004802019-10-01 14:13:35 +0200330# Workaround for not being able to have commas in macro arguments
331DT_CHOSEN_Z_CONSOLE := zephyr,console
332
333config RECOVERY_UART_DEV_NAME
334 string "UART Device Name for Recovery UART"
335 default "$(dt_chosen_label,$(DT_CHOSEN_Z_CONSOLE))" if HAS_DTS
336 default "UART_0"
337 depends on BOOT_SERIAL_UART
338 help
339 This option specifies the name of UART device to be used for
340 serial recovery.
341
Marti Bolivar0e091c92018-04-12 11:23:16 -0400342endif # MCUBOOT_SERIAL
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200343
Andrzej Puzdrowski97543282018-04-12 15:16:56 +0200344endmenu
345
Carles Cufi84ede582018-01-29 15:12:00 +0100346config MCUBOOT_DEVICE_SETTINGS
347 # Hidden selector for device-specific settings
348 bool
349 default y
350 # CPU options
351 select MCUBOOT_DEVICE_CPU_CORTEX_M0 if CPU_CORTEX_M0
Carles Cufi67c792e2018-01-29 15:14:31 +0100352 # Enable flash page layout if available
353 select FLASH_PAGE_LAYOUT if FLASH_HAS_PAGE_LAYOUT
Andrzej Puzdrowskib788c712018-04-12 12:42:49 +0200354 # Enable flash_map module as flash I/O back-end
355 select FLASH_MAP
Carles Cufi84ede582018-01-29 15:12:00 +0100356
357config MCUBOOT_DEVICE_CPU_CORTEX_M0
358 # Hidden selector for Cortex-M0 settings
359 bool
360 default n
361 select SW_VECTOR_RELAY if !CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
362
Marti Bolivar0e091c92018-04-12 11:23:16 -0400363comment "Zephyr configuration options"
Andrzej Puzdrowski64ad0922017-09-22 11:33:41 +0200364
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700365# Disabling MULTITHREADING provides a code size advantage, but
366# it requires peripheral drivers (particularly a flash driver)
367# that works properly with the option enabled.
368#
369# If you know for sure that your hardware will work, you can default
370# it to n here. Otherwise, having it on by default makes the most
371# hardware work.
372config MULTITHREADING
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100373 default y if BOOT_SERIAL_CDC_ACM #usb driver requires MULTITHREADING
Marti Bolivarf84cc4b2019-08-20 16:06:56 -0700374 default n if SOC_FAMILY_NRF
375 default y
376
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100377config LOG_IMMEDIATE
378 default n if MULTITHREADING
Andrzej Puzdrowski3f092bd2020-02-17 13:25:32 +0100379 default y
380
381config LOG_PROCESS_THREAD
382 default n # mcuboot has its own log processing thread
383
384# override USB device name
385config USB_DEVICE_PRODUCT
386 default "MCUBOOT"
Andrzej Puzdrowski9a4946c2020-02-20 12:39:12 +0100387
Håkon Øye Amundsen954dd2b2019-09-23 09:24:13 +0000388config UPDATEABLE_IMAGE_NUMBER
389 int "Number of updateable images"
390 default 1
391 help
392 Enables support of multi image update.
393
David Vinczec3084132020-02-18 14:50:47 +0100394choice
395 prompt "Downgrade prevention"
396 optional
397
Håkon Øye Amundsen2d1bac12020-01-03 13:08:09 +0000398config MCUBOOT_DOWNGRADE_PREVENTION
David Vinczec3084132020-02-18 14:50:47 +0100399 bool "SW based downgrade prevention"
Håkon Øye Amundsen2d1bac12020-01-03 13:08:09 +0000400 depends on BOOT_UPGRADE_ONLY
401 help
402 Prevent downgrades by enforcing incrementing version numbers.
403 When this option is set, any upgrade must have greater major version
404 or greater minor version with equal major version. This mechanism
405 only protects against some attacks against version downgrades (for
406 example, a JTAG could be used to write an older version).
407
David Vinczec3084132020-02-18 14:50:47 +0100408config MCUBOOT_HW_DOWNGRADE_PREVENTION
409 bool "HW based downgrade prevention"
410 help
411 Prevent undesirable/malicious software downgrades. When this option is
412 set, any upgrade must have greater or equal security counter value.
413 Because of the acceptance of equal values it allows for software
414 downgrade to some extent.
415
416endchoice
417
Robert Lubos1b19d2a2020-01-31 14:05:35 +0100418source "Kconfig.zephyr"