@@ -30,6 +30,13 @@ function(chip_ota_image TARGET_NAME)
30
30
message (FATAL_ERROR "Both INPUT_FILES and OUTPUT_FILE arguments must be specified" )
31
31
endif ()
32
32
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
+
33
40
# Prepare ota_image_tool.py argument list
34
41
if (DEFINED APPVERSION)
35
42
set (OTA_ARGS
@@ -44,6 +51,33 @@ function(chip_ota_image TARGET_NAME)
44
51
"--digest-algorithm"
45
52
"sha256"
46
53
)
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
+ )
47
81
else ()
48
82
set (OTA_ARGS
49
83
"--vendor-id"
@@ -74,9 +108,15 @@ function(chip_ota_image TARGET_NAME)
74
108
CONTENT ${OTA_ARGS}
75
109
)
76
110
111
+ if (CHIP_ROOT)
112
+ set (CONNECTEDHOMEIP_ROOT ${CHIP_ROOT} )
113
+ else ()
114
+ set (CONNECTEDHOMEIP_ROOT ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR} )
115
+ endif ()
116
+
77
117
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
80
120
)
81
121
82
122
add_custom_target (${TARGET_NAME} ALL
0 commit comments