blob: cfbf463d85be3c4f7c8f7033803f96175d3b3419 [file] [log] [blame] [view]
Almir Okato39eb63d2022-01-05 18:31:54 -03001# [Building and using MCUboot with Espressif's chips](#building-and-using-mcuboot-with-espressifs-chips)
Almir Okato428e2e72021-08-11 10:52:10 -03002
3The Espressif port is build on top of ESP-IDF HAL, therefore it is required in order to build MCUboot for Espressif SoCs.
4
5Documentation about the MCUboot bootloader design, operation and features can be found in the [design document](design.md).
6
Almir Okato39eb63d2022-01-05 18:31:54 -03007## [SoC support availability](#soc-support-availability)
Almir Okato428e2e72021-08-11 10:52:10 -03008
9The current port is available for use in the following SoCs within the OSes:
Almir Okato428e2e72021-08-11 10:52:10 -030010
Sylvio Alvesd8eff812022-01-31 23:16:06 -030011| | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
12| :-----: | :-----: | :-----: | :-----: | :-----: |
13| Zephyr | Supported | Supported | Supported | WIP |
14| NuttX | Supported | Supported | Supported | WIP |
Almir Okato39eb63d2022-01-05 18:31:54 -030015
16## [Installing requirements and dependencies](#installing-requirements-and-dependencies)
Almir Okato428e2e72021-08-11 10:52:10 -030017
181. Install additional packages required for development with MCUboot:
19
20```
Francesco Servidio4ff0c182021-10-20 15:27:16 +020021 cd ~/mcuboot # or to your directory where MCUboot is cloned
Almir Okato428e2e72021-08-11 10:52:10 -030022 pip3 install --user -r scripts/requirements.txt
23```
24
252. Update the submodules needed by the Espressif port. This may take a while.
26
27```
28git submodule update --init --recursive --checkout boot/espressif/hal/esp-idf
29```
30
Francesco Servidio582367c2021-10-20 15:36:45 +0200313. Next, get the Mbed TLS submodule required by MCUboot.
Almir Okato428e2e72021-08-11 10:52:10 -030032```
33git submodule update --init --recursive ext/mbedtls
34```
35
364. Now we need to install IDF dependencies and set environment variables. This step may take some time:
37```
38cd boot/espressif/hal/esp-idf
39./install.sh
40. ./export.sh
41cd ../..
42```
43
Almir Okato39eb63d2022-01-05 18:31:54 -030044## [Building the bootloader itself](#building-the-bootloader-itself)
Almir Okato428e2e72021-08-11 10:52:10 -030045
46The MCUboot Espressif port bootloader is built using the toolchain and tools provided by ESP-IDF. Additional configuration related to MCUboot features and slot partitioning may be made using the `bootloader.conf`.
47
Francesco Servidio2fe449d2021-10-21 12:38:36 +020048---
49***Note***
50
Almir Okato39eb63d2022-01-05 18:31:54 -030051*Replace `<TARGET>` with the target ESP32 family (like `esp32`, `esp32s2` and others).*
Francesco Servidio2fe449d2021-10-21 12:38:36 +020052
53---
Almir Okato428e2e72021-08-11 10:52:10 -030054
551. Compile and generate the ELF:
56
57```
Almir Okato39eb63d2022-01-05 18:31:54 -030058cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchain-<TARGET>.cmake -DMCUBOOT_TARGET=<TARGET> -B build -GNinja
Almir Okato428e2e72021-08-11 10:52:10 -030059cmake --build build/
60```
61
622. Convert the ELF to the final bootloader image, ready to be flashed:
63
64```
Almir Okato39eb63d2022-01-05 18:31:54 -030065esptool.py --chip <TARGET> elf2image --flash_mode dio --flash_freq 40m --flash_size <FLASH_SIZE> -o build/mcuboot_<TARGET>.bin build/mcuboot_<TARGET>.elf
Almir Okato428e2e72021-08-11 10:52:10 -030066```
67
Almir Okato39eb63d2022-01-05 18:31:54 -0300683. Flash MCUboot in your device:
Almir Okato428e2e72021-08-11 10:52:10 -030069
70```
Almir Okato39eb63d2022-01-05 18:31:54 -030071esptool.py -p <PORT> -b <BAUD> --before default_reset --after hard_reset --chip <TARGET> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <BOOTLOADER_FLASH_OFFSET> build/mcuboot_<TARGET>.bin
Almir Okato428e2e72021-08-11 10:52:10 -030072```
Sylvio Alvesd5230942022-01-20 21:35:53 -030073---
Almir Okatob365e232022-03-08 01:35:54 -030074***Note***
75You may adjust the port `<PORT>` (like `/dev/ttyUSB0`) and baud rate `<BAUD>` (like `2000000`) according to the connection to your board.
Sylvio Alvesd5230942022-01-20 21:35:53 -030076You can also skip `<PORT>` and `<BAUD>` parameters so that esptool tries to automatically detect it.
Almir Okato428e2e72021-08-11 10:52:10 -030077
Sylvio Alvesd5230942022-01-20 21:35:53 -030078*`<FLASH_SIZE>` can be found using the command below:*
79```
80esptool.py -p <PORT> -b <BAUD> flash_id
81```
Almir Okatob365e232022-03-08 01:35:54 -030082The output contains device information and its flash size:
Sylvio Alvesd5230942022-01-20 21:35:53 -030083```
84Detected flash size: 4MB
85```
86
87
88*`<BOOTLOADER_FLASH_OFFSET>` value must follow one of the addresses below:*
Almir Okatob365e232022-03-08 01:35:54 -030089
Sylvio Alvesd8eff812022-01-31 23:16:06 -030090| ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
91| :-----: | :-----: | :-----: | :-----: |
92| 0x1000 | 0x1000 | 0x0000 | 0x0000 |
Sylvio Alvesd5230942022-01-20 21:35:53 -030093
94---
Almir Okato39eb63d2022-01-05 18:31:54 -030095
96## [Signing and flashing an application](#signing-and-flashing-an-application)
97
981. Images can be regularly signed with the `scripts/imgtool.py` script:
99
100```
Sylvio Alvesd5230942022-01-20 21:35:53 -0300101imgtool.py sign --align 4 -v 0 -H 32 --pad-header -S <SLOT_SIZE> <BIN_IN> <SIGNED_BIN>
Almir Okato39eb63d2022-01-05 18:31:54 -0300102```
103
Sylvio Alvesd5230942022-01-20 21:35:53 -0300104---
105
Almir Okatob365e232022-03-08 01:35:54 -0300106***Note***
107`<SLOT_SIZE>` is the size of the slot to be used.
Sylvio Alvesd5230942022-01-20 21:35:53 -0300108Default slot0 size is `0x100000`, but it can change as per application flash partitions.
109
110For Zephyr images, `--pad-header` is not needed as it already has the padding for MCUboot header.
Almir Okato39eb63d2022-01-05 18:31:54 -0300111
112---
Sylvio Alvesd5230942022-01-20 21:35:53 -0300113
Almir Okato39eb63d2022-01-05 18:31:54 -0300114:warning: ***ATTENTION***
115
116*This is the basic signing needed for adding MCUboot headers and trailers.
117For signing with a crypto key and guarantee the authenticity of the image being booted, see the section [MCUboot image signature verification](#mcuboot-image-signature-verification) below.*
118
119---
120
1212. Flash the signed application:
122
123```
124esptool.py -p <PORT> -b <BAUD> --before default_reset --after hard_reset --chip <TARGET> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <SLOT_OFFSET> <SIGNED_BIN>
125```
126
127# [Security Chain on Espressif port](#security-chain-on-espressif-port)
128
129[MCUboot encrypted images](encrypted_images.md) do not provide full code confidentiality when only external storage is available (see [Threat model](encrypted_images.md#threat-model)) since by MCUboot design the image in Primary Slot, from where the image is executed, is stored plaintext.
130Espressif chips have off-chip flash memory, so to ensure a security chain along with MCUboot image signature verification, the hardware-assisted Secure Boot and Flash Encryption were made available on the MCUboot Espressif port.
131
132## [MCUboot image signature verification](#mcuboot-image-signature-verification)
133
134The image that MCUboot is booting can be signed with 4 types of keys: RSA-2048, RSA-3072, EC256 and ED25519. In order to enable the feature, the **bootloader** must be compiled with the following configurations:
135
136---
137***Note***
138*It is strongly recommended to generate a new signing key using `imgtool` instead of use the existent samples.*
139
140---
141
142#### For EC256 algorithm use
143```
144CONFIG_ESP_SIGN_EC256=y
145
146# Use Tinycrypt lib for EC256 or ED25519 signing
147CONFIG_ESP_USE_TINYCRYPT=y
148
149CONFIG_ESP_SIGN_KEY_FILE=<YOUR_SIGNING_KEY.pem>
150```
151
152#### For ED25519 algorithm use
153```
154CONFIG_ESP_SIGN_ED25519=y
155
156# Use Tinycrypt lib for EC256 or ED25519 signing
157CONFIG_ESP_USE_TINYCRYPT=y
158
159CONFIG_ESP_SIGN_KEY_FILE=<YOUR_SIGNING_KEY.pem>
160```
161
162#### For RSA (2048 or 3072) algorithm use
163```
164CONFIG_ESP_SIGN_RSA=y
165# RSA_LEN is 2048 or 3072
166CONFIG_ESP_SIGN_RSA_LEN=<RSA_LEN>
167
168# Use Mbed TLS lib for RSA image signing
169CONFIG_ESP_USE_MBEDTLS=y
170
171CONFIG_ESP_SIGN_KEY_FILE=<YOUR_SIGNING_KEY.pem>
172```
173
174Notice that the public key will be embedded in the bootloader code, since the hardware key storage is not supported by Espressif port.
175
176### [Signing the image](#signing-the-image)
177
178Now you need to sign the **image binary**, use the `imgtool` with `-k` parameter:
179
180```
181imgtool.py sign -k <YOUR_SIGNING_KEY.pem> --pad --pad-sig --align 4 -v 0 -H 32 --pad-header -S 0x00100000 <BIN_IN> <BIN_OUT>
182```
183If signing a Zephyr image, the `--pad-header` is not needed, as it already have the padding for MCUboot header.
184
185
186## [Secure Boot](#secure-boot)
187
188The Secure Boot implementation is based on [IDF's Secure Boot V2](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/security/secure-boot-v2.html), is hardware-assisted and RSA based, and has the role for ensuring that only authorized code will be executed on the device. This is done through bootloader signature checking by the ROM bootloader. \
189***Note***: ROM bootloader is the First Stage Bootloader, while the Espressif MCUboot port is the Second Stage Bootloader.
190
191### [Building bootloader with Secure Boot](#building-bootloader-with-secure-boot)
192
193In order to build the bootloader with the feature on, the following configurations must be enabled:
194```
195CONFIG_SECURE_BOOT=1
196CONFIG_SECURE_BOOT_V2_ENABLED=1
197CONFIG_SECURE_SIGNED_ON_BOOT=1
198CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME=1
199CONFIG_SECURE_BOOT_SUPPORTS_RSA=1
200```
201
202---
203:warning: ***ATTENTION***
204
205*On development phase is recommended add the following configuration in order to keep the debugging enabled and also to avoid any unrecoverable/permanent state change:*
206```
207CONFIG_SECURE_BOOT_ALLOW_JTAG=1
208CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE=1
209
210# Options for enabling eFuse emulation in Flash
211CONFIG_EFUSE_VIRTUAL=1
212CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH=1
213```
214
215---
216
Almir Okatob365e232022-03-08 01:35:54 -0300217---
218:warning: ***ATTENTION***
219
220*You can disable UART Download Mode by adding the following configuration:*
221```
222CONFIG_SECURE_DISABLE_ROM_DL_MODE=1
223```
224
225*This may be suitable for **production** builds. **After disabling UART Download Mode you will not be able to flash other images through UART.***
226
227*Otherwise, you can switch the UART ROM Download Mode to the Secure Download Mode. It will limit the use of Download Mode functions to simple flash read, write and erase operations.*
228```
229CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE=1
230```
231
232*Once the device makes its first full boot, these configurations cannot be reverted*
233
234---
235
Almir Okato39eb63d2022-01-05 18:31:54 -0300236Once the **bootloader image** is built, the resulting binary file is required to be signed with `espsecure.py` tool.
237
238First create a signing key:
239```
240espsecure.py generate_signing_key --version 2 <BOOTLOADER_SIGNING_KEY.pem>
241```
242
243Then sign the bootloader image:
244```
245espsecure.py sign_data --version 2 --keyfile <BOOTLOADER_SIGNING_KEY.pem> -o <BOOTLOADER_BIN_OUT> <BOOTLOADER_BIN_IN>
246```
247
248---
249:warning: ***ATTENTION***
250
251*Once the bootloader is flashed and the device resets, the **first boot will enable Secure Boot** and the bootloader and key **no longer can be modified**. So **ENSURE** that both bootloader and key are correct and you did not forget anything before flashing.*
252
253---
254
255Flash the bootloader as following, with `--after no_reset` flag, so you can reset the device only when assured:
256```
257esptool.py -p <PORT> -b 2000000 --after no_reset --chip <ESP_CHIP> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <BOOTLOADER_FLASH_OFFSET> <SIGNED_BOOTLOADER_BIN>
258```
259
260### [Secure Boot Process](#secure-boot-process)
261
262Secure boot uses a signature block appended to the bootloader image in order to verify the authenticity. The signature block contains the RSA-3072 signature of that image and the RSA-3072 public key.
263
264On its **first boot** the Secure Boot is not enabled on the device eFuses yet, neither the key nor digests. So the first boot will have the following process:
265
2661. On startup, since it is the first boot, the ROM bootloader will not verify the bootloader image (the Secure Boot bit in the eFuse is disabled) yet, so it proceeds to execute it (our MCUboot bootloader port).
2672. Bootloader calculates the SHA-256 hash digest of the public key and writes the result to eFuse.
2683. Bootloader validates the application images and prepare the booting process (MCUboot phase).
2694. Bootloader burns eFuse to enable Secure Boot V2.
2705. Bootloader proceeds to load the Primary image.
271
272After that the Secure Boot feature is permanently enabled and on every next boot the ROM bootloader will verify the MCUboot bootloader image.
273The process of an usual boot:
274
2751. On startup, the ROM bootloader checks the Secure Boot enable bit in the eFuse. If it is enabled, the boot will proceed as following.
2762. ROM bootloader verifies the bootloader's signature block integrity (magic number and CRC). Interrupt boot if it fails.
2773. ROM bootloader verifies the bootloader image, interrupt boot if any step fails.: \
2783.1. Compare the SHA-256 hash digest of the public key embedded in the bootloader’s signature block with the digest saved in the eFuses. \
2793.2. Generate the application image digest and match it with the image digest in the signature block. \
2803.3. Use the public key to verify the signature of the bootloader image, using RSA-PSS with the image digest calculated from previous step for comparison.
2814. ROM bootloader executes the bootloader image.
2825. Bootloader does the usual verification (MCUboot phase).
2836. Proceeds to boot the Primary image.
284
285## [Flash Encryption](#flash-encryption)
286
287The Espressif Flash Encryption is hardware-assisted, transparent to the MCUboot process and is an additional security measure beyond MCUboot existent features.
288The Flash Encryption implementation is also based on [IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/security/flash-encryption.html) and is intended for encrypting off-chip flash memory contents, so it is protected against physical reading.
289
290When enabling the Flash Encryption, the user can encrypt the content either using a **device generated key** (remains unknown and unreadable) or a **host generated key** (owner is responsible for keeping the key private and safe). After the flash encryption gets enabled through eFuse burning on the device, all read and write operations are decrypted/encrypted in runtime.
291
292### [Building bootloader with Flash Encryption](#building-bootloader-with-flash-encryption)
293
294In order to build the bootloader with the feature on, the following configurations must be enabled:
295
296For **release mode**:
297```
298CONFIG_SECURE_FLASH_ENC_ENABLED=1
299CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE=1
300```
301
302For **development mode**:
303```
304CONFIG_SECURE_FLASH_ENC_ENABLED=1
305CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT=1
306```
Almir Okatob365e232022-03-08 01:35:54 -0300307
308---
Almir Okato39eb63d2022-01-05 18:31:54 -0300309:warning: ***ATTENTION***
310
311*On development phase is strongly recommended adding the following configuration in order to keep the debugging enabled and also to avoid any unrecoverable/permanent state change:*
312```
313CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC=1
314CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC=1
315CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE=1
316CONFIG_SECURE_BOOT_ALLOW_JTAG=1
317
318# Options for enabling eFuse emulation in Flash
319CONFIG_EFUSE_VIRTUAL=1
320CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH=1
321```
Almir Okatob365e232022-03-08 01:35:54 -0300322---
Almir Okato39eb63d2022-01-05 18:31:54 -0300323
324---
325:warning: ***ATTENTION***
326
327*Unless the recommended flags for **DEVELOPMENT MODE** were enabled, the actions made by Flash Encryption process are **PERMANENT**.* \
328*Once the bootloader is flashed and the device resets, the **first boot will enable Flash Encryption, encrypt the flash content including bootloader and image slots, burn the eFuses that no longer can be modified** and if device generated the key **it will not be recoverable**.* \
329*When on **RELEASE MODE**, **ENSURE** that the application with an update agent is flashed before reset the device.*
330
Almir Okatob365e232022-03-08 01:35:54 -0300331*In the same way as Secure Boot feature, you can disable UART Download Mode by adding the following configuration:*
332```
333CONFIG_SECURE_DISABLE_ROM_DL_MODE=1
334```
335
336*This may be suitable for **production** builds. **After disabling UART Download Mode you will not be able to flash other images through UART.***
337
338*Otherwise, you can switch the UART Download Mode to the Secure Download Mode. It will limit the use of Download Mode functions to simple flash read, write and erase operations.*
339```
340CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE=1
341```
342
343*These configurations cannot be reverted after the device's first boot*
344
Almir Okato39eb63d2022-01-05 18:31:54 -0300345---
346
Sylvio Alvesd5230942022-01-20 21:35:53 -0300347### [Signing the image when working with Flash Encryption](#signing-the-image-when-working-with-flash-encryption)
348
349When enabling flash encryption, it is required to signed the image using 32-byte alignment: `--align 32 --max-align 32`.
350
351Command example:
352```
353imgtool.py sign -k <YOUR_SIGNING_KEY.pem> --pad --pad-sig --align 32 --max-align 32 -v 0 -H 32 --pad-header -S <SLOT_SIZE> <BIN_IN> <BIN_OUT>
354```
355
Almir Okato39eb63d2022-01-05 18:31:54 -0300356### [Device generated key](#device-generated-key)
357
358First ensure that the application image is able to perform encrypted read and write operations to the SPI Flash.
359Flash the bootloader and application normally:
360
361```
362esptool.py -p <PORT> -b 2000000 --after no_reset --chip <ESP_CHIP> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <BOOTLOADER_FLASH_OFFSET> <BOOTLOADER_BIN>
363```
364```
365esptool.py -p <PORT> -b 2000000 --after no_reset --chip <ESP_CHIP> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <PRIMARY_SLOT_FLASH_OFFSET> <APPLICATION_BIN>
366```
367
368On the **first boot**, the bootloader will:
3691. Generate Flash Encryption key and write to eFuse.
3702. Encrypt flash in-place including bootloader, image primary/secondary slot and scratch.
3713. Burn eFuse to enable Flash Encryption.
3724. Reset system to ensure Flash Encryption cache resets properly.
373
374### [Host generated key](#host-generated-key)
375
Almir Okatob365e232022-03-08 01:35:54 -0300376First ensure that the application image is able to perform encrypted read and write operations to the SPI Flash. Also ensure that the **UART ROM Download Mode is not disabled** - or that the **Secure Download Mode is enabled**.
Almir Okato39eb63d2022-01-05 18:31:54 -0300377Before flashing, generate the encryption key using `espsecure.py` tool:
378```
379espsecure.py generate_flash_encryption_key <FLASH_ENCRYPTION_KEY.bin>
380```
381
Almir Okatob365e232022-03-08 01:35:54 -0300382Burn the key into the device's eFuse (keep a copy on the host), this action can be done **only once**:
Almir Okato39eb63d2022-01-05 18:31:54 -0300383
384---
385:warning: ***ATTENTION***
386
Almir Okatob365e232022-03-08 01:35:54 -0300387*eFuse emulation in Flash configuration options do not have any effect, so if the key burning command below is used, it will actually burn the physical eFuse.*
Almir Okato39eb63d2022-01-05 18:31:54 -0300388
389---
390
391- ESP32
392```
393espefuse.py --port PORT burn_key flash_encryption <FLASH_ENCRYPTION_KEY.bin>
394```
395
Sylvio Alvesd8eff812022-01-31 23:16:06 -0300396- ESP32S2, ESP32C3 and ESP32S3
Almir Okato39eb63d2022-01-05 18:31:54 -0300397```
398espefuse.py --port PORT burn_key BLOCK <FLASH_ENCRYPTION_KEY.bin> <KEYPURPOSE>
399```
400
401BLOCK is a free keyblock between BLOCK_KEY0 and BLOCK_KEY5. And KEYPURPOSE is either XTS_AES_128_KEY, XTS_AES_256_KEY_1, XTS_AES_256_KEY_2 (AES XTS 256 is available only in ESP32S2).
402
403Now, similar as the Device generated key, the bootloader and application can be flashed plaintext. The **first boot** will encrypt the flash content using the host key burned in the eFuse instead of generate a new one.
404
405Flashing the bootloader and application:
406
407```
408esptool.py -p <PORT> -b 2000000 --after no_reset --chip <ESP_CHIP> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <BOOTLOADER_FLASH_OFFSET> <BOOTLOADER_BIN>
409```
410```
411esptool.py -p <PORT> -b 2000000 --after no_reset --chip <ESP_CHIP> write_flash --flash_mode dio --flash_size <FLASH_SIZE> --flash_freq 40m <PRIMARY_SLOT_FLASH_OFFSET> <APPLICATION_BIN>
412```
413
414On the **first boot**, the bootloader will:
4151. Encrypt flash in-place including bootloader, image primary/secondary slot and scratch using the written key.
4162. Burn eFuse to enable Flash Encryption.
4173. Reset system to ensure Flash Encryption cache resets properly.
418
Almir Okatob365e232022-03-08 01:35:54 -0300419Encrypting data on the host:
420- ESP32
421```
422espsecure.py encrypt_flash_data --keyfile <FLASH_ENCRYPTION_KEY.bin> --address <FLASH_OFFSET> --output <OUTPUT_DATA> <INPUT_DATA>
423```
424
425- ESP32-S2, ESP32-C3 and ESP32-S3
426```
427espsecure.py encrypt_flash_data --aes_xts --keyfile <FLASH_ENCRYPTION_KEY.bin> --address <FLASH_OFFSET> --output <OUTPUT_DATA> <INPUT_DATA>
428```
429
430---
431***Note***
432OTA updates are required to be sent plaintext. The reason is that, as said before, after the Flash Encryption is enabled all read/write operations are decrypted/encrypted in runtime, so as e.g. if pre-encrypted data is sent for an OTA update, it would be wrongly double-encrypted when the update agent writes to the flash.
433
434For updating with an image encrypted on the host, flash it through serial using `esptool.py` as above. **UART ROM Download Mode must not be disabled**.
435
436---
437
Almir Okato39eb63d2022-01-05 18:31:54 -0300438## [Security Chain scheme](#security-chain-scheme)
439
440Using the 3 features, Secure Boot, Image signature verification and Flash Encryption, a Security Chain can be established so only trusted code is executed, and also the code and content residing in the off-chip flash are protected against undesirable reading.
441
442The overall final process when all features are enabled:
4431. ROM bootloader validates the MCUboot bootloader using RSA signature verification.
4442. MCUboot bootloader validates the image using the chosen algorithm EC256/RSA/ED25519. It also validates an upcoming image when updating.
4453. Flash Encryption guarantees that code and data are not exposed.
446
447### [Size Limitation](#size-limitation)
448
449When all 3 features are enable at same time, the bootloader size may exceed the fixed limit for the ROM bootloader checking on the Espressif chips **depending on which algorithm** was chosen for MCUboot image signing. The issue https://github.com/mcu-tools/mcuboot/issues/1262 was created to track this limitation.