Kconfig.projbuild 56 KB

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