diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 340103c8f4..3e350decd8 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -119,6 +119,18 @@ menu "Main Flash configuration" For new users, DO NOT enable this config. + config SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND + bool "Enable chip suspend feature on c6 or h2 anyway (DO NOT ENABLE FOR NEW USERS OR APPLICATIONS)" + default n + help + Flash suspend has defect on ESP32C6 until v0.2 and ESP32H2 until v1.2. If you already use suspend + feature for massive protection, you can enable this for bypassing check after knowing the risk. + But if you are new users, or developing new applications, or producing a new batch, + please DO NOT enable this config option. + + For more information, please refer to errata or connect to Espressif business support team. + + endmenu endmenu diff --git a/components/spi_flash/esp_flash_api.c b/components/spi_flash/esp_flash_api.c index e9bf9d8bfe..b3380b8be7 100644 --- a/components/spi_flash/esp_flash_api.c +++ b/components/spi_flash/esp_flash_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,9 @@ #include "esp_rom_spiflash.h" #include "esp_private/esp_clk.h" #include "esp_spi_flash_counters.h" +#include "esp_check.h" +#include "hal/efuse_hal.h" +#include "soc/chip_revision.h" #if CONFIG_IDF_TARGET_ESP32S2 #include "esp_crypto_lock.h" // for locking flash encryption peripheral @@ -1439,6 +1442,20 @@ restore_cache: //init suspend mode cmd, uses internal. esp_err_t esp_flash_suspend_cmd_init(esp_flash_t* chip) { +#if !CONFIG_SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND +#if CONFIG_IDF_TARGET_ESP32H2 + if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102)) { + ESP_LOGE(TAG, "ESP32H2 chips lower than v1.2 are not recommended to suspend the Flash"); + return ESP_ERR_NOT_SUPPORTED; + } +#endif +#if CONFIG_IDF_TARGET_ESP32C6 + if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 2)) { + ESP_LOGE(TAG, "ESP32C6 chips lower than v0.2 are not recommended to suspend the Flash"); + return ESP_ERR_NOT_SUPPORTED; + } +#endif +#endif ESP_EARLY_LOGW(TAG, "Flash suspend feature is enabled"); if (chip->chip_drv->get_chip_caps == NULL) { // chip caps get failed, pass the flash capability check. diff --git a/components/spi_flash/test_apps/esp_flash_stress/sdkconfig.ci.esp32c3_suspend b/components/spi_flash/test_apps/esp_flash_stress/sdkconfig.ci.esp32c3_suspend index 0addf025a2..60f9b137c9 100644 --- a/components/spi_flash/test_apps/esp_flash_stress/sdkconfig.ci.esp32c3_suspend +++ b/components/spi_flash/test_apps/esp_flash_stress/sdkconfig.ci.esp32c3_suspend @@ -2,3 +2,4 @@ CONFIG_IDF_TARGET="esp32c3" CONFIG_SPI_FLASH_AUTO_SUSPEND=y +CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y diff --git a/components/spi_flash/test_apps/flash_suspend/sdkconfig.defaults b/components/spi_flash/test_apps/flash_suspend/sdkconfig.defaults index cdb818d6f9..223b872891 100644 --- a/components/spi_flash/test_apps/flash_suspend/sdkconfig.defaults +++ b/components/spi_flash/test_apps/flash_suspend/sdkconfig.defaults @@ -1,4 +1,5 @@ -CONFIG_ESP_TASK_WDT=n +CONFIG_ESP_TASK_WDT_INIT=n CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y diff --git a/examples/system/flash_suspend/sdkconfig.ci.flash_suspend b/examples/system/flash_suspend/sdkconfig.ci.flash_suspend index 8c84ea2be2..5d2e7c157f 100644 --- a/examples/system/flash_suspend/sdkconfig.ci.flash_suspend +++ b/examples/system/flash_suspend/sdkconfig.ci.flash_suspend @@ -2,3 +2,4 @@ CONFIG_SPI_FLASH_AUTO_SUSPEND=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND=y