Skip to content

Commit 69d980e

Browse files
committed
[nrf toup] Saving boot reason on nRF54h20
-Use NRF_RESETINFO register to get boot reason Signed-off-by: Konrad Grucel <[email protected]>
1 parent 93c712e commit 69d980e

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

src/platform/Zephyr/DiagnosticDataProviderImpl.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const size_t kMaxHeapSize = CONFIG_SRAM_BASE_ADDRESS + KB(CONFIG_SRAM_SIZE) - PO
5252

5353
#endif
5454

55+
#ifdef CONFIG_SOC_SERIES_NRF54HX
56+
#include <hal/nrf_resetinfo.h>
57+
#endif
58+
5559
namespace chip {
5660
namespace DeviceLayer {
5761

@@ -60,6 +64,32 @@ namespace {
6064
BootReasonType DetermineBootReason()
6165
{
6266
#ifdef CONFIG_HWINFO
67+
68+
#ifdef CONFIG_SOC_SERIES_NRF54HX
69+
uint32_t reason = nrf_resetinfo_resetreas_global_get(NRF_RESETINFO);
70+
71+
if (reason & RESETINFO_RESETREAS_GLOBAL_RESETPORONLY_Msk)
72+
{
73+
return BootReasonType::kBrownOutReset;
74+
}
75+
76+
if (reason & RESETINFO_RESETREAS_GLOBAL_DOG_Msk)
77+
{
78+
return BootReasonType::kHardwareWatchdogReset;
79+
}
80+
81+
if ((reason & (RESETINFO_RESETREAS_GLOBAL_RESETPIN_Msk | RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk)) ==
82+
(RESETINFO_RESETREAS_GLOBAL_RESETPIN_Msk | RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk))
83+
{
84+
return BootReasonType::kPowerOnReboot;
85+
}
86+
87+
if ((reason & (RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk | RESETINFO_RESETREAS_GLOBAL_SECSREQ_Msk)) ==
88+
(RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk | RESETINFO_RESETREAS_GLOBAL_SECSREQ_Msk))
89+
{
90+
return BootReasonType::kSoftwareUpdateCompleted;
91+
}
92+
#else
6393
uint32_t reason;
6494

6595
if (hwinfo_get_reset_cause(&reason) != 0)
@@ -103,6 +133,7 @@ BootReasonType DetermineBootReason()
103133
#endif
104134
return BootReasonType::kSoftwareReset;
105135
}
136+
#endif
106137
#endif
107138

108139
return BootReasonType::kUnspecified;

src/platform/nrfconnect/Reboot.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,7 @@
2828
namespace chip {
2929
namespace DeviceLayer {
3030

31-
#if defined(CONFIG_ARCH_POSIX) || defined(CONFIG_SOC_SERIES_NRF54HX)
32-
33-
void Reboot(SoftwareRebootReason reason)
34-
{
35-
sys_reboot(SYS_REBOOT_WARM);
36-
}
37-
38-
SoftwareRebootReason GetSoftwareRebootReason()
39-
{
40-
return SoftwareRebootReason::kOther;
41-
}
42-
43-
#else
31+
#if !(defined(CONFIG_ARCH_POSIX) || defined(CONFIG_SOC_SERIES_NRF54HX))
4432

4533
using RetainedReason = decltype(nrf_power_gpregret_get(NRF_POWER, 0));
4634

0 commit comments

Comments
 (0)