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. +
@@ -209,7 +216,7 @@ following states are possible: initiated. - _Pressed for less than 3 s_ — Initiates the OTA software update - process. This feature is disabled by default, but can be enabled by + over Bluetooth LE process. This feature is disabled by default, but can be enabled by following the [Building with Device Firmware Upgrade support](#building-with-device-firmware-upgrade-support) instruction. @@ -384,11 +391,19 @@ Semiconductor's kit you own: ### Building with Device Firmware Upgrade support -To build the example with configuration that enables DFU, run the following +Support for DFU using Matter OTA is enabled by default. + +To enable DFU over Bluetooth LE, run the following +command with _build-target_ replaced with the build target name of the Nordic +Semiconductor kit you are using (for example `nrf52840dk_nrf52840`): + + $ west build -b build-target -- -DBUILD_WITH_DFU=BLE + +To completely disable support for both DFU methods, run the following command with _build-target_ replaced with the build target name of the Nordic -Semiconductor's kit you own (for example `nrf52840dk_nrf52840`): +Semiconductor kit you are using (for example `nrf52840dk_nrf52840`): - $ west build -b build-target -- -DBUILD_WITH_DFU=1 + $ west build -b build-target -- -DBUILD_WITH_DFU=OFF > **Note**: > @@ -398,14 +413,19 @@ Semiconductor's kit you own (for example `nrf52840dk_nrf52840`): > Multi-image mode allows to upgrade more firmware images and is suitable for > upgrading the application core and network core firmware in two-core nRF5340 > DK devices. +> +> Currently the multi-image mode is only available for the DFU over Bluetooth LE method. + #### Changing Device Firmware Upgrade configuration -To change the default DFU configuration, edit the -`overlay-single_image_dfu_support.conf` or -`overlay-multi_image_dfu_support.conf` overlay files depending on whether the -build target device supports multi-image DFU (nRF5340 DK) or single-image DFU -(nRF52840 DK). The files are located in the `config/nrfconnect/app` directory. +To change the default DFU configuration, edit the following overlay files corresponding to the selected configuration: +- `overlay-mcuboot_qspi_nor_support.conf` - general file enabling MCUboot and QSPI NOR support, used by all DFU configurations +- `overlay-single_image_smp_dfu_support.conf` - file enabling single-image DFU over Bluetooth LE using SMP +- `overlay-multi_image_smp_dfu_support.conf` - file enabling multi-image DFU over Bluetooth LE using SMP +- `overlay-ota_requestor.conf` - file enabling Matter OTA Requestor support. + +The files are located in the `config/nrfconnect/app` directory. You can also define the desired options in your example's `prj.conf` file. #### Changing bootloader configuration diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 0e72c2478f052a..40fd1eea1f2993 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -32,12 +32,13 @@ endif() option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) if(BUILD_WITH_DFU) if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") - list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_dfu_support.conf) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf) 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) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf) set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/configuration/mcuboot_single_image_dfu.conf CACHE INTERNAL "") endif() + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf) set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) endif() diff --git a/examples/lock-app/nrfconnect/README.md b/examples/lock-app/nrfconnect/README.md index 9ba97aec6f326e..5ae4ced9e0b082 100644 --- a/examples/lock-app/nrfconnect/README.md +++ b/examples/lock-app/nrfconnect/README.md @@ -397,11 +397,12 @@ Semiconductor's kit you own (for example `nrf52840dk_nrf52840`): #### Changing Device Firmware Upgrade configuration -To change the default DFU configuration, edit the -`overlay-single_image_dfu_support.conf` or -`overlay-multi_image_dfu_support.conf` overlay files depending on whether the -build target device supports multi-image DFU (nRF5340 DK) or single-image DFU -(nRF52840 DK). The files are located in the `config/nrfconnect/app` directory. +To change the default DFU configuration, edit some of the following overlay files depending on selected configuration: +- `overlay-mcuboot_qspi_nor_support.conf` - generic file enabling MCUboot and QSPI NOR support, used by all DFU configurations +- `overlay-single_image_smp_dfu_support.conf` - file enabling single-image DFU over Bluetooth LE using SMP +- `overlay-multi_image_smp_dfu_support.conf` - file enabling multi-image DFU over Bluetooth LE using SMP + +The files are located in the `config/nrfconnect/app` directory. You can also define the desired options in your example's `prj.conf` file. #### Changing bootloader configuration diff --git a/examples/pump-app/nrfconnect/CMakeLists.txt b/examples/pump-app/nrfconnect/CMakeLists.txt index 0b720f209c1eab..ad342be5b4bb54 100644 --- a/examples/pump-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-app/nrfconnect/CMakeLists.txt @@ -32,12 +32,13 @@ endif() option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) if(BUILD_WITH_DFU) if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") - list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_dfu_support.conf) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf) 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) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf) set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/configuration/mcuboot_single_image_dfu.conf CACHE INTERNAL "") endif() + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf) set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) endif() diff --git a/examples/pump-controller-app/nrfconnect/CMakeLists.txt b/examples/pump-controller-app/nrfconnect/CMakeLists.txt index cbae1f77e94f4f..108f5fa5b73515 100644 --- a/examples/pump-controller-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-controller-app/nrfconnect/CMakeLists.txt @@ -32,12 +32,13 @@ endif() option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) if(BUILD_WITH_DFU) if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") - list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_dfu_support.conf) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-multi_image_smp_dfu_support.conf) 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) + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-single_image_smp_dfu_support.conf) set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/configuration/mcuboot_single_image_dfu.conf CACHE INTERNAL "") endif() + list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-mcuboot_qspi_nor_support.conf) set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) endif()