Kconfig.projbuild 54 KB

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