@@ -80,6 +80,45 @@ void __attribute__((section(".iram1"))) __start(void)
8080 esp_rom_Cache_Invalidate_ICache_All ();
8181 esp_rom_Cache_Resume_ICache (0 );
8282
83+ /*
84+ * If we need use SPIRAM, we should use data cache, or if we want to
85+ * access rodata, we also should use data cache.
86+ * Configure the mode of data : cache size, cache associated ways, cache
87+ * line size.
88+ * Enable data cache, so if we don't use SPIRAM, it just works.
89+ */
90+ #if CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB
91+ #if CONFIG_ESP32S2_DATA_CACHE_8KB
92+ esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_DCACHE_LOW ,
93+ CACHE_MEMORY_INVALID , CACHE_MEMORY_INVALID );
94+ cache_size = CACHE_SIZE_8KB ;
95+ #else
96+ esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_DCACHE_LOW ,
97+ CACHE_MEMORY_DCACHE_HIGH , CACHE_MEMORY_INVALID );
98+ cache_size = CACHE_SIZE_16KB ;
99+ #endif
100+ #else
101+ #if CONFIG_ESP32S2_DATA_CACHE_8KB
102+ esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_ICACHE_HIGH ,
103+ CACHE_MEMORY_DCACHE_LOW , CACHE_MEMORY_INVALID );
104+ cache_size = CACHE_SIZE_8KB ;
105+ #else
106+ esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_ICACHE_HIGH ,
107+ CACHE_MEMORY_DCACHE_LOW , CACHE_MEMORY_DCACHE_HIGH );
108+ cache_size = CACHE_SIZE_16KB ;
109+ #endif
110+ #endif
111+
112+ cache_ways = CACHE_4WAYS_ASSOC ;
113+ #if CONFIG_ESP32S2_DATA_CACHE_LINE_16B
114+ cache_line_size = CACHE_LINE_SIZE_16B ;
115+ #else
116+ cache_line_size = CACHE_LINE_SIZE_32B ;
117+ #endif
118+ esp_rom_Cache_Set_DCache_Mode (cache_size , cache_ways , cache_line_size );
119+ esp_rom_Cache_Invalidate_DCache_All ();
120+ esp_rom_Cache_Enable_DCache (0 );
121+
83122#if !CONFIG_BOOTLOADER_ESP_IDF
84123 /* The watchdog timer is enabled in the 1st stage (ROM) bootloader.
85124 * We're done booting, so disable it.
0 commit comments