Skip to content

Commit

Permalink
Added changes for the build errores
Browse files Browse the repository at this point in the history
  • Loading branch information
shgutte committed Mar 27, 2024
1 parent 37c9252 commit d7cc14b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 49 deletions.
5 changes: 5 additions & 0 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ config("silabs-wifi-config") {
if (rs91x_wpa3_transition) {
defines += [ "WIFI_ENABLE_SECURITY_WPA3_TRANSITION=1" ]
}


if (chip_enable_multi_ota_requestor) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_MULTI_OTA_REQUESTOR=1" ]
}
}

source_set("siwx917-common") {
Expand Down
3 changes: 1 addition & 2 deletions src/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# limitations under the License.

import("//build_overrides/chip.gni")

import("${chip_root}/src/platform/device.gni")

import("${chip_root}/third_party/silabs/efr32_sdk.gni")
import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/third_party/silabs/silabs_board.gni")
Expand Down
11 changes: 7 additions & 4 deletions src/platform/silabs/multi-ota/OTAMultiImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <platform/DiagnosticDataProvider.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <platform/internal/GenericConfigurationManagerImpl.h>

#include <platform/silabs/multi-ota/OTAMultiImageProcessorImpl.h>

using namespace chip::DeviceLayer;
Expand All @@ -31,9 +30,11 @@ using namespace ::chip::DeviceLayer::Internal;
static chip::OTAMultiImageProcessorImpl gImageProcessor;

extern "C" {
#if SL_BTLCTRL_MUX
#include "btl_interface.h"
#endif // SL_BTLCTRL_MUX
#include "em_bus.h" // For CORE_CRITICAL_SECTION
#if SL_WIFI
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
#include "spi_multiplex.h"
#endif // SL_WIFI
}
Expand Down Expand Up @@ -114,7 +115,9 @@ void OTAMultiImageProcessorImpl::HandlePrepareDownload(intptr_t context)

ChipLogProgress(SoftwareUpdate, "HandlePrepareDownload: started");

#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
CORE_CRITICAL_SECTION(bootloader_init();)
#endif

imageProcessor->mParams.downloadedBytes = 0;

Expand Down Expand Up @@ -422,9 +425,9 @@ void OTAMultiImageProcessorImpl::HandleApply(intptr_t context)

// TODO: check where to put this
// ConfigurationManagerImpl().StoreSoftwareUpdateCompleted();

// This reboots the device
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
CORE_CRITICAL_SECTION(bootloader_rebootAndInstall();)
#endif
}

CHIP_ERROR OTAMultiImageProcessorImpl::ReleaseBlock()
Expand Down
57 changes: 22 additions & 35 deletions src/platform/silabs/multi-ota/SiWx917/OTAFirmwareProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ uint8_t flag = RPS_HEADER;
namespace chip {

// Define static memebers
uint8_t OTAFirmwareProcessor::mReset = false;
//bool OTAFirmwareProcessor::mReset = false;
uint32_t OTAFirmwareProcessor::mWriteOffset = 0;
uint16_t OTAFirmwareProcessor::writeBufOffset = 0;
uint8_t OTAFirmwareProcessor::writeBuffer[kAlignmentBytes] __attribute__((aligned(4))) = { 0 };
Expand Down Expand Up @@ -109,24 +109,18 @@ CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block)
// should be set to true in HandleProcessBlock
if (status == SL_STATUS_FW_UPDATE_DONE)
{
mReset = true;
//mReset = true;
}
else
{
ChipLogError(SoftwareUpdate, "ERROR: In HandleProcessBlock sl_si91x_fwup_load() error %ld", status);
imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
return;
// TODO: add this somewhere
// imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
// TODO: Replace CHIP_ERROR_CANCELLED with new error statement
return CHIP_ERROR_CANCELLED;
}
}
}
if (err)
{
ChipLogError(SoftwareUpdate, "bootloader_eraseWriteStorage() error: %ld", err);
// TODO: add this somewhere
// imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
// TODO: Replace CHIP_ERROR_CANCELLED with new error statement
return CHIP_ERROR_CANCELLED;
}
mWriteOffset += kAlignmentBytes;
}
}
Expand All @@ -147,25 +141,15 @@ CHIP_ERROR OTAFirmwareProcessor::ProcessDescriptor(ByteSpan & block)

CHIP_ERROR OTAFirmwareProcessor::ApplyAction()
{
uint32_t err = SL_BOOTLOADER_OK;
if (err != SL_BOOTLOADER_OK)
{
ChipLogError(SoftwareUpdate, "bootloader_verifyImage() error: %ld", err);
// Call the OTARequestor API to reset the state
GetRequestorInstance()->CancelImageUpdate();

return SL_GENERIC_OTA_ERROR;
}

CORE_CRITICAL_SECTION(err = bootloader_setImageToBootload(mSlotId);)
if (err != SL_BOOTLOADER_OK)
{
ChipLogError(SoftwareUpdate, "bootloader_setImageToBootload() error: %ld", err);
// Call the OTARequestor API to reset the state
GetRequestorInstance()->CancelImageUpdate();
return SL_GENERIC_OTA_ERROR;
}

// This reboots the device
// if (mReset)
// {
// ChipLogProgress(SoftwareUpdate, "M4 Firmware update complete");
// // 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_soft_reset();
// }
return CHIP_NO_ERROR;
}

Expand All @@ -189,19 +173,22 @@ CHIP_ERROR OTAFirmwareProcessor::FinalizeAction()
{
if (status == SL_STATUS_FW_UPDATE_DONE)
{
mReset = true;
// mReset = true;
}
else
{
ChipLogError(SoftwareUpdate, "ERROR: In HandleFinalize for last chunk sl_si91x_fwup_load() error %ld", status);
imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
return;

// TODO: add this somewhere
// imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
// TODO: Replace CHIP_ERROR_CANCELLED with new error statement
return CHIP_ERROR_CANCELLED;
}
}

}

return err ? CHIP_ERROR_WRITE_FAILED : CHIP_NO_ERROR;
return status ? CHIP_ERROR_CANCELLED : CHIP_NO_ERROR;
}

} // namespace chip
16 changes: 8 additions & 8 deletions src/platform/silabs/multi-ota/SiWx917/OTAFirmwareProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ class OTAFirmwareProcessor : public OTATlvProcessor
CHIP_ERROR Clear() override;
CHIP_ERROR ApplyAction() override;
CHIP_ERROR FinalizeAction() override;

static constexpr size_t kAlignmentBytes = 64;
static bool mReset = false;
static uint32_t mWriteOffset; // End of last written block
// Bootloader storage API requires the buffer size to be a multiple of 4.
static uint8_t writeBuffer[kAlignmentBytes] __attribute__((aligned(4)));
// Offset indicates how far the write buffer has been filled
static uint16_t writeBufOffset;
private:
CHIP_ERROR ProcessInternal(ByteSpan & block) override;
CHIP_ERROR ProcessDescriptor(ByteSpan & block);
Expand All @@ -47,13 +53,7 @@ class OTAFirmwareProcessor : public OTATlvProcessor
#if OTA_ENCRYPTION_ENABLE
uint32_t mUnalignmentNum;
#endif
static constexpr size_t kAlignmentBytes = 64;
static uint32_t mWriteOffset; // End of last written block
static uint8_t mSlotId; // Bootloader storage slot
// Bootloader storage API requires the buffer size to be a multiple of 4.
static uint8_t writeBuffer[kAlignmentBytes] __attribute__((aligned(4)));
// Offset indicates how far the write buffer has been filled
static uint16_t writeBufOffset;

};

} // namespace chip

0 comments on commit d7cc14b

Please sign in to comment.