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

[nrfconnect][ota] Change image checking condition for OTA. #28983

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 1 addition & 5 deletions examples/all-clusters-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down
6 changes: 1 addition & 5 deletions examples/light-switch-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize Timers
Expand Down
14 changes: 5 additions & 9 deletions examples/lighting-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ CHIP_ERROR AppTask::Init()
GetDFUOverSMP().ConfirmNewImage();
#endif

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
OtaConfirmNewImage();
#endif

// Initialize lighting device (PWM)
uint8_t minLightLevel = kDefaultMinLevel;
Clusters::LevelControl::Attributes::MinLevel::Get(kLightEndpointId, &minLightLevel);
Expand All @@ -217,15 +222,6 @@ CHIP_ERROR AppTask::Init()
}
mPWMDevice.SetCallbacks(ActionInitiated, ActionCompleted);

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
#endif

// Initialize CHIP server
#if CONFIG_CHIP_FACTORY_DATA
ReturnErrorOnFailure(mFactoryDataProvider.Init());
Expand Down
6 changes: 1 addition & 5 deletions examples/lock-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down
20 changes: 15 additions & 5 deletions examples/platform/nrfconnect/util/OTAUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,30 @@ void InitBasicOTARequestor()
imageProcessor.TriggerFlashAction(ExternalFlashManager::Action::SLEEP);
}

CHIP_ERROR OtaConfirmNewImage()
void OtaConfirmNewImage()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifndef CONFIG_SOC_SERIES_NRF53X
/* Check if the image is run in the REVERT mode and eventually
confirm it to prevent reverting on the next boot.
On nRF53 target there is not way to verify current swap type
because we use permanent swap so we can skip it. */
VerifyOrReturn(mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT);
#endif

OTAImageProcessorImpl & imageProcessor = GetOTAImageProcessor();
if (imageProcessor.IsFirstImageRun())
if (!boot_is_img_confirmed())
{
CHIP_ERROR err = System::MapErrorZephyr(boot_write_img_confirmed());
if (CHIP_NO_ERROR == err)
{
imageProcessor.SetImageConfirmed();
ChipLogProgress(SoftwareUpdate, "New firmware image confirmed");
}
else
{
ChipLogError(SoftwareUpdate, "Failed to confirm firmware image, it will be reverted on the next boot");
}
}
ChipLogError(SoftwareUpdate, "Failed to confirm firmware image, it will be reverted on the next boot");
return err;
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/nrfconnect/util/include/OTAUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void InitBasicOTARequestor();
* boot after the OTA update.
* Other CHIP_ERROR codes if the image could not be confirmed.
*/
CHIP_ERROR OtaConfirmNewImage();
void OtaConfirmNewImage();

#endif // CONFIG_CHIP_OTA_REQUESTOR

Expand Down
6 changes: 1 addition & 5 deletions examples/pump-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down
6 changes: 1 addition & 5 deletions examples/pump-controller-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down
6 changes: 1 addition & 5 deletions examples/window-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ CHIP_ERROR AppTask::Init()

#ifdef CONFIG_CHIP_OTA_REQUESTOR
/* OTA image confirmation must be done before the factory data init. */
err = OtaConfirmNewImage();
if (err != CHIP_NO_ERROR)
{
return err;
}
OtaConfirmNewImage();
#endif

// Initialize CHIP server
Expand Down