Kconfig.projbuild 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. menu "Bootloader config"
  2. choice BOOTLOADER_COMPILER_OPTIMIZATION
  3. prompt "Bootloader optimization Level"
  4. default BOOTLOADER_COMPILER_OPTIMIZATION_SIZE
  5. help
  6. This option sets compiler optimization level (gcc -O argument)
  7. for the bootloader.
  8. - The default "Size" setting will add the -0s flag to CFLAGS.
  9. - The "Debug" setting will add the -Og flag to CFLAGS.
  10. - The "Performance" setting will add the -O2 flag to CFLAGS.
  11. - The "None" setting will add the -O0 flag to CFLAGS.
  12. Note that custom optimization levels may be unsupported.
  13. config BOOTLOADER_COMPILER_OPTIMIZATION_SIZE
  14. bool "Size (-Os)"
  15. config BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG
  16. bool "Debug (-Og)"
  17. config BOOTLOADER_COMPILER_OPTIMIZATION_PERF
  18. bool "Optimize for performance (-O2)"
  19. config BOOTLOADER_COMPILER_OPTIMIZATION_NONE
  20. bool "Debug without optimization (-O0)"
  21. endchoice
  22. choice BOOTLOADER_LOG_LEVEL
  23. bool "Bootloader log verbosity"
  24. default BOOTLOADER_LOG_LEVEL_INFO
  25. help
  26. Specify how much output to see in bootloader logs.
  27. config BOOTLOADER_LOG_LEVEL_NONE
  28. bool "No output"
  29. config BOOTLOADER_LOG_LEVEL_ERROR
  30. bool "Error"
  31. config BOOTLOADER_LOG_LEVEL_WARN
  32. bool "Warning"
  33. config BOOTLOADER_LOG_LEVEL_INFO
  34. bool "Info"
  35. config BOOTLOADER_LOG_LEVEL_DEBUG
  36. bool "Debug"
  37. config BOOTLOADER_LOG_LEVEL_VERBOSE
  38. bool "Verbose"
  39. endchoice
  40. config BOOTLOADER_LOG_LEVEL
  41. int
  42. default 0 if BOOTLOADER_LOG_LEVEL_NONE
  43. default 1 if BOOTLOADER_LOG_LEVEL_ERROR
  44. default 2 if BOOTLOADER_LOG_LEVEL_WARN
  45. default 3 if BOOTLOADER_LOG_LEVEL_INFO
  46. default 4 if BOOTLOADER_LOG_LEVEL_DEBUG
  47. default 5 if BOOTLOADER_LOG_LEVEL_VERBOSE
  48. config BOOTLOADER_SPI_WP_PIN
  49. int "SPI Flash WP Pin when customising pins via eFuse (read help)"
  50. range 0 33
  51. default 7
  52. depends on ESPTOOLPY_FLASHMODE_QIO || ESPTOOLPY_FLASHMODE_QOUT
  53. help
  54. This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
  55. overriden by setting the eFuses SPI_PAD_CONFIG_xxx.
  56. When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
  57. pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. That pin number is compiled into the
  58. bootloader instead.
  59. The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
  60. choice BOOTLOADER_VDDSDIO_BOOST
  61. bool "VDDSDIO LDO voltage"
  62. default BOOTLOADER_VDDSDIO_BOOST_1_9V
  63. help
  64. If this option is enabled, and VDDSDIO LDO is set to 1.8V (using eFuse
  65. or MTDI bootstrapping pin), bootloader will change LDO settings to
  66. output 1.9V instead. This helps prevent flash chip from browning out
  67. during flash programming operations.
  68. This option has no effect if VDDSDIO is set to 3.3V, or if the internal
  69. VDDSDIO regulator is disabled via eFuse.
  70. config BOOTLOADER_VDDSDIO_BOOST_1_8V
  71. bool "1.8V"
  72. depends on !ESPTOOLPY_FLASHFREQ_80M
  73. config BOOTLOADER_VDDSDIO_BOOST_1_9V
  74. bool "1.9V"
  75. endchoice
  76. config BOOTLOADER_FACTORY_RESET
  77. bool "GPIO triggers factory reset"
  78. default N
  79. help
  80. Allows to reset the device to factory settings:
  81. - clear one or more data partitions;
  82. - boot from "factory" partition.
  83. The factory reset will occur if there is a GPIO input pulled low while device starts up.
  84. See settings below.
  85. config BOOTLOADER_NUM_PIN_FACTORY_RESET
  86. int "Number of the GPIO input for factory reset"
  87. depends on BOOTLOADER_FACTORY_RESET
  88. range 0 39
  89. default 4
  90. help
  91. The selected GPIO will be configured as an input with internal pull-up enabled.
  92. To trigger a factory reset, this GPIO must be pulled low on reset.
  93. Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
  94. config BOOTLOADER_OTA_DATA_ERASE
  95. bool "Clear OTA data on factory reset (select factory partition)"
  96. depends on BOOTLOADER_FACTORY_RESET
  97. help
  98. The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a
  99. factory reset.
  100. config BOOTLOADER_DATA_FACTORY_RESET
  101. string "Comma-separated names of partitions to clear on factory reset"
  102. depends on BOOTLOADER_FACTORY_RESET
  103. default "nvs"
  104. help
  105. Allows customers to select which data partitions will be erased while factory reset.
  106. Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this:
  107. "nvs, phy_init, ...")
  108. Make sure that the name specified in the partition table and here are the same.
  109. Partitions of type "app" cannot be specified here.
  110. config BOOTLOADER_APP_TEST
  111. bool "GPIO triggers boot from test app partition"
  112. default N
  113. help
  114. Allows to run the test app from "TEST" partition.
  115. A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
  116. See settings below.
  117. config BOOTLOADER_NUM_PIN_APP_TEST
  118. int "Number of the GPIO input to boot TEST partition"
  119. depends on BOOTLOADER_APP_TEST
  120. range 0 39
  121. default 18
  122. help
  123. The selected GPIO will be configured as an input with internal pull-up enabled.
  124. To trigger a test app, this GPIO must be pulled low on reset.
  125. After the GPIO input is deactivated and the device reboots, the old application will boot.
  126. (factory or OTA[x]).
  127. Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
  128. config BOOTLOADER_HOLD_TIME_GPIO
  129. int "Hold time of GPIO for reset/test mode (seconds)"
  130. depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
  131. default 5
  132. help
  133. The GPIO must be held low continuously for this period of time after reset
  134. before a factory reset or test partition boot (as applicable) is performed.
  135. config BOOTLOADER_WDT_ENABLE
  136. bool "Use RTC watchdog in start code"
  137. default y
  138. help
  139. Tracks the execution time of startup code.
  140. If the execution time is exceeded, the RTC_WDT will restart system.
  141. It is also useful to prevent a lock up in start code caused by an unstable power source.
  142. NOTE: Tracks the execution time starts from the bootloader code - re-set timeout, while selecting the
  143. source for slow_clk - and ends calling app_main.
  144. Re-set timeout is needed due to WDT uses a SLOW_CLK clock source. After changing a frequency slow_clk a
  145. time of WDT needs to re-set for new frequency.
  146. slow_clk depends on ESP32_RTC_CLK_SRC (INTERNAL_RC or EXTERNAL_CRYSTAL).
  147. config BOOTLOADER_WDT_DISABLE_IN_USER_CODE
  148. bool "Allows RTC watchdog disable in user code"
  149. depends on BOOTLOADER_WDT_ENABLE
  150. default n
  151. help
  152. If it is set, the client must itself reset or disable rtc_wdt in their code (app_main()).
  153. Otherwise rtc_wdt will be disabled before calling app_main function.
  154. Use function rtc_wdt_feed() for resetting counter of rtc_wdt.
  155. Use function rtc_wdt_disable() for disabling rtc_wdt.
  156. config BOOTLOADER_WDT_TIME_MS
  157. int "Timeout for RTC watchdog (ms)"
  158. depends on BOOTLOADER_WDT_ENABLE
  159. default 9000
  160. range 0 120000
  161. help
  162. Verify that this parameter is correct and more then the execution time.
  163. Pay attention to options such as reset to factory, trigger test partition and encryption on boot
  164. - these options can increase the execution time.
  165. Note: RTC_WDT will reset while encryption operations will be performed.
  166. config BOOTLOADER_APP_ROLLBACK_ENABLE
  167. bool "Enable app rollback support"
  168. default n
  169. help
  170. After updating the app, the bootloader runs a new app with the "ESP_OTA_IMG_PENDING_VERIFY" state set.
  171. This state prevents the re-run of this app. After the first boot of the new app in the user code, the
  172. function should be called to confirm the operability of the app or vice versa about its non-operability.
  173. If the app is working, then it is marked as valid. Otherwise, it is marked as not valid and rolls back to
  174. the previous working app. A reboot is performed, and the app is booted before the software update.
  175. Note: If during the first boot a new app the power goes out or the WDT works, then roll back will happen.
  176. Rollback is possible only between the apps with the same security versions.
  177. config BOOTLOADER_APP_ANTI_ROLLBACK
  178. bool "Enable app anti-rollback support"
  179. depends on BOOTLOADER_APP_ROLLBACK_ENABLE
  180. default n
  181. help
  182. This option prevents rollback to previous firmware/application image with lower security version.
  183. config BOOTLOADER_APP_SECURE_VERSION
  184. int "eFuse secure version of app"
  185. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  186. default 0
  187. help
  188. The secure version is the sequence number stored in the header of each firmware.
  189. The security version is set in the bootloader, version is recorded in the eFuse field
  190. as the number of set ones. The allocated number of bits in the efuse field
  191. for storing the security version is limited (see BOOTLOADER_APP_SEC_VER_SIZE_EFUSE_FIELD option).
  192. Bootloader: When bootloader selects an app to boot, an app is selected that has
  193. a security version greater or equal that recorded in eFuse field.
  194. The app is booted with a higher (or equal) secure version.
  195. The security version is worth increasing if in previous versions there is
  196. a significant vulnerability and their use is not acceptable.
  197. Your partition table should has a scheme with ota_0 + ota_1 (without factory).
  198. config BOOTLOADER_APP_SEC_VER_SIZE_EFUSE_FIELD
  199. int "Size of the efuse secure version field"
  200. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  201. range 1 32 if IDF_TARGET_ESP32
  202. default 32 if IDF_TARGET_ESP32
  203. range 1 16 if IDF_TARGET_ESP32S2
  204. default 16 if IDF_TARGET_ESP32S2
  205. help
  206. The size of the efuse secure version field.
  207. Its length is limited to 32 bits for ESP32 and 16 bits for ESP32-S2.
  208. This determines how many times the security version can be increased.
  209. config BOOTLOADER_EFUSE_SECURE_VERSION_EMULATE
  210. bool "Emulate operations with efuse secure version(only test)"
  211. default n
  212. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  213. help
  214. This option allow emulate read/write operations with efuse secure version.
  215. It allow to test anti-rollback implemention without permanent write eFuse bits.
  216. In partition table should be exist this partition `emul_efuse, data, 5, , 0x2000`.
  217. config BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
  218. bool "Skip image validation when exiting deep sleep"
  219. depends on (SECURE_BOOT && SECURE_BOOT_INSECURE) || !SECURE_BOOT
  220. default n
  221. help
  222. This option disables the normal validation of an image coming out of
  223. deep sleep (checksums, SHA256, and signature). This is a trade-off
  224. between wakeup performance from deep sleep, and image integrity checks.
  225. Only enable this if you know what you are doing. It should not be used
  226. in conjunction with using deep_sleep() entry and changing the active OTA
  227. partition as this would skip the validation upon first load of the new
  228. OTA partition.
  229. config BOOTLOADER_RESERVE_RTC_SIZE
  230. hex
  231. default 0x10 if BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP || BOOTLOADER_CUSTOM_RESERVE_RTC
  232. default 0
  233. help
  234. Reserve RTC FAST memory for Skip image validation. This option in bytes.
  235. This option reserves an area in the RTC FAST memory (access only PRO_CPU).
  236. Used to save the addresses of the selected application.
  237. When a wakeup occurs (from Deep sleep), the bootloader retrieves it and
  238. loads the application without validation.
  239. config BOOTLOADER_CUSTOM_RESERVE_RTC
  240. bool "Reserve RTC FAST memory for custom purposes"
  241. default n
  242. help
  243. This option allows the customer to place data in the RTC FAST memory,
  244. this area remains valid when rebooted, except for power loss.
  245. This memory is located at a fixed address and is available
  246. for both the bootloader and the application.
  247. (The application and bootoloader must be compiled with the same option).
  248. The RTC FAST memory has access only through PRO_CPU.
  249. config BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE
  250. hex "Size in bytes for custom purposes"
  251. range 0 0x10
  252. default 0
  253. depends on BOOTLOADER_CUSTOM_RESERVE_RTC
  254. help
  255. This option reserves in RTC FAST memory the area for custom purposes.
  256. If you want to create your own bootloader and save more information
  257. in this area of memory, you can increase it. It must be a multiple of 4 bytes.
  258. This area (rtc_retain_mem_t) is reserved and has access from the bootloader and an application.
  259. endmenu # Bootloader
  260. menu "Security features"
  261. # These three are the actual options to check in code,
  262. # selected by the displayed options
  263. config SECURE_SIGNED_ON_BOOT
  264. bool
  265. default y
  266. depends on SECURE_BOOT || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
  267. config SECURE_SIGNED_ON_UPDATE
  268. bool
  269. default y
  270. depends on SECURE_BOOT || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
  271. config SECURE_SIGNED_APPS
  272. bool
  273. default y
  274. select MBEDTLS_ECP_DP_SECP256R1_ENABLED
  275. select MBEDTLS_ECP_C
  276. select MBEDTLS_ECDH_C
  277. select MBEDTLS_ECDSA_C
  278. depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
  279. config SECURE_SIGNED_APPS_NO_SECURE_BOOT
  280. bool "Require signed app images"
  281. depends on !SECURE_BOOT
  282. help
  283. Require apps to be signed to verify their integrity.
  284. This option uses the same app signature scheme as hardware secure boot, but unlike hardware secure boot it
  285. does not prevent the bootloader from being physically updated. This means that the device can be secured
  286. against remote network access, but not physical access. Compared to using hardware Secure Boot this option
  287. is much simpler to implement.
  288. choice SECURE_SIGNED_APPS_SCHEME
  289. bool "App Signing Scheme"
  290. depends on SECURE_BOOT || SECURE_SIGNED_APPS_NO_SECURE_BOOT
  291. default SECURE_SIGNED_APPS_ECDSA_SCHEME if SECURE_BOOT_V1_ENABLED
  292. default SECURE_SIGNED_APPS_RSA_SCHEME if SECURE_BOOT_V2_ENABLED
  293. help
  294. Select the Secure App signing scheme. Depends on the Chip Revision.
  295. There are two options:
  296. 1. ECDSA based secure boot scheme. (Only choice for Secure Boot V1)
  297. Supported in ESP32 and ESP32-ECO3.
  298. 2. The RSA based secure boot scheme. (Only choice for Secure Boot V2)
  299. Supported in ESP32-ECO3. (ESP32 Chip Revision 3 onwards)
  300. config SECURE_SIGNED_APPS_ECDSA_SCHEME
  301. bool "ECDSA"
  302. depends on IDF_TARGET_ESP32 && (SECURE_SIGNED_APPS_NO_SECURE_BOOT || SECURE_BOOT_V1_ENABLED)
  303. help
  304. Embeds the ECDSA public key in the bootloader and signs the application with an ECDSA key.
  305. Refer to the documentation before enabling.
  306. config SECURE_SIGNED_APPS_RSA_SCHEME
  307. bool "RSA"
  308. depends on ESP32_REV_MIN_3 && SECURE_BOOT_V2_ENABLED
  309. help
  310. Appends the RSA-3072 based Signature block to the application.
  311. Refer to <Secure Boot Version 2 documentation link> before enabling.
  312. endchoice
  313. config SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
  314. bool "Bootloader verifies app signatures"
  315. default n
  316. depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
  317. help
  318. If this option is set, the bootloader will be compiled with code to verify that an app is signed before
  319. booting it.
  320. If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
  321. If hardware secure boot is not enabled, this option doesn't add significant security by itself so most
  322. users will want to leave it disabled.
  323. config SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
  324. bool "Verify app signature on update"
  325. default y
  326. depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
  327. help
  328. If this option is set, any OTA updated apps will have the signature verified before being considered valid.
  329. When enabled, the signature is automatically checked whenever the esp_ota_ops.h APIs are used for OTA
  330. updates, or esp_image_format.h APIs are used to verify apps.
  331. If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
  332. If hardware secure boot is not enabled, this option still adds significant security against network-based
  333. attackers by preventing spoofing of OTA updates.
  334. config SECURE_BOOT
  335. bool "Enable hardware Secure Boot in bootloader (READ DOCS FIRST)"
  336. default n
  337. help
  338. Build a bootloader which enables Secure Boot on first boot.
  339. Once enabled, Secure Boot will not boot a modified bootloader. The bootloader will only load a partition
  340. table or boot an app if the data has a verified digital signature. There are implications for reflashing
  341. updated apps once secure boot is enabled.
  342. When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
  343. choice SECURE_BOOT_VERSION
  344. bool "Select secure boot version"
  345. default SECURE_BOOT_V2_ENABLED if ESP32_REV_MIN_3
  346. depends on SECURE_BOOT
  347. help
  348. Select the Secure Boot Version. Depends on the Chip Revision.
  349. Secure Boot V2 is the new RSA based secure boot scheme.
  350. Supported in ESP32-ECO3. (ESP32 Chip Revision 3 onwards)
  351. Secure Boot V1 is the AES based secure boot scheme.
  352. Supported in ESP32 and ESP32-ECO3.
  353. config SECURE_BOOT_V1_ENABLED
  354. bool "Enable Secure Boot version 1"
  355. depends on IDF_TARGET_ESP32
  356. help
  357. Build a bootloader which enables secure boot version 1 on first boot.
  358. Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
  359. config SECURE_BOOT_V2_ENABLED
  360. bool "Enable Secure Boot version 2"
  361. depends on ESP32_REV_MIN_3
  362. help
  363. Build a bootloader which enables Secure Boot version 2 on first boot.
  364. Refer to Secure Boot V2 section of the ESP-IDF Programmer's Guide for this version before enabling.
  365. endchoice
  366. choice SECURE_BOOTLOADER_MODE
  367. bool "Secure bootloader mode"
  368. depends on SECURE_BOOT_V1_ENABLED
  369. default SECURE_BOOTLOADER_ONE_TIME_FLASH
  370. config SECURE_BOOTLOADER_ONE_TIME_FLASH
  371. bool "One-time flash"
  372. help
  373. On first boot, the bootloader will generate a key which is not readable externally or by software. A
  374. digest is generated from the bootloader image itself. This digest will be verified on each subsequent
  375. boot.
  376. Enabling this option means that the bootloader cannot be changed after the first time it is booted.
  377. config SECURE_BOOTLOADER_REFLASHABLE
  378. bool "Reflashable"
  379. help
  380. Generate a reusable secure bootloader key, derived (via SHA-256) from the secure boot signing key.
  381. This allows the secure bootloader to be re-flashed by anyone with access to the secure boot signing
  382. key.
  383. This option is less secure than one-time flash, because a leak of the digest key from one device
  384. allows reflashing of any device that uses it.
  385. endchoice
  386. config SECURE_BOOT_BUILD_SIGNED_BINARIES
  387. bool "Sign binaries during build"
  388. depends on SECURE_SIGNED_APPS
  389. default y
  390. help
  391. Once secure boot or signed app requirement is enabled, app images are required to be signed.
  392. If enabled (default), these binary files are signed as part of the build process. The file named in
  393. "Secure boot private signing key" will be used to sign the image.
  394. If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py.
  395. Version 1 to enable ECDSA Based Secure Boot and Version 2 to enable RSA based Secure Boot.
  396. (for example, on a remote signing server.)
  397. config SECURE_BOOT_SIGNING_KEY
  398. string "Secure boot private signing key"
  399. depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
  400. default "secure_boot_signing_key.pem"
  401. help
  402. Path to the key file used to sign app images.
  403. Key file is an ECDSA private key (NIST256p curve) in PEM format for Secure Boot V1.
  404. Key file is an RSA private key in PEM format for Secure Boot V2.
  405. Path is evaluated relative to the project directory.
  406. You can generate a new signing key by running the following command:
  407. espsecure.py generate_signing_key secure_boot_signing_key.pem
  408. See the Secure Boot section of the ESP-IDF Programmer's Guide for this version for details.
  409. config SECURE_BOOT_VERIFICATION_KEY
  410. string "Secure boot public signature verification key"
  411. depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES && !SECURE_SIGNED_APPS_RSA_SCHEME
  412. default "signature_verification_key.bin"
  413. help
  414. Path to a public key file used to verify signed images.
  415. Secure Boot V1: This ECDSA public key is compiled into the bootloader and/or
  416. app, to verify app images.
  417. Secure Boot V2: This RSA public key is compiled into the signature block at
  418. the end of the bootloader/app.
  419. Key file is in raw binary format, and can be extracted from a
  420. PEM formatted private key using the espsecure.py
  421. extract_public_key command.
  422. Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
  423. choice SECURE_BOOTLOADER_KEY_ENCODING
  424. bool "Hardware Key Encoding"
  425. depends on SECURE_BOOTLOADER_REFLASHABLE
  426. default SECURE_BOOTLOADER_KEY_ENCODING_256BIT
  427. help
  428. In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and
  429. can be written to eFuse with espefuse.py.
  430. Normally this is a 256-bit key, but if 3/4 Coding Scheme is used on the device then the eFuse key is
  431. truncated to 192 bits.
  432. This configuration item doesn't change any firmware code, it only changes the size of key binary which is
  433. generated at build time.
  434. config SECURE_BOOTLOADER_KEY_ENCODING_256BIT
  435. bool "No encoding (256 bit key)"
  436. config SECURE_BOOTLOADER_KEY_ENCODING_192BIT
  437. bool "3/4 encoding (192 bit key)"
  438. endchoice
  439. config SECURE_BOOT_INSECURE
  440. bool "Allow potentially insecure options"
  441. depends on SECURE_BOOT
  442. default N
  443. help
  444. You can disable some of the default protections offered by secure boot, in order to enable testing or a
  445. custom combination of security features.
  446. Only enable these options if you are very sure.
  447. Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
  448. config SECURE_FLASH_ENC_ENABLED
  449. bool "Enable flash encryption on boot (READ DOCS FIRST)"
  450. default N
  451. help
  452. If this option is set, flash contents will be encrypted by the bootloader on first boot.
  453. Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
  454. system is complicated and not always possible.
  455. Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html
  456. before enabling.
  457. choice SECURE_FLASH_ENCRYPTION_KEYSIZE
  458. bool "Size of generated AES-XTS key"
  459. default SECURE_FLASH_ENCRYPTION_AES128
  460. depends on IDF_TARGET_ESP32S2 && SECURE_FLASH_ENC_ENABLED
  461. help
  462. Size of generated AES-XTS key.
  463. AES-128 uses a 256-bit key (32 bytes) which occupies one Efuse key block.
  464. AES-256 uses a 512-bit key (64 bytes) which occupies two Efuse key blocks.
  465. This setting is ignored if either type of key is already burned to Efuse before the first boot.
  466. In this case, the pre-burned key is used and no new key is generated.
  467. config SECURE_FLASH_ENCRYPTION_AES128
  468. bool "AES-128 (256-bit key)"
  469. config SECURE_FLASH_ENCRYPTION_AES256
  470. bool "AES-256 (512-bit key)"
  471. endchoice
  472. choice SECURE_FLASH_ENCRYPTION_MODE
  473. bool "Enable usage mode"
  474. depends on SECURE_FLASH_ENC_ENABLED
  475. default SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  476. help
  477. By default Development mode is enabled which allows UART bootloader to perform flash encryption operations
  478. Select Release mode only for production or manufacturing. Once enabled you can not reflash using UART
  479. bootloader
  480. Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version and
  481. https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html for details.
  482. config SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  483. bool "Development(NOT SECURE)"
  484. select SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
  485. config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
  486. bool "Release"
  487. endchoice
  488. menu "Potentially insecure options"
  489. visible if SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT || SECURE_BOOT_INSECURE
  490. # NOTE: Options in this menu NEED to have SECURE_BOOT_INSECURE
  491. # and/or SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT in "depends on", as the menu
  492. # itself doesn't enable/disable its children (if it's not set,
  493. # it's possible for the insecure menu to be disabled but the insecure option
  494. # to remain on which is very bad.)
  495. config SECURE_BOOT_ALLOW_ROM_BASIC
  496. bool "Leave ROM BASIC Interpreter available on reset"
  497. depends on SECURE_BOOT_INSECURE || SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  498. default N
  499. help
  500. By default, the BASIC ROM Console starts on reset if no valid bootloader is
  501. read from the flash.
  502. When either flash encryption or secure boot are enabled, the default is to
  503. disable this BASIC fallback mode permanently via eFuse.
  504. If this option is set, this eFuse is not burned and the BASIC ROM Console may
  505. remain accessible. Only set this option in testing environments.
  506. config SECURE_BOOT_ALLOW_JTAG
  507. bool "Allow JTAG Debugging"
  508. depends on SECURE_BOOT_INSECURE || SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  509. default N
  510. help
  511. If not set (default), the bootloader will permanently disable JTAG (across entire chip) on first boot
  512. when either secure boot or flash encryption is enabled.
  513. Setting this option leaves JTAG on for debugging, which negates all protections of flash encryption
  514. and some of the protections of secure boot.
  515. Only set this option in testing environments.
  516. config SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
  517. bool "Allow app partition length not 64KB aligned"
  518. depends on SECURE_BOOT_INSECURE
  519. help
  520. If not set (default), app partition size must be a multiple of 64KB. App images are padded to 64KB
  521. length, and the bootloader checks any trailing bytes after the signature (before the next 64KB
  522. boundary) have not been written. This is because flash cache maps entire 64KB pages into the address
  523. space. This prevents an attacker from appending unverified data after the app image in the flash,
  524. causing it to be mapped into the address space.
  525. Setting this option allows the app partition length to be unaligned, and disables padding of the app
  526. image to this length. It is generally not recommended to set this option, unless you have a legacy
  527. partitioning scheme which doesn't support 64KB aligned partition lengths.
  528. config SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS
  529. bool "Allow additional read protecting of efuses"
  530. depends on SECURE_BOOT_INSECURE && SECURE_BOOT_V2_ENABLED
  531. help
  532. If not set (default, recommended), on first boot the bootloader will burn the WR_DIS_RD_DIS
  533. efuse when Secure Boot is enabled. This prevents any more efuses from being read protected.
  534. If this option is set, it will remain possible to write the EFUSE_RD_DIS efuse field after Secure
  535. Boot is enabled. This may allow an attacker to read-protect the BLK2 efuse holding the public
  536. key digest, causing an immediate denial of service and possibly allowing an additional fault
  537. injection attack to bypass the signature protection.
  538. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
  539. bool "Leave UART bootloader encryption enabled"
  540. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  541. default N
  542. help
  543. If not set (default), the bootloader will permanently disable UART bootloader encryption access on
  544. first boot. If set, the UART bootloader will still be able to access hardware encryption.
  545. It is recommended to only set this option in testing environments.
  546. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC
  547. bool "Leave UART bootloader decryption enabled"
  548. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  549. default N
  550. help
  551. If not set (default), the bootloader will permanently disable UART bootloader decryption access on
  552. first boot. If set, the UART bootloader will still be able to access hardware decryption.
  553. Only set this option in testing environments. Setting this option allows complete bypass of flash
  554. encryption.
  555. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
  556. bool "Leave UART bootloader flash cache enabled"
  557. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  558. default N
  559. help
  560. If not set (default), the bootloader will permanently disable UART bootloader flash cache access on
  561. first boot. If set, the UART bootloader will still be able to access the flash cache.
  562. Only set this option in testing environments.
  563. config SECURE_FLASH_REQUIRE_ALREADY_ENABLED
  564. bool "Require flash encryption to be already enabled"
  565. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  566. default N
  567. help
  568. If not set (default), and flash encryption is not yet enabled in eFuses, the 2nd stage bootloader
  569. will enable flash encryption: generate the flash encryption key and program eFuses.
  570. If this option is set, and flash encryption is not yet enabled, the bootloader will error out and
  571. reboot.
  572. If flash encryption is enabled in eFuses, this option does not change the bootloader behavior.
  573. Only use this option in testing environments, to avoid accidentally enabling flash encryption on
  574. the wrong device. The device needs to have flash encryption already enabled using espefuse.py.
  575. endmenu # Potentially Insecure
  576. endmenu # Security features