mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
esp32: Switch SPIRAM stack in esp_restart_noos() to internal stack
If esp_restart_noos() is run and the stack address points to external memory (SPIRAM) then Cache_Read_Disable() raises up the error "Cache disabled but cached memory region accessed" to fix this we switch stack to internal RAM before disable cache. Added unit tests. Closes: https://github.com/espressif/esp-idf/issues/5107
This commit is contained in:
@@ -88,6 +88,16 @@ void IRAM_ATTR esp_restart_noos(void)
|
||||
uart_tx_wait_idle(1);
|
||||
uart_tx_wait_idle(2);
|
||||
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
if (esp_ptr_external_ram(get_sp())) {
|
||||
// If stack_addr is from External Memory (CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is used)
|
||||
// then need to switch SP to Internal Memory otherwise
|
||||
// we will get the "Cache disabled but cached memory region accessed" error after Cache_Read_Disable.
|
||||
uint32_t new_sp = SOC_DRAM_LOW + (SOC_DRAM_HIGH - SOC_DRAM_LOW) / 2;
|
||||
SET_STACK(new_sp);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disable cache
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Read_Disable(1);
|
||||
|
Reference in New Issue
Block a user