@@ -59,32 +59,7 @@ void __attribute__((section(".iram1"))) __start(void)
5959 * Configure the mode of instruction cache :
6060 * cache size, cache associated ways, cache line size.
6161 */
62- cache_size_t cache_size ;
63- cache_ways_t cache_ways ;
64- cache_line_size_t cache_line_size ;
65-
66- #if CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB
67- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_INVALID ,
68- CACHE_MEMORY_INVALID , CACHE_MEMORY_INVALID );
69- cache_size = CACHE_SIZE_8KB ;
70- #else
71- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_ICACHE_HIGH ,
72- CACHE_MEMORY_INVALID , CACHE_MEMORY_INVALID );
73- cache_size = CACHE_SIZE_16KB ;
74- #endif
75-
76- cache_ways = CACHE_4WAYS_ASSOC ;
77-
78- #if CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B
79- cache_line_size = CACHE_LINE_SIZE_16B ;
80- #else
81- cache_line_size = CACHE_LINE_SIZE_32B ;
82- #endif
83-
84- esp_rom_Cache_Suspend_ICache ();
85- esp_rom_Cache_Set_ICache_Mode (cache_size , cache_ways , cache_line_size );
86- esp_rom_Cache_Invalidate_ICache_All ();
87- esp_rom_Cache_Resume_ICache (0 );
62+ esp_config_instruction_cache_mode ();
8863
8964 /*
9065 * If we need use SPIRAM, we should use data cache, or if we want to
@@ -93,36 +68,7 @@ void __attribute__((section(".iram1"))) __start(void)
9368 * line size.
9469 * Enable data cache, so if we don't use SPIRAM, it just works.
9570 */
96- #if CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB
97- #if CONFIG_ESP32S2_DATA_CACHE_8KB
98- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_DCACHE_LOW ,
99- CACHE_MEMORY_INVALID , CACHE_MEMORY_INVALID );
100- cache_size = CACHE_SIZE_8KB ;
101- #else
102- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_DCACHE_LOW ,
103- CACHE_MEMORY_DCACHE_HIGH , CACHE_MEMORY_INVALID );
104- cache_size = CACHE_SIZE_16KB ;
105- #endif
106- #else
107- #if CONFIG_ESP32S2_DATA_CACHE_8KB
108- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_ICACHE_HIGH ,
109- CACHE_MEMORY_DCACHE_LOW , CACHE_MEMORY_INVALID );
110- cache_size = CACHE_SIZE_8KB ;
111- #else
112- esp_rom_Cache_Allocate_SRAM (CACHE_MEMORY_ICACHE_LOW , CACHE_MEMORY_ICACHE_HIGH ,
113- CACHE_MEMORY_DCACHE_LOW , CACHE_MEMORY_DCACHE_HIGH );
114- cache_size = CACHE_SIZE_16KB ;
115- #endif
116- #endif
117-
118- cache_ways = CACHE_4WAYS_ASSOC ;
119- #if CONFIG_ESP32S2_DATA_CACHE_LINE_16B
120- cache_line_size = CACHE_LINE_SIZE_16B ;
121- #else
122- cache_line_size = CACHE_LINE_SIZE_32B ;
123- #endif
124- esp_rom_Cache_Set_DCache_Mode (cache_size , cache_ways , cache_line_size );
125- esp_rom_Cache_Invalidate_DCache_All ();
71+ esp_config_data_cache_mode ();
12672 esp_rom_Cache_Enable_DCache (0 );
12773
12874#if !CONFIG_BOOTLOADER_ESP_IDF
@@ -165,6 +111,11 @@ void __attribute__((section(".iram1"))) __start(void)
165111#endif
166112
167113#if CONFIG_ESP_SPIRAM
114+
115+ memset (& _ext_ram_bss_start ,
116+ 0 ,
117+ (& _ext_ram_bss_end - & _ext_ram_bss_start ) * sizeof (_ext_ram_bss_start ));
118+
168119 esp_err_t err = esp_spiram_init ();
169120
170121 if (err != ESP_OK ) {
@@ -177,10 +128,7 @@ void __attribute__((section(".iram1"))) __start(void)
177128 abort ();
178129 }
179130
180- memset (& _ext_ram_bss_start ,
181- 0 ,
182- (& _ext_ram_bss_end - & _ext_ram_bss_start ) * sizeof (_ext_ram_bss_start ));
183- #endif
131+ #endif /* CONFIG_ESP_SPIRAM */
184132
185133/* Scheduler is not started at this point. Hence, guard functions
186134 * must be initialized after esp_spiram_init_cache which internally
0 commit comments