@@ -103,8 +103,7 @@ bool OTAImageProcessorImpl::IsFirstImageRun()
103
103
104
104
requestor = GetRequestorInstance ();
105
105
106
- return (requestor->GetTargetVersion () == runningSwVer) &&
107
- (requestor->GetCurrentUpdateState () == chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying );
106
+ return (requestor->GetCurrentUpdateState () == chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying );
108
107
}
109
108
110
109
/* makes room for the new block if needed */
@@ -167,7 +166,7 @@ static bool writeExtFlashImgPages(NVS_Handle handle, ssize_t offset, MutableByte
167
166
}
168
167
169
168
/* Erase the MCUBoot slot */
170
- #define BOOT_SLOT_SIZE (0x000F6000 ) /* must match flash_map_backend */
169
+ #define BOOT_SLOT_SIZE (0x000F2000 ) /* must match flash_map_backend */
171
170
static bool eraseExtSlot (NVS_Handle handle)
172
171
{
173
172
int_fast16_t status;
@@ -200,6 +199,22 @@ static bool eraseExtHeader(NVS_Handle handle)
200
199
201
200
CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage ()
202
201
{
202
+ OTARequestorInterface * requestor = chip::GetRequestorInstance ();
203
+ if (requestor == nullptr )
204
+ {
205
+ return CHIP_ERROR_INTERNAL;
206
+ }
207
+
208
+ uint32_t currentVersion;
209
+ uint32_t targetVersion = requestor->GetTargetVersion ();
210
+ ReturnErrorOnFailure (DeviceLayer::ConfigurationMgr ().GetSoftwareVersion (currentVersion));
211
+ if (currentVersion != targetVersion)
212
+ {
213
+ ChipLogError (SoftwareUpdate, " Current software version = %" PRIu32 " , expected software version = %" PRIu32, currentVersion,
214
+ targetVersion);
215
+ return CHIP_ERROR_INCORRECT_STATE;
216
+ }
217
+
203
218
return CHIP_NO_ERROR;
204
219
}
205
220
@@ -268,6 +283,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context)
268
283
}
269
284
270
285
/* reset SoC to kick MCUBoot */
286
+ ChipLogProgress (SoftwareUpdate," Resetting device to kick off MCUBoot" );
271
287
SysCtrlSystemReset ();
272
288
}
273
289
0 commit comments