Kconfig.projbuild 44 KB

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