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] [WiFi] Added changes for the 917 Wi-Fi multi-ota feature #37611

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
17c5611
Added changes for the multi ota 917 soc
shgutte Mar 26, 2024
5eef7f6
Added changes for the build errores
shgutte Mar 27, 2024
5b07de3
Added changes for 917 soc
shgutte Apr 7, 2024
ea8c80f
Added changes for the name for 917 NCP
shgutte Apr 8, 2024
ad4dd34
Deleted the 917 NCP file
shgutte Apr 10, 2024
7762e37
Added fixed for 917 SoC build changes
shgutte Apr 10, 2024
5949e9f
Added changes for 917 SOC
shgutte Apr 11, 2024
6e80e03
Added changes for the 917 SOC build error
shgutte Apr 11, 2024
4cfdfd5
Added changes for the 917 SoC ota reset
shgutte Apr 11, 2024
627f9ba
Added changes for OTA 917 SoC script
shgutte Apr 11, 2024
5a7d83b
Added changes for 917 build
shgutte Apr 11, 2024
08bab24
Added debugging logs for the files
shgutte Apr 14, 2024
f4bf610
Removed the duplicate code
shgutte Apr 14, 2024
e6c3a13
Added changes for the SoC Application
shgutte Apr 15, 2024
cdc63ed
Added changes for builkd issue with EFR32 multi OTA
shgutte Apr 16, 2024
593eaf3
Added changes for the OTA 917 NCP
shgutte Apr 16, 2024
14ed08e
Added changes for the OTA tlv
shgutte Apr 16, 2024
479d2a2
Added changes for the comment
shgutte Apr 17, 2024
4cf6b09
Added changes for the process block for WIfi
shgutte Apr 17, 2024
23cea72
Removed the mWriteOffset in firmware processor
shgutte Apr 17, 2024
47d37f0
Removed unessory comment
shgutte Apr 17, 2024
f9934da
Added changes for the ProcessInternal OTA WiFi
shgutte Apr 17, 2024
14bc689
Added changes for WiFi OTA processor
shgutte Apr 19, 2024
d855d64
Removed the unwanted line
shgutte Apr 19, 2024
f799676
Cleanup of the code
shgutte Apr 19, 2024
298adc8
Corrected #ifdef comments
shgutte Apr 19, 2024
a672c7b
Removed unwanted comment
shgutte Apr 19, 2024
ec02a69
Added back the set_logger function
shgutte Apr 19, 2024
d09abe5
Applied suggestion
selissia Apr 19, 2024
d76ef10
Added changes realted to comment
shgutte Apr 22, 2024
cae741a
Discription for input command is updated
shgutte Apr 22, 2024
df781e7
Added changes for build file of 917 SoC
shgutte Apr 24, 2024
a3dd261
Added changes for encryption
shgutte Apr 24, 2024
293f69c
Adds changes for the multi-ota updated
shgutte Feb 24, 2025
66e2d0c
Adds changes for the customProcessor
shgutte Feb 24, 2025
1e93535
Refacred the code and removed the not required code
shgutte Feb 25, 2025
a7b01b0
Adds change for script
shgutte Feb 25, 2025
3ddad76
Adds changes for the 917 NCP
shgutte Feb 28, 2025
1150a2a
Restyle done
shgutte Mar 4, 2025
072d222
Adds OTA_ENCRYPTION_ENABLE commnet
shgutte Mar 4, 2025
420fa5c
Added SL_STATUS_SI91X_FW_UPDATE_DONE directly
shgutte Mar 4, 2025
65f7c04
Removed the OTAImageTypex
shgutte Mar 4, 2025
0bc1e0d
Added comment for 917 NCP
shgutte Mar 4, 2025
187a3da
Removed the comment
shgutte Mar 4, 2025
f06b8b2
Changed the comment for SLI_SI91X_MCU_INTERFACE
shgutte Mar 4, 2025
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
4 changes: 4 additions & 0 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ config("siwx917-common-config") {
defines += [ "HEAP_MONITORING" ]
}

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

ldflags = [ "-Wl,--no-warn-rwx-segment" ]
}

Expand Down
32 changes: 32 additions & 0 deletions scripts/tools/silabs/ota/ota_multi_image_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TAG:
APPLICATION = 1
BOOTLOADER = 2
FACTORY_DATA = 3
WIFI_917_TA_M4 = 4
Copy link
Contributor

Choose a reason for hiding this comment

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

WIFI_917_TA_M4 why are we using device specific tag name here?



def set_logger():
Expand Down Expand Up @@ -163,6 +164,32 @@ def generate_app(args: object):
return [OTA_APP_TLV_TEMP, args.app_input_file]


def generate_wifi_image(args: object):
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is a copy paste of the generate app function outside of the tag change.

Why do we need a specific tag to the M4 / TA image?
If we do need a specific tag, we should modify the function to take the tag as input instead.

"""
Generate app payload with descriptor. If a certain option is not specified, use the default values.
Copy link
Contributor

Choose a reason for hiding this comment

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

comment needs to be updated

"""
logging.info("App descriptor information:")

descriptor = generate_descriptor(args.app_version, args.app_version_str, args.app_build_date)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this required? looks to be application specific

logging.info(f"App encryption enable: {args.enc_enable}")
if args.enc_enable:
inputFile = open(args.wifi_input_file, "rb")
enc_file = crypto_utils.encryptData(inputFile.read(), args.input_ota_key, INITIALIZATION_VECTOR)
enc_file1 = bytes([ord(x) for x in enc_file])
file_size = len(enc_file1)
payload = generate_header(TAG.WIFI_917_TA_M4, len(descriptor) + file_size) + descriptor + enc_file1
else:
file_size = os.path.getsize(args.wifi_input_file)
logging.info(f"file size: {file_size}")
payload = generate_header(TAG.WIFI_917_TA_M4, len(descriptor) + file_size) + descriptor

write_to_temp(OTA_APP_TLV_TEMP, payload)
if args.enc_enable:
return [OTA_APP_TLV_TEMP]
else:
return [OTA_APP_TLV_TEMP, args.wifi_input_file]


def generate_bootloader(args: object):
"""
Generate SSBL payload with descriptor. If a certain option is not specified, use the default values.
Expand Down Expand Up @@ -259,6 +286,9 @@ def create_image(args: object):
if args.app_input_file:
input_files += generate_app(args)

if args.wifi_input_file:
input_files += generate_wifi_image(args)

if len(input_files) == 0:
print("Please specify an input option.")
sys.exit(1)
Expand Down Expand Up @@ -312,6 +342,8 @@ def any_base_int(s): return int(s, 0)

create_parser.add_argument('-app', "--app-input-file",
help='Path to application input file')
create_parser.add_argument('-wifi', "--wifi-input-file",
help='Path to OTA image for SiWx917 (TA/M4/Combined file)')
create_parser.add_argument('--app-version', type=any_base_int,
help='Application Software version (numeric)')
create_parser.add_argument('--app-version-str', type=str,
Expand Down
14 changes: 11 additions & 3 deletions src/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.

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

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

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/platform/silabs/wifi/args.gni")
Expand Down Expand Up @@ -77,7 +75,17 @@ static_library("SiWx917") {
"SiWxPlatformInterface.h",
]

if (chip_enable_ota_requestor) {
if (chip_enable_multi_ota_requestor) {
sources += [
"${silabs_platform_dir}/multi-ota/OTAMultiImageProcessorImpl.cpp",
"${silabs_platform_dir}/multi-ota/OTAMultiImageProcessorImpl.h",
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.cpp",
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.h",
"${silabs_platform_dir}/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.cpp",
"${silabs_platform_dir}/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.h",
"${silabs_platform_dir}/multi-ota/OTAHooks.cpp",
]
} else if (chip_enable_ota_requestor) {
sources += [
"${silabs_platform_dir}/OTAImageProcessorImpl.h",
"OTAImageProcessorImpl.cpp",
Expand Down
7 changes: 7 additions & 0 deletions src/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ static_library("efr32") {
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.cpp",
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.h",
]

if (chip_enable_wifi) {
sources += [
"${silabs_platform_dir}/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.cpp",
"${silabs_platform_dir}/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.h",
]
}
Comment on lines +108 to +113
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need these for all NCP combos?

} else if (chip_enable_ota_requestor) {
sources += [
"${silabs_platform_dir}/OTAImageProcessorImpl.h",
Expand Down
1 change: 1 addition & 0 deletions src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ CHIP_ERROR OTAFirmwareProcessor::Clear()
CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block)
{
uint32_t err = SL_BOOTLOADER_OK;
ChipLogProgress(SoftwareUpdate,"ProcessInternal Thread Block processing");
if (!mDescriptorProcessed)
{
ReturnErrorOnFailure(ProcessDescriptor(block));
Expand Down
43 changes: 30 additions & 13 deletions src/platform/silabs/multi-ota/OTAHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,43 @@
#include <app/clusters/ota-requestor/OTARequestorInterface.h>

#include <platform/silabs/multi-ota/OTAFactoryDataProcessor.h>
#ifndef SLI_SI91X_MCU_INTERFACE
#include <platform/silabs/multi-ota/OTAFirmwareProcessor.h>
#endif

#if SL_WIFI
#include <platform/silabs/multi-ota/SiWx917/OTAWiFiFirmwareProcessor.h>
#endif

#if OTA_TEST_CUSTOM_TLVS
#include <platform/silabs/multi-ota/OTACustomProcessor.h>
#endif

CHIP_ERROR chip::OTAMultiImageProcessorImpl::ProcessDescriptor(void * descriptor)
{
#ifndef SLI_SI91X_MCU_INTERFACE
[[maybe_unused]] auto desc = static_cast<chip::OTAFirmwareProcessor::Descriptor *>(descriptor);
ChipLogDetail(SoftwareUpdate, "Descriptor: %ld, %s, %s", desc->version, desc->versionString, desc->buildDate);
#endif

#if SL_WIFI
auto descWiFi = static_cast<chip::OTAWiFiFirmwareProcessor::Descriptor *>(descriptor);
ChipLogDetail(SoftwareUpdate, "Descriptor: %ld, %s, %s", descWiFi->version, descWiFi->versionString, descWiFi->buildDate);
#endif

return CHIP_NO_ERROR;
}

CHIP_ERROR chip::OTAMultiImageProcessorImpl::OtaHookInit()
{
static chip::OTAFirmwareProcessor sApplicationProcessor;
static chip::OTAFactoryDataProcessor sFactoryDataProcessor;
Copy link
Contributor

Choose a reason for hiding this comment

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

sFactoryDataProcessor why was this required before and not now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is present in the code just went down in the macros which are there for WIFI and EFR


sApplicationProcessor.RegisterDescriptorCallback(ProcessDescriptor);
sFactoryDataProcessor.RegisterDescriptorCallback(ProcessDescriptor);

auto & imageProcessor = chip::OTAMultiImageProcessorImpl::GetDefaultInstance();
ReturnErrorOnFailure(
imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kApplicationProcessor), &sApplicationProcessor));
ReturnErrorOnFailure(
imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kFactoryDataProcessor), &sFactoryDataProcessor));

#ifndef SLI_SI91X_MCU_INTERFACE
static chip::OTAFirmwareProcessor sApplicationProcessor;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is sApplicationProcessor not required for SLI_SI91X_MCU_INTERFACE, the Si917 should also have an application processor right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because 917 SoC directly support the combined image so we don't need to implement the separate processor for it

sApplicationProcessor.RegisterDescriptorCallback(ProcessDescriptor);
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kApplicationProcessor), &sApplicationProcessor));
#endif

#if OTA_TEST_CUSTOM_TLVS
static chip::OTACustomProcessor customProcessor1;
Expand All @@ -59,9 +69,16 @@ CHIP_ERROR chip::OTAMultiImageProcessorImpl::OtaHookInit()
customProcessor2.RegisterDescriptorCallback(ProcessDescriptor);
customProcessor3.RegisterDescriptorCallback(ProcessDescriptor);

ReturnErrorOnFailure(imageProcessor.RegisterProcessor(8, &customProcessor1));
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(9, &customProcessor2));
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(10, &customProcessor3));
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kCustomProcessor1), &customProcessor1));
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kCustomProcessor2), &customProcessor2));
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kCustomProcessor3), &customProcessor3));
#endif

#ifdef SL_WIFI
static chip::OTAWiFiFirmwareProcessor sWifiFirmwareProcessor;
sWifiFirmwareProcessor.RegisterDescriptorCallback(ProcessDescriptor);
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(static_cast<uint32_t>(OTAProcessorTag::kWiFiProcessor), &sWifiFirmwareProcessor));
#endif

return CHIP_NO_ERROR;
}
}
21 changes: 14 additions & 7 deletions src/platform/silabs/multi-ota/OTAMultiImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@
#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;
using namespace ::chip::DeviceLayer::Internal;

static chip::OTAMultiImageProcessorImpl gImageProcessor;

#if SL_WIFI
#include <platform/silabs/wifi/ncp/spi_multiplex.h>
#endif // SL_WIFI

extern "C" {
#if SL_BTLCTRL_MUX
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not useful without including the spi_multiplex.h

#include "btl_interface.h"
#include "sl_core.h"
#endif // SL_BTLCTRL_MUX
#include "em_bus.h" // For CORE_CRITICAL_SECTION
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
#include "btl_interface.h"
#endif // SLI_SI91X_MCU_INTERFACE
}

namespace chip {
Expand All @@ -59,7 +60,6 @@ void OTAMultiImageProcessorImpl::Clear()
mParams.totalFileBytes = 0;
mParams.downloadedBytes = 0;
mCurrentProcessor = nullptr;

ReleaseBlock();
}

Expand Down Expand Up @@ -115,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 @@ -202,6 +204,8 @@ CHIP_ERROR OTAMultiImageProcessorImpl::SelectProcessor(ByteSpan & block)

CHIP_ERROR OTAMultiImageProcessorImpl::RegisterProcessor(uint32_t tag, OTATlvProcessor * processor)
{

ChipLogDetail(SoftwareUpdate, "RegisterProcessor with tag: %ld", tag);
auto pair = mProcessorMap.find(tag);
if (pair != mProcessorMap.end())
{
Expand Down Expand Up @@ -420,9 +424,12 @@ void OTAMultiImageProcessorImpl::HandleApply(intptr_t context)
imageProcessor->mAccumulator.Clear();

ChipLogProgress(SoftwareUpdate, "HandleApply: Finished");

// This reboots the device
// TODO: check where to put this
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP
CORE_CRITICAL_SECTION(bootloader_rebootAndInstall();)
#endif
// ConfigurationManagerImpl().StoreSoftwareUpdateCompleted();
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented code if not required.

}

CHIP_ERROR OTAMultiImageProcessorImpl::ReleaseBlock()
Expand Down
11 changes: 9 additions & 2 deletions src/platform/silabs/multi-ota/OTATlvProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ using namespace ::chip::DeviceLayer::Internal;

namespace chip {

#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
typedef enum
{
APPLICATION,
BOOTLOADER,
FACTORY_DATA,
WIFI_917_TA_M4_COMBINED,
} OTAImageType;

#if SL_MATTER_ENABLE_OTA_ENCRYPTION
constexpr uint8_t au8Iv[] = { 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x00, 0x00, 0x00, 0x00 };
#endif
CHIP_ERROR OTATlvProcessor::Process(ByteSpan & block)
Expand All @@ -57,7 +65,6 @@ CHIP_ERROR OTATlvProcessor::Process(ByteSpan & block)
}
}
}

return status;
}

Expand Down
12 changes: 8 additions & 4 deletions src/platform/silabs/multi-ota/OTATlvProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ struct OTATlvHeader
uint32_t length;
};

// TLV tags synced with ota files generate by scripts/tools/silabs/ota/ota_image_tool.py
// TLV tags synced with ota files generated by scripts/tools/silabs/ota/ota_image_tool.py
enum class OTAProcessorTag
{
kApplicationProcessor = 1,
kBootloaderProcessor = 2,
kFactoryDataProcessor = 3
kApplicationProcessor = 1,
kBootloaderProcessor = 2 ,
kFactoryDataProcessor = 3,
kWiFiProcessor = 4,
kCustomProcessor1 = 8,
kCustomProcessor2 = 9,
kCustomProcessor3 = 10,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

a limit or bound for the enum would be recommended for which we can test if the OTAProcessorTag is not unbound.


/**
Expand Down
Loading
Loading