security: write-protect DIS_ICAHE and DIS_DCACHE

Closes IDF-5177
This commit is contained in:
KonstantinKondrashov
2023-03-08 00:09:45 +08:00
parent 266a58f85b
commit 723b2e86e5
20 changed files with 118 additions and 1 deletions

View File

@@ -79,5 +79,13 @@ esp_err_t esp_flash_encryption_enable_secure_features(void)
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_EFUSE_RD_DISABLE);
#endif
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
// Set write-protection for DIS_ICACHE to prevent bricking chip in case it will be set accidentally.
// esp32 has DIS_ICACHE. Write-protection bit = 3.
// List of eFuses with the same write protection bit:
// MAC, MAC_CRC, DISABLE_APP_CPU, DISABLE_BT, DIS_CACHE, VOL_LEVEL_HP_INV.
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_DIS_CACHE);
#endif
return ESP_OK;
}