feat(esp_system): add CPU lockup debug support for esp32h4 and esp32s31

This commit is contained in:
Marius Vikhammer
2026-04-22 11:11:02 +08:00
parent 38e2cacc27
commit 8e2b416c38
38 changed files with 533 additions and 246 deletions
@@ -42,7 +42,7 @@
ESP_LOG_ATTR_TAG(TAG, "boot.esp32s2");
#if SOC_RTC_WDT_SUPPORTED
static void wdt_reset_cpu0_info_enable(void)
void bootloader_enable_cpu_reset_info(void)
{
DPORT_REG_SET_BIT(DPORT_PERI_CLK_EN_REG, DPORT_PERI_EN_ASSIST_DEBUG);
DPORT_REG_CLR_BIT(DPORT_PERI_RST_EN_REG, DPORT_PERI_EN_ASSIST_DEBUG);
@@ -50,7 +50,7 @@ static void wdt_reset_cpu0_info_enable(void)
REG_WRITE(ASSIST_DEBUG_PRO_RCD_RECORDING, 1);
}
static void wdt_reset_info_dump(int cpu)
void bootloader_dump_wdt_reset_info(int cpu)
{
uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 0;
@@ -83,20 +83,15 @@ static void wdt_reset_info_dump(int cpu)
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0DATA 0x%08"PRIx32, cpu_name, lsdata);
}
static void bootloader_check_wdt_reset(void)
bool bootloader_check_if_wdt_reset(int cpu, soc_reset_reason_t rst_reason)
{
int wdt_rst = 0;
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
(void) cpu;
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 || rst_reason == RESET_REASON_CORE_MWDT1 ||
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_MWDT1 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
wdt_rst = 1;
return true;
}
if (wdt_rst) {
// if reset by WDT dump info from trace port
wdt_reset_info_dump(0);
}
wdt_reset_cpu0_info_enable();
return false;
}
static void bootloader_super_wdt_auto_feed(void)
@@ -169,10 +164,8 @@ esp_err_t bootloader_init(void)
}
#endif // !CONFIG_APP_BUILD_TYPE_RAM
#if SOC_RTC_WDT_SUPPORTED
// check whether a WDT reset happened
bootloader_check_wdt_reset();
#endif
// check reset reason and dump diagnostic info
bootloader_check_reset();
#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED
// config WDT
bootloader_config_wdt();