]> granicus.if.org Git - esp-idf/blob - components/bootloader/Kconfig.projbuild
Merge branch 'bugfix/btdm_security_vulnerability' into 'master'
[esp-idf] / components / bootloader / Kconfig.projbuild
1 menu "Bootloader config"
2 choice LOG_BOOTLOADER_LEVEL
3    bool "Bootloader log verbosity"
4    default LOG_BOOTLOADER_LEVEL_INFO
5    help
6        Specify how much output to see in bootloader logs.
7
8 config LOG_BOOTLOADER_LEVEL_NONE
9    bool "No output"
10 config LOG_BOOTLOADER_LEVEL_ERROR
11    bool "Error"
12 config LOG_BOOTLOADER_LEVEL_WARN
13    bool "Warning"
14 config LOG_BOOTLOADER_LEVEL_INFO
15    bool "Info"
16 config LOG_BOOTLOADER_LEVEL_DEBUG
17    bool "Debug"
18 config LOG_BOOTLOADER_LEVEL_VERBOSE
19    bool "Verbose"
20 endchoice
21
22 config LOG_BOOTLOADER_LEVEL
23     int
24     default 0 if LOG_BOOTLOADER_LEVEL_NONE
25     default 1 if LOG_BOOTLOADER_LEVEL_ERROR
26     default 2 if LOG_BOOTLOADER_LEVEL_WARN
27     default 3 if LOG_BOOTLOADER_LEVEL_INFO
28     default 4 if LOG_BOOTLOADER_LEVEL_DEBUG
29     default 5 if LOG_BOOTLOADER_LEVEL_VERBOSE
30
31 config BOOTLOADER_SPI_WP_PIN
32     int "SPI Flash WP Pin when customising pins via efuse (read help)"
33     range 0 33
34     default 7
35     depends on FLASHMODE_QIO || FLASHMODE_QOUT
36     help
37         This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
38         overriden by setting the efuses SPI_PAD_CONFIG_xxx.
39
40         When this is the case, the Efuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
41         pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in Efuse. That pin number is compiled into the bootloader
42         instead.
43
44         The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
45
46 choice BOOTLOADER_VDDSDIO_BOOST
47     bool "VDDSDIO LDO voltage"
48     default BOOTLOADER_VDDSDIO_BOOST_1_9V
49     help
50         If this option is enabled, and VDDSDIO LDO is set to 1.8V (using EFUSE
51         or MTDI bootstrapping pin), bootloader will change LDO settings to
52         output 1.9V instead. This helps prevent flash chip from browning out
53         during flash programming operations.
54
55         This option has no effect if VDDSDIO is set to 3.3V, or if the internal
56         VDDSDIO regulator is disabled via efuse.
57
58 config BOOTLOADER_VDDSDIO_BOOST_1_8V
59     bool "1.8V"
60     depends on !ESPTOOLPY_FLASHFREQ_80M
61 config BOOTLOADER_VDDSDIO_BOOST_1_9V
62     bool "1.9V"
63 endchoice
64
65 config BOOTLOADER_FACTORY_RESET
66     bool "GPIO triggers factory reset"
67     default N
68     help
69         Allows to reset the device to factory settings:
70         - clear one or more data partitions;
71         - boot from "factory" partition.
72         The factory reset will occur if there is a GPIO input pulled low while device starts up.
73         See settings below.
74
75 config BOOTLOADER_NUM_PIN_FACTORY_RESET
76     int "Number of the GPIO input for factory reset"
77     depends on BOOTLOADER_FACTORY_RESET
78     range 0 39
79     default 4
80     help
81         The selected GPIO will be configured as an input with internal pull-up enabled.
82         To trigger a factory reset, this GPIO must be pulled low on reset.
83         Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
84
85 config BOOTLOADER_OTA_DATA_ERASE
86     bool "Clear OTA data on factory reset (select factory partition)"
87     depends on BOOTLOADER_FACTORY_RESET
88     help
89         The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a factory reset.
90
91 config BOOTLOADER_DATA_FACTORY_RESET
92      string "Comma-separated names of partitions to clear on factory reset"
93      depends on BOOTLOADER_FACTORY_RESET
94      default "nvs"
95      help
96         Allows customers to select which data partitions will be erased while factory reset.
97         
98         Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this: "nvs, phy_init, ...")
99         Make sure that the name specified in the partition table and here are the same. 
100         Partitions of type "app" cannot be specified here.
101
102 config BOOTLOADER_APP_TEST
103     bool "GPIO triggers boot from test app partition"
104     default N
105     help
106         Allows to run the test app from "TEST" partition.
107         A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
108         See settings below.
109
110 config BOOTLOADER_NUM_PIN_APP_TEST
111     int "Number of the GPIO input to boot TEST partition"
112     depends on BOOTLOADER_APP_TEST
113     range 0 39
114     default 18
115     help
116         The selected GPIO will be configured as an input with internal pull-up enabled.
117         To trigger a test app, this GPIO must be pulled low on reset.
118         After the GPIO input is deactivated and the device reboots, the old application will boot. 
119         (factory or OTA[x]).
120         Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
121
122 config BOOTLOADER_HOLD_TIME_GPIO
123     int "Hold time of GPIO for reset/test mode (seconds)"
124     depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
125     default 5
126     help
127         The GPIO must be held low continuously for this period of time after reset 
128         before a factory reset or test partition boot (as applicable) is performed.
129
130 endmenu  # Bootloader
131
132
133 menu "Security features"
134
135 config SECURE_BOOT_ENABLED
136     bool "Enable secure boot in bootloader (READ DOCS FIRST)"
137     default N
138     help
139         Build a bootloader which enables secure boot on first boot.
140
141         Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition table or boot an app if the data has a verified digital signature. There are implications for reflashing updated apps once secure boot is enabled.
142
143         When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
144
145         Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
146
147 choice SECURE_BOOTLOADER_MODE
148     bool "Secure bootloader mode"
149     depends on SECURE_BOOT_ENABLED
150     default SECURE_BOOTLOADER_ONE_TIME_FLASH
151
152 config SECURE_BOOTLOADER_ONE_TIME_FLASH
153        bool "One-time flash"
154        help
155            On first boot, the bootloader will generate a key which is not readable externally or by software. A digest is generated from the bootloader image itself. This digest will be verified on each subsequent boot.
156
157            Enabling this option means that the bootloader cannot be changed after the first time it is booted.
158
159 config SECURE_BOOTLOADER_REFLASHABLE
160     bool "Reflashable"
161     help
162         Generate a reusable secure bootloader key, derived (via SHA-256) from the secure boot signing key.
163
164         This allows the secure bootloader to be re-flashed by anyone with access to the secure boot signing key.
165
166         This option is less secure than one-time flash, because a leak of the digest key from one device allows reflashing of any device that uses it.
167
168 endchoice
169
170 config SECURE_BOOT_BUILD_SIGNED_BINARIES
171      bool "Sign binaries during build"
172      depends on SECURE_BOOT_ENABLED
173      default y
174      help
175         Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
176
177         If enabled, these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
178
179         If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py (for example, on a remote signing server.)
180
181 config SECURE_BOOT_SIGNING_KEY
182      string "Secure boot private signing key"
183      depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
184      default secure_boot_signing_key.pem
185      help
186         Path to the key file used to sign partition tables and app images for secure boot. Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
187
188         Key file is an ECDSA private key (NIST256p curve) in PEM format.
189
190         Path is evaluated relative to the project directory.
191
192         You can generate a new signing key by running the following command:
193         espsecure.py generate_signing_key secure_boot_signing_key.pem
194
195         See docs/security/secure-boot.rst for details.
196
197 config SECURE_BOOT_VERIFICATION_KEY
198     string "Secure boot public signature verification key"
199     depends on SECURE_BOOT_ENABLED && !SECURE_BOOT_BUILD_SIGNED_BINARIES
200     default signature_verification_key.bin
201     help
202        Path to a public key file used to verify signed images. This key is compiled into the bootloader,
203        and may also be used to verify signatures on OTA images after download.
204
205        Key file is in raw binary format, and can be extracted from a
206        PEM formatted private key using the espsecure.py
207        extract_public_key command.
208
209        Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
210
211 config SECURE_BOOT_INSECURE
212     bool "Allow potentially insecure options"
213     depends on SECURE_BOOT_ENABLED
214     default N
215     help
216        You can disable some of the default protections offered by secure boot, in order to enable testing or a custom combination of security features.
217
218        Only enable these options if you are very sure.
219
220        Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
221
222 config FLASH_ENCRYPTION_ENABLED
223     bool "Enable flash encryption on boot (READ DOCS FIRST)"
224     default N
225     help
226        If this option is set, flash contents will be encrypted by the bootloader on first boot.
227
228        Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
229        system is complicated and not always possible.
230
231        Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html before enabling.
232
233 config FLASH_ENCRYPTION_INSECURE
234     bool "Allow potentially insecure options"
235     depends on FLASH_ENCRYPTION_ENABLED
236     default N
237     help
238        You can disable some of the default protections offered by flash encryption, in order to enable testing or a custom combination of security features.
239
240        Only enable these options if you are very sure.
241
242        Refer to docs/security/secure-boot.rst and docs/security/flash-encryption.rst for details.
243
244 menu "Potentially insecure options"
245     visible if FLASH_ENCRYPTION_INSECURE || SECURE_BOOT_INSECURE
246
247 # NOTE: Options in this menu NEED to have SECURE_BOOT_INSECURE
248 # and/or FLASH_ENCRYPTION_INSECURE in "depends on", as the menu
249 # itself doesn't enable/disable its children (if it's not set,
250 # it's possible for the insecure menu to be disabled but the insecure option
251 # to remain on which is very bad.)
252
253 config SECURE_BOOT_ALLOW_ROM_BASIC
254        bool "Leave ROM BASIC Interpreter available on reset"
255        depends on SECURE_BOOT_INSECURE || FLASH_ENCRYPTION_INSECURE
256        default N
257        help
258           By default, the BASIC ROM Console starts on reset if no valid bootloader is
259           read from the flash.
260
261           When either flash encryption or secure boot are enabled, the default is to
262           disable this BASIC fallback mode permanently via efuse.
263
264           If this option is set, this efuse is not burned and the BASIC ROM Console may
265           remain accessible.  Only set this option in testing environments.
266
267 config SECURE_BOOT_ALLOW_JTAG
268        bool "Allow JTAG Debugging"
269        depends on SECURE_BOOT_INSECURE || FLASH_ENCRYPTION_INSECURE
270        default N
271        help
272           If not set (default), the bootloader will permanently disable JTAG (across entire chip) on first boot when either secure boot or flash encryption is enabled.
273
274           Setting this option leaves JTAG on for debugging, which negates all protections of flash encryption and some of the protections of secure boot.
275
276           Only set this option in testing environments.
277
278 config SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
279        bool "Allow app partition length not 64KB aligned"
280        depends on SECURE_BOOT_INSECURE
281        help
282            If not set (default), app partition size must be a multiple of 64KB. App images are padded to 64KB length, and the bootloader checks any trailing bytes after the signature (before the next 64KB boundary) have not been written. This is because flash cache maps entire 64KB pages into the address space. This prevents an attacker from appending unverified data after the app image in the flash, causing it to be mapped into the address space.
283
284            Setting this option allows the app partition length to be unaligned, and disables padding of the app image to this length. It is generally not recommended to set this option, unless you have a legacy partitioning scheme which doesn't support 64KB aligned partition lengths.
285
286 config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_ENCRYPT
287     bool "Leave UART bootloader encryption enabled"
288     depends on FLASH_ENCRYPTION_INSECURE
289     default N
290     help
291         If not set (default), the bootloader will permanently disable UART bootloader encryption access on first boot. If set, the UART bootloader will still be able to access hardware encryption.
292
293         It is recommended to only set this option in testing environments.
294
295 config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_DECRYPT
296     bool "Leave UART bootloader decryption enabled"
297     depends on FLASH_ENCRYPTION_INSECURE
298     default N
299     help
300         If not set (default), the bootloader will permanently disable UART bootloader decryption access on first boot. If set, the UART bootloader will still be able to access hardware decryption.
301
302         Only set this option in testing environments. Setting this option allows complete bypass of flash encryption.
303
304 config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_CACHE
305     bool "Leave UART bootloader flash cache enabled"
306     depends on FLASH_ENCRYPTION_INSECURE
307     default N
308     help
309         If not set (default), the bootloader will permanently disable UART bootloader flash cache access on first boot. If set, the UART bootloader will still be able to access the flash cache.
310
311         Only set this option in testing environments.
312
313 config SECURE_BOOT_TEST_MODE
314        bool "Secure boot test mode: don't permanently set any efuses"
315        depends on SECURE_BOOT_INSECURE
316        default N
317        help
318           If this option is set, all permanent secure boot changes (via Efuse) are disabled.
319
320           Log output will state changes which would be applied, but they will not be.
321
322           This option is for testing purposes only - it completely disables secure boot protection.
323
324
325 endmenu  # Potentially Insecure
326 endmenu  # Security features