From 738a04aefba01a72fbc0e46fc86fa17e7e6cad83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Sat, 28 Jul 2018 19:02:54 +0200 Subject: cardem: show detailed reset cause this helps detecting when a reset was due to the watchdog Change-Id: I2d59c2f2c8fe9e559eddfafacf25879263ef81ff --- firmware/apps/cardem/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/firmware/apps/cardem/main.c b/firmware/apps/cardem/main.c index ae46794..7d65c7e 100644 --- a/firmware/apps/cardem/main.c +++ b/firmware/apps/cardem/main.c @@ -157,11 +157,25 @@ extern int main(void) "SIMtrace2 firmware " GIT_VERSION " (C) 2010-2016 by Harald Welte\n\r" "=============================================================================\n\r"); +#if (TRACE_LEVEL >= TRACE_LEVEL_INFO) TRACE_INFO("Chip ID: 0x%08x (Ext 0x%08x)\n\r", CHIPID->CHIPID_CIDR, CHIPID->CHIPID_EXID); TRACE_INFO("Serial Nr. %08x-%08x-%08x-%08x\n\r", g_unique_id[0], g_unique_id[1], g_unique_id[2], g_unique_id[3]); - TRACE_INFO("Reset Cause: 0x%x\n\r", (RSTC->RSTC_SR & RSTC_SR_RSTTYP_Msk) >> RSTC_SR_RSTTYP_Pos); + uint8_t reset_cause = (RSTC->RSTC_SR & RSTC_SR_RSTTYP_Msk) >> RSTC_SR_RSTTYP_Pos; + static const char* reset_causes[] = { + "general reset (first power-up reset)", + "backup reset (return from backup mode)", + "watchdog reset (watchdog fault occurred)", + "software reset (processor reset required by the software)", + "user reset (NRST pin detected low)", + }; + if (reset_cause < ARRAY_SIZE(reset_causes)) { + TRACE_INFO("Reset Cause: %s\n\r", reset_causes[reset_cause]); + } else { + TRACE_INFO("Reset Cause: 0x%x\n\r", (RSTC->RSTC_SR & RSTC_SR_RSTTYP_Msk) >> RSTC_SR_RSTTYP_Pos); + } +#endif board_main_top(); -- cgit v1.2.3