mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
system: Log PC and task id on watchdog
For debug, in common code let's log the watchdog PC and task id as our SW panic params. BUG=chromium:790006 BRANCH=none TEST=manually test scarlet rev2 from a1-a3, b1-b2: (a1) Add 'while(1);' in button ISR (a2) Boot and press the button (a3) When watchdog is triggeried, check with 'panicinfo' that saved R5 is the PC for button ISR. (b1) 'crash watchdog' in EC console (b2) Check with 'panicinfo' that CONSOLE task id is saved in EXCEPTION and PC is saved in R5. Change-Id: I64d2fcf594dd24b0951e002ab8e80ebcac2d1def Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/803618 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
/*
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user