diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index 7ad83e0a9b68bb..39efab85d61e66 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 00c620e9326e78..7b1a88b1b3ee9a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -107,7 +107,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -237,7 +237,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index 989e263675d9cf..ca77207d322d94 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.5.75 + # image: connectedhomeip/chip-build-cirque:0.5.77 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index e8da8037750c1b..a3ccea381f4060 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.5.75 + image: connectedhomeip/chip-build-doxygen:0.5.77 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 2d5f40b7826883..ab358c4e7721a9 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.5.75 + image: connectedhomeip/chip-build-ti:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 3b71f064e013a8..548909c27aa7bb 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.5.75 + image: connectedhomeip/chip-build-efr32:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 2ac147fcab4366..a6099debcf8ccd 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.75 + image: connectedhomeip/chip-build-esp32:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -118,7 +118,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.75 + image: connectedhomeip/chip-build-esp32:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 35ebc105f73a64..8604a3b6756326 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.5.75 + image: connectedhomeip/chip-build-infineon:0.5.77 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 1bf51ac1e3b070..3342c4f5739884 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.5.75 + image: connectedhomeip/chip-build-k32w:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 6ad5590f00379a..88ffe8491e48df 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.5.75 + image: connectedhomeip/chip-build-crosscompile:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index 300182a55fa450..c1c9971c9dd985 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.5.75 + image: connectedhomeip/chip-build-imx:0.5.77 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 25246dcb4e0683..f557aaeb597f9f 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index f0b4e80cc2f5c3..19d59ad4bad2a8 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.5.75 + image: connectedhomeip/chip-build-mbed-os:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index d29bb9fc3f6d0f..458bf7fa712c80 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.5.75 + image: connectedhomeip/chip-build-nrf-platform:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index ace36d1373e789..278d535dbe0a55 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 12061f605d2a71..58fea93d501b9f 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.5.75 + image: connectedhomeip/chip-build-telink:0.5.77 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 22c4152f0d5902..eeadfd200d916b 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.5.75 + image: connectedhomeip/chip-build-tizen:0.5.77 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 7cbc347042c685..cd278c6c1e75b0 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.75 + image: connectedhomeip/chip-build-android:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index c54fd61836a4b5..c2ecc70cdecd91 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index aba3d6760cc63f..c9e26c8cc97914 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.5.75 + image: connectedhomeip/chip-build-esp32-qemu:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 0ce3451f8c9741..4ab6fcfbe0f6b3 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.5.75 + image: connectedhomeip/chip-build-esp32:0.5.77 steps: - uses: Wandalen/wretry.action@v1.0.15 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.5.75 + image: connectedhomeip/chip-build-efr32:0.5.77 steps: - uses: Wandalen/wretry.action@v1.0.15 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index db5b4fe1331b74..bf59a586b67bde 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.75 + image: connectedhomeip/chip-build-android:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 32908b04f2f7ea..771c4949340f04 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -237,7 +237,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index b82411998f3681..92c5db7a27a938 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.75 + image: connectedhomeip/chip-build:0.5.77 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 9c2c299f1b5e0e..0584c11887fd1d 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-zap:0.5.75 + image: connectedhomeip/chip-build-zap:0.5.77 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index 7a6ad22c9e2271..f5a1d809540dfd 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-zap:0.5.75 + image: connectedhomeip/chip-build-zap:0.5.77 defaults: run: shell: sh diff --git a/config/nrfconnect/.nrfconnect-recommended-revision b/config/nrfconnect/.nrfconnect-recommended-revision index 64f70a191193e6..bf3768f23580c0 100644 --- a/config/nrfconnect/.nrfconnect-recommended-revision +++ b/config/nrfconnect/.nrfconnect-recommended-revision @@ -1 +1 @@ -5ea8f7fa91d7315fcc6cd9eb3aa74f9640d0abac +fd5905aa6b04febd99d00dba6c482ac25eb15222 diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index d75f3eddd3d9f3..f88a9a81d246da 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -30,7 +30,6 @@ if (CONFIG_CHIP) include(ExternalProject) include(../../zephyr/ota-image.cmake) include(../../zephyr/zephyr-util.cmake) -include(ota-content-header.cmake) # ============================================================================== # Declare configuration variables and define constants @@ -100,7 +99,7 @@ endif() if (CONFIG_POSIX_API) list(APPEND CHIP_CFLAGS -D_SYS__PTHREADTYPES_H_ - -isystem${ZEPHYR_BASE}/include/posix + -isystem${ZEPHYR_BASE}/include/zephyr/posix ) endif() @@ -342,32 +341,13 @@ add_dependencies(chip chip-gn) # ============================================================================== if (CONFIG_CHIP_OTA_IMAGE_BUILD) - if (CONFIG_CHIP_OTA_IMAGE_INCLUDE_MCUBOOT) - list(APPEND CHIP_IMAGE_TYPES "mcuboot") - list(APPEND CHIP_IMAGE_PATHS "${APPLICATION_BINARY_DIR}/mcuboot/zephyr/zephyr.bin") - endif() - - list(APPEND CHIP_IMAGE_TYPES "app_mcuboot") - list(APPEND CHIP_IMAGE_PATHS "${PROJECT_BINARY_DIR}/app_update.bin") - - if (CONFIG_NRF53_UPGRADE_NETWORK_CORE) - list(APPEND CHIP_IMAGE_TYPES "net_mcuboot") - list(APPEND CHIP_IMAGE_PATHS "${PROJECT_BINARY_DIR}/net_core_app_update.bin") - endif() - - chip_ota_content_header(chip-ota-content-header - FILE_TYPES ${CHIP_IMAGE_TYPES} - FILE_PATHS ${CHIP_IMAGE_PATHS} - OUTPUT_FILE ${PROJECT_BINARY_DIR}/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME}.content - ) chip_ota_image(chip-ota-image - INPUT_FILES ${PROJECT_BINARY_DIR}/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME}.content ${CHIP_IMAGE_PATHS} + INPUT_FILES ${PROJECT_BINARY_DIR}/dfu_multi_image.bin OUTPUT_FILE ${PROJECT_BINARY_DIR}/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME} ) - add_dependencies(chip-ota-content-header mcuboot_sign_target) - add_dependencies(chip-ota-image chip-ota-content-header) + add_dependencies(chip-ota-image dfu_multi_image_pkg) endif() endif() # CONFIG_CHIP diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index de12cbb5e6ad67..1f657aef3b9657 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -31,6 +31,7 @@ config CHIP_NFC_COMMISSIONING # See config/zephyr/Kconfig for full definition config CHIP_OTA_REQUESTOR bool + imply DFU_MULTI_IMAGE imply DFU_TARGET imply BOOTLOADER_MCUBOOT imply IMG_MANAGER @@ -60,6 +61,7 @@ config CHIP_OTA_IMAGE_BUILD bool default y if CHIP_OTA_REQUESTOR depends on SIGN_IMAGES + select DFU_MULTI_IMAGE_PACKAGE_BUILD config CHIP_EXAMPLE_DEVICE_INFO_PROVIDER bool "Include default device information provider build" diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index 73216d9dbfc9c2..4ffa2034b9b22a 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -190,6 +190,15 @@ config CHIP_EXTENDED_DISCOVERY bool default y +config NVS_LOOKUP_CACHE + bool + default y + +# Increase the default RX stack size +config IEEE802154_NRF5_RX_STACK_SIZE + int + default 1024 + # Enable OpenThread config NET_L2_OPENTHREAD @@ -202,9 +211,9 @@ choice OPENTHREAD_SECURITY default OPENTHREAD_NRF_SECURITY_CHOICE endchoice -config CC3XX_BACKEND - bool - default n +config PSA_CRYPTO_DRIVER_CC3XX + bool + default n config OBERON_BACKEND bool @@ -347,6 +356,10 @@ endif # SOC_SERIES_NRF52X if SOC_SERIES_NRF53X +config UPDATEABLE_IMAGE_NUMBER + int + default 2 + # Generate random numbers using Xoroshiro algorithm instead of direct calls # to the cryptocell library to workaround firmware hangs. choice RNG_GENERATOR_CHOICE diff --git a/config/nrfconnect/chip-module/Kconfig.features b/config/nrfconnect/chip-module/Kconfig.features index 07c0cc5c4759aa..cdcac79444c824 100644 --- a/config/nrfconnect/chip-module/Kconfig.features +++ b/config/nrfconnect/chip-module/Kconfig.features @@ -93,16 +93,6 @@ config SYSTEM_WORKQUEUE_STACK_SIZE if SOC_SERIES_NRF53X -config UPDATEABLE_IMAGE_NUMBER - int - default 2 - -# FLASH nop device is enabled to prevent bus faults when mcumgr tries to access -# simulated partition with network core image data. -config FLASH_NOP_DEVICE - bool - default y - # Enable custom SMP request to erase settings partition. config MCUMGR_GRP_ZEPHYR_BASIC bool diff --git a/config/nrfconnect/chip-module/make_ota_content_header.py b/config/nrfconnect/chip-module/make_ota_content_header.py deleted file mode 100755 index 1aa437a6b96f30..00000000000000 --- a/config/nrfconnect/chip-module/make_ota_content_header.py +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env python3 - -# -# Copyright (c) 2022 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -""" -Utility for creating a Matter OTA content header that describes a list of files -included in a Matter OTA image. The header format is specific to the nRF Connect -platform. - -Usage example: - -./make_ota_content_header.py \ - --file mcuboot mcuboot/zephyr/zephyr.bin \ - --file app_mcuboot zephyr/app_update.bin \ - out.header -""" - -import argparse -import os -import struct -import sys -from enum import IntEnum - -sys.path.insert(0, os.path.join(os.path.dirname( - __file__), '../../../src/controller/python')) -from chip.tlv import TLVWriter, uint # noqa: E402 - - -# Context-specific tags describing members of the top-level header TLV structure -class HeaderTag(IntEnum): - FILE_INFO_LIST = 0, - - -# Context-specific tags describing members of the file info TLV structure -class FileInfoTag(IntEnum): - FILE_ID = 0, - FILE_SIZE = 1, - - -# File identifiers for all the supported file types -FILE_IDS = dict( - mcuboot=0, - app_mcuboot=1, - net_mcuboot=2, -) - - -def generate_header_tlv(file_infos: list): - """ - Generate TLV structure describing OTA image contents: - - Header ::= - [0] FileInfoList: [ - [0]: - [0] FileId: - [1] FileSize: - [1]: - [0] FileId: - [1] FileSize: - ... - ] - """ - - writer = TLVWriter() - writer.put(None, { - HeaderTag.FILE_INFO_LIST: [{ - FileInfoTag.FILE_ID: uint(file_id), - FileInfoTag.FILE_SIZE: uint(file_size), - } for file_id, file_size in file_infos] - }) - - return writer.encoding - - -def generate_header(file_infos: list, output_file: str): - """ - Generate OTA image content header and save it to file - """ - - header_tlv = generate_header_tlv(file_infos) - header = struct.pack(' -#include -#include +#include +#include using namespace ::chip; using namespace ::chip::Credentials; @@ -154,9 +154,7 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif + // We only have network commissioning on endpoint 0. emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); ConfigurationMgr().LogDeviceConfig(); @@ -377,6 +375,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t /* aArg Instance().mIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (aEvent->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/all-clusters-app/nrfconnect/main/main.cpp b/examples/all-clusters-app/nrfconnect/main/main.cpp index 8f71ca55e41070..8563856d1cffd6 100644 --- a/examples/all-clusters-app/nrfconnect/main/main.cpp +++ b/examples/all-clusters-app/nrfconnect/main/main.cpp @@ -17,11 +17,11 @@ #include "AppTask.h" -#include +#include #if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) -#include -#include +#include +#include #endif LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/chef/nrfconnect/main.cpp b/examples/chef/nrfconnect/main.cpp index 4f427797c069d5..650a3664b975d2 100644 --- a/examples/chef/nrfconnect/main.cpp +++ b/examples/chef/nrfconnect/main.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #if CONFIG_ENABLE_CHIP_SHELL || CONFIG_CHIP_LIB_SHELL #include diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index 8128558fbc9e95..f8dfd2d63d4750 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -39,8 +39,8 @@ #endif #include -#include -#include +#include +#include using namespace ::chip; using namespace ::chip::app; @@ -156,10 +156,7 @@ CHIP_ERROR AppTask::Init() // Initialize DFU #ifdef CONFIG_MCUMGR_SMP_BT GetDFUOverSMP().Init(RequestSMPAdvertisingStart); -#ifndef CONFIG_CHIP_OTA_REQUESTOR - // When OTA Requestor is enabled, it is responsible for confirming new images. GetDFUOverSMP().ConfirmNewImage(); -#endif #endif // Print initial configs @@ -171,9 +168,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); @@ -392,6 +386,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t /* arg * sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (aEvent->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: if ((ConnectivityMgr().NumBLEConnections() == 0) && (!sIsThreadProvisioned || !sIsThreadEnabled)) { diff --git a/examples/light-switch-app/nrfconnect/main/BindingHandler.cpp b/examples/light-switch-app/nrfconnect/main/BindingHandler.cpp index 9cf98455d66ede..678e48df31b674 100644 --- a/examples/light-switch-app/nrfconnect/main/BindingHandler.cpp +++ b/examples/light-switch-app/nrfconnect/main/BindingHandler.cpp @@ -21,7 +21,7 @@ #include "ShellCommands.h" #endif -#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); using namespace chip; diff --git a/examples/light-switch-app/nrfconnect/main/main.cpp b/examples/light-switch-app/nrfconnect/main/main.cpp index 87098ff4b3e5d3..e463898978fb91 100644 --- a/examples/light-switch-app/nrfconnect/main/main.cpp +++ b/examples/light-switch-app/nrfconnect/main/main.cpp @@ -18,7 +18,7 @@ #include "AppTask.h" -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/lighting-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay b/examples/lighting-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay index d8784e3714a921..96f955afe880cf 100644 --- a/examples/lighting-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay +++ b/examples/lighting-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay @@ -41,15 +41,31 @@ pwmleds { pwm_led1: pwm_led_1 { - pwms = < &pwm0 0xe >; + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; }; }; &pwm0 { - /delete-property/ ch0-pin; - /delete-property/ ch0-inverted; - ch1-pin = < 0xe >; - ch1-inverted; + pinctrl-0 = <&pwm0_default_alt>; + pinctrl-1 = <&pwm0_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; + +&pinctrl { + pwm0_default_alt: pwm0_default_alt { + group1 { + psels = ; + nordic,invert; + }; + }; + + pwm0_sleep_alt: pwm0_sleep_alt { + group1 { + psels = ; + low-power-enable; + }; + }; + }; diff --git a/examples/lighting-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/lighting-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index 01794dc6524a33..1e1fc11fa67052 100644 --- a/examples/lighting-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/lighting-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -31,7 +31,7 @@ pwmleds { compatible = "pwm-leds"; pwm_led1: pwm_led_1 { - pwms = < &pwm0 0x1d >; + pwms = < &pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; }; @@ -82,8 +82,24 @@ }; &pwm0 { - /delete-property/ ch0-pin; - /delete-property/ ch0-inverted; - ch1-pin = < 0x1d >; - ch1-inverted; + pinctrl-0 = <&pwm0_default_alt>; + pinctrl-1 = <&pwm0_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; + +&pinctrl { + pwm0_default_alt: pwm0_default_alt { + group1 { + psels = ; + nordic,invert; + }; + }; + + pwm0_sleep_alt: pwm0_sleep_alt { + group1 { + psels = ; + low-power-enable; + }; + }; + }; diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 073f06e82b6417..a108dc1b4bf89b 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -45,8 +45,8 @@ #endif #include -#include -#include +#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); @@ -78,9 +78,10 @@ LEDWidget sStatusLED; LEDWidget sIdentifyLED; LEDWidget sUnusedLED; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sHaveBLEConnections = false; +const struct pwm_dt_spec sLightPwmDevice = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)); +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sHaveBLEConnections = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -142,7 +143,7 @@ CHIP_ERROR AppTask::Init() uint8_t maxLightLevel = kDefaultMaxLevel; Clusters::LevelControl::Attributes::MaxLevel::Get(kLightEndpointId, &maxLightLevel); - int ret = mPWMDevice.Init(LIGHTING_PWM_DEVICE, LIGHTING_PWM_CHANNEL, minLightLevel, maxLightLevel, maxLightLevel); + int ret = mPWMDevice.Init(&sLightPwmDevice, minLightLevel, maxLightLevel, maxLightLevel); if (ret != 0) { return chip::System::MapErrorZephyr(ret); @@ -164,10 +165,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP GetDFUOverSMP().Init(RequestSMPAdvertisingStart); -#ifndef CONFIG_CHIP_OTA_REQUESTOR - // When OTA Requestor is enabled, it is responsible for confirming new images. GetDFUOverSMP().ConfirmNewImage(); -#endif #endif // Initialize CHIP server @@ -181,9 +179,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); @@ -493,6 +488,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/lighting-app/nrfconnect/main/include/AppConfig.h b/examples/lighting-app/nrfconnect/main/include/AppConfig.h index 31430a5609ac75..cf6c580dc8a81c 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppConfig.h +++ b/examples/lighting-app/nrfconnect/main/include/AppConfig.h @@ -30,8 +30,6 @@ #define BLE_ADVERTISEMENT_START_BUTTON_MASK DK_BTN4_MSK #define SYSTEM_STATE_LED DK_LED1 // led0 in device tree -#define LIGHTING_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led1))) -#define LIGHTING_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led1)) // Time it takes in ms for the simulated actuator to move from one state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/lighting-app/nrfconnect/main/main.cpp b/examples/lighting-app/nrfconnect/main/main.cpp index 0b718e25fa2e84..9a487fcc8c2895 100644 --- a/examples/lighting-app/nrfconnect/main/main.cpp +++ b/examples/lighting-app/nrfconnect/main/main.cpp @@ -20,15 +20,15 @@ #include -#include +#include #ifdef CONFIG_CHIP_PW_RPC #include "Rpc.h" #endif #if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) -#include -#include +#include +#include #endif LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 95d651ca015c6a..5917cfe34a8d95 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -42,8 +42,8 @@ #endif #include -#include -#include +#include +#include using namespace ::chip; using namespace ::chip::app; @@ -148,10 +148,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP GetDFUOverSMP().Init(RequestSMPAdvertisingStart); -#ifndef CONFIG_CHIP_OTA_REQUESTOR - // When OTA Requestor is enabled, it is responsible for confirming new images. GetDFUOverSMP().ConfirmNewImage(); -#endif #endif // Initialize CHIP server @@ -163,9 +160,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); @@ -464,6 +458,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/lock-app/nrfconnect/main/include/BoltLockManager.h b/examples/lock-app/nrfconnect/main/include/BoltLockManager.h index feb320b4e70ae1..deeff6024de5a3 100644 --- a/examples/lock-app/nrfconnect/main/include/BoltLockManager.h +++ b/examples/lock-app/nrfconnect/main/include/BoltLockManager.h @@ -21,7 +21,7 @@ #include -#include +#include #include diff --git a/examples/lock-app/nrfconnect/main/main.cpp b/examples/lock-app/nrfconnect/main/main.cpp index 1867a549b5b005..a20f86082131a4 100644 --- a/examples/lock-app/nrfconnect/main/main.cpp +++ b/examples/lock-app/nrfconnect/main/main.cpp @@ -19,7 +19,7 @@ #include "AppTask.h" -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/pigweed-app/nrfconnect/main/main.cpp b/examples/pigweed-app/nrfconnect/main/main.cpp index e74b61652641f2..78c6212929e8c7 100644 --- a/examples/pigweed-app/nrfconnect/main/main.cpp +++ b/examples/pigweed-app/nrfconnect/main/main.cpp @@ -26,7 +26,7 @@ #include "pw_sys_io_nrfconnect/init.h" #include -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/platform/nrfconnect/Rpc.cpp b/examples/platform/nrfconnect/Rpc.cpp index b9e1ae666f8be7..14cced6d5b1062 100644 --- a/examples/platform/nrfconnect/Rpc.cpp +++ b/examples/platform/nrfconnect/Rpc.cpp @@ -22,9 +22,9 @@ #include "PigweedLoggerMutex.h" #include "pigweed/RpcService.h" #include "pw_sys_io_nrfconnect/init.h" -#include +#include -#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/platform/nrfconnect/Rpc.h b/examples/platform/nrfconnect/Rpc.h index e5375eeb17b31c..f0aeaf45b61fba 100644 --- a/examples/platform/nrfconnect/Rpc.h +++ b/examples/platform/nrfconnect/Rpc.h @@ -18,7 +18,7 @@ #pragma once -#include +#include namespace chip { namespace rpc { diff --git a/examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc b/examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc index e23a006dd6359c..3781eaa738d45f 100644 --- a/examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc +++ b/examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc @@ -20,10 +20,10 @@ #include "console/console.h" #include "pw_sys_io/sys_io.h" #include -#include +#include #ifdef CONFIG_USB -#include +#include #endif extern "C" void pw_sys_io_Init() diff --git a/examples/platform/nrfconnect/util/DFUOverSMP.cpp b/examples/platform/nrfconnect/util/DFUOverSMP.cpp index 03c491b3460bee..c4b496d575fc26 100644 --- a/examples/platform/nrfconnect/util/DFUOverSMP.cpp +++ b/examples/platform/nrfconnect/util/DFUOverSMP.cpp @@ -21,10 +21,10 @@ #error "DFUOverSMP requires MCUMGR module configs enabled" #endif -#include #include -#include #include +#include +#include #include diff --git a/examples/platform/nrfconnect/util/DFUTrigger.cpp b/examples/platform/nrfconnect/util/DFUTrigger.cpp index b1c14bc792409c..c287e56097fd6b 100644 --- a/examples/platform/nrfconnect/util/DFUTrigger.cpp +++ b/examples/platform/nrfconnect/util/DFUTrigger.cpp @@ -20,8 +20,8 @@ #error "The command for triggerring the DFU is available for nRF52840 Dongle only" #endif -#include -#include +#include +#include namespace { constexpr const char * kGPIOController = "GPIO_0"; diff --git a/examples/platform/nrfconnect/util/LEDWidget.cpp b/examples/platform/nrfconnect/util/LEDWidget.cpp index 703460eb5bf7e4..eca7765ab0a0d9 100644 --- a/examples/platform/nrfconnect/util/LEDWidget.cpp +++ b/examples/platform/nrfconnect/util/LEDWidget.cpp @@ -20,7 +20,7 @@ #include "LEDWidget.h" #include -#include +#include static LEDWidget::LEDWidgetStateUpdateHandler sStateUpdateCallback; diff --git a/examples/platform/nrfconnect/util/OTAUtil.cpp b/examples/platform/nrfconnect/util/OTAUtil.cpp index ed7b2368ce098a..4addd5c30a7d30 100644 --- a/examples/platform/nrfconnect/util/OTAUtil.cpp +++ b/examples/platform/nrfconnect/util/OTAUtil.cpp @@ -52,6 +52,8 @@ OTAImageProcessorImpl & GetOTAImageProcessor() void InitBasicOTARequestor() { + VerifyOrReturn(GetRequestorInstance() == nullptr); + OTAImageProcessorImpl & imageProcessor = GetOTAImageProcessor(); imageProcessor.SetOTADownloader(&sBDXDownloader); sBDXDownloader.SetImageProcessorDelegate(&imageProcessor); diff --git a/examples/platform/nrfconnect/util/PWMDevice.cpp b/examples/platform/nrfconnect/util/PWMDevice.cpp index 929f538f792819..43e3600a15cec9 100644 --- a/examples/platform/nrfconnect/util/PWMDevice.cpp +++ b/examples/platform/nrfconnect/util/PWMDevice.cpp @@ -22,24 +22,23 @@ #include -#include -#include -#include +#include +#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); -int PWMDevice::Init(const device * aPWMDevice, uint32_t aPWMChannel, uint8_t aMinLevel, uint8_t aMaxLevel, uint8_t aDefaultLevel) +int PWMDevice::Init(const pwm_dt_spec * aPWMDevice, uint8_t aMinLevel, uint8_t aMaxLevel, uint8_t aDefaultLevel) { - mState = kState_On; - mMinLevel = aMinLevel; - mMaxLevel = aMaxLevel; - mLevel = aDefaultLevel; - mPwmDevice = aPWMDevice; - mPwmChannel = aPWMChannel; - - if (!device_is_ready(mPwmDevice)) + mState = kState_On; + mMinLevel = aMinLevel; + mMaxLevel = aMaxLevel; + mLevel = aDefaultLevel; + mPwmDevice = aPWMDevice; + + if (!device_is_ready(mPwmDevice->dev)) { - LOG_ERR("PWM device %s is not ready", mPwmDevice->name); + LOG_ERR("PWM device %s is not ready", mPwmDevice->dev->name); return -ENODEV; } @@ -124,9 +123,9 @@ void PWMDevice::Set(bool aOn) void PWMDevice::UpdateLight() { - constexpr uint32_t kPwmWidthUs = 20000u; const uint8_t maxEffectiveLevel = mMaxLevel - mMinLevel; const uint8_t effectiveLevel = mState == kState_On ? chip::min(mLevel - mMinLevel, maxEffectiveLevel) : 0; - pwm_pin_set_usec(mPwmDevice, mPwmChannel, kPwmWidthUs, kPwmWidthUs * effectiveLevel / maxEffectiveLevel, 0); + pwm_set_pulse_dt(mPwmDevice, + static_cast(static_cast(mPwmDevice->period) * effectiveLevel / maxEffectiveLevel)); } diff --git a/examples/platform/nrfconnect/util/PigweedLogger.cpp b/examples/platform/nrfconnect/util/PigweedLogger.cpp index ed08e7af12784d..6aae4a062a6f05 100644 --- a/examples/platform/nrfconnect/util/PigweedLogger.cpp +++ b/examples/platform/nrfconnect/util/PigweedLogger.cpp @@ -24,11 +24,11 @@ * needs to use HDLC/UART for another purpose like the RPC server. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/examples/platform/nrfconnect/util/ThreadUtil.cpp b/examples/platform/nrfconnect/util/ThreadUtil.cpp index 5ca7b5874acaf2..b3564d8cbf80de 100644 --- a/examples/platform/nrfconnect/util/ThreadUtil.cpp +++ b/examples/platform/nrfconnect/util/ThreadUtil.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/examples/platform/nrfconnect/util/include/DFUOverSMP.h b/examples/platform/nrfconnect/util/include/DFUOverSMP.h index 846a8a13394ee9..c6c04b474b8f68 100644 --- a/examples/platform/nrfconnect/util/include/DFUOverSMP.h +++ b/examples/platform/nrfconnect/util/include/DFUOverSMP.h @@ -25,7 +25,7 @@ #include -#include +#include typedef void (*DFUOverSMPRestartAdvertisingHandler)(void); diff --git a/examples/platform/nrfconnect/util/include/LEDWidget.h b/examples/platform/nrfconnect/util/include/LEDWidget.h index 7c76c49810157f..4859bc9bf048df 100644 --- a/examples/platform/nrfconnect/util/include/LEDWidget.h +++ b/examples/platform/nrfconnect/util/include/LEDWidget.h @@ -20,7 +20,7 @@ #include -#include +#include class LEDWidget { diff --git a/examples/platform/nrfconnect/util/include/PWMDevice.h b/examples/platform/nrfconnect/util/include/PWMDevice.h index d83a45d92e982b..250383efa93c0e 100644 --- a/examples/platform/nrfconnect/util/include/PWMDevice.h +++ b/examples/platform/nrfconnect/util/include/PWMDevice.h @@ -18,7 +18,8 @@ #pragma once #include -#include +#include +#include class PWMDevice { @@ -40,21 +41,21 @@ class PWMDevice using PWMCallback = void (*)(Action_t, int32_t); - int Init(const device * aPWMDevice, uint32_t aPWMChannel, uint8_t aMinLevel, uint8_t aMaxLevel, uint8_t aDefaultLevel = 0); + int Init(const pwm_dt_spec * aPWMDevice, uint8_t aMinLevel, uint8_t aMaxLevel, uint8_t aDefaultLevel = 0); bool IsTurnedOn() const { return mState == kState_On; } uint8_t GetLevel() const { return mLevel; } uint8_t GetMinLevel() const { return mMinLevel; } uint8_t GetMaxLevel() const { return mMaxLevel; } bool InitiateAction(Action_t aAction, int32_t aActor, uint8_t * aValue); void SetCallbacks(PWMCallback aActionInitiatedClb, PWMCallback aActionCompletedClb); - const device * GetDevice() { return mPwmDevice; } + const device * GetDevice() { return mPwmDevice->dev; } private: State_t mState; uint8_t mMinLevel; uint8_t mMaxLevel; uint8_t mLevel; - const device * mPwmDevice; + const pwm_dt_spec * mPwmDevice; uint32_t mPwmChannel; PWMCallback mActionInitiatedClb; diff --git a/examples/platform/nrfconnect/util/include/PigweedLogger.h b/examples/platform/nrfconnect/util/include/PigweedLogger.h index 69d011a0c4c8c2..ac106231802e50 100644 --- a/examples/platform/nrfconnect/util/include/PigweedLogger.h +++ b/examples/platform/nrfconnect/util/include/PigweedLogger.h @@ -17,7 +17,7 @@ #pragma once -#include +#include namespace PigweedLogger { diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 38d4c610746ec3..b101418cad4ebf 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -42,8 +42,8 @@ #endif #include -#include -#include +#include +#include using namespace ::chip; using namespace ::chip::app::Clusters; @@ -144,10 +144,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP GetDFUOverSMP().Init(RequestSMPAdvertisingStart); -#ifndef CONFIG_CHIP_OTA_REQUESTOR - // When OTA Requestor is enabled, it is responsible for confirming new images. GetDFUOverSMP().ConfirmNewImage(); -#endif #endif // Initialize CHIP server @@ -160,9 +157,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); @@ -474,6 +468,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/pump-app/nrfconnect/main/PumpManager.cpp b/examples/pump-app/nrfconnect/main/PumpManager.cpp index 0e13b861c23eca..e7c0b6240c554b 100644 --- a/examples/pump-app/nrfconnect/main/PumpManager.cpp +++ b/examples/pump-app/nrfconnect/main/PumpManager.cpp @@ -22,8 +22,8 @@ #include "AppConfig.h" #include "AppTask.h" -#include -#include +#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/pump-app/nrfconnect/main/main.cpp b/examples/pump-app/nrfconnect/main/main.cpp index 1867a549b5b005..a20f86082131a4 100644 --- a/examples/pump-app/nrfconnect/main/main.cpp +++ b/examples/pump-app/nrfconnect/main/main.cpp @@ -19,7 +19,7 @@ #include "AppTask.h" -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index fedcfd9ef87dbc..1a0aa8202bbdfd 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -42,8 +42,8 @@ #endif #include -#include -#include +#include +#include using namespace ::chip; using namespace ::chip::app; @@ -141,10 +141,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP GetDFUOverSMP().Init(RequestSMPAdvertisingStart); -#ifndef CONFIG_CHIP_OTA_REQUESTOR - // When OTA Requestor is enabled, it is responsible for confirming new images. GetDFUOverSMP().ConfirmNewImage(); -#endif #endif // Initialize CHIP server @@ -156,9 +153,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); @@ -470,6 +464,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/pump-controller-app/nrfconnect/main/PumpManager.cpp b/examples/pump-controller-app/nrfconnect/main/PumpManager.cpp index c61a2a4a56e4aa..a7f654baeeead6 100644 --- a/examples/pump-controller-app/nrfconnect/main/PumpManager.cpp +++ b/examples/pump-controller-app/nrfconnect/main/PumpManager.cpp @@ -22,8 +22,8 @@ #include "AppConfig.h" #include "AppTask.h" -#include -#include +#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/pump-controller-app/nrfconnect/main/main.cpp b/examples/pump-controller-app/nrfconnect/main/main.cpp index 1867a549b5b005..a20f86082131a4 100644 --- a/examples/pump-controller-app/nrfconnect/main/main.cpp +++ b/examples/pump-controller-app/nrfconnect/main/main.cpp @@ -19,7 +19,7 @@ #include "AppTask.h" -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/examples/window-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay b/examples/window-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay index b16a44113b8aef..096e3208740df9 100644 --- a/examples/window-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay +++ b/examples/window-app/nrfconnect/boards/nrf52840dk_nrf52840.overlay @@ -40,11 +40,12 @@ }; pwmleds { + compatible = "pwm-leds"; pwm_led1: pwm_led_1 { - pwms = < &pwm0 0xe >; + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; pwm_led2: pwm_led_2 { - pwms = < &pwm1 0xf >; + pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; }; }; @@ -73,14 +74,23 @@ }; &pwm0 { - /delete-property/ ch0-pin; - /delete-property/ ch0-inverted; - ch1-pin = < 0xe >; - ch1-inverted; + pinctrl-0 = <&pwm0_default_alt>; + pinctrl-1 = <&pwm0_sleep_alt>; + pinctrl-names = "default", "sleep"; }; -&pwm1 { - status = "okay"; - ch1-pin = < 0xf >; - ch1-inverted; -}; +&pinctrl { + pwm0_default_alt: pwm0_default_alt { + group1 { + psels = , ; + nordic,invert; + }; + }; + + pwm0_sleep_alt: pwm0_sleep_alt { + group1 { + psels = , ; + low-power-enable; + }; + }; +}; \ No newline at end of file diff --git a/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index 88368b93afe890..b87553d5dd7b11 100644 --- a/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -30,12 +30,11 @@ }; pwmleds { - compatible = "pwm-leds"; pwm_led1: pwm_led_1 { - pwms = < &pwm0 0x1d >; + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; pwm_led2: pwm_led_2 { - pwms = < &pwm1 0x1e >; + pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>; }; }; @@ -103,14 +102,23 @@ }; &pwm0 { - /delete-property/ ch0-pin; - /delete-property/ ch0-inverted; - ch1-pin = < 0x1d >; - ch1-inverted; + pinctrl-0 = <&pwm0_default_alt>; + pinctrl-1 = <&pwm0_sleep_alt>; + pinctrl-names = "default", "sleep"; }; -&pwm1 { - status = "okay"; - ch1-pin = < 0x1e >; - ch1-inverted; +&pinctrl { + pwm0_default_alt: pwm0_default_alt { + group1 { + psels = , ; + nordic,invert; + }; + }; + + pwm0_sleep_alt: pwm0_sleep_alt { + group1 { + psels = , ; + low-power-enable; + }; + }; }; diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index 216bf06c5551bf..976b3d69a40a71 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -39,8 +39,8 @@ #endif #include -#include -#include +#include +#include #define FACTORY_RESET_TRIGGER_TIMEOUT 3000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 @@ -151,9 +151,6 @@ CHIP_ERROR AppTask::Init() gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); -#if CONFIG_CHIP_OTA_REQUESTOR - InitBasicOTARequestor(); -#endif ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); @@ -488,6 +485,14 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t) Instance().mIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); UpdateStatusLED(); break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (aEvent->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; default: break; } diff --git a/examples/window-app/nrfconnect/main/WindowCovering.cpp b/examples/window-app/nrfconnect/main/WindowCovering.cpp index f1667045390384..f4041c254e27bc 100644 --- a/examples/window-app/nrfconnect/main/WindowCovering.cpp +++ b/examples/window-app/nrfconnect/main/WindowCovering.cpp @@ -23,9 +23,9 @@ #include #include -#include #include -#include +#include +#include LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); @@ -33,6 +33,8 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace chip::app::Clusters::WindowCovering; +static const struct pwm_dt_spec sLiftPwmDevice = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)); +static const struct pwm_dt_spec sTiltPwmDevice = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led2)); static k_timer sLiftTimer; static k_timer sTiltTimer; static constexpr uint32_t sMoveTimeoutMs{ 200 }; @@ -42,11 +44,11 @@ WindowCovering::WindowCovering() mLiftLED.Init(LIFT_STATE_LED); mTiltLED.Init(TILT_STATE_LED); - if (mLiftIndicator.Init(LIFT_PWM_DEVICE, LIFT_PWM_CHANNEL, 0, 255) != 0) + if (mLiftIndicator.Init(&sLiftPwmDevice, 0, 255) != 0) { LOG_ERR("Cannot initialize the lift indicator"); } - if (mTiltIndicator.Init(TILT_PWM_DEVICE, TILT_PWM_CHANNEL, 0, 255) != 0) + if (mTiltIndicator.Init(&sTiltPwmDevice, 0, 255) != 0) { LOG_ERR("Cannot initialize the tilt indicator"); } diff --git a/examples/window-app/nrfconnect/main/ZclCallbacks.cpp b/examples/window-app/nrfconnect/main/ZclCallbacks.cpp index f8407af3ffb07c..d4a1c541c93bbc 100644 --- a/examples/window-app/nrfconnect/main/ZclCallbacks.cpp +++ b/examples/window-app/nrfconnect/main/ZclCallbacks.cpp @@ -73,7 +73,9 @@ void MatterWindowCoveringClusterServerAttributeChangedCallback(const app::Concre case Attributes::CurrentPositionTiltPercent100ths::Id: WindowCovering::Instance().PositionLEDUpdate(WindowCovering::MoveType::TILT); break; + default: + WindowCovering::Instance().SchedulePostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId); + break; }; } - WindowCovering::Instance().SchedulePostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId); } diff --git a/examples/window-app/nrfconnect/main/include/AppConfig.h b/examples/window-app/nrfconnect/main/include/AppConfig.h index 46770401c0e2eb..7dadc1bc572667 100644 --- a/examples/window-app/nrfconnect/main/include/AppConfig.h +++ b/examples/window-app/nrfconnect/main/include/AppConfig.h @@ -29,9 +29,3 @@ #define SYSTEM_STATE_LED DK_LED1 #define LIFT_STATE_LED DK_LED2 #define TILT_STATE_LED DK_LED3 - -#define LIFT_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led1))) -#define LIFT_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led1)) - -#define TILT_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led2))) -#define TILT_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led2)) diff --git a/examples/window-app/nrfconnect/main/include/CHIPProjectConfig.h b/examples/window-app/nrfconnect/main/include/CHIPProjectConfig.h index df571c7319dd07..de64851584ba9d 100644 --- a/examples/window-app/nrfconnect/main/include/CHIPProjectConfig.h +++ b/examples/window-app/nrfconnect/main/include/CHIPProjectConfig.h @@ -31,8 +31,8 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 #ifdef CONFIG_CHIP_THREAD_SSED -#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL 1000_ms32 -#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 1000_ms32 +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL 500_ms32 +#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 500_ms32 #else #define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 2000_ms32 #endif diff --git a/examples/window-app/nrfconnect/main/main.cpp b/examples/window-app/nrfconnect/main/main.cpp index bb67947911cad1..40233508ccc702 100644 --- a/examples/window-app/nrfconnect/main/main.cpp +++ b/examples/window-app/nrfconnect/main/main.cpp @@ -17,7 +17,7 @@ #include "AppTask.h" -#include +#include LOG_MODULE_REGISTER(app, CONFIG_MATTER_LOG_LEVEL); diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index b83748bea2db46..01abb43a458c9b 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 4b3717b825b905..12325b791124cf 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -28,7 +28,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -45,7 +45,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -62,7 +62,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -79,7 +79,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-vscode:0.5.77" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index b5877349a1c204..d6a6a2dfc7adae 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -73,8 +73,6 @@ static_library("nrfconnect") { if (chip_enable_ota_requestor) { sources += [ - "OTAImageContentHeader.cpp", - "OTAImageContentHeader.h", "OTAImageProcessorImpl.cpp", "OTAImageProcessorImpl.h", ] diff --git a/src/platform/nrfconnect/CHIPPlatformConfig.h b/src/platform/nrfconnect/CHIPPlatformConfig.h index b34fc5ab5fa423..4d8bc0371a9d38 100644 --- a/src/platform/nrfconnect/CHIPPlatformConfig.h +++ b/src/platform/nrfconnect/CHIPPlatformConfig.h @@ -37,7 +37,7 @@ // Size of the statically allocated context for SHA256 operations in CryptoPAL // determined empirically. #ifdef CONFIG_CC3XX_BACKEND -#define CHIP_CONFIG_SHA256_CONTEXT_SIZE 240 +#define CHIP_CONFIG_SHA256_CONTEXT_SIZE 244 #else #define CHIP_CONFIG_SHA256_CONTEXT_SIZE 208 #endif diff --git a/src/platform/nrfconnect/OTAImageContentHeader.cpp b/src/platform/nrfconnect/OTAImageContentHeader.cpp deleted file mode 100644 index 3eb21e2d3bfee2..00000000000000 --- a/src/platform/nrfconnect/OTAImageContentHeader.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "OTAImageContentHeader.h" - -#include -#include -#include -#include - -namespace chip { -namespace DeviceLayer { - -namespace { - -enum class HeaderTag : uint8_t -{ - kFileInfoList = 0, -}; - -enum class FileInfoTag : uint8_t -{ - kFileId = 0, - kFileSize = 1, -}; - -/// Maximum supported Matter OTA image content header size -constexpr uint32_t kMaxHeaderSize = 1024; -} // namespace - -void OTAImageContentHeaderParser::Init() -{ - mState = State::kInitialized; - mBufferOffset = 0; - mHeaderTlvSize = 0; - mBuffer.Alloc(sizeof(mHeaderTlvSize)); -} - -void OTAImageContentHeaderParser::Clear() -{ - mState = State::kNotInitialized; - mBufferOffset = 0; - mHeaderTlvSize = 0; - mBuffer.Free(); -} - -CHIP_ERROR OTAImageContentHeaderParser::AccumulateAndDecode(ByteSpan & buffer, OTAImageContentHeader & header) -{ - CHIP_ERROR error = CHIP_NO_ERROR; - - if (mState == State::kInitialized) - { - ReturnErrorCodeIf(!mBuffer, CHIP_ERROR_NO_MEMORY); - Append(buffer, sizeof(mHeaderTlvSize) - mBufferOffset); - error = DecodeFixed(); - } - - if (mState == State::kTlv) - { - Append(buffer, mHeaderTlvSize - mBufferOffset); - error = DecodeTlv(header); - } - - if (error != CHIP_NO_ERROR && error != CHIP_ERROR_BUFFER_TOO_SMALL) - { - Clear(); - } - - return error; -} - -void OTAImageContentHeaderParser::Append(ByteSpan & buffer, uint32_t numBytes) -{ - numBytes = chip::min(numBytes, static_cast(buffer.size())); - memcpy(&mBuffer[mBufferOffset], buffer.data(), numBytes); - mBufferOffset += numBytes; - buffer = buffer.SubSpan(numBytes); -} - -CHIP_ERROR OTAImageContentHeaderParser::DecodeFixed() -{ - ReturnErrorCodeIf(mBufferOffset < sizeof(mHeaderTlvSize), CHIP_ERROR_BUFFER_TOO_SMALL); - - mHeaderTlvSize = Encoding::LittleEndian::Get32(mBuffer.Get()); - // Safety check against malicious headers. - ReturnErrorCodeIf(mHeaderTlvSize > kMaxHeaderSize, CHIP_ERROR_NO_MEMORY); - ReturnErrorCodeIf(!mBuffer.Alloc(mHeaderTlvSize), CHIP_ERROR_NO_MEMORY); - - mState = State::kTlv; - mBufferOffset = 0; - - return CHIP_NO_ERROR; -} - -CHIP_ERROR OTAImageContentHeaderParser::DecodeTlv(OTAImageContentHeader & header) -{ - ReturnErrorCodeIf(mBufferOffset < mHeaderTlvSize, CHIP_ERROR_BUFFER_TOO_SMALL); - - TLV::TLVReader tlvReader; - tlvReader.Init(mBuffer.Get(), mBufferOffset); - ReturnErrorOnFailure(tlvReader.Next(TLV::TLVType::kTLVType_Structure, TLV::AnonymousTag())); - - TLV::TLVType outerType; - ReturnErrorOnFailure(tlvReader.EnterContainer(outerType)); - - TLV::TLVType headerType; - ReturnErrorOnFailure(tlvReader.Next(TLV::TLVType::kTLVType_Array, TLV::ContextTag(to_underlying(HeaderTag::kFileInfoList)))); - ReturnErrorOnFailure(tlvReader.EnterContainer(headerType)); - - size_t fileNo = 0; - - while (tlvReader.Next(TLV::TLVType::kTLVType_Structure, TLV::AnonymousTag()) == CHIP_NO_ERROR) - { - ReturnErrorCodeIf(fileNo >= OTAImageContentHeader::kMaxFiles, CHIP_ERROR_NO_MEMORY); - - TLV::TLVType arrayType; - ReturnErrorOnFailure(tlvReader.EnterContainer(arrayType)); - - ReturnErrorOnFailure(tlvReader.Next(TLV::ContextTag(to_underlying(FileInfoTag::kFileId)))); - ReturnErrorOnFailure(tlvReader.Get(header.mFiles[fileNo].mFileId)); - ReturnErrorOnFailure(tlvReader.Next(TLV::ContextTag(to_underlying(FileInfoTag::kFileSize)))); - ReturnErrorOnFailure(tlvReader.Get(header.mFiles[fileNo].mFileSize)); - ++fileNo; - - ReturnErrorOnFailure(tlvReader.ExitContainer(arrayType)); - } - - ReturnErrorOnFailure(tlvReader.ExitContainer(headerType)); - ReturnErrorOnFailure(tlvReader.ExitContainer(outerType)); - - return CHIP_NO_ERROR; -} - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/nrfconnect/OTAImageContentHeader.h b/src/platform/nrfconnect/OTAImageContentHeader.h deleted file mode 100644 index f56108a6f5469c..00000000000000 --- a/src/platform/nrfconnect/OTAImageContentHeader.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -#include - -namespace chip { -namespace DeviceLayer { - -struct OTAImageContentHeader -{ - static constexpr size_t kMaxFiles = 3; - - enum class FileId : uint32_t - { - kMcuboot = 0, - kAppMcuboot = 1, - kNetMcuboot = 2, - }; - - struct FileInfo - { - FileId mFileId; - uint32_t mFileSize; - }; - - FileInfo mFiles[kMaxFiles]; -}; - -class OTAImageContentHeaderParser -{ -public: - /** - * @brief Prepare the parser for accepting Matter OTA image chunks. - * - * The method can be called many times to reset the parser state. - */ - void Init(); - - /** - * @brief Clear all resources associated with the parser. - */ - void Clear(); - - /** - * @brief Returns if the parser is ready to accept subsequent Matter OTA image chunks. - */ - bool IsInitialized() const { return mState != State::kNotInitialized; } - - /** - * @brief Decode nRF Connect Matter OTA image content header - * - * The method takes subsequent chunks of the Matter OTA image file and decodes the header when - * enough data has been provided. If more image chunks are needed, CHIP_ERROR_BUFFER_TOO_SMALL - * error is returned. Other error codes indicate that the header is invalid. - * - * @param buffer Byte span containing a subsequent Matter OTA image chunk. When the method - * returns CHIP_NO_ERROR, the byte span is used to return a remaining part - * of the chunk, not used by the header. - * @param header Structure to store results of the operation. - * - * @retval CHIP_NO_ERROR Header has been decoded successfully. - * @retval CHIP_ERROR_BUFFER_TOO_SMALL Provided buffers are insufficient to decode the - * header. A user is expected call the method again - * when the next image chunk is available. - * @retval Error code Encoded header is invalid. - */ - CHIP_ERROR AccumulateAndDecode(ByteSpan & buffer, OTAImageContentHeader & header); - -private: - enum State - { - kNotInitialized, - kInitialized, - kTlv - }; - - void Append(ByteSpan & buffer, uint32_t numBytes); - CHIP_ERROR DecodeFixed(); - CHIP_ERROR DecodeTlv(OTAImageContentHeader & header); - - State mState; - uint32_t mBufferOffset; - uint32_t mHeaderTlvSize; - Platform::ScopedMemoryBuffer mBuffer; -}; - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp index e117b29ca8a954..d9caebbd34a430 100644 --- a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp +++ b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -45,33 +46,41 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl() { mHeaderParser.Init(); - mContentHeaderParser.Init(); ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_mcuboot_set_buf(mBuffer, sizeof(mBuffer)))); + ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_init(mBuffer, sizeof(mBuffer)))); + + for (int image_id = 0; image_id < CONFIG_UPDATEABLE_IMAGE_NUMBER; ++image_id) + { + dfu_image_writer writer; + writer.image_id = image_id; + writer.open = [](int id, size_t size) { return dfu_target_init(DFU_TARGET_IMAGE_TYPE_MCUBOOT, id, size, nullptr); }; + writer.write = [](const uint8_t * chunk, size_t chunk_size) { return dfu_target_write(chunk, chunk_size); }; + writer.close = [](bool success) { return dfu_target_done(success); }; + + ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer))); + }; return CHIP_NO_ERROR; } CHIP_ERROR OTAImageProcessorImpl::Finalize() { - return CHIP_NO_ERROR; + return System::MapErrorZephyr(dfu_multi_image_done(true)); } CHIP_ERROR OTAImageProcessorImpl::Abort() { - CHIP_ERROR error = System::MapErrorZephyr(dfu_target_reset()); + CHIP_ERROR error = System::MapErrorZephyr(dfu_multi_image_done(false)); TriggerFlashAction(FlashHandler::Action::SLEEP); + return error; } CHIP_ERROR OTAImageProcessorImpl::Apply() { - int err = dfu_target_done(true); - if (!err) - { - // schedule update of all possible targets by caling this function with argument -1 - err = dfu_target_schedule_update(-1); - } + // Schedule update of all images + int err = dfu_target_schedule_update(-1); TriggerFlashAction(FlashHandler::Action::SLEEP); @@ -96,67 +105,25 @@ CHIP_ERROR OTAImageProcessorImpl::Apply() #endif } -CHIP_ERROR OTAImageProcessorImpl::SwitchToNextImage(const ByteSpan & aRemainingData) -{ - mCurrentImage.mFileInfo = &mContentHeader.mFiles[static_cast(ImageType::kNetImage)]; - mCurrentImage.mImageType = ImageType::kNetImage; - - if (mCurrentImage.mFileInfo->mFileSize > 0) - { - // finish app-core dfu target to inform mcuboot that all bytes were written - ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_done(true))); - // Reset app-core target to allow switching a target to the next one - ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_reset())); - // initialize next dfu target to store net-core image. - ReturnErrorOnFailure(System::MapErrorZephyr( - dfu_target_init(DFU_TARGET_IMAGE_TYPE_MCUBOOT, static_cast(mCurrentImage.mImageType), /* size */ 0, nullptr))); - // write remaining data to new image - ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_write(aRemainingData.data(), aRemainingData.size()))); - mCurrentImage.mCurrentOffset = aRemainingData.size(); - } - return CHIP_NO_ERROR; -} - CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & aBlock) { VerifyOrReturnError(mDownloader != nullptr, CHIP_ERROR_INCORRECT_STATE); CHIP_ERROR error = ProcessHeader(aBlock); + if (error == CHIP_NO_ERROR) { - mCurrentImage.mCurrentOffset += aBlock.size(); - if (mCurrentImage.mCurrentOffset >= mCurrentImage.mFileInfo->mFileSize) - { - // create new subspan with data which should be moved to the next image - ByteSpan remainingData = aBlock.SubSpan( - aBlock.size() - (mCurrentImage.mCurrentOffset - static_cast(mCurrentImage.mFileInfo->mFileSize))); - // write last data of previous image - error = System::MapErrorZephyr(dfu_target_write(aBlock.data(), aBlock.size() - remainingData.size())); - if (OTAImageContentHeader::FileId::kAppMcuboot == mCurrentImage.mFileInfo->mFileId && CHIP_NO_ERROR == error) - { - // switch to net image - error = SwitchToNextImage(remainingData); - } - else - { - // Finish process with error to ensure that only two images are available. - error = CHIP_ERROR_INVALID_DATA_LIST; - } - } - else - { - // DFU target library buffers data internally, so do not clone the block data. - error = System::MapErrorZephyr(dfu_target_write(aBlock.data(), aBlock.size())); - } + // DFU target library buffers data internally, so do not clone the block data. + error = System::MapErrorZephyr(dfu_multi_image_write(mParams.downloadedBytes, aBlock.data(), aBlock.size())); + mParams.downloadedBytes += aBlock.size(); } // Report the result back to the downloader asynchronously. return DeviceLayer::SystemLayer().ScheduleLambda([this, error, aBlock] { if (error == CHIP_NO_ERROR) { - mParams.downloadedBytes += aBlock.size(); - ChipLogDetail(SoftwareUpdate, "Processed %llu/%u Bytes of image no. %u", mCurrentImage.mCurrentOffset, - mCurrentImage.mFileInfo->mFileSize, static_cast(mCurrentImage.mImageType)); + ChipLogDetail(SoftwareUpdate, "Downloaded %u/%u bytes", static_cast(mParams.downloadedBytes), + static_cast(mParams.totalFileBytes)); mDownloader->FetchNextData(); } else @@ -198,26 +165,6 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & aBlock) mHeaderParser.Clear(); } - if (mContentHeaderParser.IsInitialized() && !aBlock.empty()) - { - CHIP_ERROR error = mContentHeaderParser.AccumulateAndDecode(aBlock, mContentHeader); - - // Needs more data to decode the header - ReturnErrorCodeIf(error == CHIP_ERROR_BUFFER_TOO_SMALL, CHIP_NO_ERROR); - ReturnErrorOnFailure(error); - - if (OTAImageContentHeader::FileId::kAppMcuboot == mContentHeader.mFiles[0].mFileId) - { - mCurrentImage.mFileInfo = &mContentHeader.mFiles[static_cast(ImageType::kAppImage)]; - mCurrentImage.mImageType = ImageType::kAppImage; - // Initialize dfu target to receive first image - ReturnErrorOnFailure(System::MapErrorZephyr(dfu_target_init( - DFU_TARGET_IMAGE_TYPE_MCUBOOT, static_cast(mCurrentImage.mImageType), /* size */ 0, nullptr))); - } - - mContentHeaderParser.Clear(); - } - return CHIP_NO_ERROR; } diff --git a/src/platform/nrfconnect/OTAImageProcessorImpl.h b/src/platform/nrfconnect/OTAImageProcessorImpl.h index 59529c49a1d552..99b9c13e9d7693 100644 --- a/src/platform/nrfconnect/OTAImageProcessorImpl.h +++ b/src/platform/nrfconnect/OTAImageProcessorImpl.h @@ -19,7 +19,6 @@ #include #include #include -#include namespace chip { @@ -44,22 +43,10 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface public: static constexpr size_t kBufferSize = CONFIG_CHIP_OTA_REQUESTOR_BUFFER_SIZE; - OTAImageProcessorImpl(FlashHandler * flashHandler = nullptr) : mFlashHandler(flashHandler){}; - - enum class ImageType : uint8_t - { - kAppImage = 0, - kNetImage = 1 - }; + explicit OTAImageProcessorImpl(FlashHandler * flashHandler = nullptr) : mFlashHandler(flashHandler) {} void SetOTADownloader(OTADownloader * downloader) { mDownloader = downloader; }; - - struct OTAImage - { - OTAImageContentHeader::FileInfo * mFileInfo; - ImageType mImageType; - uint64_t mCurrentOffset; - }; + void TriggerFlashAction(FlashHandler::Action action); CHIP_ERROR PrepareDownload() override; CHIP_ERROR Finalize() override; @@ -68,19 +55,14 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface CHIP_ERROR ProcessBlock(ByteSpan & aBlock) override; bool IsFirstImageRun() override; CHIP_ERROR ConfirmCurrentImage() override; - void TriggerFlashAction(FlashHandler::Action action); private: CHIP_ERROR PrepareDownloadImpl(); CHIP_ERROR ProcessHeader(ByteSpan & aBlock); - CHIP_ERROR SwitchToNextImage(const ByteSpan & aRemainingData); OTADownloader * mDownloader = nullptr; OTAImageHeaderParser mHeaderParser; - OTAImageContentHeaderParser mContentHeaderParser; uint8_t mBuffer[kBufferSize]; - OTAImageContentHeader mContentHeader; - OTAImage mCurrentImage; FlashHandler * mFlashHandler; };