Skip to content

Commit 073f0bc

Browse files
[NXP][ZEPHYR] Add option to mark OTA image as permanent or as a test (project-chip#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>
1 parent f7db85e commit 073f0bc

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

config/nxp/chip-module/Kconfig

+20
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,23 @@ config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY
256256
Reboots the device automatically after downloading a new firmware update
257257
to swap the old and the new firmware images. The reboot happens only when
258258
a user consents to apply the firmware update.
259+
260+
choice CHIP_OTA_REQUEST_UPGRADE_TYPE
261+
prompt "Type of the upgrade to apply on new images"
262+
default CHIP_OTA_REQUEST_UPGRADE_TEST
263+
depends on CHIP_OTA_REQUESTOR
264+
265+
config CHIP_OTA_REQUEST_UPGRADE_PERMANENT
266+
bool "Mark the image as permanent"
267+
help
268+
The upgrade will be permanent on the next reboot.
269+
No coming back to the old image.
270+
271+
config CHIP_OTA_REQUEST_UPGRADE_TEST
272+
bool "Mark the image as a test"
273+
help
274+
The upgrade will be marked as a test.
275+
Image will be run on the next reboot, if confirmed it
276+
becomes permanent, otherwise the new image is reverted.
277+
278+
endchoice

config/nxp/chip-module/Kconfig.defaults

+1-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ choice NET_TC_THREAD_TYPE
127127
default NET_TC_THREAD_PREEMPTIVE
128128
endchoice
129129

130-
config NET_TCP_WORK_QUEUE_THREAD_PRIO
130+
config NET_TCP_WORKER_PRIO
131131
default -16
132132

133133
config NET_TC_TX_THREAD_BASE_PRIO
@@ -406,6 +406,3 @@ config FLASH_SHELL
406406
endif # SHELL
407407

408408
endif
409-
410-
config NXP_FW_LOADER_MONOLITHIC
411-
default y if NXP_FW_LOADER

docs/guides/nxp_zephyr_ota_software_update.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ and `CONFIG_MCUBOOT_SIGNATURE_KEY_FILE` needs to point to that same key.
114114
paths starts from the MCUBoot repository root. This option can be changed
115115
in: `config/nxp/app/bootloader.conf`
116116

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

127+
When an OTA image is received it can either be marked as permanent or as a test,
128+
The Kconfig `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TYPE` can choose one of those
129+
configurations (Defined in `/config/nxp/chip-module/Kconfig`):
130+
131+
- `CONFIG_CHIP_OTA_REQUEST_UPGRADE_PERMANENT`: From the next reboot, this
132+
image will be run permanently.
133+
- `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TEST`: The image will be run on the next
134+
reboot, but it will be reverted if it doesn't get confirmed. The image needs
135+
to confirm itself to become permanent.
136+
137+
By default, the upgrade type used is `CONFIG_CHIP_OTA_REQUEST_UPGRADE_TEST`, and
138+
OTA image confirms itself during the initialization stage after the fundamental
139+
parts of the application are initialized properly to make sure this new image
140+
boots correctly. This confirmation is done by
141+
`chip::NXP::App::OTARequestorInitiator::HandleSelfTest()`.
142+
127143
JLink can be used to flash the mixed binary at the base address 0x8000000, using
128144
the command :
129145

src/platform/nxp/zephyr/ota/OTAImageProcessorImpl.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828

2929
static struct stream_flash_ctx stream;
3030

31+
#ifdef CONFIG_CHIP_OTA_REQUEST_UPGRADE_PERMANENT
32+
#define UPDATE_TYPE BOOT_UPGRADE_PERMANENT
33+
#else
34+
#define UPDATE_TYPE BOOT_UPGRADE_TEST
35+
#endif
36+
3137
namespace chip {
3238
namespace DeviceLayer {
3339

@@ -85,7 +91,7 @@ CHIP_ERROR OTAImageProcessorImpl::Abort()
8591
CHIP_ERROR OTAImageProcessorImpl::Apply()
8692
{
8793
// Schedule update of image
88-
int err = boot_request_upgrade(BOOT_UPGRADE_PERMANENT);
94+
int err = boot_request_upgrade(UPDATE_TYPE);
8995

9096
#ifdef CONFIG_CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY
9197
if (!err)

0 commit comments

Comments
 (0)