Skip to content

Commit 79aa09c

Browse files
[nrfconnect] Minor OTA Requestor fixes (project-chip#18607)
1. Increase the default sleep time between emitting the shutdown event and rebooting the device to apply a new image. That is to increase chances of delivering the event to subscribers. 2. Do not auto-confirm a new image using the DFUoverSMP module when OTA Requestor is enabled. In such a case, it is the OTA Requestor's job to confirm the image and notify OTA Provider that it has just happened. 3. Limit UPGRADE_ONLY mode to nRF53 (it was mistakenly enabled for all Nordic boards). 4. Change OTAImageProcessorImpl::IsFirstImageRun impl to make it work even if UPGRADE_ONLY mode is enabled. Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
1 parent b47f90a commit 79aa09c

File tree

9 files changed

+31
-7
lines changed

9 files changed

+31
-7
lines changed

config/nrfconnect/chip-module/Kconfig.mcuboot.defaults

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ config BOOT_ENCRYPT_X25519
3636
bool
3737
default n
3838

39-
choice BOOT_IMAGE_UPGRADE_MODE
40-
default BOOT_UPGRADE_ONLY
41-
endchoice
42-
4339
config BOOT_BOOTSTRAP
4440
bool
4541
default n
@@ -119,6 +115,11 @@ config UPDATEABLE_IMAGE_NUMBER
119115
int
120116
default 2
121117

118+
# Multi-image updates do not support image swapping yet.
119+
choice BOOT_IMAGE_UPGRADE_MODE
120+
default BOOT_UPGRADE_ONLY
121+
endchoice
122+
122123
# The network core cannot access external flash directly. The flash simulator must be used to
123124
# provide a memory region that is used to forward the new firmware to the network core.
124125
config FLASH_SIMULATOR

examples/light-switch-app/nrfconnect/main/AppTask.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ CHIP_ERROR AppTask::Init()
153153
// Initialize DFU
154154
#ifdef CONFIG_MCUMGR_SMP_BT
155155
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
156+
#ifndef CONFIG_CHIP_OTA_REQUESTOR
157+
// When OTA Requestor is enabled, it is responsible for confirming new images.
156158
GetDFUOverSMP().ConfirmNewImage();
159+
#endif
157160
#endif
158161

159162
// Print initial configs

examples/lighting-app/nrfconnect/main/AppTask.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ CHIP_ERROR AppTask::Init()
161161
#ifdef CONFIG_MCUMGR_SMP_BT
162162
// Initialize DFU over SMP
163163
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
164+
#ifndef CONFIG_CHIP_OTA_REQUESTOR
165+
// When OTA Requestor is enabled, it is responsible for confirming new images.
164166
GetDFUOverSMP().ConfirmNewImage();
167+
#endif
165168
#endif
166169

167170
// Initialize CHIP server

examples/lock-app/nrfconnect/main/AppTask.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ CHIP_ERROR AppTask::Init()
145145
#ifdef CONFIG_MCUMGR_SMP_BT
146146
// Initialize DFU over SMP
147147
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
148+
#ifndef CONFIG_CHIP_OTA_REQUESTOR
149+
// When OTA Requestor is enabled, it is responsible for confirming new images.
148150
GetDFUOverSMP().ConfirmNewImage();
151+
#endif
149152
#endif
150153

151154
// Initialize CHIP server

examples/platform/nrfconnect/util/OTAUtil.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ void InitBasicOTARequestor()
5353
sBDXDownloader.SetImageProcessorDelegate(&imageProcessor);
5454
sOTARequestorStorage.Init(Server::GetInstance().GetPersistentStorage());
5555
sOTARequestor.Init(Server::GetInstance(), sOTARequestorStorage, sOTARequestorDriver, sBDXDownloader);
56-
sOTARequestorDriver.Init(&sOTARequestor, &imageProcessor);
5756
chip::SetRequestorInstance(&sOTARequestor);
57+
sOTARequestorDriver.Init(&sOTARequestor, &imageProcessor);
5858
}

examples/pump-app/nrfconnect/main/AppTask.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ CHIP_ERROR AppTask::Init()
141141
#ifdef CONFIG_MCUMGR_SMP_BT
142142
// Initialize DFU over SMP
143143
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
144+
#ifndef CONFIG_CHIP_OTA_REQUESTOR
145+
// When OTA Requestor is enabled, it is responsible for confirming new images.
144146
GetDFUOverSMP().ConfirmNewImage();
147+
#endif
145148
#endif
146149

147150
// Initialize CHIP server

examples/pump-controller-app/nrfconnect/main/AppTask.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ CHIP_ERROR AppTask::Init()
138138
#ifdef CONFIG_MCUMGR_SMP_BT
139139
// Initialize DFU over SMP
140140
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
141+
#ifndef CONFIG_CHIP_OTA_REQUESTOR
142+
// When OTA Requestor is enabled, it is responsible for confirming new images.
141143
GetDFUOverSMP().ConfirmNewImage();
144+
#endif
142145
#endif
143146

144147
// Initialize CHIP server

src/platform/nrfconnect/CHIPDevicePlatformConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
#ifndef CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS
7171
/// Time to sleep after running server shutdown actions to let lower layers complete the actions.
7272
/// This may include transmitting packets created by the actions.
73-
#define CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS 10
73+
#define CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS 500
7474
#endif // CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS
7575

7676
#ifndef CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO

src/platform/nrfconnect/OTAImageProcessorImpl.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "OTAImageProcessorImpl.h"
1919

2020
#include <app/clusters/ota-requestor/OTADownloader.h>
21+
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
2122
#include <lib/support/CodeUtils.h>
2223
#include <platform/CHIPDeviceLayer.h>
2324
#include <system/SystemError.h>
@@ -160,7 +161,14 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & aBlock)
160161

161162
bool OTAImageProcessorImpl::IsFirstImageRun()
162163
{
163-
return mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT;
164+
OTARequestorInterface * requestor = GetRequestorInstance();
165+
ReturnErrorCodeIf(requestor == nullptr, false);
166+
167+
uint32_t currentVersion;
168+
ReturnErrorCodeIf(ConfigurationMgr().GetSoftwareVersion(currentVersion) != CHIP_NO_ERROR, false);
169+
170+
return requestor->GetCurrentUpdateState() == OTARequestorInterface::OTAUpdateStateEnum::kApplying &&
171+
requestor->GetTargetVersion() == currentVersion;
164172
}
165173

166174
CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage()

0 commit comments

Comments
 (0)