Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs]Move fetching reboot cause code to our platform abstraction. #31891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading