From ca1f363dbcb00d6161b5b62ffb6d0c7571d4590f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Stasiak?= Date: Wed, 30 Jul 2025 16:00:13 +0200 Subject: [PATCH 1/2] [nrf fromlist] drivers: hwinfo: nrf: extend supported reset reasons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added missing supported reset reasons based on conditional guards. Upstream PR #: 93910 Signed-off-by: Michał Stasiak --- drivers/hwinfo/hwinfo_nrf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index f5a6ed38a20..3d3314ddf58 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -207,6 +207,15 @@ int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported) | RESET_SOFTWARE | RESET_CPU_LOCKUP | RESET_LOW_POWER_WAKE +#if NRFX_RESET_REASON_HAS_VBUS + | RESET_POR +#endif +#if NRFX_RESET_REASON_HAS_GRTC + | RESET_CLOCK +#endif +#if defined(NRFX_RESET_REASON_TAMPC_MASK) || defined(NRFX_RESET_REASON_SECTAMPER_MASK) + | RESET_SECURITY +#endif | RESET_DEBUG); return 0; From 7d731670f3aa13a49a1930643c06eaab88ad9305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Stasiak?= Date: Thu, 31 Jul 2025 11:22:37 +0200 Subject: [PATCH 2/2] [nrf fromlist] samples: nordic: system_off: check for supported reset causes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check whether used reset causes are supported by hwinfo driver. Upstream PR #: 93910 Signed-off-by: Michał Stasiak --- samples/boards/nordic/system_off/src/main.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/samples/boards/nordic/system_off/src/main.c b/samples/boards/nordic/system_off/src/main.c index d119eff87da..b4c2eeb2b1b 100644 --- a/samples/boards/nordic/system_off/src/main.c +++ b/samples/boards/nordic/system_off/src/main.c @@ -31,8 +31,17 @@ 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(uint32_t reset_cause) +int print_reset_cause(uint32_t reset_cause) { + int32_t ret; + uint32_t supported; + + ret = hwinfo_get_supported_reset_cause((uint32_t *) &supported); + + if (ret || !(reset_cause & supported)) { + return -ENOTSUP; + } + if (reset_cause & RESET_DEBUG) { printf("Reset by debugger.\n"); } else if (reset_cause & RESET_CLOCK) { @@ -42,6 +51,8 @@ void print_reset_cause(uint32_t reset_cause) } else { printf("Other wake up cause 0x%08X.\n", reset_cause); } + + return 0; } int main(void) @@ -57,7 +68,12 @@ int main(void) printf("\n%s system off demo\n", CONFIG_BOARD); hwinfo_get_reset_cause(&reset_cause); - print_reset_cause(reset_cause); + rc = print_reset_cause(reset_cause); + + if (rc < 0) { + printf("Reset cause not supported.\n"); + return 0; + } if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) { bool retained_ok = retained_validate();