Skip to content

Commit f6b0020

Browse files
Move getting the reboot cause to platform abstraction. Set a getter for the reboot cause so different stacks can obtain it (project-chip#31891)
1 parent 0929845 commit f6b0020

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

src/platform/silabs/ConfigurationManagerImpl.h

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
7373
void RunConfigUnitTest(void) override;
7474

7575
// ===== Private members reserved for use by this class only.
76-
uint32_t rebootCause;
7776
static void DoFactoryReset(intptr_t arg);
7877
};
7978

src/platform/silabs/efr32/ConfigurationManagerImpl.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222
* for EFR32 platforms using the Silicon Labs SDK.
2323
*/
2424
/* this file behaves like a config.h, comes first */
25-
#include <platform/internal/CHIPDeviceLayerInternal.h>
26-
27-
#include <platform/internal/GenericConfigurationManagerImpl.ipp>
28-
2925
#include <platform/ConfigurationManager.h>
3026
#include <platform/DiagnosticDataProvider.h>
27+
#include <platform/internal/CHIPDeviceLayerInternal.h>
28+
#include <platform/internal/GenericConfigurationManagerImpl.ipp>
3129
#include <platform/silabs/SilabsConfig.h>
32-
33-
#include "em_rmu.h"
30+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
3431

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

58-
// TODO: Initialize the global GroupKeyStore object here (#1626)
59-
6055
IncreaseBootCount();
61-
rebootCause = RMU_ResetCauseGet();
62-
RMU_ResetCauseClear();
63-
6456
err = CHIP_NO_ERROR;
6557

6658
exit:
@@ -99,6 +91,8 @@ CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason)
9991
{
10092
// rebootCause is obtained at bootup.
10193
BootReasonType matterBootCause;
94+
uint32_t rebootCause = Silabs::GetPlatform().GetRebootCause();
95+
10296
#if defined(_SILICON_LABS_32B_SERIES_1)
10397
if (rebootCause & RMU_RSTCAUSE_PORST || rebootCause & RMU_RSTCAUSE_EXTRST) // PowerOn or External pin reset
10498
{

src/platform/silabs/platformAbstraction/GsdkSpam.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

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

20+
#include "em_rmu.h"
2021
#include "sl_system_kernel.h"
2122

2223
#ifdef ENABLE_WSTK_LEDS
@@ -69,6 +70,10 @@ CHIP_ERROR SilabsPlatform::Init(void)
6970
{
7071
sl_system_init();
7172

73+
mRebootCause = RMU_ResetCauseGet();
74+
// Clear register so it does accumualate the causes of each reset
75+
RMU_ResetCauseClear();
76+
7277
#if CHIP_ENABLE_OPENTHREAD
7378
sl_ot_sys_init();
7479
#endif

src/platform/silabs/platformAbstraction/SilabsPlatform.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase
4949
#endif
5050

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

5354
static SilabsButtonCb mButtonCallback;
5455

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

68+
uint32_t mRebootCause = 0;
6769
static SilabsPlatform sSilabsPlatformAbstractionManager;
6870
};
6971

src/platform/silabs/platformAbstraction/SilabsPlatformBase.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SilabsPlatformAbstractionBase
3535
virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; }
3636
virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; }
3737
virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; }
38+
virtual uint32_t GetRebootCause() = 0;
3839

3940
// Scheduler
4041
virtual void StartScheduler(void) = 0;

0 commit comments

Comments
 (0)