diff options
author | Harald Welte <laforge@gnumonks.org> | 2019-05-17 18:36:01 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-05-17 19:19:18 +0200 |
commit | 9ab4bc865b530190eac0d3eca3ff3f8a1b7e1b7e (patch) | |
tree | ef2ae3b9c4a7e63cd045725bd91bff8988fd4dc7 | |
parent | 2dc67e93b23275225d75b530bf51e0c6a409beab (diff) |
main: Print reset causes on boot
Change-Id: I6d6c9a435ca997d829d0b02c26e4c8aee78fa88b
-rw-r--r-- | sysmoOCTSIM/main.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c index f11fe58..b16c817 100644 --- a/sysmoOCTSIM/main.c +++ b/sysmoOCTSIM/main.c @@ -1020,12 +1020,37 @@ static int get_chip_unique_serial_str(char *out, size_t len) return 0; } +#define RSTCAUSE_STR_SIZE 64 +static void get_rstcause_str(char *out) +{ + uint8_t val = hri_rstc_read_RCAUSE_reg(RSTC); + *out = '\0'; + if (val & RSTC_RCAUSE_POR) + strcat(out, "POR "); + if (val & RSTC_RCAUSE_BODCORE) + strcat(out, "BODCORE "); + if (val & RSTC_RCAUSE_BODVDD) + strcat(out, "BODVDD "); + if (val & RSTC_RCAUSE_NVM) + strcat(out, "NVM "); + if (val & RSTC_RCAUSE_EXT) + strcat(out, "EXT "); + if (val & RSTC_RCAUSE_WDT) + strcat(out, "WDT "); + if (val & RSTC_RCAUSE_SYST) + strcat(out, "SYST "); + if (val & RSTC_RCAUSE_BACKUP) + strcat(out, "BACKUP "); +} + int main(void) { char sernr_buf[16*2+1]; + char rstcause_buf[RSTCAUSE_STR_SIZE]; atmel_start_init(); get_chip_unique_serial_str(sernr_buf, sizeof(sernr_buf)); + get_rstcause_str(rstcause_buf); usb_start(); @@ -1051,6 +1076,7 @@ int main(void) "(C) 2018-2019 by sysmocom - s.f.m.c. GmbH and contributors\n\r" "=============================================================================\n\r"); printf("Chip ID: %s\r\n", sernr_buf); + printf("Reset cause: %s\r\n", rstcause_buf); talloc_enable_null_tracking(); g_tall_ctx = talloc_named_const(NULL, 0, "global"); |