-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: master
Are you sure you want to change the base?
Changes from 38 commits
17c5611
5eef7f6
5b07de3
ea8c80f
ad4dd34
7762e37
5949e9f
6e80e03
4cfdfd5
627f9ba
5a7d83b
08bab24
f4bf610
e6c3a13
cdc63ed
593eaf3
14ed08e
479d2a2
4cf6b09
23cea72
47d37f0
f9934da
14bc689
d855d64
f799676
298adc8
a672c7b
ec02a69
d09abe5
d76ef10
cae741a
df781e7
a3dd261
293f69c
66e2d0c
1e93535
a7b01b0
3ddad76
1150a2a
072d222
420fa5c
65f7c04
0bc1e0d
187a3da
f06b8b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ class TAG: | |
APPLICATION = 1 | ||
BOOTLOADER = 2 | ||
FACTORY_DATA = 3 | ||
WIFI_917_TA_M4 = 4 | ||
|
||
|
||
def set_logger(): | ||
|
@@ -163,6 +164,32 @@ def generate_app(args: object): | |
return [OTA_APP_TLV_TEMP, args.app_input_file] | ||
|
||
|
||
def generate_wifi_image(args: object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
""" | ||
Generate app payload with descriptor. If a certain option is not specified, use the default values. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
@@ -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) | ||
|
@@ -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)') | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
create_parser.add_argument('--app-version', type=any_base_int, | ||
help='Application Software version (numeric)') | ||
create_parser.add_argument('--app-version-str', type=str, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not useful without including the |
||
#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" | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif // SLI_SI91X_MCU_INTERFACE | ||
} | ||
|
||
namespace chip { | ||
|
@@ -59,7 +60,6 @@ void OTAMultiImageProcessorImpl::Clear() | |
mParams.totalFileBytes = 0; | ||
mParams.downloadedBytes = 0; | ||
mCurrentProcessor = nullptr; | ||
|
||
ReleaseBlock(); | ||
} | ||
|
||
|
@@ -115,7 +115,9 @@ void OTAMultiImageProcessorImpl::HandlePrepareDownload(intptr_t context) | |
|
||
ChipLogProgress(SoftwareUpdate, "HandlePrepareDownload: started"); | ||
|
||
#ifndef SLI_SI91X_MCU_INTERFACE // required for 917 NCP | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CORE_CRITICAL_SECTION(bootloader_init();) | ||
#endif | ||
|
||
imageProcessor->mParams.downloadedBytes = 0; | ||
|
||
|
@@ -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()) | ||
{ | ||
|
@@ -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 | ||
shgutte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CORE_CRITICAL_SECTION(bootloader_rebootAndInstall();) | ||
#endif | ||
// ConfigurationManagerImpl().StoreSoftwareUpdateCompleted(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented code if not required. |
||
} | ||
|
||
CHIP_ERROR OTAMultiImageProcessorImpl::ReleaseBlock() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
/** | ||
|
There was a problem hiding this comment.
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?