Skip to content

Commit 61e095a

Browse files
committed
Adds changes for the updated wifi firmware
1 parent db87cd5 commit 61e095a

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

src/platform/silabs/multi-ota/OTAHooks.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,20 @@ CHIP_ERROR chip::OTAMultiImageProcessorImpl::ProcessDescriptor(void * descriptor
5050

5151
CHIP_ERROR chip::OTAMultiImageProcessorImpl::OtaHookInit()
5252
{
53+
auto & imageProcessor = chip::OTAMultiImageProcessorImpl::GetDefaultInstance();
54+
55+
#ifndef SLI_SI91X_MCU_INTERFACE
5356
static chip::OTAFirmwareProcessor sApplicationProcessor;
5457
static chip::OTAFactoryDataProcessor sFactoryDataProcessor;
5558

5659
sApplicationProcessor.RegisterDescriptorCallback(ProcessDescriptor);
5760
sFactoryDataProcessor.RegisterDescriptorCallback(ProcessDescriptor);
5861

59-
auto & imageProcessor = chip::OTAMultiImageProcessorImpl::GetDefaultInstance();
6062
ReturnErrorOnFailure(
6163
imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kApplicationProcessor), &sApplicationProcessor));
6264
ReturnErrorOnFailure(
6365
imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kFactoryDataProcessor), &sFactoryDataProcessor));
66+
#endif
6467

6568
#if OTA_TEST_CUSTOM_TLVS
6669
static chip::OTACustomProcessor customProcessor1;
@@ -75,5 +78,11 @@ CHIP_ERROR chip::OTAMultiImageProcessorImpl::OtaHookInit()
7578
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(9, &customProcessor2));
7679
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(10, &customProcessor3));
7780
#endif
81+
82+
#ifdef SL_WIFI
83+
static chip::OTAWiFiFirmwareProcessor sWifiFirmwareProcessor;
84+
sWifiFirmwareProcessor.RegisterDescriptorCallback(ProcessDescriptor);
85+
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kWiFiProcessor), &sWifiFirmwareProcessor));
86+
#endif
7887
return CHIP_NO_ERROR;
7988
}

src/platform/silabs/multi-ota/OTAMultiImageProcessorImpl.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ void OTAMultiImageProcessorImpl::HandlePrepareDownload(intptr_t context)
116116

117117
ChipLogProgress(SoftwareUpdate, "HandlePrepareDownload: started");
118118

119+
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
119120
CORE_CRITICAL_SECTION(bootloader_init();)
121+
#endif
120122

121123
imageProcessor->mParams.downloadedBytes = 0;
122124

src/platform/silabs/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.cpp

+18-21
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <platform/silabs/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.h>
2222

2323
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
24-
#include "wfx_host_events.h"
2524
#include <platform/silabs/SilabsConfig.h>
2625
#ifdef __cplusplus
2726
extern "C" {
@@ -37,7 +36,7 @@
3736
#define RPS_HEADER 1
3837
#define RPS_DATA 2
3938

40-
#define SL_STATUS_FW_UPDATE_DONE SL_STATUS_SI91X_NO_AP_FOUND
39+
#define SL_STATUS_FW_UPDATE_DONE SL_STATUS_SI91X_FW_UPDATE_DONE
4140
uint8_t flag = RPS_HEADER;
4241

4342
namespace chip {
@@ -47,8 +46,8 @@
4746

4847
CHIP_ERROR OTAWiFiFirmwareProcessor::Init()
4948
{
50-
ReturnErrorCodeIf(mCallbackProcessDescriptor == nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED);
51-
mAccumulator.Init(sizeof(Descriptor));
49+
VerifyOrReturnError(mCallbackProcessDescriptor != nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED);
50+
mAccumulator.Init(sizeof(Descriptor));
5251
#if OTA_ENCRYPTION_ENABLE
5352
mUnalignmentNum = 0;
5453
#endif
@@ -70,31 +69,30 @@
7069

7170
CHIP_ERROR OTAWiFiFirmwareProcessor::ProcessInternal(ByteSpan & block)
7271
{
73-
int32_t status = SL_STATUS_OK;
72+
int32_t status = SL_STATUS_OK;
7473
// Store the header of the OTA file
7574
static uint8_t writeBuffer[kAlignmentBytes] __attribute__((aligned(4))) = { 0 };
76-
// Used to tranfer other block to processor
75+
// Used to transfer other blocks to the processor
7776
static uint8_t writeDataBuffer[1024] __attribute__((aligned(4))) = { 0 };
7877

7978
if (!mDescriptorProcessed)
8079
{
8180
ReturnErrorOnFailure(ProcessDescriptor(block));
8281
#if OTA_ENCRYPTION_ENABLE
83-
/* 16 bytes to used to store undecrypted data because of unalignment */
82+
// 16 bytes used to store undecrypted data due to unalignment
8483
mAccumulator.Init(requestedOtaMaxBlockSize + 16);
8584
#endif
8685
}
8786

8887
#if OTA_ENCRYPTION_ENABLE
89-
MutableByteSpan mBlock = MutableByteSpan(mAccumulator.data(), mAccumulator.GetThreshold());
88+
MutableByteSpan mBlock(mAccumulator.data(), mAccumulator.GetThreshold());
9089
memcpy(&mBlock[0], &mBlock[requestedOtaMaxBlockSize], mUnalignmentNum);
9190
memcpy(&mBlock[mUnalignmentNum], block.data(), block.size());
9291

9392
if (mUnalignmentNum + block.size() < requestedOtaMaxBlockSize)
9493
{
95-
uint32_t mAlignmentNum = (mUnalignmentNum + block.size()) / 16;
96-
mAlignmentNum = mAlignmentNum * 16;
97-
mUnalignmentNum = (mUnalignmentNum + block.size()) % 16;
94+
uint32_t mAlignmentNum = (mUnalignmentNum + block.size()) / 16 * 16;
95+
mUnalignmentNum = (mUnalignmentNum + block.size()) % 16;
9896
memcpy(&mBlock[requestedOtaMaxBlockSize], &mBlock[mAlignmentNum], mUnalignmentNum);
9997
mBlock.reduce_size(mAlignmentNum);
10098
}
@@ -109,23 +107,22 @@
109107
#endif
110108

111109
if (flag == RPS_HEADER)
112-
{
113-
memcpy(&writeBuffer, block.data(), kAlignmentBytes);
114-
// Send RPS header which is received as first chunk
110+
{
111+
memcpy(writeBuffer, block.data(), kAlignmentBytes);
112+
// Send RPS header received as the first chunk
115113
status = sl_si91x_fwup_start(writeBuffer);
116114
status = sl_si91x_fwup_load(writeBuffer, kAlignmentBytes);
117-
flag = RPS_DATA;
118-
memcpy(&writeDataBuffer, block.data() + kAlignmentBytes, (block.size() - kAlignmentBytes));
119-
status = sl_si91x_fwup_load(writeDataBuffer, (block.size() - kAlignmentBytes));
120-
}
115+
flag = RPS_DATA;
116+
memcpy(writeDataBuffer, block.data() + kAlignmentBytes, block.size() - kAlignmentBytes);
117+
status = sl_si91x_fwup_load(writeDataBuffer, block.size() - kAlignmentBytes);
118+
}
121119
else if (flag == RPS_DATA)
122120
{
123-
memcpy(&writeDataBuffer, block.data(), block.size());
121+
memcpy(writeDataBuffer, block.data(), block.size());
124122
// Send RPS content
125123
status = sl_si91x_fwup_load(writeDataBuffer, block.size());
126124
if (status != SL_STATUS_OK)
127125
{
128-
// When TA recived all the blocks it will return SL_STATUS_FW_UPDATE_DONE status
129126
if (status == SL_STATUS_FW_UPDATE_DONE)
130127
{
131128
mReset = true;
@@ -162,7 +159,7 @@
162159
// send system reset request to reset the MCU and upgrade the m4 image
163160
ChipLogProgress(SoftwareUpdate, "SoC Soft Reset initiated!");
164161
// Reboots the device
165-
sl_si91x_soc_soft_reset();
162+
sl_si91x_soc_nvic_reset();
166163
#endif
167164
}
168165
return CHIP_NO_ERROR;

0 commit comments

Comments
 (0)