summaryrefslogtreecommitdiff
path: root/core/cortex-m/watchdog.c
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2021-05-28 19:01:16 +0200
committerCommit Bot <commit-bot@chromium.org>2021-06-09 22:48:00 +0000
commita608b1bd1e6f2e901faf9ae896b9838c83323e2a (patch)
tree4f68c0e9d739d6fa06f4ca202c19970a15f3fa0b /core/cortex-m/watchdog.c
parentdb3d4c5ba4718ebe5a2f601db495b512e175552d (diff)
downloadchrome-ec-a608b1bd1e6f2e901faf9ae896b9838c83323e2a.tar.gz
cortex-m/watchdog: Flush and invalidate D-cache while handling watchdog
Affected boards (only STM32H7): - nocturne_fp (dartmonkey) - nucleo-h743zi This fixes problem with RO reporting 'sysjump' reset cause, but not 'watchdog' after issuing 'crash watchdog' command. Also, problem with missing task ID and PC in saved panic data was fixed too. These problems come from not flushing cache before reset occurs. When cache is enabled, it's not guaranteed that all memory changes will be saved in RAM. After reboot, cache is invalidated, so some of memory changes will be lost. In this case, 'magic' field from jump_data structure was not zeroed and part of panic data was missing. It caused RO to report sysjump after watchdog was triggered, and missing 'watchdog' reset cause (RO used reset cause from jump data). BUG=b:170432597 BRANCH=none TEST=Compile dartmonkey firmware and run it on eg. icetower. In RW, issue 'crash watchdog'. Make sure that RO reports 'watchdog' reset cause. After sysjump to RW check panic data using 'panicinfo' command. Especially the following: - R4 register (crash reason) should be set to 0xdead6664 (watchdog) - R5 register (info) should be set to PC - PROCESS EXCEPTION value should be set to task ID Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ie8d861e5a07b58140445aeaa191cc0098618401b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2923504 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'core/cortex-m/watchdog.c')
-rw-r--r--core/cortex-m/watchdog.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/cortex-m/watchdog.c b/core/cortex-m/watchdog.c
index 3e62b5f4c5..9e4a82c7b0 100644
--- a/core/cortex-m/watchdog.c
+++ b/core/cortex-m/watchdog.c
@@ -6,6 +6,7 @@
/* Watchdog common code */
#include "common.h"
+#include "cpu.h"
#include "panic.h"
#include "task.h"
#include "timer.h"
@@ -28,6 +29,13 @@ void __keep watchdog_trace(uint32_t excep_lr, uint32_t excep_sp)
panic_set_reason(PANIC_SW_WATCHDOG, stack[6],
(excep_lr & 0xf) == 1 ? 0xff : task_get_current());
+ /*
+ * This is our last breath, the last opportunity to sort out all
+ * matters. Flush and invalidate D-cache if cache enabled.
+ */
+ if (IS_ENABLED(CONFIG_ARMV7M_CACHE))
+ cpu_clean_invalidate_dcache();
+
panic_printf("### WATCHDOG PC=%08x / LR=%08x / pSP=%08x ",
stack[6], stack[5], psp);
if ((excep_lr & 0xf) == 1)