Merge branch 'bugfix/reenable_encrypted_partition_write_v4.1' into 'release/v4.1'

Re-enable encrypted flash read/writes even if flash encryption is disabled (v4.1)

See merge request espressif/esp-idf!12191
This commit is contained in:
Mahavir Jain 2021-02-02 18:31:04 +08:00
commit 83aaee86d8
4 changed files with 16 additions and 4 deletions

View File

@ -539,6 +539,7 @@ menu "Security features"
config SECURE_FLASH_ENC_ENABLED
bool "Enable flash encryption on boot (READ DOCS FIRST)"
default N
select SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
help
If this option is set, flash contents will be encrypted by the bootloader on first boot.

View File

@ -139,4 +139,13 @@ menu "SPI Flash driver"
endmenu #auto detect flash chips
config SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
bool "Enable encrypted partition read/write operations"
default y
help
This option enables flash read/write operations to encrypted partition/s. This option
is kept enabled irrespective of state of flash encryption feature. However, in case
application is not using flash encryption feature and is in need of some additional
memory from IRAM region (~1KB) then this config can be disabled.
endmenu

View File

@ -349,7 +349,7 @@ esp_err_t esp_partition_read(const esp_partition_t* partition,
return spi_flash_read(partition->address + src_offset, dst, size);
#endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
} else {
#if CONFIG_SECURE_FLASH_ENC_ENABLED
#if CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
if (partition->flash_chip != esp_flash_default_chip) {
return ESP_ERR_NOT_SUPPORTED;
}
@ -369,7 +369,7 @@ esp_err_t esp_partition_read(const esp_partition_t* partition,
return ESP_OK;
#else
return ESP_ERR_NOT_SUPPORTED;
#endif // CONFIG_SECURE_FLASH_ENC_ENABLED
#endif // CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
}
}
@ -391,14 +391,14 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
return spi_flash_write(dst_offset, src, size);
#endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
} else {
#if CONFIG_SECURE_FLASH_ENC_ENABLED
#if CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
if (partition->flash_chip != esp_flash_default_chip) {
return ESP_ERR_NOT_SUPPORTED;
}
return spi_flash_write_encrypted(dst_offset, src, size);
#else
return ESP_ERR_NOT_SUPPORTED;
#endif // CONFIG_SECURE_FLASH_ENC_ENABLED
#endif // CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
}
}

View File

@ -3,3 +3,5 @@ CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=800
CONFIG_SPIRAM_OCCUPY_NO_HOST=y
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
# Disable encrypted flash reads/writes to save IRAM in this build configuration
CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n