Skip to content

Commit

Permalink
[nrf toup] Saving boot reason on nRF54h20
Browse files Browse the repository at this point in the history
-Use NRF_RESETINFO register to get boot reason

Signed-off-by: Konrad Grucel <[email protected]>
  • Loading branch information
kg-nordicsemi committed Nov 25, 2024
1 parent 93c712e commit 69d980e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
31 changes: 31 additions & 0 deletions src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const size_t kMaxHeapSize = CONFIG_SRAM_BASE_ADDRESS + KB(CONFIG_SRAM_SIZE) - PO

#endif

#ifdef CONFIG_SOC_SERIES_NRF54HX
#include <hal/nrf_resetinfo.h>
#endif

namespace chip {
namespace DeviceLayer {

Expand All @@ -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)
Expand Down Expand Up @@ -103,6 +133,7 @@ BootReasonType DetermineBootReason()
#endif
return BootReasonType::kSoftwareReset;
}
#endif
#endif

return BootReasonType::kUnspecified;
Expand Down
14 changes: 1 addition & 13 deletions src/platform/nrfconnect/Reboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 69d980e

Please sign in to comment.