Skip to content

Commit

Permalink
Pull request project-chip#1542: MATTER-3071 - Fix Reboot Cause always 0
Browse files Browse the repository at this point in the history
Merge in WMN_TOOLS/matter from fix_rebootCause to RC_2.3.0-1.3

Squashed commit of the following:

commit 1e0d75e8c6fc5ca265c97cf0f62ec97fe1c556f5
Author: Junior Martinez <[email protected]>
Date:   Mon Feb 5 03:40:14 2024 -0500

    Move getting the reboot cause to platform abstraction. Set a getter for the reboot cause so different stacks can obtain it (project-chip#31891)
  • Loading branch information
jmartinez-silabs committed Feb 5, 2024
1 parent 42eb728 commit 1391d88
Show file tree
Hide file tree
Showing 5 changed files with 14 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
3 changes: 3 additions & 0 deletions src/platform/silabs/platformAbstraction/SilabsPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase

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

static SilabsButtonCb mButtonCallback;
uint8_t GetButtonState(uint8_t button) override;

Expand All @@ -65,6 +67,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 1391d88

Please sign in to comment.