Skip to content

Commit 7a815f6

Browse files
authored
[OIS] OTA requestor and DFU implementation (#27573)
* [OIS] Add OTAImageProcessorImpl class Provides the implementation of the OTA Image Processor class for Open IOT SDK platform. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Add Matter OTA support Add Device Firmware Update manager class implementation. It provides firmware update functionality based on Matter OTA Requestor cluster. Add OTA enable support flag in Cmake build, passing it to Matter stack build. Add DFU manager to OIS platform code. Add post-build command to create OTA update image from signed binary. Extend OIS example documentation with TF-M and DFU support. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Add OTA Requestor application OIS implementation of OTA requestor example. Add new example to build script and VScode tasks. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Extend integration tests suite Add updateBinaryPath, otaProvider and softwareVersion options to OIS integraiton test suite. Propagating them to fixtures module. Add terminal device implementation. Run Linux applications as subprocess, read/write process output/input. Add ota_provider fixture - run OTA provider application as terminal device. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Add OTA requestor integration test and CI Add OTA requestor integration test implementation. Add OTA requestor test options in run script. Extending OIS workflow with build the OTA requestor example, build the OTA provider (Linux), test OTA requestor example. Signed-off-by: ATmobica <artur.tynecki@arm.com> --------- Signed-off-by: ATmobica <artur.tynecki@arm.com>
1 parent 9cfbdfe commit 7a815f6

29 files changed

+1966
-2
lines changed

.github/workflows/examples-openiotsdk.yaml

+31-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Checkout submodules & Bootstrap
5050
uses: ./.github/actions/checkout-submodules-and-bootstrap
5151
with:
52-
platform: openiotsdk
52+
platform: openiotsdk linux
5353
extra-submodule-parameters: " --recursive"
5454

5555
- name: Set up environment for size reports
@@ -101,11 +101,28 @@ jobs:
101101
examples/all-clusters-app/openiotsdk/build/chip-openiotsdk-all-clusters-app-example.elf \
102102
/tmp/bloat_reports/
103103
104+
- name: Build ota-requestor-app example
105+
id: build_ota_requestor_app
106+
timeout-minutes: 10
107+
run: |
108+
scripts/examples/openiotsdk_example.sh -v 1 -V 0.0.1 ota-requestor-app
109+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
110+
openiotsdk release ota-requestor-app \
111+
examples/ota-requestor-app/openiotsdk/build/chip-openiotsdk-ota-requestor-app-example.elf \
112+
/tmp/bloat_reports/
113+
104114
- name: Build unit tests (mbedtls)
105115
id: build_unit_tests_mbedtls
106116
run: |
107117
scripts/examples/openiotsdk_example.sh -b mbedtls unit-tests
108118
119+
- name: Build the OTA provider (Linux)
120+
id: build_ota_provider_app
121+
if: steps.build_ota_requestor_app.outcome == 'success'
122+
timeout-minutes: 10
123+
run: |
124+
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux/ out/ota-provider chip_config_network_layer_ble=false
125+
109126
- name: "Test: shell example"
110127
if: steps.build_shell.outcome == 'success'
111128
run: |
@@ -138,6 +155,19 @@ jobs:
138155
'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap all-clusters-app'
139156
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down
140157
158+
- name: "Test: ota-requestor-app example"
159+
if: steps.build_ota_requestor_app.outcome == 'success' && steps.build_ota_provider_app.outcome == 'success'
160+
timeout-minutes: 30
161+
run: |
162+
mkdir out/binaries
163+
cp examples/ota-requestor-app/openiotsdk/build/chip-openiotsdk-ota-requestor-app-example.elf out/binaries/
164+
scripts/examples/openiotsdk_example.sh -c -v 2 -V 0.0.2 ota-requestor-app
165+
cp examples/ota-requestor-app/openiotsdk/build/chip-openiotsdk-ota-requestor-app-example.ota out/binaries/
166+
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME up
167+
scripts/run_in_python_env.sh out/venv \
168+
'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -p out/binaries -v 2 -V 0.0.2 -C test -n ${TEST_NETWORK_NAME}tap ota-requestor-app'
169+
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down
170+
141171
- name: "Test: unit-tests (mbedtls)"
142172
if: steps.build_unit_tests_mbedtls.outcome == 'success'
143173
run: |

config/openiotsdk/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ matter_add_gn_arg_bool ("chip_error_logging" CONFIG_CHIP_ERRO
6464
matter_add_gn_arg_string("chip_crypto" "${CONFIG_CHIP_CRYPTO}")
6565
matter_add_gn_arg_string("chip_openiotsdk_software_version" "${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION}")
6666
matter_add_gn_arg_string("chip_openiotsdk_software_version_string" "${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING}")
67+
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OPEN_IOT_SDK_OTA_ENABLE)
6768
if (TARGET cmsis-rtos-api)
6869
matter_add_gn_arg_string("target_os" "cmsis-rtos")
6970
endif()

config/openiotsdk/cmake/chip.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ set(CONFIG_CHIP_ERROR_LOGGING YES CACHE BOOL "Enable logging at error level")
3535
set(CONFIG_CHIP_CRYPTO "mbedtls" CACHE STRING "Matter crypto backend. Mbedtls as default")
3636
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION "0" CACHE STRING "Software version number")
3737
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING ${TFM_NS_APP_VERSION} CACHE STRING "Software version in string format x.x.x")
38+
set(CONFIG_CHIP_OPEN_IOT_SDK_OTA_ENABLE NO CACHE BOOL "Enable OTA support")
3839
set(CONFIG_GN_DEPENDENCIES "")
3940

4041
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")

config/openiotsdk/cmake/sdk.cmake

+36
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,42 @@ function(sdk_post_build target)
300300
VERBATIM
301301
)
302302
iotsdk_tf_m_merge_images(${target} 0x10000000 0x38000000 0x28060000)
303+
if(CONFIG_CHIP_OPEN_IOT_SDK_OTA_ENABLE)
304+
add_custom_command(
305+
TARGET
306+
${target}
307+
POST_BUILD
308+
DEPENDS
309+
$<TARGET_FILE_DIR:${target}>/${target}.bin
310+
COMMAND
311+
# Sign the update image
312+
python3 ${BINARY_DIR}/install/image_signing/scripts/wrapper/wrapper.py
313+
--layout ${BINARY_DIR}/install/image_signing/layout_files/signing_layout_ns.o
314+
-v ${MCUBOOT_IMAGE_VERSION_NS}
315+
-k ${BINARY_DIR}/install/image_signing/keys/root-RSA-3072_1.pem
316+
--public-key-format full
317+
--align 1 --pad-header -H 0x400 -s auto -d "(0, 0.0.0+0)"
318+
$<TARGET_FILE_DIR:${target}>/${target}.bin
319+
--overwrite-only
320+
--measured-boot-record
321+
$<TARGET_FILE_DIR:${target}>/${target}_signed.ota
322+
COMMAND
323+
# Create OTA udpate file
324+
${CHIP_ROOT}/src/app/ota_image_tool.py
325+
create
326+
-v 0xfff1 -p 0x8001
327+
-vn ${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION}
328+
-vs "${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING}"
329+
-da sha256
330+
$<TARGET_FILE_DIR:${target}>/${target}_signed.ota
331+
$<TARGET_FILE_DIR:${target}>/${APP_NAME}.ota
332+
# Cleanup
333+
COMMAND rm
334+
ARGS -Rf
335+
$<TARGET_FILE_DIR:${target}>/${target}_signed.ota
336+
VERBATIM
337+
)
338+
endif()
303339
# Cleanup
304340
add_custom_command(
305341
TARGET

docs/guides/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [Open IoT SDK - Examples](./openiotsdk_examples.md)
2828
- [Open IoT SDK - Unit Tests](./openiotsdk_unit_tests.md)
2929
- [Open IoT SDK - Commissioning](./openiotsdk_commissioning.md)
30+
- [Open IoT SDK - Software Update](./openiotsdk_examples_software_update.md)
3031

3132
## Development Guides
3233

docs/guides/openiotsdk_examples.md

+46-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ shell
1212
lock-app
1313
tv-app
1414
all-clusters-app
15+
ota-requestor-app
1516
```
1617

1718
You can use these examples as a reference for creating your own applications.
@@ -291,7 +292,20 @@ Processing Environment (`NSPE`). The bootloader and the secure part are also
291292
built from `TF-M` sources. All components are merged into a single executable
292293
file at the end of the building process.
293294
294-
You can also provide the own version of Matter example by setting
295+
The project-specific configuration of `TF-M` can be provide by defining its own
296+
header file for `TF-M` config and passing the path to it via the
297+
`TFM_PROJECT_CONFIG_HEADER_FILE` variable.
298+
299+
```
300+
set(TFM_PROJECT_CONFIG_HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tf-m-config/TfmProjectConfig.h")
301+
```
302+
303+
If the project-specific configuration is not provided the base `TF-M` settings
304+
are used
305+
[config_base.h](https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/tree/config/config_base.h).
306+
It can be used as a pattern for the custom configuration header.
307+
308+
You can also provide your own version of a Matter example by setting the
295309
`TFM_NS_APP_VERSION` variable.
296310
297311
```
@@ -365,6 +379,37 @@ cmake -G <...> -DCONFIG_CHIP_CRYPTO=<mbedtls | psa> <...>
365379
> The `TF-M PSA crypto` option requires enabling [TF-M](#trusted-firmware-m)
366380
> support.
367381
382+
### Device Firmware Update
383+
384+
Device Firmware Update (`DFU`) can be enabled in the application by setting the
385+
`CONFIG_CHIP_OPEN_IOT_SDK_OTA_ENABLE` variable:
386+
387+
```
388+
set(CONFIG_CHIP_OPEN_IOT_SDK_OTA_ENABLE YES)
389+
```
390+
391+
This provides the proper service for Matter's `OTA Requestor` cluster. The
392+
[TF-M Firmware Update Service](https://arm-software.github.io/psa-api/fwu/1.0/)
393+
is the backend for all firmware update operations. The `DFU Manager` module is
394+
attached to the application and allows full usage of the `OTA Requestor`
395+
cluster.
396+
397+
You can also provide your own version of the Matter example to the Matter stack
398+
by setting `CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION` and
399+
`CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING` variables.
400+
401+
```
402+
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION "1")
403+
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING "0.0.1")
404+
```
405+
406+
The default value for `CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING` is set
407+
to `TFM_NS_APP_VERSION`.
408+
409+
> 💡 **Notes**:
410+
>
411+
> The `DFU` option requires enabling [TF-M](#trusted-firmware-m) support.
412+
368413
## Building
369414
370415
You can build examples using the dedicated VSCode task or by calling directly

0 commit comments

Comments
 (0)