diff --git a/components/bootloader_support/src/esp32/bootloader_flash_config_esp32.c b/components/bootloader_support/src/bootloader_flash_config_esp32.c similarity index 100% rename from components/bootloader_support/src/esp32/bootloader_flash_config_esp32.c rename to components/bootloader_support/src/bootloader_flash_config_esp32.c diff --git a/components/bootloader_support/src/esp32s2beta/bootloader_flash_config_esp32s2beta.c b/components/bootloader_support/src/bootloader_flash_config_esp32s2beta.c similarity index 100% rename from components/bootloader_support/src/esp32s2beta/bootloader_flash_config_esp32s2beta.c rename to components/bootloader_support/src/bootloader_flash_config_esp32s2beta.c diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index b73a8362c..63b19cd96 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -13,13 +13,16 @@ else() "spi_flash_chip_generic.c" "spi_flash_chip_issi.c" ) - if(NOT CONFIG_SPI_FLASH_USE_LEGACY_IMPL) - list(APPEND srcs "esp_flash_api.c" - "esp_flash_spi_init.c" + if (NOT CONFIG_IDF_TARGET_ESP32S2BETA) + # TODO: workaround until ESP32-S2 supports new API, can be always included + list(APPEND srcs "esp_flash_spi_init.c" "memspi_host_driver.c" "spi_flash_os_func_app.c" - "spi_flash_os_func_noos.c" - ) + "spi_flash_os_func_noos.c") + endif() + + if(NOT CONFIG_SPI_FLASH_USE_LEGACY_IMPL) + list(APPEND srcs "esp_flash_api.c") endif() set(priv_requires bootloader_support app_update soc) endif() diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 8a10651ff..edd8892fc 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -77,6 +77,15 @@ menu "SPI Flash driver" bool "Allowed" endchoice + # Force the Legacy implementation to be used on ESP32S2Beta + # + # TODO esp32s2beta: Remove once SPI Flash HAL available on S2 Beta + config SPI_FLASH_FORCE_LEGACY_ESP32S2BETA + bool + default y + depends on IDF_TARGET_ESP32S2BETA + select SPI_FLASH_USE_LEGACY_IMPL + config SPI_FLASH_USE_LEGACY_IMPL bool "Use the legacy implementation before IDF v4.0" default n diff --git a/components/spi_flash/esp32/flash_ops_esp32.c b/components/spi_flash/esp32/flash_ops_esp32.c index 4a33eaa38..71f9b3dab 100644 --- a/components/spi_flash/esp32/flash_ops_esp32.c +++ b/components/spi_flash/esp32/flash_ops_esp32.c @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include -#include "esp_spi_flash_chip.h" #include "esp_spi_flash.h" -#include "cache_utils.h" #include "esp32/rom/spi_flash.h" #include "esp32/rom/cache.h" @@ -38,7 +36,7 @@ esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_a { const uint8_t *ssrc = (const uint8_t *)src; esp_rom_spiflash_result_t rc; - rc = spi_flash_unlock(); + rc = esp_rom_spiflash_unlock(); if (rc != ESP_ROM_SPIFLASH_RESULT_OK) { return rc; } diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index 0755de72c..99b2db237 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -700,3 +700,8 @@ void spi_flash_dump_counters(void) } #endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS + +#if defined(CONFIG_SPI_FLASH_USE_LEGACY_IMPL) && defined(CONFIG_IDF_TARGET_ESP32S2BETA) +// TODO esp32s2beta: Remove once ESP32S2Beta has new SPI Flash API support +esp_flash_t *esp_flash_default_chip = NULL; +#endif