Skip to content

Commit 4a53c4e

Browse files
committed
Merge branch 'bugfix/esp32c5_encrypted_flash_write_v2' into 'master'
fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption See merge request espressif/esp-idf!43301
2 parents a365e79 + 3c5d2e6 commit 4a53c4e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

components/esp_security/src/init.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ static void esp_key_mgr_init(void)
5555

5656
ESP_SYSTEM_INIT_FN(esp_security_init, SECONDARY, BIT(0), 103)
5757
{
58+
#if CONFIG_IDF_TARGET_ESP32C5
59+
// Check for unsupported configuration: flash encryption with CPU frequency > 160MHz
60+
// Manual encrypted flash writes are not stable at higher CPU clock.
61+
// Please refer to the ESP32-C5 SoC Errata document for more details.
62+
if (efuse_hal_flash_encryption_enabled() && CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ > 160) {
63+
ESP_EARLY_LOGE(TAG, "Flash encryption with CPU frequency > 160MHz is not supported. Please reconfigure the CPU frequency.");
64+
return ESP_ERR_NOT_SUPPORTED;
65+
}
66+
#endif
67+
5868
esp_crypto_clk_init();
5969

6070
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT

components/esp_system/port/soc/esp32c5/Kconfig.cpu

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
choice ESP_DEFAULT_CPU_FREQ_MHZ
22
prompt "CPU frequency"
33
default ESP_DEFAULT_CPU_FREQ_MHZ_40 if IDF_ENV_FPGA
4+
default ESP_DEFAULT_CPU_FREQ_MHZ_160 if SECURE_FLASH_ENC_ENABLED
45
default ESP_DEFAULT_CPU_FREQ_MHZ_240
56
help
6-
CPU frequency to be set on application startup.
7+
CPU frequency to be set on application startup. For flash encryption enabled case,
8+
the default CPU frequency is 160MHz as the encrypted flash writes are not stable at
9+
higher CPU clock. Please see SoC Errata document for details.
710

811
config ESP_DEFAULT_CPU_FREQ_MHZ_40
912
bool "40 MHz"
@@ -13,6 +16,9 @@ choice ESP_DEFAULT_CPU_FREQ_MHZ
1316
config ESP_DEFAULT_CPU_FREQ_MHZ_160
1417
bool "160 MHz"
1518
config ESP_DEFAULT_CPU_FREQ_MHZ_240
19+
# Encrypted flash writes aren't supported at 240 MHz.
20+
# Please see SoC Errata document for details.
21+
depends on !SECURE_FLASH_ENC_ENABLED
1622
bool "240 MHz"
1723
endchoice
1824

0 commit comments

Comments
 (0)