From 5404e3d4341b59679cd386dcf160bdb273ddb692 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Wed, 8 Apr 2020 00:42:46 +0800 Subject: [PATCH] esp_flash: fix cache exception when CS pin is through IOMUX --- components/spi_flash/esp_flash_spi_init.c | 2 ++ components/spi_flash/linker.lf | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index ad519a8297..ad94931a98 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -88,6 +88,8 @@ static IRAM_ATTR NOINLINE_ATTR void cs_initialize(esp_flash_t *chip, const esp_f //initialization, disable the cache temporarily chip->os_func->start(chip->os_func_data); if (use_iomux) { + // This requires `gpio_iomux_in` and `gpio_iomux_out` to be in the IRAM. + // `linker.lf` is used fulfill this requirement. gpio_iomux_in(cs_io_num, spics_in); gpio_iomux_out(cs_io_num, spics_func, false); } else { diff --git a/components/spi_flash/linker.lf b/components/spi_flash/linker.lf index efd5875d57..a31658712f 100644 --- a/components/spi_flash/linker.lf +++ b/components/spi_flash/linker.lf @@ -8,3 +8,9 @@ entries: spi_flash_chip_gd(noflash) memspi_host_driver (noflash) +# `spi_bus_add_flash_device` uses these functions when the cache is disabled +[mapping:driver_spiflash] +archive: libdriver.a +entries: + gpio:gpio_iomux_out (noflash) + gpio:gpio_iomux_in (noflash)