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] Fix the secure soc reset issue #37965

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
3 changes: 1 addition & 2 deletions examples/platform/silabs/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Efr32Device final : public Device
osTimer_t mRebootTimerBuffer;
osTimerAttr_t mRebootTimerAttr = { .name = "Reboot", .cb_mem = &mRebootTimerBuffer, .cb_size = osTimerCbSize };

static void RebootHandler(void * timerCbArg) { NVIC_SystemReset(); }
static void RebootHandler(void * timerCbArg) { Silabs::GetPlatform().SoftwareReset(); }
};
#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE

Expand Down Expand Up @@ -225,6 +225,5 @@ void Init()
// Start App task.
sRpcTaskHandle = osThreadNew(RunRpcService, nullptr, &kRpcTaskAttr);
}

} // namespace rpc
} // namespace chip
2 changes: 1 addition & 1 deletion src/platform/silabs/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
// Block the task for 500 ms before the reset occurs to allow RPC response to be sent
osDelay(pdMS_TO_TICKS(500));

NVIC_SystemReset();
Silabs::GetPlatform().SoftwareReset();
}

#ifdef SL_WIFI
Expand Down
4 changes: 2 additions & 2 deletions src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
#include <platform/silabs/OTAImageProcessorImpl.h>
#include <platform/silabs/SilabsConfig.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
#include <platform/silabs/wifi/WifiInterface.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
Expand All @@ -42,7 +43,6 @@ extern "C" {

uint8_t flag = RPS_HEADER;
static chip::OTAImageProcessorImpl gImageProcessor;

namespace chip {

// Define static memebers
Expand Down Expand Up @@ -229,7 +229,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context)
// send system reset request to reset the MCU and upgrade the m4 image
ChipLogProgress(SoftwareUpdate, "SoC Soft Reset initiated!");
// Reboots the device
sl_si91x_soc_nvic_reset();
DeviceLayer::Silabs::GetPlatform().SoftwareReset();
}
}

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 @@ -124,6 +124,11 @@ CHIP_ERROR SilabsPlatform::Init(void)
return CHIP_NO_ERROR;
}

void SilabsPlatform::SoftwareReset()
{
NVIC_SystemReset();
}

CHIP_ERROR SilabsPlatform::FlashInit()
{
#if defined(SL_TRUSTZONE_NONSECURE)
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 @@ -61,6 +61,8 @@ class SilabsPlatform : virtual public SilabsPlatformAbstractionBase
CHIP_ERROR FlashErasePage(uint32_t addr) override;
CHIP_ERROR FlashWritePage(uint32_t addr, const uint8_t * data, size_t size) override;

void SoftwareReset(void) override;

private:
friend SilabsPlatform & GetPlatform(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class SilabsPlatformAbstractionBase
virtual CHIP_ERROR FlashErasePage(uint32_t addr) { return CHIP_ERROR_NOT_IMPLEMENTED; }
virtual CHIP_ERROR FlashWritePage(uint32_t addr, const uint8_t * data, size_t size) { return CHIP_ERROR_NOT_IMPLEMENTED; }

// soft reset
virtual void SoftwareReset(void) {}
Copy link
Contributor

@mkardous-silabs mkardous-silabs Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be pure virtual since it is a required function and can we add function comments?


// BLE Specific Method

protected:
Expand Down
7 changes: 7 additions & 0 deletions src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ extern "C" {
#endif // SL_SI91X_BOARD_INIT
#include "sl_event_handler.h"

#include "sl_si91x_hal_soc_soft_reset.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be an extern C include?


#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
#include "sl_si91x_button.h"
#include "sl_si91x_button_pin_config.h"
Expand Down Expand Up @@ -208,6 +210,11 @@ uint8_t SilabsPlatform::GetButtonState(uint8_t button)
}
#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT

void SilabsPlatform::SoftwareReset()
{
sl_si91x_soc_nvic_reset();
}

CHIP_ERROR SilabsPlatform::FlashInit()
{
return CHIP_NO_ERROR;
Expand Down
Loading