diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 3c0a106aea..b16504a907 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -52,6 +52,10 @@ const size_t kMaxHeapSize = CONFIG_SRAM_BASE_ADDRESS + KB(CONFIG_SRAM_SIZE) - PO #endif +#ifdef CONFIG_SOC_SERIES_NRF54HX +#include +#endif + namespace chip { namespace DeviceLayer { @@ -59,9 +63,42 @@ namespace { BootReasonType DetermineBootReason() { -#ifdef CONFIG_HWINFO +#if defined(CONFIG_SOC_SERIES_NRF54HX) || defined(CONFIG_HWINFO) uint32_t reason; +#endif + +#ifdef CONFIG_SOC_SERIES_NRF54HX + reason = nrf_resetinfo_resetreas_global_get(NRF_RESETINFO); + + if (reason == RESETINFO_RESETREAS_GLOBAL_ResetValue) + { + return BootReasonType::kSoftwareReset; + } + + if (reason & RESETINFO_RESETREAS_GLOBAL_RESETPORONLY_Msk) + { + return BootReasonType::kBrownOutReset; + } + if (reason & RESETINFO_RESETREAS_GLOBAL_DOG_Msk) + { + return BootReasonType::kHardwareWatchdogReset; + } + + if ((reason & (RESETINFO_RESETREAS_GLOBAL_RESETPIN_Msk | RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk)) == + (RESETINFO_RESETREAS_GLOBAL_RESETPIN_Msk | RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk)) + { + return BootReasonType::kPowerOnReboot; + } + + if ((reason & (RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk | RESETINFO_RESETREAS_GLOBAL_SECSREQ_Msk)) == + (RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk | RESETINFO_RESETREAS_GLOBAL_SECSREQ_Msk)) + { + return BootReasonType::kSoftwareUpdateCompleted; + } +#endif + +#ifdef CONFIG_HWINFO if (hwinfo_get_reset_cause(&reason) != 0) { return BootReasonType::kUnspecified;