Skip to content

Commit

Permalink
Move getting the reboot cause to platform abstraction. Set a getter f…
Browse files Browse the repository at this point in the history
…or the reboot cause so different stacks can obtain it (project-chip#31891)
  • Loading branch information
jmartinez-silabs authored and raul-marquez-csa committed Feb 16, 2024
1 parent 826ee2e commit 88dac24
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/platform/silabs/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
void RunConfigUnitTest(void) override;

// ===== Private members reserved for use by this class only.
uint32_t rebootCause;
static void DoFactoryReset(intptr_t arg);
};

Expand Down
16 changes: 5 additions & 11 deletions src/platform/silabs/efr32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
* for EFR32 platforms using the Silicon Labs SDK.
*/
/* this file behaves like a config.h, comes first */
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/internal/GenericConfigurationManagerImpl.ipp>

#include <platform/ConfigurationManager.h>
#include <platform/DiagnosticDataProvider.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <platform/internal/GenericConfigurationManagerImpl.ipp>
#include <platform/silabs/SilabsConfig.h>

#include "em_rmu.h"
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
#include "wfx_host_events.h"
Expand All @@ -55,12 +52,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
err = Internal::GenericConfigurationManagerImpl<SilabsConfig>::Init();
SuccessOrExit(err);

// TODO: Initialize the global GroupKeyStore object here (#1626)

IncreaseBootCount();
rebootCause = RMU_ResetCauseGet();
RMU_ResetCauseClear();

err = CHIP_NO_ERROR;

exit:
Expand Down Expand Up @@ -99,6 +91,8 @@ CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason)
{
// rebootCause is obtained at bootup.
BootReasonType matterBootCause;
uint32_t rebootCause = Silabs::GetPlatform().GetRebootCause();

#if defined(_SILICON_LABS_32B_SERIES_1)
if (rebootCause & RMU_RSTCAUSE_PORST || rebootCause & RMU_RSTCAUSE_EXTRST) // PowerOn or External pin reset
{
Expand Down
5 changes: 5 additions & 0 deletions src/platform/silabs/platformAbstraction/GsdkSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <platform/silabs/platformAbstraction/SilabsPlatform.h>

#include "em_rmu.h"
#include "sl_system_kernel.h"

#ifdef ENABLE_WSTK_LEDS
Expand Down Expand Up @@ -69,6 +70,10 @@ CHIP_ERROR SilabsPlatform::Init(void)
{
sl_system_init();

mRebootCause = RMU_ResetCauseGet();
// Clear register so it does accumualate the causes of each reset
RMU_ResetCauseClear();

#if CHIP_ENABLE_OPENTHREAD
sl_ot_sys_init();
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/platform/silabs/platformAbstraction/SilabsPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase
#endif

inline void SetButtonsCb(SilabsButtonCb callback) override { mButtonCallback = callback; }
inline uint32_t GetRebootCause() { return mRebootCause; }

static SilabsButtonCb mButtonCallback;

Expand All @@ -64,6 +65,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase
SilabsPlatform(){};
virtual ~SilabsPlatform() = default;

uint32_t mRebootCause = 0;
static SilabsPlatform sSilabsPlatformAbstractionManager;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SilabsPlatformAbstractionBase
virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; }
virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; }
virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; }
virtual uint32_t GetRebootCause() = 0;

// Scheduler
virtual void StartScheduler(void) = 0;
Expand Down

0 comments on commit 88dac24

Please sign in to comment.