Skip to content

Commit 501f56b

Browse files
committed
Added changes for the multi OTA 917 NCP
1 parent d7cc14b commit 501f56b

12 files changed

+626
-326
lines changed

src/platform/silabs/SiWx917/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ static_library("SiWx917") {
7171
"${silabs_platform_dir}/multi-ota/OTAMultiImageProcessorImpl.h",
7272
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.cpp",
7373
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.h",
74+
"${silabs_platform_dir}/multi-ota/OTAUtilityFirmwareProcessor.cpp",
75+
"${silabs_platform_dir}/multi-ota/OTAUtilityFirmwareProcessor.h",
7476
"${silabs_platform_dir}/multi-ota/SiWx917/OTAFirmwareProcessor.cpp",
7577
"${silabs_platform_dir}/multi-ota/SiWx917/OTAFirmwareProcessor.h",
7678
"${silabs_platform_dir}/multi-ota/SiWx917/OTAHooks.cpp",

src/platform/silabs/efr32/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static_library("efr32") {
8484
"${silabs_platform_dir}/multi-ota/OTAMultiImageProcessorImpl.h",
8585
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.cpp",
8686
"${silabs_platform_dir}/multi-ota/OTATlvProcessor.h",
87+
"${silabs_platform_dir}/multi-ota/OTAUtilityFirmwareProcessor.cpp",
88+
"${silabs_platform_dir}/multi-ota/OTAUtilityFirmwareProcessor.h",
8789
"${silabs_platform_dir}/multi-ota/efr32/OTAFirmwareProcessor.cpp",
8890
"${silabs_platform_dir}/multi-ota/efr32/OTAFirmwareProcessor.h",
8991
"${silabs_platform_dir}/multi-ota/efr32/OTAHooks.cpp",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <platform/internal/CHIPDeviceLayerInternal.h>
20+
#include <platform/silabs/multi-ota/OTAMultiImageProcessorImpl.h>
21+
#include <platform/silabs/multi-ota/efr32/OTAFirmwareProcessor.h>
22+
23+
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
24+
#include "wfx_host_events.h"
25+
#include <platform/silabs/SilabsConfig.h>
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
#include "sl_si91x_driver.h"
30+
#ifdef SLI_SI91X_MCU_INTERFACE
31+
#include "sl_si91x_hal_soc_soft_reset.h"
32+
#endif
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
37+
// TODO: more descriptive error codes
38+
#define SL_OTA_ERROR 1L
39+
40+
namespace chip {
41+
42+
CHIP_ERROR OTAFirmwareProcessor::Init()
43+
{
44+
ReturnErrorCodeIf(mCallbackProcessDescriptor == nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED);
45+
return OTAUtilityFirmwareProcessor::getInstance()->Init();
46+
}
47+
48+
CHIP_ERROR OTAFirmwareProcessor::Clear()
49+
{
50+
OTATlvProcessor::ClearInternal();
51+
return OTAUtilityFirmwareProcessor::getInstance()->Clear();
52+
}
53+
54+
CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block)
55+
{
56+
return OTAUtilityFirmwareProcessor::getInstance()->ProcessInternal917(block);
57+
}
58+
59+
CHIP_ERROR OTAFirmwareProcessor::ProcessDescriptor(ByteSpan & block)
60+
{
61+
OTADataAccumulator *mAccumulator = &OTAUtilityFirmwareProcessor::getInstance()->mAccumulator;
62+
ReturnErrorOnFailure(mAccumulator->Accumulate(block));
63+
ReturnErrorOnFailure(mCallbackProcessDescriptor(static_cast<void *>(mAccumulator->data())));
64+
return OTAUtilityFirmwareProcessor::getInstance()->ProcessDescriptor(block);
65+
}
66+
67+
CHIP_ERROR OTAFirmwareProcessor::ApplyAction()
68+
{
69+
return OTAUtilityFirmwareProcessor::getInstance()->ApplyAction917();
70+
}
71+
72+
CHIP_ERROR OTAFirmwareProcessor::FinalizeAction()
73+
{
74+
return OTAUtilityFirmwareProcessor::getInstance()->FinalizeAction917();
75+
}
76+
77+
} // namespace chip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <lib/support/Span.h>
22+
#include <platform/silabs/multi-ota/OTATlvProcessor.h>
23+
#include "OTAUtilityFirmwareProcessor.h"
24+
25+
namespace chip {
26+
27+
class OTAFirmwareProcessor : public OTATlvProcessor
28+
{
29+
public:
30+
struct Descriptor
31+
{
32+
uint32_t version;
33+
char versionString[kVersionStringSize];
34+
char buildDate[kBuildDateSize];
35+
};
36+
37+
CHIP_ERROR Init() override;
38+
CHIP_ERROR Clear() override;
39+
CHIP_ERROR ApplyAction() override;
40+
CHIP_ERROR FinalizeAction() override;
41+
private:
42+
CHIP_ERROR ProcessInternal(ByteSpan & block) override;
43+
CHIP_ERROR ProcessDescriptor(ByteSpan & block);
44+
};
45+
46+
} // namespace chip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <include/platform/CHIPDeviceLayer.h>
20+
#include <platform/silabs/multi-ota/OTAMultiImageProcessorImpl.h>
21+
22+
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
23+
24+
#include <platform/silabs/multi-ota/efr32/OTAFirmwareProcessor.h>
25+
26+
CHIP_ERROR chip::OTAMultiImageProcessorImpl::ProcessDescriptor(void * descriptor)
27+
{
28+
auto desc = static_cast<chip::OTAFirmwareProcessor::Descriptor *>(descriptor);
29+
ChipLogDetail(SoftwareUpdate, "Descriptor: %ld, %s, %s", desc->version, desc->versionString, desc->buildDate);
30+
31+
return CHIP_NO_ERROR;
32+
}
33+
34+
CHIP_ERROR chip::OTAMultiImageProcessorImpl::OtaHookInit()
35+
{
36+
static chip::OTAFirmwareProcessor sApplicationProcessor;
37+
38+
sApplicationProcessor.RegisterDescriptorCallback(ProcessDescriptor);
39+
40+
auto & imageProcessor = chip::OTAMultiImageProcessorImpl::GetDefaultInstance();
41+
ReturnErrorOnFailure(imageProcessor.RegisterProcessor(6, &sApplicationProcessor));
42+
43+
return CHIP_NO_ERROR;
44+
}

0 commit comments

Comments
 (0)