Merge branch 'feat/riscv-spiram-stack-pointer-update-before-restart_v5.5' into 'release/v5.5'

fix(esp_system): fix PSRAM stack crash in esp_restart_noos on RISC-V SPIRAM chips (v5.5)

See merge request espressif/esp-idf!48068
This commit is contained in:
Marius Vikhammer
2026-05-15 19:08:48 +08:00
6 changed files with 250 additions and 134 deletions
+12 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -101,6 +101,17 @@ FORCE_INLINE_ATTR void *rv_utils_get_sp(void)
return sp;
}
/* Switch the stack pointer to a new address.
*
* Unlike the Xtensa SET_STACK, no window register management is required on
* RISC-V; a plain register move is sufficient. The "memory" clobber prevents
* the compiler from reordering any accesses across the switch.
*/
FORCE_INLINE_ATTR void rv_utils_set_sp(void *new_sp)
{
asm volatile ("mv sp, %0" :: "r"(new_sp) : "memory");
}
FORCE_INLINE_ATTR uint32_t __attribute__((always_inline)) rv_utils_get_cycle_count(void)
{
#if !SOC_CPU_HAS_CSR_PC