Skip to content

Commit 6df9de8

Browse files
committed
esp32: fix initialization with PSRAM + SMP
Cache flush must be done prior to the APP cpu initalization. This, however, must be true for the case where PSRAM is not available or not selected. To do that, this commit flushs the cache during the device initialization.
1 parent c06a742 commit 6df9de8

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

arch/xtensa/src/common/espressif/esp_loader.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
273273
#endif
274274

275275
#ifdef CONFIG_ARCH_CHIP_ESP32
276-
cache_read_disable(0);
277-
cache_flush(0);
276+
cache_read_disable(PRO_CPU_NUM);
277+
cache_flush(PRO_CPU_NUM);
278+
# ifdef CONFIG_SMP
279+
cache_flush(APP_CPU_NUM);
280+
cache_read_enable(APP_CPU_NUM);
281+
# endif
278282
#else
279283
cache_hal_disable(CACHE_TYPE_ALL);
280284
#endif

arch/xtensa/src/esp32/esp32_spiram.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@
6868
# error "FLASH speed can only be equal to or higher than SRAM speed while SRAM is enabled!"
6969
#endif
7070

71-
/****************************************************************************
72-
* ROM Function Prototypes
73-
****************************************************************************/
74-
75-
extern void cache_flush(int cpu);
76-
extern void cache_read_enable(int cpu);
77-
7871
/****************************************************************************
7972
* Private Data
8073
****************************************************************************/
@@ -253,8 +246,6 @@ void IRAM_ATTR esp_spiram_init_cache(void)
253246
/* Flush and enable icache for APP CPU */
254247

255248
#ifdef CONFIG_SMP
256-
cache_flush(APP_CPU_NUM);
257-
cache_read_enable(APP_CPU_NUM);
258249
regval = getreg32(DPORT_APP_CACHE_CTRL1_REG);
259250
regval &= ~(1 << DPORT_APP_CACHE_MASK_DRAM1);
260251
putreg32(regval, DPORT_APP_CACHE_CTRL1_REG);

0 commit comments

Comments
 (0)