diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index be2c009449..75da86677c 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -231,6 +231,10 @@ config SOC_SHARED_IDCACHE_SUPPORTED bool default y +config SOC_IDCACHE_PER_CORE + bool + default y + config SOC_CPU_CORES_NUM int default 2 diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 2e028cedc6..ca5c0144e3 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -138,7 +138,8 @@ #endif /*-------------------------- CACHE CAPS --------------------------------------*/ -#define SOC_SHARED_IDCACHE_SUPPORTED 1 //Shared Cache for both instructions and data +#define SOC_SHARED_IDCACHE_SUPPORTED 1 //Shared Cache for both instructions and data within one core +#define SOC_IDCACHE_PER_CORE 1 //Independent Cache unit pre core /*-------------------------- CPU CAPS ----------------------------------------*/ #define SOC_CPU_CORES_NUM 2 diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index f91817d69b..146df092f6 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -221,13 +221,16 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void) // with non-iram interrupts and the scheduler disabled. None of these CPUs will // touch external RAM or flash this way, so we can safely disable caches. spi_flash_disable_cache(cpuid, &s_flash_op_cache_state[cpuid]); +#if SOC_IDCACHE_PER_CORE + //only needed if cache(s) is per core spi_flash_disable_cache(other_cpuid, &s_flash_op_cache_state[other_cpuid]); +#endif } void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void) { const int cpuid = xPortGetCoreID(); - const uint32_t other_cpuid = (cpuid == 0) ? 1 : 0; + #ifndef NDEBUG // Sanity check: flash operation ends on the same CPU as it has started assert(cpuid == s_flash_op_cpu); @@ -238,7 +241,11 @@ void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void) // Re-enable cache on both CPUs. After this, cache (flash and external RAM) should work again. spi_flash_restore_cache(cpuid, s_flash_op_cache_state[cpuid]); +#if SOC_IDCACHE_PER_CORE + //only needed if cache(s) is per core + const uint32_t other_cpuid = (cpuid == 0) ? 1 : 0; spi_flash_restore_cache(other_cpuid, s_flash_op_cache_state[other_cpuid]); +#endif if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { // Signal to spi_flash_op_block_task that flash operation is complete