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 28, 2024
1 parent 9cfd6e1 commit 286f3d3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,53 @@ 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 {

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;
Expand Down

0 comments on commit 286f3d3

Please sign in to comment.