fix(esp_hw_support): guard CSR_PRV_MODE usage in esp_cpu_get_curr_privilege_level

CSR_PRV_MODE is only defined for a subset of RISC-V targets. Targets
that lack it (e.g. esp32h21, esp32h4, esp32s31) caused an assembler
error. Fall back to returning -1 (unsupported) when the CSR is not
defined.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Marius Vikhammer
2026-03-24 17:34:26 +08:00
parent 07a6ec9b6e
commit 8e66081ae3
+3 -1
View File
@@ -154,8 +154,10 @@ FORCE_INLINE_ATTR __attribute__((always_inline)) int esp_cpu_get_curr_privilege_
#else
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
return PRV_M;
#else
#elif defined(CSR_PRV_MODE)
return RV_READ_CSR(CSR_PRV_MODE);
#else
return -1;
#endif
#endif
}