Skip to content

Commit

Permalink
fix(MMU): fixed mmap deadlock when using multicore app with unicore b…
Browse files Browse the repository at this point in the history
…ootloader

Closes #11617
  • Loading branch information
ginkgm committed Aug 16, 2024
1 parent 466a392 commit 87cc3cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/esp_system/port/cpu_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,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)
Expand All @@ -341,9 +352,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);
Expand Down

0 comments on commit 87cc3cb

Please sign in to comment.