2
0

Kconfig.projbuild 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. menu "Bootloader config"
  2. choice BOOTLOADER_LOG_LEVEL
  3. bool "Bootloader log verbosity"
  4. default BOOTLOADER_LOG_LEVEL_INFO
  5. help
  6. Specify how much output to see in bootloader logs.
  7. config BOOTLOADER_LOG_LEVEL_NONE
  8. bool "No output"
  9. config BOOTLOADER_LOG_LEVEL_ERROR
  10. bool "Error"
  11. config BOOTLOADER_LOG_LEVEL_WARN
  12. bool "Warning"
  13. config BOOTLOADER_LOG_LEVEL_INFO
  14. bool "Info"
  15. config BOOTLOADER_LOG_LEVEL_DEBUG
  16. bool "Debug"
  17. config BOOTLOADER_LOG_LEVEL_VERBOSE
  18. bool "Verbose"
  19. endchoice
  20. config BOOTLOADER_LOG_LEVEL
  21. int
  22. default 0 if BOOTLOADER_LOG_LEVEL_NONE
  23. default 1 if BOOTLOADER_LOG_LEVEL_ERROR
  24. default 2 if BOOTLOADER_LOG_LEVEL_WARN
  25. default 3 if BOOTLOADER_LOG_LEVEL_INFO
  26. default 4 if BOOTLOADER_LOG_LEVEL_DEBUG
  27. default 5 if BOOTLOADER_LOG_LEVEL_VERBOSE
  28. config BOOTLOADER_SPI_WP_PIN
  29. int "SPI Flash WP Pin when customising pins via eFuse (read help)"
  30. range 0 33
  31. default 7
  32. depends on ESPTOOLPY_FLASHMODE_QIO || ESPTOOLPY_FLASHMODE_QOUT
  33. help
  34. This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
  35. overriden by setting the eFuses SPI_PAD_CONFIG_xxx.
  36. When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
  37. pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. That pin number is compiled into the
  38. bootloader instead.
  39. The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
  40. choice BOOTLOADER_VDDSDIO_BOOST
  41. bool "VDDSDIO LDO voltage"
  42. default BOOTLOADER_VDDSDIO_BOOST_1_9V
  43. help
  44. If this option is enabled, and VDDSDIO LDO is set to 1.8V (using eFuse
  45. or MTDI bootstrapping pin), bootloader will change LDO settings to
  46. output 1.9V instead. This helps prevent flash chip from browning out
  47. during flash programming operations.
  48. This option has no effect if VDDSDIO is set to 3.3V, or if the internal
  49. VDDSDIO regulator is disabled via eFuse.
  50. config BOOTLOADER_VDDSDIO_BOOST_1_8V
  51. bool "1.8V"
  52. depends on !ESPTOOLPY_FLASHFREQ_80M
  53. config BOOTLOADER_VDDSDIO_BOOST_1_9V
  54. bool "1.9V"
  55. endchoice
  56. config BOOTLOADER_FACTORY_RESET
  57. bool "GPIO triggers factory reset"
  58. default N
  59. help
  60. Allows to reset the device to factory settings:
  61. - clear one or more data partitions;
  62. - boot from "factory" partition.
  63. The factory reset will occur if there is a GPIO input pulled low while device starts up.
  64. See settings below.
  65. config BOOTLOADER_NUM_PIN_FACTORY_RESET
  66. int "Number of the GPIO input for factory reset"
  67. depends on BOOTLOADER_FACTORY_RESET
  68. range 0 39
  69. default 4
  70. help
  71. The selected GPIO will be configured as an input with internal pull-up enabled.
  72. To trigger a factory reset, this GPIO must be pulled low on reset.
  73. Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
  74. config BOOTLOADER_OTA_DATA_ERASE
  75. bool "Clear OTA data on factory reset (select factory partition)"
  76. depends on BOOTLOADER_FACTORY_RESET
  77. help
  78. The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a
  79. factory reset.
  80. config BOOTLOADER_DATA_FACTORY_RESET
  81. string "Comma-separated names of partitions to clear on factory reset"
  82. depends on BOOTLOADER_FACTORY_RESET
  83. default "nvs"
  84. help
  85. Allows customers to select which data partitions will be erased while factory reset.
  86. Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this:
  87. "nvs, phy_init, ...")
  88. Make sure that the name specified in the partition table and here are the same.
  89. Partitions of type "app" cannot be specified here.
  90. config BOOTLOADER_APP_TEST
  91. bool "GPIO triggers boot from test app partition"
  92. default N
  93. help
  94. Allows to run the test app from "TEST" partition.
  95. A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
  96. See settings below.
  97. config BOOTLOADER_NUM_PIN_APP_TEST
  98. int "Number of the GPIO input to boot TEST partition"
  99. depends on BOOTLOADER_APP_TEST
  100. range 0 39
  101. default 18
  102. help
  103. The selected GPIO will be configured as an input with internal pull-up enabled.
  104. To trigger a test app, this GPIO must be pulled low on reset.
  105. After the GPIO input is deactivated and the device reboots, the old application will boot.
  106. (factory or OTA[x]).
  107. Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
  108. config BOOTLOADER_HOLD_TIME_GPIO
  109. int "Hold time of GPIO for reset/test mode (seconds)"
  110. depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
  111. default 5
  112. help
  113. The GPIO must be held low continuously for this period of time after reset
  114. before a factory reset or test partition boot (as applicable) is performed.
  115. config BOOTLOADER_WDT_ENABLE
  116. bool "Use RTC watchdog in start code"
  117. default y
  118. help
  119. Tracks the execution time of startup code.
  120. If the execution time is exceeded, the RTC_WDT will restart system.
  121. It is also useful to prevent a lock up in start code caused by an unstable power source.
  122. NOTE: Tracks the execution time starts from the bootloader code - re-set timeout, while selecting the
  123. source for slow_clk - and ends calling app_main.
  124. Re-set timeout is needed due to WDT uses a SLOW_CLK clock source. After changing a frequency slow_clk a
  125. time of WDT needs to re-set for new frequency.
  126. slow_clk depends on ESP32_RTC_CLK_SRC (INTERNAL_RC or EXTERNAL_CRYSTAL).
  127. config BOOTLOADER_WDT_DISABLE_IN_USER_CODE
  128. bool "Allows RTC watchdog disable in user code"
  129. depends on BOOTLOADER_WDT_ENABLE
  130. default n
  131. help
  132. If it is set, the client must itself reset or disable rtc_wdt in their code (app_main()).
  133. Otherwise rtc_wdt will be disabled before calling app_main function.
  134. Use function rtc_wdt_feed() for resetting counter of rtc_wdt.
  135. Use function rtc_wdt_disable() for disabling rtc_wdt.
  136. config BOOTLOADER_WDT_TIME_MS
  137. int "Timeout for RTC watchdog (ms)"
  138. depends on BOOTLOADER_WDT_ENABLE
  139. default 9000
  140. range 0 120000
  141. help
  142. Verify that this parameter is correct and more then the execution time.
  143. Pay attention to options such as reset to factory, trigger test partition and encryption on boot
  144. - these options can increase the execution time.
  145. Note: RTC_WDT will reset while encryption operations will be performed.
  146. config BOOTLOADER_APP_ROLLBACK_ENABLE
  147. bool "Enable app rollback support"
  148. default n
  149. help
  150. After updating the app, the bootloader runs a new app with the "ESP_OTA_IMG_PENDING_VERIFY" state set.
  151. This state prevents the re-run of this app. After the first boot of the new app in the user code, the
  152. function should be called to confirm the operability of the app or vice versa about its non-operability.
  153. If the app is working, then it is marked as valid. Otherwise, it is marked as not valid and rolls back to
  154. the previous working app. A reboot is performed, and the app is booted before the software update.
  155. Note: If during the first boot a new app the power goes out or the WDT works, then roll back will happen.
  156. Rollback is possible only between the apps with the same security versions.
  157. config BOOTLOADER_APP_ANTI_ROLLBACK
  158. bool "Enable app anti-rollback support"
  159. depends on BOOTLOADER_APP_ROLLBACK_ENABLE
  160. default n
  161. help
  162. This option prevents rollback to previous firmware/application image with lower security version.
  163. config BOOTLOADER_APP_SECURE_VERSION
  164. int "eFuse secure version of app"
  165. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  166. default 0
  167. help
  168. The secure version is the sequence number stored in the header of each firmware.
  169. The security version is set in the bootloader, version is recorded in the eFuse field
  170. as the number of set ones. The allocated number of bits in the efuse field
  171. for storing the security version is limited (see BOOTLOADER_APP_SEC_VER_SIZE_EFUSE_FIELD option).
  172. Bootloader: When bootloader selects an app to boot, an app is selected that has
  173. a security version greater or equal that recorded in eFuse field.
  174. The app is booted with a higher (or equal) secure version.
  175. The security version is worth increasing if in previous versions there is
  176. a significant vulnerability and their use is not acceptable.
  177. Your partition table should has a scheme with ota_0 + ota_1 (without factory).
  178. config BOOTLOADER_APP_SEC_VER_SIZE_EFUSE_FIELD
  179. int "Size of the efuse secure version field"
  180. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  181. range 1 32
  182. default 32
  183. help
  184. The size of the efuse secure version field. Its length is limited to 32 bits.
  185. This determines how many times the security version can be increased.
  186. config BOOTLOADER_EFUSE_SECURE_VERSION_EMULATE
  187. bool "Emulate operations with efuse secure version(only test)"
  188. default n
  189. depends on BOOTLOADER_APP_ANTI_ROLLBACK
  190. help
  191. This option allow emulate read/write operations with efuse secure version.
  192. It allow to test anti-rollback implemention without permanent write eFuse bits.
  193. In partition table should be exist this partition `emul_efuse, data, 5, , 0x2000`.
  194. endmenu # Bootloader
  195. menu "Security features"
  196. # These three are the actual options to check in code,
  197. # selected by the displayed options
  198. config SECURE_SIGNED_ON_BOOT
  199. bool
  200. default y
  201. depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
  202. config SECURE_SIGNED_ON_UPDATE
  203. bool
  204. default y
  205. select MBEDTLS_ECP_DP_SECP256R1_ENABLED
  206. depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
  207. config SECURE_SIGNED_APPS
  208. bool
  209. default y
  210. depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
  211. config SECURE_SIGNED_APPS_NO_SECURE_BOOT
  212. bool "Require signed app images"
  213. default n
  214. depends on !SECURE_BOOT_ENABLED
  215. help
  216. Require apps to be signed to verify their integrity.
  217. This option uses the same app signature scheme as hardware secure boot, but unlike hardware secure boot it
  218. does not prevent the bootloader from being physically updated. This means that the device can be secured
  219. against remote network access, but not physical access. Compared to using hardware Secure Boot this option
  220. is much simpler to implement.
  221. config SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
  222. bool "Bootloader verifies app signatures"
  223. default n
  224. depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
  225. help
  226. If this option is set, the bootloader will be compiled with code to verify that an app is signed before
  227. booting it.
  228. If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
  229. If hardware secure boot is not enabled, this option doesn't add significant security by itself so most
  230. users will want to leave it disabled.
  231. config SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
  232. bool "Verify app signature on update"
  233. default y
  234. depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
  235. help
  236. If this option is set, any OTA updated apps will have the signature verified before being considered valid.
  237. When enabled, the signature is automatically checked whenever the esp_ota_ops.h APIs are used for OTA
  238. updates, or esp_image_format.h APIs are used to verify apps.
  239. If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
  240. If hardware secure boot is not enabled, this option still adds significant security against network-based
  241. attackers by preventing spoofing of OTA updates.
  242. config SECURE_BOOT_ENABLED
  243. bool "Enable hardware secure boot in bootloader (READ DOCS FIRST)"
  244. default n
  245. help
  246. Build a bootloader which enables secure boot on first boot.
  247. Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition
  248. table or boot an app if the data has a verified digital signature. There are implications for reflashing
  249. updated apps once secure boot is enabled.
  250. When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
  251. Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
  252. choice SECURE_BOOTLOADER_MODE
  253. bool "Secure bootloader mode"
  254. depends on SECURE_BOOT_ENABLED
  255. default SECURE_BOOTLOADER_ONE_TIME_FLASH
  256. config SECURE_BOOTLOADER_ONE_TIME_FLASH
  257. bool "One-time flash"
  258. help
  259. On first boot, the bootloader will generate a key which is not readable externally or by software. A
  260. digest is generated from the bootloader image itself. This digest will be verified on each subsequent
  261. boot.
  262. Enabling this option means that the bootloader cannot be changed after the first time it is booted.
  263. config SECURE_BOOTLOADER_REFLASHABLE
  264. bool "Reflashable"
  265. help
  266. Generate a reusable secure bootloader key, derived (via SHA-256) from the secure boot signing key.
  267. This allows the secure bootloader to be re-flashed by anyone with access to the secure boot signing
  268. key.
  269. This option is less secure than one-time flash, because a leak of the digest key from one device
  270. allows reflashing of any device that uses it.
  271. endchoice
  272. config SECURE_BOOT_BUILD_SIGNED_BINARIES
  273. bool "Sign binaries during build"
  274. depends on SECURE_SIGNED_APPS
  275. default y
  276. help
  277. Once secure boot or signed app requirement is enabled, app images are required to be signed.
  278. If enabled (default), these binary files are signed as part of the build process. The file named in
  279. "Secure boot private signing key" will be used to sign the image.
  280. If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py
  281. (for example, on a remote signing server.)
  282. config SECURE_BOOT_SIGNING_KEY
  283. string "Secure boot private signing key"
  284. depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
  285. default secure_boot_signing_key.pem
  286. help
  287. Path to the key file used to sign app images.
  288. Key file is an ECDSA private key (NIST256p curve) in PEM format.
  289. Path is evaluated relative to the project directory.
  290. You can generate a new signing key by running the following command:
  291. espsecure.py generate_signing_key secure_boot_signing_key.pem
  292. See https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html for details.
  293. config SECURE_BOOT_VERIFICATION_KEY
  294. string "Secure boot public signature verification key"
  295. depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
  296. default signature_verification_key.bin
  297. help
  298. Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or
  299. app, to verify app images.
  300. Key file is in raw binary format, and can be extracted from a
  301. PEM formatted private key using the espsecure.py
  302. extract_public_key command.
  303. Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
  304. choice SECURE_BOOTLOADER_KEY_ENCODING
  305. bool "Hardware Key Encoding"
  306. depends on SECURE_BOOTLOADER_REFLASHABLE
  307. default SECURE_BOOTLOADER_NO_ENCODING
  308. help
  309. In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and
  310. can be written to eFuse with espefuse.py.
  311. Normally this is a 256-bit key, but if 3/4 Coding Scheme is used on the device then the eFuse key is
  312. truncated to 192 bits.
  313. This configuration item doesn't change any firmware code, it only changes the size of key binary which is
  314. generated at build time.
  315. config SECURE_BOOTLOADER_KEY_ENCODING_256BIT
  316. bool "No encoding (256 bit key)"
  317. config SECURE_BOOTLOADER_KEY_ENCODING_192BIT
  318. bool "3/4 encoding (192 bit key)"
  319. endchoice
  320. config SECURE_BOOT_INSECURE
  321. bool "Allow potentially insecure options"
  322. depends on SECURE_BOOT_ENABLED
  323. default N
  324. help
  325. You can disable some of the default protections offered by secure boot, in order to enable testing or a
  326. custom combination of security features.
  327. Only enable these options if you are very sure.
  328. Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
  329. config SECURE_FLASH_ENC_ENABLED
  330. bool "Enable flash encryption on boot (READ DOCS FIRST)"
  331. default N
  332. help
  333. If this option is set, flash contents will be encrypted by the bootloader on first boot.
  334. Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
  335. system is complicated and not always possible.
  336. Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html
  337. before enabling.
  338. choice SECURE_FLASH_ENCRYPTION_MODE
  339. bool "Enable usage mode"
  340. depends on SECURE_FLASH_ENC_ENABLED
  341. default SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  342. help
  343. By default Development mode is enabled which allows UART bootloader to perform flash encryption operations
  344. Select Release mode only for production or manufacturing. Once enabled you can not reflash using UART
  345. bootloader
  346. Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html and
  347. https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html for details.
  348. config SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  349. bool "Development(NOT SECURE)"
  350. select SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
  351. config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
  352. bool "Release"
  353. endchoice
  354. menu "Potentially insecure options"
  355. visible if SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT || SECURE_BOOT_INSECURE
  356. # NOTE: Options in this menu NEED to have SECURE_BOOT_INSECURE
  357. # and/or SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT in "depends on", as the menu
  358. # itself doesn't enable/disable its children (if it's not set,
  359. # it's possible for the insecure menu to be disabled but the insecure option
  360. # to remain on which is very bad.)
  361. config SECURE_BOOT_ALLOW_ROM_BASIC
  362. bool "Leave ROM BASIC Interpreter available on reset"
  363. depends on SECURE_BOOT_INSECURE || SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  364. default N
  365. help
  366. By default, the BASIC ROM Console starts on reset if no valid bootloader is
  367. read from the flash.
  368. When either flash encryption or secure boot are enabled, the default is to
  369. disable this BASIC fallback mode permanently via eFuse.
  370. If this option is set, this eFuse is not burned and the BASIC ROM Console may
  371. remain accessible. Only set this option in testing environments.
  372. config SECURE_BOOT_ALLOW_JTAG
  373. bool "Allow JTAG Debugging"
  374. depends on SECURE_BOOT_INSECURE || SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  375. default N
  376. help
  377. If not set (default), the bootloader will permanently disable JTAG (across entire chip) on first boot
  378. when either secure boot or flash encryption is enabled.
  379. Setting this option leaves JTAG on for debugging, which negates all protections of flash encryption
  380. and some of the protections of secure boot.
  381. Only set this option in testing environments.
  382. config SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
  383. bool "Allow app partition length not 64KB aligned"
  384. depends on SECURE_BOOT_INSECURE
  385. help
  386. If not set (default), app partition size must be a multiple of 64KB. App images are padded to 64KB
  387. length, and the bootloader checks any trailing bytes after the signature (before the next 64KB
  388. boundary) have not been written. This is because flash cache maps entire 64KB pages into the address
  389. space. This prevents an attacker from appending unverified data after the app image in the flash,
  390. causing it to be mapped into the address space.
  391. Setting this option allows the app partition length to be unaligned, and disables padding of the app
  392. image to this length. It is generally not recommended to set this option, unless you have a legacy
  393. partitioning scheme which doesn't support 64KB aligned partition lengths.
  394. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
  395. bool "Leave UART bootloader encryption enabled"
  396. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  397. default N
  398. help
  399. If not set (default), the bootloader will permanently disable UART bootloader encryption access on
  400. first boot. If set, the UART bootloader will still be able to access hardware encryption.
  401. It is recommended to only set this option in testing environments.
  402. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC
  403. bool "Leave UART bootloader decryption enabled"
  404. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  405. default N
  406. help
  407. If not set (default), the bootloader will permanently disable UART bootloader decryption access on
  408. first boot. If set, the UART bootloader will still be able to access hardware decryption.
  409. Only set this option in testing environments. Setting this option allows complete bypass of flash
  410. encryption.
  411. config SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
  412. bool "Leave UART bootloader flash cache enabled"
  413. depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
  414. default N
  415. help
  416. If not set (default), the bootloader will permanently disable UART bootloader flash cache access on
  417. first boot. If set, the UART bootloader will still be able to access the flash cache.
  418. Only set this option in testing environments.
  419. endmenu # Potentially Insecure
  420. endmenu # Security features