Kconfig.projbuild 37 KB

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