Skip to content

Commit

Permalink
[NXP][ZEPHYR] Add option to mark OTA image as permanent or as a test (#…
Browse files Browse the repository at this point in the history
…32721)

* [NXP][ZEPHYR] Remove deprecated Kconfigs

* [NXP][ZEPHYR] Add option to mark OTA image as permanent or as a test

* [NXP][DOC] Update zephyr_ota doc

* Restyled by prettier-markdown

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Apr 3, 2024
1 parent 748aeeb commit 1348216
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
20 changes: 20 additions & 0 deletions config/nxp/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,23 @@ config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY
Reboots the device automatically after downloading a new firmware update
to swap the old and the new firmware images. The reboot happens only when
a user consents to apply the firmware update.

choice CHIP_OTA_REQUEST_UPGRADE_TYPE
prompt "Type of the upgrade to apply on new images"
default CHIP_OTA_REQUEST_UPGRADE_TEST
depends on CHIP_OTA_REQUESTOR

config CHIP_OTA_REQUEST_UPGRADE_PERMANENT
bool "Mark the image as permanent"
help
The upgrade will be permanent on the next reboot.
No coming back to the old image.

config CHIP_OTA_REQUEST_UPGRADE_TEST
bool "Mark the image as a test"
help
The upgrade will be marked as a test.
Image will be run on the next reboot, if confirmed it
becomes permanent, otherwise the new image is reverted.

endchoice
5 changes: 1 addition & 4 deletions config/nxp/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ choice NET_TC_THREAD_TYPE
default NET_TC_THREAD_PREEMPTIVE
endchoice

config NET_TCP_WORK_QUEUE_THREAD_PRIO
config NET_TCP_WORKER_PRIO
default -16

config NET_TC_TX_THREAD_BASE_PRIO
Expand Down Expand Up @@ -406,6 +406,3 @@ config FLASH_SHELL
endif # SHELL

endif

config NXP_FW_LOADER_MONOLITHIC
default y if NXP_FW_LOADER
18 changes: 17 additions & 1 deletion docs/guides/nxp_zephyr_ota_software_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ and `CONFIG_MCUBOOT_SIGNATURE_KEY_FILE` needs to point to that same key.
paths starts from the MCUBoot repository root. This option can be changed
in: `config/nxp/app/bootloader.conf`

- `CONFIG_BOOT_SIGNATURE_KEY_FILE`: This is used for the application to be
- `CONFIG_MCUBOOT_SIGNATURE_KEY_FILE`: This is used for the application to be
loaded by the bootloader. The path can be either absolute or relative.
Relative paths starts from the west workspace location. This option can be
changed in the application .conf files.
Expand All @@ -124,6 +124,22 @@ Refer to those two files for more information:
- [MCUBoot Config used for the MCUBoot Image](https://github.com/zephyrproject-rtos/mcuboot/blob/main/boot/zephyr/Kconfig)
- [MCUBoot Config used for the application](https://github.com/zephyrproject-rtos/zephyr/blob/main/modules/Kconfig.mcuboot)

When an OTA image is received it can either be marked as permanent or as a test,
The Kconfig `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TYPE` can choose one of those
configurations (Defined in `/config/nxp/chip-module/Kconfig`):

- `CONFIG_CHIP_OTA_REQUEST_UPGRADE_PERMANENT`: From the next reboot, this
image will be run permanently.
- `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TEST`: The image will be run on the next
reboot, but it will be reverted if it doesn't get confirmed. The image needs
to confirm itself to become permanent.

By default, the upgrade type used is `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TEST`, and
OTA image confirms itself during the initialization stage after the fundamental
parts of the application are initialized properly to make sure this new image
boots correctly. This confirmation is done by
`chip::NXP::App::OTARequestorInitiator::HandleSelfTest()`.

JLink can be used to flash the mixed binary at the base address 0x8000000, using
the command :

Expand Down
8 changes: 7 additions & 1 deletion src/platform/nxp/zephyr/ota/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

static struct stream_flash_ctx stream;

#ifdef CONFIG_CHIP_OTA_REQUEST_UPGRADE_PERMANENT
#define UPDATE_TYPE BOOT_UPGRADE_PERMANENT
#else
#define UPDATE_TYPE BOOT_UPGRADE_TEST
#endif

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -85,7 +91,7 @@ CHIP_ERROR OTAImageProcessorImpl::Abort()
CHIP_ERROR OTAImageProcessorImpl::Apply()
{
// Schedule update of image
int err = boot_request_upgrade(BOOT_UPGRADE_PERMANENT);
int err = boot_request_upgrade(UPDATE_TYPE);

#ifdef CONFIG_CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY
if (!err)
Expand Down

0 comments on commit 1348216

Please sign in to comment.