diff --git a/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf b/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf new file mode 100644 index 00000000000000..51901e0f573240 --- /dev/null +++ b/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf @@ -0,0 +1,22 @@ +# +# 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. +# + +CONFIG_BOOTLOADER_MCUBOOT=y + +# QSPI configuration +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 diff --git a/config/nrfconnect/app/overlay-multi_image_dfu_support.conf b/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf similarity index 85% rename from config/nrfconnect/app/overlay-multi_image_dfu_support.conf rename to config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf index 644a86c64d5835..8292a2ba13f5d1 100644 --- a/config/nrfconnect/app/overlay-multi_image_dfu_support.conf +++ b/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Project CHIP Authors +# 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. @@ -14,14 +14,8 @@ # limitations under the License. # -CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_UPDATEABLE_IMAGE_NUMBER=2 -# QSPI configuration -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 - # MCU Manager and SMP configuration CONFIG_MCUMGR=y CONFIG_MCUMGR_CMD_IMG_MGMT=y diff --git a/config/nrfconnect/app/overlay-single_image_dfu_support.conf b/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf similarity index 96% rename from config/nrfconnect/app/overlay-single_image_dfu_support.conf rename to config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf index 363cd4bcd5f925..d03b7dead22b4f 100644 --- a/config/nrfconnect/app/overlay-single_image_dfu_support.conf +++ b/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Project CHIP Authors +# 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. diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 6aecc3d070be2f..09f6343bbfeceb 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -32,6 +32,7 @@ config CHIP_NFC_COMMISSIONING config CHIP_OTA_REQUESTOR bool imply DFU_TARGET + imply IMG_MANAGER imply STREAM_FLASH imply STREAM_FLASH_ERASE diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index ce3632847361a9..af1ee19b12547d 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -30,16 +30,29 @@ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf) list(APPEND CONF_FILE boards/${BOARD}.conf) endif() -option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) -if(BUILD_WITH_DFU) +set(BUILD_WITH_DFU "MATTER" CACHE STRING "Build target with Device Firmware Upgrade support") +if(NOT BUILD_WITH_DFU STREQUAL "OFF") + if(BUILD_WITH_DFU STREQUAL "BLE") + if(BOARD STREQUAL "nrf5340dk_nrf5340_cpuapp") + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf) + else() + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf) + endif() + elseif(NOT BUILD_WITH_DFU STREQUAL "MATTER") + message(FATAL_ERROR "Selected invalid BUILD_WITH_DFU value: ${BUILD_WITH_DFU}") + endif() + + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf) + # Enable Matter OTA Requestor list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-ota_requestor.conf) - if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") - list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_dfu_support.conf) + + if(BOARD STREQUAL "nrf5340dk_nrf5340_cpuapp") + # DFU over Matter doesn't support multi-image update yet, but using this configs should not harm it anyway. set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/configuration/mcuboot_multi_image_dfu.conf CACHE INTERNAL "") else() - list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-single_image_dfu_support.conf) set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/configuration/mcuboot_single_image_dfu.conf CACHE INTERNAL "") endif() + set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) endif() @@ -84,7 +97,7 @@ chip_configure_data_model(app GEN_DIR ${GEN_DIR}/lighting-app/zap-generated ) -if(BUILD_WITH_DFU) +if(BUILD_WITH_DFU STREQUAL "BLE") target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp) endif() diff --git a/examples/lighting-app/nrfconnect/README.md b/examples/lighting-app/nrfconnect/README.md index 1cdc8c295f4845..6b24c420570127 100644 --- a/examples/lighting-app/nrfconnect/README.md +++ b/examples/lighting-app/nrfconnect/README.md @@ -98,28 +98,20 @@ with other Thread devices in the network. ### Device Firmware Upgrade -The example allows enabling the over-the-air Device Firmware Upgrade feature. In -this process, the device hosting new firmware image sends the image to the -Matter device using Bluetooth LE transport and -[Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt). -The -[MCUboot](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/index.html) -bootloader solution then replaces the old firmware image with the new one. +The example supports over-the-air (OTA) device firmware upgrade (DFU) using one of the two available methods: +- Matter OTA update that is mandatory for Matter-compliant devices and enabled by default +- [Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt) over Bluetooth LE, an optional proprietary method that can be enabled to work alongside the default Matter OTA update. Note that this protocol is not a part of the Matter specification. -#### Bootloader +For both methods, the [MCUboot](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/index.html) bootloader solution is used to replace the old firmware image with the new one. -MCUboot is a secure bootloader used for swapping firmware images of different -versions and generating proper build output files that can be used in the device -firmware upgrade process. +#### Matter Over-the-Air Update -The bootloader solution requires an area of flash memory to swap application -images during the firmware upgrade. The Nordic devices use an external memory -chip for this purpose. The memory chip communicates with the microcontroller -through the QSPI bus. +The Matter over-the-air update distinguishes two types of nodes: OTA Provider and OTA Requestor. -See the -[Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support) -section to learn how to change MCUboot and flash configuration in this example. +An OTA Provider is a node that hosts a new firmware image and is able to respond on an OTA Requestor's +queries regarding availability of new firmware images or requests to start sending the update packages. + +An OTA Requestor is a node that wants to download a new firmware image and sends requests to an OTA Provider to start the update process. #### Simple Management Protocol @@ -127,7 +119,7 @@ Simple Management Protocol (SMP) is a basic transfer encoding that is used for device management purposes, including application image management. SMP supports using different transports, such as Bluetooth LE, UDP, or serial USB/UART. -In this example, the CHIP device runs the SMP Server to download the application +In this example, the Matter device runs the SMP Server to download the application update image using the Bluetooth LE transport. See the @@ -135,6 +127,21 @@ See the section to learn how to enable SMP and use it for the DFU purpose in this example. +#### Bootloader + +MCUboot is a secure bootloader used for swapping firmware images of different +versions and generating proper build output files that can be used in the device +firmware upgrade process. + +The bootloader solution requires an area of flash memory to swap application +images during the firmware upgrade. Nordic Semiconductor devices use an external memory +chip for this purpose. The memory chip communicates with the microcontroller +through the QSPI bus. + +See the +[Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support) +section to learn how to change MCUboot and flash configuration in this example. +