Skip to content

Commit 8bef5e3

Browse files
align to OTA suit
1 parent 01f9bdc commit 8bef5e3

File tree

5 files changed

+53
-106
lines changed

5 files changed

+53
-106
lines changed

config/nrfconnect/chip-module/Kconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ config CHIP_OTA_REQUESTOR
6060
bool
6161
imply DFU_MULTI_IMAGE
6262
imply DFU_TARGET
63-
imply BOOTLOADER_MCUBOOT
64-
imply IMG_MANAGER
63+
imply BOOTLOADER_MCUBOOT if !CHIP_SUIT
64+
imply IMG_MANAGER if !CHIP_SUIT
6565
imply STREAM_FLASH
6666
imply STREAM_FLASH_ERASE
6767

config/nrfconnect/chip-module/Kconfig.defaults

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ config BOOT_IMAGE_ACCESS_HOOKS
214214
config UPDATEABLE_IMAGE_NUMBER
215215
default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE
216216
default 2 if SOC_SERIES_NRF53X
217+
default 1 if SUIT
217218

218219
config DFU_MULTI_IMAGE_MAX_IMAGE_COUNT
219220
default 3 if NRF_WIFI_PATCHES_EXT_FLASH_STORE

config/zephyr/ota-image.cmake

+42-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ function(chip_ota_image TARGET_NAME)
3030
message(FATAL_ERROR "Both INPUT_FILES and OUTPUT_FILE arguments must be specified")
3131
endif()
3232

33+
if(SYSBUILD)
34+
sysbuild_get(CONFIG_CHIP_DEVICE_SOFTWARE_VERSION IMAGE ${DEFAULT_IMAGE} VAR CONFIG_CHIP_DEVICE_SOFTWARE_VERSION KCONFIG)
35+
sysbuild_get(CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING IMAGE ${DEFAULT_IMAGE} VAR CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING KCONFIG)
36+
sysbuild_get(CONFIG_CHIP_DEVICE_VENDOR_ID IMAGE ${DEFAULT_IMAGE} VAR CONFIG_CHIP_DEVICE_VENDOR_ID KCONFIG)
37+
sysbuild_get(CONFIG_CHIP_DEVICE_PRODUCT_ID IMAGE ${DEFAULT_IMAGE} VAR CONFIG_CHIP_DEVICE_PRODUCT_ID KCONFIG)
38+
endif()
39+
3340
# Prepare ota_image_tool.py argument list
3441
if(DEFINED APPVERSION)
3542
set(OTA_ARGS
@@ -44,6 +51,33 @@ function(chip_ota_image TARGET_NAME)
4451
"--digest-algorithm"
4552
"sha256"
4653
)
54+
elseif(EXISTS ${APP_DIR}/VERSION)
55+
file(READ ${APP_DIR}/VERSION ver)
56+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${APP_DIR}/VERSION)
57+
string(REGEX MATCH "VERSION_MAJOR = ([0-9]*)" _ ${ver})
58+
set(app_version_major ${CMAKE_MATCH_1})
59+
string(REGEX MATCH "VERSION_MINOR = ([0-9]*)" _ ${ver})
60+
set(app_version_minor ${CMAKE_MATCH_1})
61+
string(REGEX MATCH "PATCHLEVEL = ([0-9]*)" _ ${ver})
62+
set(app_version_patchlevel ${CMAKE_MATCH_1})
63+
string(REGEX MATCH "VERSION_TWEAK = ([0-9]*)" _ ${ver})
64+
set(app_version_tweak ${CMAKE_MATCH_1})
65+
66+
set(APP_VERSION_STRING "${app_version_major}.${app_version_minor}.${app_version_patchlevel}+${app_version_tweak}")
67+
math(EXPR APPVERSION "(${app_version_major} << 24) | (${app_version_minor} << 16) | (${app_version_patchlevel} << 8) | ${app_version_tweak}" OUTPUT_FORMAT HEXADECIMAL)
68+
69+
set(OTA_ARGS
70+
"--vendor-id"
71+
${CONFIG_CHIP_DEVICE_VENDOR_ID}
72+
"--product-id"
73+
${CONFIG_CHIP_DEVICE_PRODUCT_ID}
74+
"--version"
75+
${APPVERSION}
76+
"--version-str"
77+
${APP_VERSION_STRING}
78+
"--digest-algorithm"
79+
"sha256"
80+
)
4781
else()
4882
set(OTA_ARGS
4983
"--vendor-id"
@@ -74,9 +108,15 @@ function(chip_ota_image TARGET_NAME)
74108
CONTENT ${OTA_ARGS}
75109
)
76110

111+
if (CHIP_ROOT)
112+
set(CONNECTEDHOMEIP_ROOT ${CHIP_ROOT})
113+
else()
114+
set(CONNECTEDHOMEIP_ROOT ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR})
115+
endif()
116+
77117
add_custom_command(OUTPUT ${ARG_OUTPUT_FILE}
78-
COMMAND ${Python3_EXECUTABLE} ${CHIP_ROOT}/src/app/ota_image_tool.py create @${ARG_OUTPUT_FILE}.args
79-
DEPENDS ${ARG_INPUT_FILES} ${CHIP_ROOT}/src/app/ota_image_tool.py
118+
COMMAND ${Python3_EXECUTABLE} ${CONNECTEDHOMEIP_ROOT}/src/app/ota_image_tool.py create @${ARG_OUTPUT_FILE}.args
119+
DEPENDS ${ARG_INPUT_FILES} ${CONNECTEDHOMEIP_ROOT}/src/app/ota_image_tool.py
80120
)
81121

82122
add_custom_target(${TARGET_NAME} ALL

config/zephyr/ota-image_sysbuild.cmake

-102
This file was deleted.

src/platform/nrfconnect/OTAImageProcessorImpl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333

3434
#include <dfu/dfu_multi_image.h>
3535
#include <dfu/dfu_target.h>
36+
#ifdef CONFIG_BOOTLOADER_MCUBOOT
3637
#include <dfu/dfu_target_mcuboot.h>
3738
#include <zephyr/dfu/mcuboot.h>
39+
#elif defined(CONFIG_SUIT)
40+
#include <dfu/dfu_target_suit.h>
41+
#endif
3842
#include <zephyr/logging/log.h>
3943
#include <zephyr/pm/device.h>
4044

@@ -75,7 +79,11 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl()
7579
{
7680
mHeaderParser.Init();
7781
mParams = {};
82+
#ifdef CONFIG_BOOTLOADER_MCUBOOT
7883
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_mcuboot_set_buf(mBuffer, sizeof(mBuffer))));
84+
#elif defined(CONFIG_SUIT)
85+
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_suit_set_buf(mBuffer, sizeof(mBuffer))));
86+
#endif
7987
ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_init(mBuffer, sizeof(mBuffer))));
8088

8189
for (int image_id = 0; image_id < CONFIG_UPDATEABLE_IMAGE_NUMBER; ++image_id)

0 commit comments

Comments
 (0)