diff --git a/samples/boards/nordic/system_off/prj.conf b/samples/boards/nordic/system_off/prj.conf index 3849b9c2746..04450d5a22d 100644 --- a/samples/boards/nordic/system_off/prj.conf +++ b/samples/boards/nordic/system_off/prj.conf @@ -2,3 +2,4 @@ CONFIG_PM_DEVICE=y CONFIG_GPIO=y CONFIG_CRC=y CONFIG_POWEROFF=y +CONFIG_HWINFO=y diff --git a/samples/boards/nordic/system_off/sample.yaml b/samples/boards/nordic/system_off/sample.yaml index 35483a81373..6b953645138 100644 --- a/samples/boards/nordic/system_off/sample.yaml +++ b/samples/boards/nordic/system_off/sample.yaml @@ -68,6 +68,7 @@ tests: - "Retained data not supported" - "Entering system off; wait 2 seconds to restart" - "system off demo" + - "Wakeup from System OFF by GRTC." - "Retained data not supported" - "Entering system off; wait 2 seconds to restart" sample.boards.nrf.system_off.retained_mem.grtc_wakeup: @@ -97,6 +98,7 @@ tests: - "Off count: 1" - "Active Ticks:" - "Entering system off; wait 2 seconds to restart" + - "Wakeup from System OFF by GRTC." sample.boards.nrf.system_off.lpcomp_wakeup: extra_args: DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_comparator.overlay" platform_allow: diff --git a/samples/boards/nordic/system_off/src/main.c b/samples/boards/nordic/system_off/src/main.c index e8617be2c5f..0b0cbf3cb0b 100644 --- a/samples/boards/nordic/system_off/src/main.c +++ b/samples/boards/nordic/system_off/src/main.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,20 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios); static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp)); #endif +void print_reset_cause(void) +{ + uint32_t reset_cause; + + hwinfo_get_reset_cause(&reset_cause); + if (reset_cause & RESET_DEBUG) { + printf("Reset by debugger.\n"); + } else if (reset_cause & RESET_CLOCK) { + printf("Wakeup from System OFF by GRTC.\n"); + } else { + printf("Other wake up cause 0x%08X.\n", reset_cause); + } +} + int main(void) { int rc; @@ -39,6 +54,7 @@ int main(void) } printf("\n%s system off demo\n", CONFIG_BOARD); + print_reset_cause(); if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) { bool retained_ok = retained_validate(); @@ -98,6 +114,7 @@ int main(void) retained_update(); } + hwinfo_clear_reset_cause(); sys_poweroff(); return 0;