mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/c3_master_flash_enc_support' into 'master'
flash encryption: merge C3 flash encryption changes to master See merge request espressif/esp-idf!12040
This commit is contained in:
commit
a7da0c894b
@ -39,6 +39,7 @@
|
||||
#include "sys/param.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/crc.h"
|
||||
@ -52,13 +53,14 @@
|
||||
|
||||
#define SUB_TYPE_ID(i) (i & 0x0F)
|
||||
|
||||
/* Partial_data is word aligned so no reallocation is necessary for encrypted flash write */
|
||||
typedef struct ota_ops_entry_ {
|
||||
uint32_t handle;
|
||||
const esp_partition_t *part;
|
||||
bool need_erase;
|
||||
uint32_t wrote_size;
|
||||
uint8_t partial_bytes;
|
||||
uint8_t partial_data[16];
|
||||
WORD_ALIGNED_ATTR uint8_t partial_data[16];
|
||||
LIST_ENTRY(ota_ops_entry_) entries;
|
||||
} ota_ops_entry_t;
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#include "bootloader_flash_priv.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_utility.h"
|
||||
@ -23,88 +22,142 @@
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_efuse_table.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
|
||||
static const char *TAG = "flash_encrypt";
|
||||
|
||||
/* Static functions for stages of flash encryption */
|
||||
static esp_err_t initialise_flash_encryption(void);
|
||||
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis);
|
||||
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis) __attribute__((unused));
|
||||
static esp_err_t encrypt_bootloader(void);
|
||||
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions);
|
||||
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition);
|
||||
|
||||
esp_err_t esp_flash_encrypt_check_and_update(void)
|
||||
{
|
||||
// TODO ESP32-C3 IDF-2116
|
||||
uint32_t cnt = REG_GET_FIELD(EFUSE_RD_REPEAT_DATA1_REG, EFUSE_SPI_BOOT_CRYPT_CNT);
|
||||
ESP_LOGV(TAG, "SPI_BOOT_CRYPT_CNT 0x%x", cnt);
|
||||
uint8_t flash_crypt_wr_dis = 0;
|
||||
uint32_t flash_crypt_cnt = 0;
|
||||
|
||||
bool flash_crypt_wr_dis = false; // TODO: check if CRYPT_CNT is write disabled
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_SPI_BOOT_CRYPT_CNT, &flash_crypt_cnt, 3);
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT, &flash_crypt_wr_dis, 1);
|
||||
|
||||
_Static_assert(EFUSE_SPI_BOOT_CRYPT_CNT == 0x7, "assuming CRYPT_CNT is only 3 bits wide");
|
||||
ESP_LOGV(TAG, "SPI_BOOT_CRYPT_CNT 0x%x", flash_crypt_cnt);
|
||||
ESP_LOGV(TAG, "EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT 0x%x", flash_crypt_wr_dis);
|
||||
|
||||
if (cnt == 1 || cnt == 3 || cnt == 7) {
|
||||
if (__builtin_parity(flash_crypt_cnt) == 1) {
|
||||
/* Flash is already encrypted */
|
||||
int left;
|
||||
if (cnt == 7 /* || disabled */) {
|
||||
left = 0;
|
||||
} else if (cnt == 3) {
|
||||
left = 1;
|
||||
} else {
|
||||
left = 2;
|
||||
int left = (flash_crypt_cnt == 1) ? 1 : 0;
|
||||
if (flash_crypt_wr_dis) {
|
||||
left = 0; /* can't update FLASH_CRYPT_CNT, no more flashes */
|
||||
}
|
||||
ESP_LOGI(TAG, "flash encryption is enabled (%d plaintext flashes left)", left);
|
||||
return ESP_OK;
|
||||
} else {
|
||||
#ifndef CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
/* Flash is not encrypted, so encrypt it! */
|
||||
return encrypt_flash_contents(cnt, flash_crypt_wr_dis);
|
||||
return encrypt_flash_contents(flash_crypt_cnt, flash_crypt_wr_dis);
|
||||
#else
|
||||
ESP_LOGE(TAG, "flash encryption is not enabled, and SECURE_FLASH_REQUIRE_ALREADY_ENABLED "
|
||||
"is set, refusing to boot.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
#endif // CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t initialise_flash_encryption(void)
|
||||
static esp_err_t check_and_generate_encryption_keys(void)
|
||||
{
|
||||
/* Before first flash encryption pass, need to initialise key & crypto config */
|
||||
esp_efuse_block_t aes_128_key_block;
|
||||
|
||||
/* Find out if a key is already set */
|
||||
bool has_key = ets_efuse_find_purpose(ETS_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY, NULL);
|
||||
bool has_key = esp_efuse_find_purpose(ESP_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY, &aes_128_key_block);
|
||||
bool dis_write = false;
|
||||
bool dis_read = false;
|
||||
|
||||
if (has_key) {
|
||||
ESP_LOGI(TAG, "Using pre-existing key in efuse");
|
||||
|
||||
ESP_LOGE(TAG, "TODO: Check key is read & write protected"); // TODO
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Generating new flash encryption key...");
|
||||
const unsigned BLOCKS_NEEDED = 1;
|
||||
const ets_efuse_purpose_t PURPOSE_START = ETS_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY;
|
||||
const ets_efuse_purpose_t PURPOSE_END = ETS_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY;
|
||||
|
||||
if (ets_efuse_count_unused_key_blocks() < BLOCKS_NEEDED) {
|
||||
ESP_LOGE(TAG, "Not enough free efuse key blocks (need %d) to continue", BLOCKS_NEEDED);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
for (ets_efuse_purpose_t purpose = PURPOSE_START; purpose <= PURPOSE_END; purpose++) {
|
||||
uint32_t buf[8] = {0};
|
||||
bootloader_fill_random(buf, sizeof(buf));
|
||||
ets_efuse_block_t block = ets_efuse_find_unused_key_block();
|
||||
ESP_LOGD(TAG, "Writing ETS_EFUSE_BLOCK_KEY%d with purpose %d",
|
||||
block - ETS_EFUSE_BLOCK_KEY0, purpose);
|
||||
bootloader_debug_buffer(buf, sizeof(buf), "Key content");
|
||||
int r = ets_efuse_write_key(block, purpose, buf, sizeof(buf));
|
||||
bzero(buf, sizeof(buf));
|
||||
if (r != 0) {
|
||||
ESP_LOGE(TAG, "Failed to write efuse block %d with purpose %d. Can't continue.");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "Key generation complete");
|
||||
// If there are keys set, they must be write and read protected!
|
||||
if(has_key) {
|
||||
dis_write = esp_efuse_get_key_dis_write(aes_128_key_block);
|
||||
dis_read = esp_efuse_get_key_dis_read(aes_128_key_block);
|
||||
}
|
||||
|
||||
ESP_LOGE(TAG, "TODO: burn remaining security protection bits");
|
||||
|
||||
return ESP_OK;
|
||||
if(has_key && (!dis_read || !dis_write)) {
|
||||
ESP_LOGE(TAG, "Invalid key state, a key was set but not read and write protected.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if(!has_key && !dis_write && !dis_read) {
|
||||
ESP_LOGI(TAG, "Generating new flash encryption key...");
|
||||
|
||||
enum { BLOCKS_NEEDED = 1 };
|
||||
esp_efuse_purpose_t purposes[BLOCKS_NEEDED] = {
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY,
|
||||
};
|
||||
|
||||
uint8_t keys[BLOCKS_NEEDED][32] = { 0 };
|
||||
for (int i = 0; i < BLOCKS_NEEDED; ++i) {
|
||||
bootloader_fill_random(keys[i], 32);
|
||||
}
|
||||
|
||||
esp_err_t err = esp_efuse_write_keys(purposes, keys, BLOCKS_NEEDED);
|
||||
if (err != ESP_OK) {
|
||||
if (err == ESP_ERR_NOT_ENOUGH_UNUSED_KEY_BLOCKS) {
|
||||
ESP_LOGE(TAG, "Not enough free efuse key blocks (need %d) to continue", BLOCKS_NEEDED);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to write efuse block with purpose (err=0x%x). Can't continue.", err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
ESP_LOGD(TAG, "Key generation complete");
|
||||
return ESP_OK;
|
||||
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Using pre-existing key in efuse");
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t initialise_flash_encryption(void)
|
||||
{
|
||||
esp_efuse_batch_write_begin(); /* Batch all efuse writes at the end of this function */
|
||||
|
||||
esp_err_t key_state = check_and_generate_encryption_keys();
|
||||
if(key_state != ESP_OK) {
|
||||
esp_efuse_batch_write_cancel();
|
||||
return key_state;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
|
||||
ESP_LOGI(TAG, "Disable UART bootloader encryption...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling UART bootloader encryption");
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
|
||||
ESP_LOGI(TAG, "Disable UART bootloader cache...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_DOWNLOAD_ICACHE);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling UART bootloader cache - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
|
||||
ESP_LOGI(TAG, "Disable JTAG...");
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_PAD_JTAG);
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_USB_JTAG);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
|
||||
#endif
|
||||
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_DIS_LEGACY_SPI_BOOT);
|
||||
|
||||
esp_err_t err = esp_efuse_batch_write_commit();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Error programming security eFuses (err=0x%x).", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Encrypt all flash data that should be encrypted */
|
||||
@ -117,7 +170,7 @@ static esp_err_t encrypt_flash_contents(uint32_t spi_boot_crypt_cnt, bool flash_
|
||||
/* If the last spi_boot_crypt_cnt bit is burned or write-disabled, the
|
||||
device can't re-encrypt itself. */
|
||||
if (flash_crypt_wr_dis || spi_boot_crypt_cnt == EFUSE_SPI_BOOT_CRYPT_CNT) {
|
||||
ESP_LOGE(TAG, "Cannot re-encrypt data (SPI_BOOT_CRYPT_CNT 0x%02x write disabled %d", spi_boot_crypt_cnt, flash_crypt_wr_dis);
|
||||
ESP_LOGE(TAG, "Cannot re-encrypt data SPI_BOOT_CRYPT_CNT 0x%02x write disabled %d", spi_boot_crypt_cnt, flash_crypt_wr_dis);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@ -155,13 +208,17 @@ static esp_err_t encrypt_flash_contents(uint32_t spi_boot_crypt_cnt, bool flash_
|
||||
/* Set least significant 0-bit in spi_boot_crypt_cnt */
|
||||
int ffs_inv = __builtin_ffs((~spi_boot_crypt_cnt) & 0x7);
|
||||
/* ffs_inv shouldn't be zero, as zero implies spi_boot_crypt_cnt == 0xFF */
|
||||
uint32_t new_spi_boot_crypt_cnt = spi_boot_crypt_cnt + (1 << (ffs_inv - 1));
|
||||
ESP_LOGD(TAG, "SPI_BOOT_CRYPT_CNT 0x%x -> 0x%x", spi_boot_crypt_cnt, new_spi_boot_crypt_cnt);
|
||||
uint32_t new_spi_boot_crypt_cnt = (1 << (ffs_inv - 1));
|
||||
ESP_LOGD(TAG, "SPI_BOOT_CRYPT_CNT 0x%x -> 0x%x", spi_boot_crypt_cnt, new_spi_boot_crypt_cnt + spi_boot_crypt_cnt);
|
||||
|
||||
ets_efuse_clear_program_registers();
|
||||
REG_SET_FIELD(EFUSE_PGM_DATA2_REG, EFUSE_SPI_BOOT_CRYPT_CNT, new_spi_boot_crypt_cnt);
|
||||
ets_efuse_program(ETS_EFUSE_BLOCK0);
|
||||
esp_efuse_write_field_blob(ESP_EFUSE_SPI_BOOT_CRYPT_CNT, &new_spi_boot_crypt_cnt, 3);
|
||||
|
||||
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
|
||||
//Secure SPI boot cnt after its update if needed.
|
||||
const uint32_t spi_boot_cnt_wr_dis = 1;
|
||||
ESP_LOGI(TAG, "Write protecting SPI_CRYPT_CNT eFuse");
|
||||
esp_efuse_write_field_blob(ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT, &spi_boot_cnt_wr_dis, 1);
|
||||
#endif
|
||||
ESP_LOGI(TAG, "Flash encryption completed");
|
||||
|
||||
return ESP_OK;
|
||||
@ -174,20 +231,28 @@ static esp_err_t encrypt_bootloader(void)
|
||||
/* Check for plaintext bootloader (verification will fail if it's already encrypted) */
|
||||
if (esp_image_verify_bootloader(&image_length) == ESP_OK) {
|
||||
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
|
||||
|
||||
#if CONFIG_SECURE_BOOT_V2_ENABLED
|
||||
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
|
||||
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
|
||||
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
#endif // CONFIG_SECURE_BOOT_V2_ENABLED
|
||||
|
||||
err = esp_flash_encrypt_region(ESP_BOOTLOADER_OFFSET, image_length);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt bootloader in place: 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (esp_secure_boot_enabled()) {
|
||||
// TODO: anything different for secure boot?
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(TAG, "no valid bootloader was found");
|
||||
ESP_LOGI(TAG, "bootloader encrypted successfully");
|
||||
return err;
|
||||
}
|
||||
else {
|
||||
ESP_LOGW(TAG, "no valid bootloader was found");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions)
|
||||
@ -213,9 +278,11 @@ static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partitio
|
||||
}
|
||||
|
||||
/* Valid partition table loaded */
|
||||
ESP_LOGI(TAG, "partition table encrypted and loaded successfully");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition)
|
||||
{
|
||||
esp_err_t err;
|
||||
@ -248,6 +315,7 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length)
|
||||
{
|
||||
esp_err_t err;
|
||||
@ -258,7 +326,12 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length)
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
wdt_hal_context_t rtc_wdt_ctx = {.inst = WDT_RWDT, .rwdt_dev = &RTCCNTL};
|
||||
for (size_t i = 0; i < data_length; i += FLASH_SECTOR_SIZE) {
|
||||
wdt_hal_write_protect_disable(&rtc_wdt_ctx);
|
||||
wdt_hal_feed(&rtc_wdt_ctx);
|
||||
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
|
||||
|
||||
uint32_t sec_start = i + src_addr;
|
||||
err = bootloader_flash_read(sec_start, buf, FLASH_SECTOR_SIZE, false);
|
||||
if (err != ESP_OK) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define CRYPT_CNT ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define WR_DIS_CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#define CRYPT_CNT ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define WR_DIS_CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#endif
|
||||
|
||||
@ -90,10 +90,12 @@ esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
uint8_t dis_dl_enc = 0;
|
||||
uint8_t dis_dl_enc = 0;
|
||||
uint8_t dis_dl_icache = 0;
|
||||
uint8_t dis_dl_dcache = 0;
|
||||
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint8_t dis_dl_enc = 0;
|
||||
uint8_t dis_dl_icache = 0;
|
||||
#endif
|
||||
|
||||
esp_flash_enc_mode_t mode = ESP_FLASH_ENC_MODE_DEVELOPMENT;
|
||||
@ -128,6 +130,13 @@ esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
|
||||
if (dis_dl_enc && dis_dl_icache && dis_dl_dcache) {
|
||||
mode = ESP_FLASH_ENC_MODE_RELEASE;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
dis_dl_enc = esp_efuse_read_field_bit(ESP_EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT);
|
||||
dis_dl_icache = esp_efuse_read_field_bit(ESP_EFUSE_DIS_DOWNLOAD_ICACHE);
|
||||
|
||||
if (dis_dl_enc && dis_dl_icache) {
|
||||
mode = ESP_FLASH_ENC_MODE_RELEASE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "hal/spi_flash_hal.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
static const char *TAG = "spiflash_c3";
|
||||
|
||||
@ -37,8 +38,9 @@ esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_a
|
||||
assert((dest_addr % 16) == 0);
|
||||
assert((size % 16) == 0);
|
||||
|
||||
if (!esp_ptr_internal(src)) {
|
||||
uint8_t block[128]; // Need to buffer in RAM as we write
|
||||
/* src needs to be 32 bit aligned */
|
||||
if (!esp_ptr_internal(src) || (intptr_t)src & 0x3) {
|
||||
WORD_ALIGNED_ATTR uint8_t block[128]; // Need to buffer in RAM as we write
|
||||
while (size > 0) {
|
||||
size_t next_block = MIN(size, sizeof(block));
|
||||
memcpy(block, src, next_block);
|
||||
|
145
docs/en/security/esp32_log.inc
Normal file
145
docs/en/security/esp32_log.inc
Normal file
@ -0,0 +1,145 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
--- idf_monitor on /dev/cu.SLAB_USBtoUART 115200 ---
|
||||
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
|
||||
ets Jun 8 2016 00:22:57
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13608
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (28) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (29) boot: compile time 15:37:14
|
||||
I (30) boot: Enabling RNG early entropy source...
|
||||
I (35) boot: SPI Speed : 40MHz
|
||||
I (39) boot: SPI Mode : DIO
|
||||
I (43) boot: SPI Flash Size : 4MB
|
||||
I (47) boot: Partition Table:
|
||||
I (51) boot: ## Label Usage Type ST Offset Length
|
||||
I (58) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (66) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (73) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (81) boot: End of partition table
|
||||
I (85) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (105) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (109) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (114) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (132) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (159) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (168) boot: Loaded app from partition at offset 0x20000
|
||||
I (168) boot: Checking flash encryption...
|
||||
I (168) flash_encrypt: Generating new flash encryption key...
|
||||
I (187) flash_encrypt: Read & write protecting new key...
|
||||
I (187) flash_encrypt: Setting CRYPT_CONFIG efuse to 0xF
|
||||
W (188) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (195) flash_encrypt: Disable UART bootloader decryption...
|
||||
I (201) flash_encrypt: Disable UART bootloader MMU cache...
|
||||
I (208) flash_encrypt: Disable JTAG...
|
||||
I (212) flash_encrypt: Disable ROM BASIC interpreter fallback...
|
||||
I (219) esp_image: segment 0: paddr=0x00001020 vaddr=0x3fff0018 size=0x00004 ( 4)
|
||||
I (227) esp_image: segment 1: paddr=0x0000102c vaddr=0x3fff001c size=0x02104 ( 8452)
|
||||
I (239) esp_image: segment 2: paddr=0x00003138 vaddr=0x40078000 size=0x03528 ( 13608)
|
||||
I (249) esp_image: segment 3: paddr=0x00006668 vaddr=0x40080400 size=0x01a08 ( 6664)
|
||||
I (657) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (669) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844)
|
||||
I (672) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024)
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (676) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720)
|
||||
I (692) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (719) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012)
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (722) flash_encrypt: Encrypting partition 2 at offset 0x20000...
|
||||
I (13229) flash_encrypt: Flash encryption completed
|
||||
I (13229) boot: Resetting with flash encryption enabled...
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13652
|
||||
ho 0 tail 12 room 4
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (30) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (30) boot: compile time 16:32:53
|
||||
I (31) boot: Enabling RNG early entropy source...
|
||||
I (37) boot: SPI Speed : 40MHz
|
||||
I (41) boot: SPI Mode : DIO
|
||||
I (45) boot: SPI Flash Size : 4MB
|
||||
I (49) boot: Partition Table:
|
||||
I (52) boot: ## Label Usage Type ST Offset Length
|
||||
I (60) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (67) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (75) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (82) boot: End of partition table
|
||||
I (86) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (107) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (111) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (116) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (134) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (162) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (171) boot: Loaded app from partition at offset 0x20000
|
||||
I (171) boot: Checking flash encryption...
|
||||
I (171) flash_encrypt: flash encryption is enabled (3 plaintext flashes left)
|
||||
I (178) boot: Disabling RNG early entropy source...
|
||||
I (184) cpu_start: Pro cpu up.
|
||||
I (188) cpu_start: Application information:
|
||||
I (193) cpu_start: Project name: flash-encryption
|
||||
I (198) cpu_start: App version: v4.0-dev-850-gc4447462d-dirty
|
||||
I (205) cpu_start: Compile time: Jun 17 2019 16:32:52
|
||||
I (211) cpu_start: ELF file SHA256: 8770c886bdf561a7...
|
||||
I (217) cpu_start: ESP-IDF: v4.0-dev-850-gc4447462d-dirty
|
||||
I (224) cpu_start: Starting app cpu, entry point is 0x40080e4c
|
||||
0x40080e4c: call_start_cpu1 at esp-idf/esp-idf/components/{IDF_TARGET_PATH_NAME}/cpu_start.c:265
|
||||
|
||||
I (0) cpu_start: App cpu up.
|
||||
I (235) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (241) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
|
||||
I (247) heap_init: At 3FFB2EC8 len 0002D138 (180 KiB): DRAM
|
||||
I (254) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
|
||||
I (260) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
|
||||
I (266) heap_init: At 40087FF4 len 0001800C (96 KiB): IRAM
|
||||
I (273) cpu_start: Pro cpu start user code
|
||||
I (291) cpu_start: Starting scheduler on PRO CPU.
|
||||
I (0) cpu_start: Starting scheduler on APP CPU.
|
||||
|
||||
Sample program to check Flash Encryption
|
||||
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
|
||||
Flash encryption feature is enabled
|
||||
Flash encryption mode is DEVELOPMENT
|
||||
Flash in encrypted mode with flash_crypt_cnt = 1
|
||||
Halting...
|
||||
|
||||
------
|
133
docs/en/security/esp32c3_log.inc
Normal file
133
docs/en/security/esp32c3_log.inc
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x1 (POWERON),boot:0xf (SPI_FAST_FLASH_BOOT)
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fcd6260,len:0x1b8
|
||||
load:0x3fcd6418,len:0x2538
|
||||
load:0x403ce000,len:0x704
|
||||
load:0x403d0000,len:0x34f0
|
||||
entry 0x403ce03e
|
||||
I (12) boot: ESP-IDF qa-test-v4.3-20201113-766-g870d 2nd stage bootloader
|
||||
I (13) boot: compile time 12:10:57
|
||||
I (13) boot: chip revision: 0
|
||||
I (16) boot.esp32c3: SPI Speed : 40MHz
|
||||
I (17) boot.esp32c3: SPI Mode : DIO
|
||||
I (19) boot.esp32c3: SPI Flash Size : 2MB
|
||||
I (22) boot: Enabling RNG early entropy source...
|
||||
I (28) boot: Partition Table:
|
||||
I (30) boot: ## Label Usage Type ST Offset Length
|
||||
I (33) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (37) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (41) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (44) boot: End of partition table
|
||||
I (46) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (61) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324) load
|
||||
I (64) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688) load
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (81) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (84) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (132) boot: Loaded app from partition at offset 0x20000
|
||||
I (133) boot: Checking flash encryption...
|
||||
I (137) efuse: Batch mode of writing fields is enabled
|
||||
I (140) flash_encrypt: Generating new flash encryption key...
|
||||
I (144) efuse: Writing EFUSE_BLK_KEY0 with purpose 4
|
||||
W (148) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (152) flash_encrypt: Disable UART bootloader cache...
|
||||
I (155) flash_encrypt: Disable JTAG...
|
||||
I (161) efuse: Batch mode. Prepared fields are committed
|
||||
I (162) esp_image: segment 0: paddr=0x00000020 vaddr=0x3fcd6260 size=0x001b8 ( 440)
|
||||
I (164) esp_image: segment 1: paddr=0x000001e0 vaddr=0x3fcd6418 size=0x02538 ( 9528)
|
||||
I (173) esp_image: segment 2: paddr=0x00002720 vaddr=0x403ce000 size=0x00704 ( 1796)
|
||||
I (174) esp_image: segment 3: paddr=0x00002e2c vaddr=0x403d0000 size=0x034f0 ( 13552)
|
||||
I (571) flash_encrypt: bootloader encrypted successfully
|
||||
I (627) flash_encrypt: partition table encrypted and loaded successfully
|
||||
I (628) flash_encrypt: Encrypting partition 1 at offset 0x10000 (length 0x1000)...
|
||||
I (685) flash_encrypt: Done encrypting
|
||||
I (686) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (696) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324)
|
||||
I (699) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688)
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (715) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (717) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (760) flash_encrypt: Encrypting partition 2 at offset 0x20000 (length 0x100000)...
|
||||
I (14797) flash_encrypt: Done encrypting
|
||||
I (14801) flash_encrypt: Flash encryption completed
|
||||
I (14802) boot: Resetting with flash encryption enabled...
|
||||
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
|
||||
Saved PC:0x403d0dde
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fcd6260,len:0x1b8
|
||||
load:0x3fcd6418,len:0x2538
|
||||
load:0x403ce000,len:0x704
|
||||
load:0x403d0000,len:0x34f0
|
||||
entry 0x403ce03e
|
||||
I (15) boot: ESP-IDF qa-test-v4.3-20201113-766-g870d 2nd stage bootloader
|
||||
I (15) boot: compile time 12:10:57
|
||||
I (16) boot: chip revision: 0
|
||||
I (19) boot.esp32c3: SPI Speed : 40MHz
|
||||
I (19) boot.esp32c3: SPI Mode : DIO
|
||||
I (22) boot.esp32c3: SPI Flash Size : 2MB
|
||||
I (24) boot: Enabling RNG early entropy source...
|
||||
I (30) boot: Partition Table:
|
||||
I (32) boot: ## Label Usage Type ST Offset Length
|
||||
I (36) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (39) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (43) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (47) boot: End of partition table
|
||||
I (49) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (64) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324) load
|
||||
I (67) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688) load
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (86) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (88) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (139) boot: Loaded app from partition at offset 0x20000
|
||||
I (139) boot: Checking flash encryption...
|
||||
I (144) flash_encrypt: flash encryption is enabled (1 plaintext flashes left)
|
||||
I (148) boot: Disabling RNG early entropy source...
|
||||
I (160) cpu_start: Pro cpu start user code
|
||||
I (160) cpu_start: cpu freq: 40000000
|
||||
I (161) cpu_start: Application information:
|
||||
I (161) cpu_start: Project name: flash_encryption
|
||||
I (164) cpu_start: App version: qa-test-v4.3-20201113-766-g870d
|
||||
I (168) cpu_start: Compile time: Dec 21 2020 12:10:55
|
||||
I (171) cpu_start: ELF file SHA256: 209e8947c2e6a6a6...
|
||||
I (174) cpu_start: ESP-IDF: qa-test-v4.3-20201113-766-g870d
|
||||
I (178) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (181) heap_init: At 3FC8A9F0 len 00035610 (213 KiB): D/IRAM
|
||||
I (184) heap_init: At 3FCC0000 len 0001F260 (124 KiB): STACK/DRAM
|
||||
I (188) heap_init: At 50000000 len 00002000 (8 KiB): FAKEDRAM
|
||||
W (192) flash_encrypt: Flash encryption mode is DEVELOPMENT (not secure)
|
||||
I (195) spi_flash: detected chip: gd
|
||||
I (197) spi_flash: flash io: dio
|
||||
W (199) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||
I (207) cpu_start: Starting scheduler.
|
||||
|
||||
Example to check Flash Encryption status
|
||||
This is esp32c3 chip with 1 CPU core(s), WiFi/BLE, silicon revision 0, 2MB external flash
|
||||
FLASH_CRYPT_CNT eFuse value is 1
|
||||
Flash encryption feature is enabled in DEVELOPMENT mode
|
||||
|
||||
|
||||
------
|
155
docs/en/security/esp32s2_log.inc
Normal file
155
docs/en/security/esp32s2_log.inc
Normal file
@ -0,0 +1,155 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ESP-ROM:esp32s2-rc4-20191025
|
||||
Build:Oct 25 2019
|
||||
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:1
|
||||
load:0x3ffe6260,len:0x78
|
||||
load:0x3ffe62d8,len:0x231c
|
||||
load:0x4004c000,len:0x9d8
|
||||
load:0x40050000,len:0x3cf8
|
||||
entry 0x4004c1ec
|
||||
I (48) boot: ESP-IDF qa-test-v4.3-20201113-777-gd8e1 2nd stage bootloader
|
||||
I (48) boot: compile time 11:24:04
|
||||
I (48) boot: chip revision: 0
|
||||
I (52) boot.esp32s2: SPI Speed : 80MHz
|
||||
I (57) boot.esp32s2: SPI Mode : DIO
|
||||
I (62) boot.esp32s2: SPI Flash Size : 2MB
|
||||
I (66) boot: Enabling RNG early entropy source...
|
||||
I (72) boot: Partition Table:
|
||||
I (75) boot: ## Label Usage Type ST Offset Length
|
||||
I (83) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (90) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (98) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (105) boot: End of partition table
|
||||
I (109) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (124) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764) load
|
||||
I (129) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028) load
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (136) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740) load
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (153) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (171) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972) load
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (181) boot: Loaded app from partition at offset 0x20000
|
||||
I (181) boot: Checking flash encryption...
|
||||
I (181) efuse: Batch mode of writing fields is enabled
|
||||
I (188) flash_encrypt: Generating new flash encryption key...
|
||||
W (199) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (201) flash_encrypt: Disable UART bootloader cache...
|
||||
I (207) flash_encrypt: Disable JTAG...
|
||||
I (212) efuse: Batch mode of writing fields is disabled
|
||||
I (217) esp_image: segment 0: paddr=0x00001020 vaddr=0x3ffe6260 size=0x00078 ( 120)
|
||||
I (226) esp_image: segment 1: paddr=0x000010a0 vaddr=0x3ffe62d8 size=0x0231c ( 8988)
|
||||
I (236) esp_image: segment 2: paddr=0x000033c4 vaddr=0x4004c000 size=0x009d8 ( 2520)
|
||||
I (243) esp_image: segment 3: paddr=0x00003da4 vaddr=0x40050000 size=0x03cf8 ( 15608)
|
||||
I (651) flash_encrypt: bootloader encrypted successfully
|
||||
I (704) flash_encrypt: partition table encrypted and loaded successfully
|
||||
I (704) flash_encrypt: Encrypting partition 1 at offset 0x10000 (length 0x1000)...
|
||||
I (765) flash_encrypt: Done encrypting
|
||||
I (766) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (773) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764)
|
||||
I (778) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028)
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (785) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740)
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (799) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (820) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972)
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (823) flash_encrypt: Encrypting partition 2 at offset 0x20000 (length 0x100000)...
|
||||
I (13869) flash_encrypt: Done encrypting
|
||||
I (13870) flash_encrypt: Flash encryption completed
|
||||
I (13870) boot: Resetting with flash encryption enabled...
|
||||
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ESP-ROM:esp32s2-rc4-20191025
|
||||
Build:Oct 25 2019
|
||||
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
|
||||
Saved PC:0x40051242
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:1
|
||||
load:0x3ffe6260,len:0x78
|
||||
load:0x3ffe62d8,len:0x231c
|
||||
load:0x4004c000,len:0x9d8
|
||||
load:0x40050000,len:0x3cf8
|
||||
entry 0x4004c1ec
|
||||
I (56) boot: ESP-IDF qa-test-v4.3-20201113-777-gd8e1 2nd stage bootloader
|
||||
I (56) boot: compile time 11:24:04
|
||||
I (56) boot: chip revision: 0
|
||||
I (60) boot.esp32s2: SPI Speed : 80MHz
|
||||
I (65) boot.esp32s2: SPI Mode : DIO
|
||||
I (69) boot.esp32s2: SPI Flash Size : 2MB
|
||||
I (74) boot: Enabling RNG early entropy source...
|
||||
I (80) boot: Partition Table:
|
||||
I (83) boot: ## Label Usage Type ST Offset Length
|
||||
I (90) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (98) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (105) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (113) boot: End of partition table
|
||||
I (117) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (132) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764) load
|
||||
I (137) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028) load
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (144) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740) load
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (161) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (180) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972) load
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (190) boot: Loaded app from partition at offset 0x20000
|
||||
I (191) boot: Checking flash encryption...
|
||||
I (191) flash_encrypt: flash encryption is enabled (1 plaintext flashes left)
|
||||
I (199) boot: Disabling RNG early entropy source...
|
||||
I (216) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
|
||||
I (216) cpu_start: Pro cpu up.
|
||||
I (268) cpu_start: Pro cpu start user code
|
||||
I (268) cpu_start: cpu freq: 160000000
|
||||
I (268) cpu_start: Application information:
|
||||
I (271) cpu_start: Project name: flash_encryption
|
||||
I (277) cpu_start: App version: qa-test-v4.3-20201113-777-gd8e1
|
||||
I (284) cpu_start: Compile time: Dec 21 2020 11:24:00
|
||||
I (290) cpu_start: ELF file SHA256: 30fd1b899312fef7...
|
||||
I (296) cpu_start: ESP-IDF: qa-test-v4.3-20201113-777-gd8e1
|
||||
I (303) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (310) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
|
||||
I (316) heap_init: At 3FFBF898 len 0003C768 (241 KiB): DRAM
|
||||
I (323) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
|
||||
W (329) flash_encrypt: Flash encryption mode is DEVELOPMENT (not secure)
|
||||
I (336) spi_flash: detected chip: generic
|
||||
I (341) spi_flash: flash io: dio
|
||||
W (345) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||
I (358) cpu_start: Starting scheduler on PRO CPU.
|
||||
|
||||
Example to check Flash Encryption status
|
||||
This is esp32s2 chip with 1 CPU core(s), WiFi, silicon revision 0, 2MB external flash
|
||||
FLASH_CRYPT_CNT eFuse value is 1
|
||||
Flash encryption feature is enabled in DEVELOPMENT mode
|
||||
|
||||
------
|
@ -105,29 +105,62 @@ The flash encryption operation is controlled by various eFuses available on {IDF
|
||||
- 256
|
||||
- Yes
|
||||
- x
|
||||
* - ``EFUSE_KEY_PURPOSE_N``
|
||||
* - ``KEY_PURPOSE_N``
|
||||
- Controls the purpose of eFuse block ``KEYN``, where N is between 0 and 5. Possible values: ``2`` for ``XTS_AES_256_KEY_1`` , ``3`` for ``XTS_AES_256_KEY_2``, and ``4`` for ``XTS_AES_128_KEY``. Final AES key is derived based on the value of one or two of these purpose eFuses. For a detailed description of the possible combinations see `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_, chapter Flash Encryption.
|
||||
- 4
|
||||
- Yes
|
||||
- 0
|
||||
* - ``EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT``
|
||||
* - ``DIS_DOWNLOAD_MANUAL_ENCRYPT``
|
||||
- If set, disables flash encryption when in download bootmodes.
|
||||
- 1
|
||||
- Yes
|
||||
- 0
|
||||
* - ``EFUSE_SPI_BOOT_CRYPT_CNT``
|
||||
* - ``SPI_BOOT_CRYPT_CNT``
|
||||
- Enables encryption and decryption, when an SPI boot mode is set. Feature is enabled if 1 or 3 bits are set in the eFuse, disabled otherwise.
|
||||
- 3
|
||||
- Yes
|
||||
- 0
|
||||
|
||||
Read and write access to eFuse bits is controlled by appropriate fields in the registers ``EFUSE_WR_DIS`` and ``EFUSE_RD_DIS``. For more information on {IDF_TARGET_NAME} eFuses, see :doc:`eFuse manager <../api-reference/system/efuse>`.
|
||||
.. only:: esp32c3
|
||||
|
||||
.. list-table:: eFuses Used in Flash Encryption
|
||||
:widths: 25 40 10 15 10
|
||||
:header-rows: 0
|
||||
|
||||
* - **eFuse**
|
||||
- **Description**
|
||||
- **Bit Depth**
|
||||
- **Locking for Reading/Writing Available**
|
||||
- **Default Value**
|
||||
* - ``KEYN``
|
||||
- AES key storage. N is between 0 and 5.
|
||||
- 256
|
||||
- Yes
|
||||
- x
|
||||
* - ``KEY_PURPOSE_N``
|
||||
- Controls the purpose of eFuse block ``KEYN``, where N is between 0 and 5. For flash encryption the only valid value is `XTS_AES_128_KEY`.
|
||||
- 4
|
||||
- Yes
|
||||
- 0
|
||||
* - ``DIS_DOWNLOAD_MANUAL_ENCRYPT``
|
||||
- If set, disables flash encryption when in download bootmodes.
|
||||
- 1
|
||||
- Yes
|
||||
- 0
|
||||
* - ``SPI_BOOT_CRYPT_CNT``
|
||||
- Enables encryption and decryption, when an SPI boot mode is set. Feature is enabled if 1 or 3 bits are set in the eFuse, disabled otherwise.
|
||||
- 3
|
||||
- Yes
|
||||
- 0
|
||||
|
||||
|
||||
Read and write access to eFuse bits is controlled by appropriate fields in the registers ``WR_DIS`` and ``RD_DIS``. For more information on {IDF_TARGET_NAME} eFuses, see :doc:`eFuse manager <../api-reference/system/efuse>`.
|
||||
|
||||
|
||||
Flash Encryption Process
|
||||
------------------------
|
||||
|
||||
{IDF_TARGET_CRYPT_CNT:default="EFUSE_SPI_BOOT_CRYPT_CNT",esp32="FLASH_CRYPT_CNT",esp32s2="EFUSE_SPI_BOOT_CRYPT_CNT"}
|
||||
{IDF_TARGET_CRYPT_CNT:default="EFUSE_SPI_BOOT_CRYPT_CNT",esp32="FLASH_CRYPT_CNT",esp32s2="EFUSE_SPI_BOOT_CRYPT_CNT",esp32c3="SPI_BOOT_CRYPT_CNT"}
|
||||
|
||||
Assuming that the eFuse values are in their default states and the firmware bootloader is compiled to support flash encryption, the flash encryption process executes as shown below:
|
||||
|
||||
@ -153,20 +186,37 @@ Assuming that the eFuse values are in their default states and the firmware boot
|
||||
|
||||
1. On the first power-on reset, all data in flash is un-encrypted (plaintext). The ROM bootloader loads the firmware bootloader.
|
||||
|
||||
2. Firmware bootloader reads the ``EFUSE_SPI_BOOT_CRYPT_CNT`` eFuse value (``0b00000000``). Since the value is ``0`` (even number of bits set), it configures and enables the flash encryption block. For more information on the flash encryption block, see `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_.
|
||||
2. Firmware bootloader reads the ``SPI_BOOT_CRYPT_CNT`` eFuse value (``0b000``). Since the value is ``0`` (even number of bits set), it configures and enables the flash encryption block. For more information on the flash encryption block, see `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_.
|
||||
|
||||
3. Flash encryption block generates an 256 bit or 512 bit key, depending on the value of :ref:`Size of generated AES-XTS key <CONFIG_SECURE_FLASH_ENCRYPTION_KEYSIZE>`, and writes it into respectively one or two `KEYN` eFuses. The software also updates the ``EFUSE_KEY_PURPOSE_N`` for the blocks where the keys where stored. This operation is done entirely by hardware, and the key cannot be accessed via software.
|
||||
3. Flash encryption block generates an 256 bit or 512 bit key, depending on the value of :ref:`Size of generated AES-XTS key <CONFIG_SECURE_FLASH_ENCRYPTION_KEYSIZE>`, and writes it into respectively one or two `KEYN` eFuses. The software also updates the ``KEY_PURPOSE_N`` for the blocks where the keys where stored. This operation is done entirely by hardware, and the key cannot be accessed via software.
|
||||
|
||||
4. Flash encryption block encrypts the flash contents - partitions encrypted by default and the ones marked as ``encrypted``. Encrypting in-place can take time, up to a minute for large partitions.
|
||||
|
||||
5. Firmware bootloader sets the first available bit in ``EFUSE_SPI_BOOT_CRYPT_CNT`` (0b00000001) to mark the flash contents as encrypted. Odd number of bits is set.
|
||||
5. Firmware bootloader sets the first available bit in ``SPI_BOOT_CRYPT_CNT`` (0b001) to mark the flash contents as encrypted. Odd number of bits is set.
|
||||
|
||||
6. For :ref:`flash-enc-development-mode`, the firmware bootloader allows the UART bootloader to re-flash encrypted binaries. Also, the ``EFUSE_SPI_BOOT_CRYPT_CNT`` eFuse bits are NOT write-protected.
|
||||
6. For :ref:`flash-enc-development-mode`, the firmware bootloader allows the UART bootloader to re-flash encrypted binaries. Also, the ``SPI_BOOT_CRYPT_CNT`` eFuse bits are NOT write-protected. In addition, the firmware bootloader by default sets the eFuse bits ``DIS_BOOT_REMAP``, ``DIS_DOWNLOAD_ICACHE``, ``DIS_DOWNLOAD_DCACHE``, ``HARD_DIS_JTAG`` and ``DIS_LEGACY_SPI_BOOT``.
|
||||
|
||||
7. For :ref:`flash-enc-release-mode`, the firmware bootloader sets the eFuse bits ``EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT``, ``EFUSE_DIS_BOOT_REMAP``, ``EFUSE_DIS_DOWNLOAD_ICACHE`` and ``EFUSE_DIS_DOWNLOAD_DCACHE``. It also write-protects the ``EFUSE_SPI_BOOT_CRYPT_CNT`` eFuse bits. To modify this behavior, see :ref:`uart-bootloader-encryption`.
|
||||
7. For :ref:`flash-enc-release-mode`, the firmware bootloader sets all the eFuse bits set under development mode as well as ``DIS_DOWNLOAD_MANUAL_ENCRYPT``. It also write-protects the ``SPI_BOOT_CRYPT_CNT`` eFuse bits. To modify this behavior, see :ref:`uart-bootloader-encryption`.
|
||||
|
||||
8. The device is then rebooted to start executing the encrypted image. The firmware bootloader calls the flash decryption block to decrypt the flash contents and then loads the decrypted contents into IRAM.
|
||||
|
||||
.. only:: esp32c3
|
||||
|
||||
1. On the first power-on reset, all data in flash is un-encrypted (plaintext). The ROM bootloader loads the firmware bootloader.
|
||||
|
||||
2. Firmware bootloader reads the ``SPI_BOOT_CRYPT_CNT`` eFuse value (``0b000``). Since the value is ``0`` (even number of bits set), it configures and enables the flash encryption block. For more information on the flash encryption block, see `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_.
|
||||
|
||||
3. Flash encryption block generates an 256 bit key and writes it into a `KEYN` eFuse. The software also updates the ``KEY_PURPOSE_N`` for the block where the key where stored. This operation is done entirely by hardware, and the key cannot be accessed via software.
|
||||
|
||||
4. Flash encryption block encrypts the flash contents - partitions encrypted by default and the ones marked as ``encrypted``. Encrypting in-place can take time, up to a minute for large partitions.
|
||||
|
||||
5. Firmware bootloader sets the first available bit in ``SPI_BOOT_CRYPT_CNT`` (0b001) to mark the flash contents as encrypted. Odd number of bits is set.
|
||||
|
||||
6. For :ref:`flash-enc-development-mode`, the firmware bootloader allows the UART bootloader to re-flash encrypted binaries. Also, the ``SPI_BOOT_CRYPT_CNT`` eFuse bits are NOT write-protected. In addition, the firmware bootloader by default sets the eFuse bits ``DIS_DOWNLOAD_ICACHE``, ``DIS_PAD_JTAG``, ``DIS_USB_JTAG`` and ``DIS_LEGACY_SPI_BOOT``.
|
||||
|
||||
7. For :ref:`flash-enc-release-mode`, the firmware bootloader sets all the eFuse bits set under development mode as well as ``DIS_DOWNLOAD_MANUAL_ENCRYPT``. It also write-protects the ``SPI_BOOT_CRYPT_CNT`` eFuse bits. To modify this behavior, see :ref:`uart-bootloader-encryption`.
|
||||
|
||||
8. The device is then rebooted to start executing the encrypted image. The firmware bootloader calls the flash decryption block to decrypt the flash contents and then loads the decrypted contents into IRAM.
|
||||
|
||||
During the development stage, there is a frequent need to program different plaintext flash images and test the flash encryption process. This requires that Firmware Download mode is able to load new plaintext images as many times as it might be needed. However, during manufacturing or production stages, Firmware Download mode should not be allowed to access flash contents for security reasons.
|
||||
|
||||
@ -218,7 +268,11 @@ To test flash encryption process, take the following steps:
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size`
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size` for secure-boot-v1 or :ref:`secure-boot-v2-bootloader-size` for secure-boot-v2.
|
||||
|
||||
.. only:: not esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-v2-bootloader-size`.
|
||||
|
||||
3. Run the command given below to build and flash the complete image.
|
||||
|
||||
@ -230,144 +284,16 @@ To test flash encryption process, take the following steps:
|
||||
|
||||
A sample output of the first {IDF_TARGET_NAME} boot after enabling flash encryption is given below:
|
||||
|
||||
.. code-block:: bash
|
||||
.. include:: {IDF_TARGET_TOOLCHAIN_NAME}_log.inc
|
||||
:start-after: first_boot_enc
|
||||
:end-before: ------
|
||||
|
||||
--- idf_monitor on /dev/cu.SLAB_USBtoUART 115200 ---
|
||||
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
|
||||
ets Jun 8 2016 00:22:57
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13608
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (28) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (29) boot: compile time 15:37:14
|
||||
I (30) boot: Enabling RNG early entropy source...
|
||||
I (35) boot: SPI Speed : 40MHz
|
||||
I (39) boot: SPI Mode : DIO
|
||||
I (43) boot: SPI Flash Size : 4MB
|
||||
I (47) boot: Partition Table:
|
||||
I (51) boot: ## Label Usage Type ST Offset Length
|
||||
I (58) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (66) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (73) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (81) boot: End of partition table
|
||||
I (85) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (105) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (109) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (114) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (132) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (159) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (168) boot: Loaded app from partition at offset 0x20000
|
||||
I (168) boot: Checking flash encryption...
|
||||
I (168) flash_encrypt: Generating new flash encryption key...
|
||||
I (187) flash_encrypt: Read & write protecting new key...
|
||||
I (187) flash_encrypt: Setting CRYPT_CONFIG efuse to 0xF
|
||||
W (188) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (195) flash_encrypt: Disable UART bootloader decryption...
|
||||
I (201) flash_encrypt: Disable UART bootloader MMU cache...
|
||||
I (208) flash_encrypt: Disable JTAG...
|
||||
I (212) flash_encrypt: Disable ROM BASIC interpreter fallback...
|
||||
I (219) esp_image: segment 0: paddr=0x00001020 vaddr=0x3fff0018 size=0x00004 ( 4)
|
||||
I (227) esp_image: segment 1: paddr=0x0000102c vaddr=0x3fff001c size=0x02104 ( 8452)
|
||||
I (239) esp_image: segment 2: paddr=0x00003138 vaddr=0x40078000 size=0x03528 ( 13608)
|
||||
I (249) esp_image: segment 3: paddr=0x00006668 vaddr=0x40080400 size=0x01a08 ( 6664)
|
||||
I (657) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (669) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844)
|
||||
I (672) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024)
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (676) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720)
|
||||
I (692) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (719) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012)
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (722) flash_encrypt: Encrypting partition 2 at offset 0x20000...
|
||||
I (13229) flash_encrypt: Flash encryption completed
|
||||
I (13229) boot: Resetting with flash encryption enabled...
|
||||
|
||||
A sample output of subsequent {IDF_TARGET_NAME} boots just mentions that flash encryption is already enabled:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13652
|
||||
ho 0 tail 12 room 4
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (30) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (30) boot: compile time 16:32:53
|
||||
I (31) boot: Enabling RNG early entropy source...
|
||||
I (37) boot: SPI Speed : 40MHz
|
||||
I (41) boot: SPI Mode : DIO
|
||||
I (45) boot: SPI Flash Size : 4MB
|
||||
I (49) boot: Partition Table:
|
||||
I (52) boot: ## Label Usage Type ST Offset Length
|
||||
I (60) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (67) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (75) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (82) boot: End of partition table
|
||||
I (86) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (107) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (111) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (116) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (134) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (162) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (171) boot: Loaded app from partition at offset 0x20000
|
||||
I (171) boot: Checking flash encryption...
|
||||
I (171) flash_encrypt: flash encryption is enabled (3 plaintext flashes left)
|
||||
I (178) boot: Disabling RNG early entropy source...
|
||||
I (184) cpu_start: Pro cpu up.
|
||||
I (188) cpu_start: Application information:
|
||||
I (193) cpu_start: Project name: flash-encryption
|
||||
I (198) cpu_start: App version: v4.0-dev-850-gc4447462d-dirty
|
||||
I (205) cpu_start: Compile time: Jun 17 2019 16:32:52
|
||||
I (211) cpu_start: ELF file SHA256: 8770c886bdf561a7...
|
||||
I (217) cpu_start: ESP-IDF: v4.0-dev-850-gc4447462d-dirty
|
||||
I (224) cpu_start: Starting app cpu, entry point is 0x40080e4c
|
||||
0x40080e4c: call_start_cpu1 at esp-idf/esp-idf/components/{IDF_TARGET_PATH_NAME}/cpu_start.c:265
|
||||
|
||||
I (0) cpu_start: App cpu up.
|
||||
I (235) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (241) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
|
||||
I (247) heap_init: At 3FFB2EC8 len 0002D138 (180 KiB): DRAM
|
||||
I (254) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
|
||||
I (260) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
|
||||
I (266) heap_init: At 40087FF4 len 0001800C (96 KiB): IRAM
|
||||
I (273) cpu_start: Pro cpu start user code
|
||||
I (291) cpu_start: Starting scheduler on PRO CPU.
|
||||
I (0) cpu_start: Starting scheduler on APP CPU.
|
||||
|
||||
Sample program to check Flash Encryption
|
||||
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
|
||||
Flash encryption feature is enabled
|
||||
Flash encryption mode is DEVELOPMENT
|
||||
Flash in encrypted mode with flash_crypt_cnt = 1
|
||||
Halting...
|
||||
.. include:: {IDF_TARGET_TOOLCHAIN_NAME}_log.inc
|
||||
:start-after: already_en_enc
|
||||
:end-before: ------
|
||||
|
||||
At this stage, if you need to update and re-flash binaries, see :ref:`encrypt-partitions`.
|
||||
|
||||
@ -395,13 +321,31 @@ To use a host generated key, take the following steps:
|
||||
|
||||
espsecure.py generate_flash_encryption_key my_flash_encryption_key.bin
|
||||
|
||||
3. **Before the first encrypted boot**, burn the key into your device's BLOCK1 eFuse using the command below. This action can be done **only once**.
|
||||
3. **Before the first encrypted boot**, burn the key into your device's eFuse using the command below. This action can be done **only once**.
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
espefuse.py --port PORT burn_key flash_encryption my_flash_encryption_key.bin
|
||||
|
||||
If the key is not burned and the device is started after enabling flash encryption, the {IDF_TARGET_NAME} will generate a random key that software cannot access or modify.
|
||||
.. only:: esp32s2
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
espefuse.py --port PORT burn_key BLOCK my_flash_encryption_key.bin KEYPURPOSE
|
||||
|
||||
where `BLOCK` is a free keyblock between `BLOCK_KEY0` and `BLOCK_KEY5`. And `KEYPURPOSE` is either `AES_256_KEY_1`, `XTS_AES_256_KEY_2`, `XTS_AES_128_KEY`. See `{IDF_TARGET_NAME} Technical Reference Manual <{IDF_TARGET_TRM_EN_URL}>`_ for a description of the key purposes.
|
||||
|
||||
.. only:: esp32c3
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
espefuse.py --port PORT burn_key BLOCK my_flash_encryption_key.bin XTS_AES_128_KEY
|
||||
|
||||
where `BLOCK` is a free keyblock between `BLOCK_KEY0` and `BLOCK_KEY5`.
|
||||
|
||||
If the key is not burned and the device is started after enabling flash encryption, the {IDF_TARGET_NAME} will generate a random key that software cannot access or modify.
|
||||
|
||||
4. In :ref:`project-configuration-menu`, do the following:
|
||||
|
||||
@ -412,7 +356,11 @@ To use a host generated key, take the following steps:
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size`
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size` for secure-boot-v1 or :ref:`secure-boot-v2-bootloader-size` for secure-boot-v2.
|
||||
|
||||
.. only:: not esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-v2-bootloader-size`.
|
||||
|
||||
5. Run the command given below to build and flash the complete.
|
||||
|
||||
@ -462,14 +410,18 @@ To use this mode, take the following steps:
|
||||
|
||||
- :ref:`Enable flash encryption on boot <CONFIG_SECURE_FLASH_ENC_ENABLED>`
|
||||
:esp32: - :ref:`Select Release mode <CONFIG_SECURE_FLASH_ENCRYPTION_MODE>` (Note that once Release mode is selected, the ``download_dis_encrypt`` and ``download_dis_decrypt`` eFuse bits will be burned to disable UART bootloader access to flash contents)
|
||||
:esp32s2: - :ref:`Select Release mode <CONFIG_SECURE_FLASH_ENCRYPTION_MODE>` (Note that once Release mode is selected, the ``EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT`` eFuse bit will be burned to disable UART bootloader access to flash contents)
|
||||
:not esp32: - :ref:`Select Release mode <CONFIG_SECURE_FLASH_ENCRYPTION_MODE>` (Note that once Release mode is selected, the ``EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT`` eFuse bit will be burned to disable UART bootloader access to flash contents)
|
||||
:esp32s2: - Set :ref:`Size of generated AES-XTS key <CONFIG_SECURE_FLASH_ENCRYPTION_KEYSIZE>`
|
||||
- :ref:`Select the appropriate bootloader log verbosity <CONFIG_BOOTLOADER_LOG_LEVEL>`
|
||||
- Save the configuration and exit.
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size`
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size` for secure-boot-v1 or :ref:`secure-boot-v2-bootloader-size` for secure-boot-v2.
|
||||
|
||||
.. only:: not esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-v2-bootloader-size`.
|
||||
|
||||
3. Run the command given below to build and flash the complete image.
|
||||
|
||||
@ -495,9 +447,8 @@ When using Flash Encryption in production:
|
||||
|
||||
- Do not reuse the same flash encryption key between multiple devices. This means that an attacker who copies encrypted data from one device cannot transfer it to a second device.
|
||||
:esp32: - When using ESP32 V3, if the UART ROM Download Mode is not needed for a production device then it should be disabled to provide an extra level of protection. Do this by calling :cpp:func:`esp_efuse_disable_rom_download_mode` during application startup. Alternatively, configure the project :ref:`CONFIG_ESP32_REV_MIN` level to 3 (targeting ESP32 V3 only) and enable :ref:`CONFIG_SECURE_DISABLE_ROM_DL_MODE`. The ability to disable ROM Download Mode is not available on earlier ESP32 versions.
|
||||
:esp32s2: - The UART ROM Download Mode should be disabled entirely if it is not needed, or permanently set to "Secure Download Mode" otherwise. Secure Download Mode permanently limits the available commands to basic flash read and write only. The default behaviour is to set Secure Download Mode on first boot in Release mode. To disable Download Mode entirely, enable configuration option :ref:`CONFIG_SECURE_DISABLE_ROM_DL_MODE` or call :cpp:func:`esp_efuse_disable_rom_download_mode` at runtime.
|
||||
:esp32: - Enable :doc:`Secure Boot <secure-boot-v2>` as an extra layer of protection, and to prevent an attacker from selectively corrupting any part of the flash before boot.
|
||||
:esp32s2: - Enable Secure Boot as an extra layer of protection, and to prevent an attacker from selectively corrupting any part of the flash before boot.
|
||||
:not esp32: - The UART ROM Download Mode should be disabled entirely if it is not needed, or permanently set to "Secure Download Mode" otherwise. Secure Download Mode permanently limits the available commands to basic flash read and write only. The default behaviour is to set Secure Download Mode on first boot in Release mode. To disable Download Mode entirely, enable configuration option :ref:`CONFIG_SECURE_DISABLE_ROM_DL_MODE` or call :cpp:func:`esp_efuse_disable_rom_download_mode` at runtime.
|
||||
- Enable :doc:`Secure Boot <secure-boot-v2>` as an extra layer of protection, and to prevent an attacker from selectively corrupting any part of the flash before boot.
|
||||
|
||||
Possible Failures
|
||||
-----------------
|
||||
@ -506,6 +457,8 @@ Once flash encryption is enabled, the ``{IDF_TARGET_CRYPT_CNT}`` eFuse value wil
|
||||
|
||||
1. If the bootloader partition is re-flashed with a **plaintext firmware bootloader image**, the ROM bootloader will fail to load the firmware bootloader resulting in the following failure:
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
@ -533,6 +486,23 @@ Once flash encryption is enabled, the ``{IDF_TARGET_CRYPT_CNT}`` eFuse value wil
|
||||
ets_main.c 371
|
||||
ets Jun 8 2016 00:22:57
|
||||
|
||||
.. only:: not esp32
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
invalid header: 0xb414f76b
|
||||
|
||||
.. note::
|
||||
|
||||
The value of invalid header will be different for every application.
|
||||
|
||||
.. note::
|
||||
|
||||
This error also appears if the flash contents are erased or corrupted.
|
||||
@ -690,13 +660,13 @@ For general information about ESP-IDF OTA updates, please refer to :doc:`OTA <..
|
||||
Disabling Flash Encryption
|
||||
--------------------------
|
||||
|
||||
If flash encryption was enabled accidentally, flashing of plaintext data will soft-brick the {IDF_TARGET_NAME}. The device will reboot continuously, printing the error ``flash read err, 1000``.
|
||||
If flash encryption was enabled accidentally, flashing of plaintext data will soft-brick the {IDF_TARGET_NAME}. The device will reboot continuously, printing the error ``flash read err, 1000`` or ``invalid header: 0xXXXXXX``.
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
For flash encryption in Development mode, encryption can be disabled by burning the ``{IDF_TARGET_CRYPT_CNT}`` eFuse. It can only be done three times per chip by taking the following steps:
|
||||
|
||||
.. only:: esp32s2
|
||||
.. only:: esp32s2 or esp32c3
|
||||
|
||||
For flash encryption in Development mode, encryption can be disabled by burning the ``{IDF_TARGET_CRYPT_CNT}`` eFuse. It can only be done one time per chip by taking the following steps:
|
||||
|
||||
@ -723,6 +693,8 @@ Key Points About Flash Encryption
|
||||
|
||||
:esp32s2: - Flash memory contents are encrypted using XTS-AES-128 or XTS-AES-256. The flash encryption key is 256 bits and 512 bits respectively and stored one or two ``KEYN`` eFuses internal to the chip and, by default, is protected from software access.
|
||||
|
||||
:esp32c3: - Flash memory contents are encrypted using XTS-AES-128. The flash encryption key is 256 bits and stored one``KEYN`` eFuse internal to the chip and, by default, is protected from software access.
|
||||
|
||||
- Flash access is transparent via the flash cache mapping feature of {IDF_TARGET_NAME} - any flash regions which are mapped to the address space will be transparently decrypted when read.
|
||||
|
||||
Some data partitions might need to remain unencrypted for ease of access or might require the use of flash-friendly update algorithms which are ineffective if the data is encrypted. NVS partitions for non-volatile storage cannot be encrypted since the NVS library is not directly compatible with flash encryption. For details, refer to :ref:`NVS Encryption <nvs_encryption>`.
|
||||
@ -733,7 +705,11 @@ Key Points About Flash Encryption
|
||||
|
||||
.. only:: esp32
|
||||
|
||||
The firmware bootloader app binary ``bootloader.bin`` might become too large if both secure boot and flash encryption are enabled. See :ref:`secure-boot-bootloader-size`.
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-bootloader-size` for secure-boot-v1 or :ref:`secure-boot-v2-bootloader-size` for secure-boot-v2.
|
||||
|
||||
.. only:: not esp32
|
||||
|
||||
Enabling flash encryption will increase the size of bootloader, which might require updating partition table offset. See :ref:`secure-boot-v2-bootloader-size`.
|
||||
|
||||
.. important::
|
||||
|
||||
@ -752,8 +728,7 @@ Flash encryption protects firmware against unauthorised readout and modification
|
||||
- Not all data is stored encrypted. If storing data on flash, check if the method you are using (library, API, etc.) supports flash encryption.
|
||||
- Flash encryption does not prevent an attacker from understanding the high-level layout of the flash. This is because the same AES key is used for every pair of adjacent 16 byte AES blocks. When these adjacent 16 byte blocks contain identical content (such as empty or padding areas), these blocks will encrypt to produce matching pairs of encrypted blocks. This may allow an attacker to make high-level comparisons between encrypted devices (i.e. to tell if two devices are probably running the same firmware version).
|
||||
:esp32: - For the same reason, an attacker can always tell when a pair of adjacent 16 byte blocks (32 byte aligned) contain two identical 16 byte sequences. Keep this in mind if storing sensitive data on the flash, design your flash storage so this doesn't happen (using a counter byte or some other non-identical value every 16 bytes is sufficient). :ref:`NVS Encryption <nvs_encryption>` deals with this and is suitable for many uses.
|
||||
:esp32: - Flash encryption alone may not prevent an attacker from modifying the firmware of the device. To prevent unauthorised firmware from running on the device, use flash encryption in combination with :doc:`Secure Boot <secure-boot-v2>`.
|
||||
:esp32s2: - Flash encryption alone may not prevent an attacker from modifying the firmware of the device. To prevent unauthorised firmware from running on the device, use flash encryption in combination with Secure Boot.
|
||||
- Flash encryption alone may not prevent an attacker from modifying the firmware of the device. To prevent unauthorised firmware from running on the device, use flash encryption in combination with :doc:`Secure Boot <secure-boot-v2>`.
|
||||
|
||||
.. _flash-encryption-and-secure-boot:
|
||||
|
||||
@ -816,9 +791,16 @@ On the first boot, the flash encryption process burns by default the following e
|
||||
- ``DISABLE_DL_DECRYPT`` which disables transparent flash decryption when running in UART bootloader mode, even if the eFuse ``FLASH_CRYPT_CNT`` is set to enable it in normal operation.
|
||||
- ``DISABLE_DL_CACHE`` which disables the entire MMU flash cache when running in UART bootloader mode.
|
||||
|
||||
.. only:: esp32s2
|
||||
.. only:: esp32s2 or esp32c3
|
||||
|
||||
- ``EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT`` flash encryption operation when running in UART bootloader boot mode.
|
||||
.. list::
|
||||
|
||||
- ``DIS_DOWNLOAD_MANUAL_ENCRYPT`` which disables flash encryption operation when running in UART bootloader boot mode.
|
||||
:esp32s2: - ``DIS_DOWNLOAD_ICACHE`` and ``DIS_DOWNLOAD_DCACHE`` which disables the entire MMU flash cache when running in UART bootloader mode.
|
||||
:esp32c3: - ``DIS_DOWNLOAD_ICACHE`` which disables the entire MMU flash cache when running in UART bootloader mode.
|
||||
:esp32s2: - ``HARD_DIS_JTAG`` which disables JTAG.
|
||||
:esp32c3: - ``DIS_PAD_JTAG`` and ``DIS_USB_JTAG`` which disables JTAG.
|
||||
- ``DIS_LEGACY_SPI_BOOT`` which disables Legacy SPI boot mode
|
||||
|
||||
However, before the first boot you can choose to keep any of these features enabled by burning only selected eFuses and write-protect the rest of eFuses with unset value 0. For example:
|
||||
|
||||
@ -829,6 +811,13 @@ However, before the first boot you can choose to keep any of these features enab
|
||||
espefuse.py --port PORT burn_efuse DISABLE_DL_DECRYPT
|
||||
espefuse.py --port PORT write_protect_efuse DISABLE_DL_ENCRYPT
|
||||
|
||||
.. only:: esp32s2 or esp32c3
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
espefuse.py --port PORT burn_efuse DIS_DOWNLOAD_MANUAL_ENCRYPT
|
||||
espefuse.py --port PORT write_protect_efuse DIS_DOWNLOAD_MANUAL_ENCRYPT
|
||||
|
||||
.. note::
|
||||
|
||||
Set all appropriate bits before write-protecting!
|
||||
@ -921,3 +910,17 @@ The following sections provide some reference information about the operation of
|
||||
- The flash encryption key is stored in one or two ``KEYN`` eFuses and, by default, is protected from further writes or software readout.
|
||||
|
||||
- To see the full flash encryption algorithm implemented in Python, refer to the `_flash_encryption_operation()` function in the ``espsecure.py`` source code.
|
||||
|
||||
.. only:: esp32c3
|
||||
|
||||
.. _flash-encryption-algorithm:
|
||||
|
||||
Flash Encryption Algorithm
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- {IDF_TARGET_NAME} use the XTS-AES block chiper mode with 256 bit size for flash encryption.
|
||||
|
||||
- XTS-AES is a block chiper mode specifically designed for disc encryption and addresses the weaknesses other potential modes (e.g. AES-CTR) have for this use case. A detailed description of the XTS-AES algorithm can be found in `IEEE Std 1619-2007 <https://ieeexplore.ieee.org/document/4493450>`_.
|
||||
|
||||
- The flash encryption key is stored in one ``KEYN`` eFuse and, by default, is protected from further writes or software readout.
|
||||
|
||||
- To see the full flash encryption algorithm implemented in Python, refer to the `_flash_encryption_operation()` function in the ``espsecure.py`` source code.
|
145
docs/zh_CN/security/esp32_log.inc
Normal file
145
docs/zh_CN/security/esp32_log.inc
Normal file
@ -0,0 +1,145 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
--- idf_monitor on /dev/cu.SLAB_USBtoUART 115200 ---
|
||||
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
|
||||
ets Jun 8 2016 00:22:57
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13608
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (28) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (29) boot: compile time 15:37:14
|
||||
I (30) boot: Enabling RNG early entropy source...
|
||||
I (35) boot: SPI Speed : 40MHz
|
||||
I (39) boot: SPI Mode : DIO
|
||||
I (43) boot: SPI Flash Size : 4MB
|
||||
I (47) boot: Partition Table:
|
||||
I (51) boot: ## Label Usage Type ST Offset Length
|
||||
I (58) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (66) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (73) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (81) boot: End of partition table
|
||||
I (85) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (105) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (109) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (114) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (132) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (159) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (168) boot: Loaded app from partition at offset 0x20000
|
||||
I (168) boot: Checking flash encryption...
|
||||
I (168) flash_encrypt: Generating new flash encryption key...
|
||||
I (187) flash_encrypt: Read & write protecting new key...
|
||||
I (187) flash_encrypt: Setting CRYPT_CONFIG efuse to 0xF
|
||||
W (188) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (195) flash_encrypt: Disable UART bootloader decryption...
|
||||
I (201) flash_encrypt: Disable UART bootloader MMU cache...
|
||||
I (208) flash_encrypt: Disable JTAG...
|
||||
I (212) flash_encrypt: Disable ROM BASIC interpreter fallback...
|
||||
I (219) esp_image: segment 0: paddr=0x00001020 vaddr=0x3fff0018 size=0x00004 ( 4)
|
||||
I (227) esp_image: segment 1: paddr=0x0000102c vaddr=0x3fff001c size=0x02104 ( 8452)
|
||||
I (239) esp_image: segment 2: paddr=0x00003138 vaddr=0x40078000 size=0x03528 ( 13608)
|
||||
I (249) esp_image: segment 3: paddr=0x00006668 vaddr=0x40080400 size=0x01a08 ( 6664)
|
||||
I (657) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (669) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844)
|
||||
I (672) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024)
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (676) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720)
|
||||
I (692) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (719) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012)
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (722) flash_encrypt: Encrypting partition 2 at offset 0x20000...
|
||||
I (13229) flash_encrypt: Flash encryption completed
|
||||
I (13229) boot: Resetting with flash encryption enabled...
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
||||
configsip: 0, SPIWP:0xee
|
||||
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fff0018,len:4
|
||||
load:0x3fff001c,len:8452
|
||||
load:0x40078000,len:13652
|
||||
ho 0 tail 12 room 4
|
||||
load:0x40080400,len:6664
|
||||
entry 0x40080764
|
||||
I (30) boot: ESP-IDF v4.0-dev-850-gc4447462d-dirty 2nd stage bootloader
|
||||
I (30) boot: compile time 16:32:53
|
||||
I (31) boot: Enabling RNG early entropy source...
|
||||
I (37) boot: SPI Speed : 40MHz
|
||||
I (41) boot: SPI Mode : DIO
|
||||
I (45) boot: SPI Flash Size : 4MB
|
||||
I (49) boot: Partition Table:
|
||||
I (52) boot: ## Label Usage Type ST Offset Length
|
||||
I (60) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (67) boot: 1 phy_init RF data 01 01 00010000 00001000
|
||||
I (75) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (82) boot: End of partition table
|
||||
I (86) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x0808c ( 32908) map
|
||||
I (107) esp_image: segment 1: paddr=0x000280b4 vaddr=0x3ffb0000 size=0x01ea4 ( 7844) load
|
||||
I (111) esp_image: segment 2: paddr=0x00029f60 vaddr=0x40080000 size=0x00400 ( 1024) load
|
||||
0x40080000: _WindowOverflow4 at esp-idf/esp-idf/components/freertos/xtensa_vectors.S:1778
|
||||
|
||||
I (116) esp_image: segment 3: paddr=0x0002a368 vaddr=0x40080400 size=0x05ca8 ( 23720) load
|
||||
I (134) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x126a8 ( 75432) map
|
||||
0x400d0018: _flash_cache_start at ??:?
|
||||
|
||||
I (162) esp_image: segment 5: paddr=0x000426c8 vaddr=0x400860a8 size=0x01f4c ( 8012) load
|
||||
0x400860a8: prvAddNewTaskToReadyList at esp-idf/esp-idf/components/freertos/tasks.c:4561
|
||||
|
||||
I (171) boot: Loaded app from partition at offset 0x20000
|
||||
I (171) boot: Checking flash encryption...
|
||||
I (171) flash_encrypt: flash encryption is enabled (3 plaintext flashes left)
|
||||
I (178) boot: Disabling RNG early entropy source...
|
||||
I (184) cpu_start: Pro cpu up.
|
||||
I (188) cpu_start: Application information:
|
||||
I (193) cpu_start: Project name: flash-encryption
|
||||
I (198) cpu_start: App version: v4.0-dev-850-gc4447462d-dirty
|
||||
I (205) cpu_start: Compile time: Jun 17 2019 16:32:52
|
||||
I (211) cpu_start: ELF file SHA256: 8770c886bdf561a7...
|
||||
I (217) cpu_start: ESP-IDF: v4.0-dev-850-gc4447462d-dirty
|
||||
I (224) cpu_start: Starting app cpu, entry point is 0x40080e4c
|
||||
0x40080e4c: call_start_cpu1 at esp-idf/esp-idf/components/{IDF_TARGET_PATH_NAME}/cpu_start.c:265
|
||||
|
||||
I (0) cpu_start: App cpu up.
|
||||
I (235) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (241) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
|
||||
I (247) heap_init: At 3FFB2EC8 len 0002D138 (180 KiB): DRAM
|
||||
I (254) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
|
||||
I (260) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
|
||||
I (266) heap_init: At 40087FF4 len 0001800C (96 KiB): IRAM
|
||||
I (273) cpu_start: Pro cpu start user code
|
||||
I (291) cpu_start: Starting scheduler on PRO CPU.
|
||||
I (0) cpu_start: Starting scheduler on APP CPU.
|
||||
|
||||
Sample program to check Flash Encryption
|
||||
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
|
||||
Flash encryption feature is enabled
|
||||
Flash encryption mode is DEVELOPMENT
|
||||
Flash in encrypted mode with flash_crypt_cnt = 1
|
||||
Halting...
|
||||
|
||||
------
|
133
docs/zh_CN/security/esp32c3_log.inc
Normal file
133
docs/zh_CN/security/esp32c3_log.inc
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x1 (POWERON),boot:0xf (SPI_FAST_FLASH_BOOT)
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fcd6260,len:0x1b8
|
||||
load:0x3fcd6418,len:0x2538
|
||||
load:0x403ce000,len:0x704
|
||||
load:0x403d0000,len:0x34f0
|
||||
entry 0x403ce03e
|
||||
I (12) boot: ESP-IDF qa-test-v4.3-20201113-766-g870d 2nd stage bootloader
|
||||
I (13) boot: compile time 12:10:57
|
||||
I (13) boot: chip revision: 0
|
||||
I (16) boot.esp32c3: SPI Speed : 40MHz
|
||||
I (17) boot.esp32c3: SPI Mode : DIO
|
||||
I (19) boot.esp32c3: SPI Flash Size : 2MB
|
||||
I (22) boot: Enabling RNG early entropy source...
|
||||
I (28) boot: Partition Table:
|
||||
I (30) boot: ## Label Usage Type ST Offset Length
|
||||
I (33) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (37) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (41) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (44) boot: End of partition table
|
||||
I (46) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (61) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324) load
|
||||
I (64) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688) load
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (81) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (84) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (132) boot: Loaded app from partition at offset 0x20000
|
||||
I (133) boot: Checking flash encryption...
|
||||
I (137) efuse: Batch mode of writing fields is enabled
|
||||
I (140) flash_encrypt: Generating new flash encryption key...
|
||||
I (144) efuse: Writing EFUSE_BLK_KEY0 with purpose 4
|
||||
W (148) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (152) flash_encrypt: Disable UART bootloader cache...
|
||||
I (155) flash_encrypt: Disable JTAG...
|
||||
I (161) efuse: Batch mode. Prepared fields are committed
|
||||
I (162) esp_image: segment 0: paddr=0x00000020 vaddr=0x3fcd6260 size=0x001b8 ( 440)
|
||||
I (164) esp_image: segment 1: paddr=0x000001e0 vaddr=0x3fcd6418 size=0x02538 ( 9528)
|
||||
I (173) esp_image: segment 2: paddr=0x00002720 vaddr=0x403ce000 size=0x00704 ( 1796)
|
||||
I (174) esp_image: segment 3: paddr=0x00002e2c vaddr=0x403d0000 size=0x034f0 ( 13552)
|
||||
I (571) flash_encrypt: bootloader encrypted successfully
|
||||
I (627) flash_encrypt: partition table encrypted and loaded successfully
|
||||
I (628) flash_encrypt: Encrypting partition 1 at offset 0x10000 (length 0x1000)...
|
||||
I (685) flash_encrypt: Done encrypting
|
||||
I (686) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (696) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324)
|
||||
I (699) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688)
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (715) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (717) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (760) flash_encrypt: Encrypting partition 2 at offset 0x20000 (length 0x100000)...
|
||||
I (14797) flash_encrypt: Done encrypting
|
||||
I (14801) flash_encrypt: Flash encryption completed
|
||||
I (14802) boot: Resetting with flash encryption enabled...
|
||||
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
|
||||
Saved PC:0x403d0dde
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:2
|
||||
load:0x3fcd6260,len:0x1b8
|
||||
load:0x3fcd6418,len:0x2538
|
||||
load:0x403ce000,len:0x704
|
||||
load:0x403d0000,len:0x34f0
|
||||
entry 0x403ce03e
|
||||
I (15) boot: ESP-IDF qa-test-v4.3-20201113-766-g870d 2nd stage bootloader
|
||||
I (15) boot: compile time 12:10:57
|
||||
I (16) boot: chip revision: 0
|
||||
I (19) boot.esp32c3: SPI Speed : 40MHz
|
||||
I (19) boot.esp32c3: SPI Mode : DIO
|
||||
I (22) boot.esp32c3: SPI Flash Size : 2MB
|
||||
I (24) boot: Enabling RNG early entropy source...
|
||||
I (30) boot: Partition Table:
|
||||
I (32) boot: ## Label Usage Type ST Offset Length
|
||||
I (36) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (39) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (43) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (47) boot: End of partition table
|
||||
I (49) esp_image: segment 0: paddr=0x00020020 vaddr=0x3c020020 size=0x05508 ( 21768) map
|
||||
I (64) esp_image: segment 1: paddr=0x00025530 vaddr=0x3fc88780 size=0x014cc ( 5324) load
|
||||
I (67) esp_image: segment 2: paddr=0x00026a04 vaddr=0x40380000 size=0x08780 ( 34688) load
|
||||
0x40380000: _vector_table at ??:?
|
||||
|
||||
I (86) esp_image: segment 3: paddr=0x0002f18c vaddr=0x00000000 size=0x00e8c ( 3724)
|
||||
I (88) esp_image: segment 4: paddr=0x00030020 vaddr=0x42000020 size=0x171a8 ( 94632) map
|
||||
0x42000020: esp_ota_get_app_description at /home/marius/clean/esp-idf_2/components/app_update/esp_app_desc.c:63
|
||||
|
||||
I (139) boot: Loaded app from partition at offset 0x20000
|
||||
I (139) boot: Checking flash encryption...
|
||||
I (144) flash_encrypt: flash encryption is enabled (1 plaintext flashes left)
|
||||
I (148) boot: Disabling RNG early entropy source...
|
||||
I (160) cpu_start: Pro cpu start user code
|
||||
I (160) cpu_start: cpu freq: 40000000
|
||||
I (161) cpu_start: Application information:
|
||||
I (161) cpu_start: Project name: flash_encryption
|
||||
I (164) cpu_start: App version: qa-test-v4.3-20201113-766-g870d
|
||||
I (168) cpu_start: Compile time: Dec 21 2020 12:10:55
|
||||
I (171) cpu_start: ELF file SHA256: 209e8947c2e6a6a6...
|
||||
I (174) cpu_start: ESP-IDF: qa-test-v4.3-20201113-766-g870d
|
||||
I (178) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (181) heap_init: At 3FC8A9F0 len 00035610 (213 KiB): D/IRAM
|
||||
I (184) heap_init: At 3FCC0000 len 0001F260 (124 KiB): STACK/DRAM
|
||||
I (188) heap_init: At 50000000 len 00002000 (8 KiB): FAKEDRAM
|
||||
W (192) flash_encrypt: Flash encryption mode is DEVELOPMENT (not secure)
|
||||
I (195) spi_flash: detected chip: gd
|
||||
I (197) spi_flash: flash io: dio
|
||||
W (199) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||
I (207) cpu_start: Starting scheduler.
|
||||
|
||||
Example to check Flash Encryption status
|
||||
This is esp32c3 chip with 1 CPU core(s), WiFi/BLE, silicon revision 0, 2MB external flash
|
||||
FLASH_CRYPT_CNT eFuse value is 1
|
||||
Flash encryption feature is enabled in DEVELOPMENT mode
|
||||
|
||||
|
||||
------
|
155
docs/zh_CN/security/esp32s2_log.inc
Normal file
155
docs/zh_CN/security/esp32s2_log.inc
Normal file
@ -0,0 +1,155 @@
|
||||
|
||||
.. first_boot_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ESP-ROM:esp32s2-rc4-20191025
|
||||
Build:Oct 25 2019
|
||||
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:1
|
||||
load:0x3ffe6260,len:0x78
|
||||
load:0x3ffe62d8,len:0x231c
|
||||
load:0x4004c000,len:0x9d8
|
||||
load:0x40050000,len:0x3cf8
|
||||
entry 0x4004c1ec
|
||||
I (48) boot: ESP-IDF qa-test-v4.3-20201113-777-gd8e1 2nd stage bootloader
|
||||
I (48) boot: compile time 11:24:04
|
||||
I (48) boot: chip revision: 0
|
||||
I (52) boot.esp32s2: SPI Speed : 80MHz
|
||||
I (57) boot.esp32s2: SPI Mode : DIO
|
||||
I (62) boot.esp32s2: SPI Flash Size : 2MB
|
||||
I (66) boot: Enabling RNG early entropy source...
|
||||
I (72) boot: Partition Table:
|
||||
I (75) boot: ## Label Usage Type ST Offset Length
|
||||
I (83) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (90) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (98) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (105) boot: End of partition table
|
||||
I (109) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (124) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764) load
|
||||
I (129) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028) load
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (136) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740) load
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (153) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (171) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972) load
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (181) boot: Loaded app from partition at offset 0x20000
|
||||
I (181) boot: Checking flash encryption...
|
||||
I (181) efuse: Batch mode of writing fields is enabled
|
||||
I (188) flash_encrypt: Generating new flash encryption key...
|
||||
W (199) flash_encrypt: Not disabling UART bootloader encryption
|
||||
I (201) flash_encrypt: Disable UART bootloader cache...
|
||||
I (207) flash_encrypt: Disable JTAG...
|
||||
I (212) efuse: Batch mode of writing fields is disabled
|
||||
I (217) esp_image: segment 0: paddr=0x00001020 vaddr=0x3ffe6260 size=0x00078 ( 120)
|
||||
I (226) esp_image: segment 1: paddr=0x000010a0 vaddr=0x3ffe62d8 size=0x0231c ( 8988)
|
||||
I (236) esp_image: segment 2: paddr=0x000033c4 vaddr=0x4004c000 size=0x009d8 ( 2520)
|
||||
I (243) esp_image: segment 3: paddr=0x00003da4 vaddr=0x40050000 size=0x03cf8 ( 15608)
|
||||
I (651) flash_encrypt: bootloader encrypted successfully
|
||||
I (704) flash_encrypt: partition table encrypted and loaded successfully
|
||||
I (704) flash_encrypt: Encrypting partition 1 at offset 0x10000 (length 0x1000)...
|
||||
I (765) flash_encrypt: Done encrypting
|
||||
I (766) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (773) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764)
|
||||
I (778) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028)
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (785) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740)
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (799) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (820) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972)
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (823) flash_encrypt: Encrypting partition 2 at offset 0x20000 (length 0x100000)...
|
||||
I (13869) flash_encrypt: Done encrypting
|
||||
I (13870) flash_encrypt: Flash encryption completed
|
||||
I (13870) boot: Resetting with flash encryption enabled...
|
||||
|
||||
|
||||
------
|
||||
|
||||
.. already_en_enc
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ESP-ROM:esp32s2-rc4-20191025
|
||||
Build:Oct 25 2019
|
||||
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
|
||||
Saved PC:0x40051242
|
||||
SPIWP:0xee
|
||||
mode:DIO, clock div:1
|
||||
load:0x3ffe6260,len:0x78
|
||||
load:0x3ffe62d8,len:0x231c
|
||||
load:0x4004c000,len:0x9d8
|
||||
load:0x40050000,len:0x3cf8
|
||||
entry 0x4004c1ec
|
||||
I (56) boot: ESP-IDF qa-test-v4.3-20201113-777-gd8e1 2nd stage bootloader
|
||||
I (56) boot: compile time 11:24:04
|
||||
I (56) boot: chip revision: 0
|
||||
I (60) boot.esp32s2: SPI Speed : 80MHz
|
||||
I (65) boot.esp32s2: SPI Mode : DIO
|
||||
I (69) boot.esp32s2: SPI Flash Size : 2MB
|
||||
I (74) boot: Enabling RNG early entropy source...
|
||||
I (80) boot: Partition Table:
|
||||
I (83) boot: ## Label Usage Type ST Offset Length
|
||||
I (90) boot: 0 nvs WiFi data 01 02 0000a000 00006000
|
||||
I (98) boot: 1 storage Unknown data 01 ff 00010000 00001000
|
||||
I (105) boot: 2 factory factory app 00 00 00020000 00100000
|
||||
I (113) boot: End of partition table
|
||||
I (117) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x0618c ( 24972) map
|
||||
I (132) esp_image: segment 1: paddr=0x000261b4 vaddr=0x3ffbcae0 size=0x02624 ( 9764) load
|
||||
I (137) esp_image: segment 2: paddr=0x000287e0 vaddr=0x40022000 size=0x00404 ( 1028) load
|
||||
0x40022000: _WindowOverflow4 at /home/marius/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1730
|
||||
|
||||
I (144) esp_image: segment 3: paddr=0x00028bec vaddr=0x40022404 size=0x0742c ( 29740) load
|
||||
0x40022404: _coredump_iram_end at ??:?
|
||||
|
||||
I (161) esp_image: segment 4: paddr=0x00030020 vaddr=0x40080020 size=0x1457c ( 83324) map
|
||||
0x40080020: _stext at ??:?
|
||||
|
||||
I (180) esp_image: segment 5: paddr=0x000445a4 vaddr=0x40029830 size=0x032ac ( 12972) load
|
||||
0x40029830: gpspi_flash_ll_set_miso_bitlen at /home/marius/esp-idf/examples/security/flash_encryption/build/../../../../components/hal/esp32s2/include/hal/gpspi_flash_ll.h:261
|
||||
(inlined by) spi_flash_hal_gpspi_common_command at /home/marius/esp-idf/components/hal/spi_flash_hal_common.inc:161
|
||||
|
||||
I (190) boot: Loaded app from partition at offset 0x20000
|
||||
I (191) boot: Checking flash encryption...
|
||||
I (191) flash_encrypt: flash encryption is enabled (1 plaintext flashes left)
|
||||
I (199) boot: Disabling RNG early entropy source...
|
||||
I (216) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
|
||||
I (216) cpu_start: Pro cpu up.
|
||||
I (268) cpu_start: Pro cpu start user code
|
||||
I (268) cpu_start: cpu freq: 160000000
|
||||
I (268) cpu_start: Application information:
|
||||
I (271) cpu_start: Project name: flash_encryption
|
||||
I (277) cpu_start: App version: qa-test-v4.3-20201113-777-gd8e1
|
||||
I (284) cpu_start: Compile time: Dec 21 2020 11:24:00
|
||||
I (290) cpu_start: ELF file SHA256: 30fd1b899312fef7...
|
||||
I (296) cpu_start: ESP-IDF: qa-test-v4.3-20201113-777-gd8e1
|
||||
I (303) heap_init: Initializing. RAM available for dynamic allocation:
|
||||
I (310) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
|
||||
I (316) heap_init: At 3FFBF898 len 0003C768 (241 KiB): DRAM
|
||||
I (323) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
|
||||
W (329) flash_encrypt: Flash encryption mode is DEVELOPMENT (not secure)
|
||||
I (336) spi_flash: detected chip: generic
|
||||
I (341) spi_flash: flash io: dio
|
||||
W (345) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
|
||||
I (358) cpu_start: Starting scheduler on PRO CPU.
|
||||
|
||||
Example to check Flash Encryption status
|
||||
This is esp32s2 chip with 1 CPU core(s), WiFi, silicon revision 0, 2MB external flash
|
||||
FLASH_CRYPT_CNT eFuse value is 1
|
||||
Flash encryption feature is enabled in DEVELOPMENT mode
|
||||
|
||||
------
|
@ -27,12 +27,9 @@ static const char* TAG = "example";
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_FLASH_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 7
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 3
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
@ -57,7 +54,8 @@ static void example_print_chip_info(void)
|
||||
/* Print chip information */
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
|
||||
printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
|
||||
|
Loading…
Reference in New Issue
Block a user