fix(MMU): fixed mmap deadlock when using multicore app with unicore bootloader

Closes https://github.com/espressif/esp-idf/issues/11617
This commit is contained in:
Xiao Xufeng 2024-08-10 16:53:51 +08:00
parent 1bb33a31b8
commit 52066307ed

View File

@ -315,6 +315,17 @@ static void start_other_core(void)
}
#if !SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
#if CONFIG_IDF_TARGET_ESP32
static void restore_app_mmu_from_pro_mmu(void)
{
const int mmu_reg_num = 2048;
volatile uint32_t* from = (uint32_t*)DR_REG_FLASH_MMU_TABLE_PRO;
volatile uint32_t* to = (uint32_t*)DR_REG_FLASH_MMU_TABLE_APP;
for (int i = 0; i < mmu_reg_num; i++) {
*(to++) = *(from++);
}
}
#endif
// This function is needed to make the multicore app runnable on a unicore bootloader (built with FREERTOS UNICORE).
// It does some cache settings for other CPUs.
void IRAM_ATTR do_multicore_settings(void)
@ -326,9 +337,11 @@ void IRAM_ATTR do_multicore_settings(void)
Cache_Read_Disable(1);
Cache_Flush(1);
DPORT_REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
mmu_init(1);
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
// We do not enable cache for CPU1 now because it will be done later in start_other_core().
}
restore_app_mmu_from_pro_mmu();
#endif
cache_bus_mask_t cache_bus_mask_core0 = cache_ll_l1_get_enabled_bus(0);