diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 3c0a106aea..bb154a7b73 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 { @@ -60,6 +64,32 @@ namespace { BootReasonType DetermineBootReason() { #ifdef CONFIG_HWINFO + +#ifdef CONFIG_SOC_SERIES_NRF54HX + uint32_t reason = nrf_resetinfo_resetreas_global_get(NRF_RESETINFO); + + 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; + } +#else uint32_t reason; if (hwinfo_get_reset_cause(&reason) != 0) @@ -103,6 +133,7 @@ BootReasonType DetermineBootReason() #endif return BootReasonType::kSoftwareReset; } +#endif #endif return BootReasonType::kUnspecified; diff --git a/src/platform/nrfconnect/Reboot.cpp b/src/platform/nrfconnect/Reboot.cpp index 47bff8c185..28bddb5c08 100644 --- a/src/platform/nrfconnect/Reboot.cpp +++ b/src/platform/nrfconnect/Reboot.cpp @@ -28,19 +28,7 @@ namespace chip { namespace DeviceLayer { -#if defined(CONFIG_ARCH_POSIX) || defined(CONFIG_SOC_SERIES_NRF54HX) - -void Reboot(SoftwareRebootReason reason) -{ - sys_reboot(SYS_REBOOT_WARM); -} - -SoftwareRebootReason GetSoftwareRebootReason() -{ - return SoftwareRebootReason::kOther; -} - -#else +#if !(defined(CONFIG_ARCH_POSIX) || defined(CONFIG_SOC_SERIES_NRF54HX)) using RetainedReason = decltype(nrf_power_gpregret_get(NRF_POWER, 0));