diff options
-rw-r--r-- | chip/npcx/watchdog.c | 14 | ||||
-rw-r--r-- | common/system.c | 17 | ||||
-rw-r--r-- | core/cortex-m/watchdog.c | 3 | ||||
-rw-r--r-- | core/cortex-m0/watchdog.c | 4 |
4 files changed, 19 insertions, 19 deletions
diff --git a/chip/npcx/watchdog.c b/chip/npcx/watchdog.c index 1036523996..4b43a09db2 100644 --- a/chip/npcx/watchdog.c +++ b/chip/npcx/watchdog.c @@ -59,7 +59,6 @@ static uint8_t watchdog_count(void) void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp) { int wd_cnt; - uint32_t panic_info; /* Clear timeout status for event */ SET_BIT(NPCX_ITCTS(ITIM_WDG_NO), NPCX_ITCTS_TO_STS); @@ -79,19 +78,6 @@ void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp) watchdog_trace(excep_lr, excep_sp); cflush(); - /* - * Log the panic PC if watchdog occurred in exception context - * or the watchdog task # otherwise. - */ - panic_info = ((excep_lr & 0xf) == 1) ? - ((uint32_t *)excep_sp)[6] : task_get_current(); - /* - * panic_reboot() will be called by software_panic(), so this - * typically will not return, and panic reason will appear - * as "soft". - */ - software_panic(PANIC_SW_WATCHDOG, panic_info); - /* Trigger watchdog immediately */ system_watchdog_reset(); } diff --git a/common/system.c b/common/system.c index fcd7e0d795..48c26776b9 100644 --- a/common/system.c +++ b/common/system.c @@ -788,12 +788,19 @@ void system_common_pre_init(void) #ifdef CONFIG_SOFTWARE_PANIC /* - * Log panic cause if watchdog caused reset. This - * must happen before calculating jump_data address - * because it might change panic pointer. + * Log panic cause if watchdog caused reset and panic cause + * was not already logged. This must happen before calculating + * jump_data address because it might change panic pointer. */ - if (system_get_reset_flags() & RESET_FLAG_WATCHDOG) - panic_set_reason(PANIC_SW_WATCHDOG, 0, 0); + if (system_get_reset_flags() & RESET_FLAG_WATCHDOG) { + uint32_t reason; + uint32_t info; + uint8_t exception; + + panic_get_reason(&reason, &info, &exception); + if (reason != PANIC_SW_WATCHDOG) + panic_set_reason(PANIC_SW_WATCHDOG, 0, 0); + } #endif /* diff --git a/core/cortex-m/watchdog.c b/core/cortex-m/watchdog.c index 6a047e662b..a67903df62 100644 --- a/core/cortex-m/watchdog.c +++ b/core/cortex-m/watchdog.c @@ -25,6 +25,9 @@ void __keep watchdog_trace(uint32_t excep_lr, uint32_t excep_sp) stack = (uint32_t *)psp; } + panic_set_reason(PANIC_SW_WATCHDOG, stack[6], + (excep_lr & 0xf) == 1 ? 0xff : task_get_current()); + panic_printf("### WATCHDOG PC=%08x / LR=%08x / pSP=%08x ", stack[6], stack[5], psp); if ((excep_lr & 0xf) == 1) diff --git a/core/cortex-m0/watchdog.c b/core/cortex-m0/watchdog.c index a4e34d51bf..3d53b4979c 100644 --- a/core/cortex-m0/watchdog.c +++ b/core/cortex-m0/watchdog.c @@ -25,6 +25,10 @@ void watchdog_trace(uint32_t excep_lr, uint32_t excep_sp) stack = (uint32_t *)psp; } + /* Log PC. If we were in task context, log task id too. */ + panic_set_reason(PANIC_SW_WATCHDOG, stack[6], + (excep_lr & 0xf) == 1 ? 0xff : task_get_current()); + panic_printf("### WATCHDOG PC=%08x / LR=%08x / pSP=%08x ", stack[6], stack[5], psp); if ((excep_lr & 0xf) == 1) |