diff --git a/docs/includes/matter_extension_activation.txt b/docs/includes/matter_extension_activation.txt index f10ed3f3..f6b2598c 100644 --- a/docs/includes/matter_extension_activation.txt +++ b/docs/includes/matter_extension_activation.txt @@ -26,4 +26,6 @@ To produce a size-optimized release build (no logging, console or shell), add :f Use ``nrf54lm20dk/nrf54lm20b/cpuapp`` as the board target for the nRF54LM20B SoC variant. +.. include:: /includes/matter_extension_bt_dfu.txt + See |sample matter limitations ref| for supported board targets and incompatible options. diff --git a/docs/includes/matter_extension_bt_dfu.txt b/docs/includes/matter_extension_bt_dfu.txt new file mode 100644 index 00000000..32af8e24 --- /dev/null +++ b/docs/includes/matter_extension_bt_dfu.txt @@ -0,0 +1,15 @@ +Device firmware upgrade over Bluetooth SMP +------------------------------------------ + +You can update your device's firmware over the air using two methods, both enabled by default in the Matter extension builds: + +* Matter OTA – Updates your device through MCUboot, satisfying the Matter specification's requirement to support at least one over-the-air software update method. + +* Device Firmware Upgrade (DFU) over Bluetooth LE – Updates your device using the `Simple Management Protocol`_ (SMP). + To enable this method, select the :file:`prj_matter_fota.conf` configuration by setting the ``FILE_SUFFIX=matter_fota`` option. + +Matter OTA and SMP DFU are independent transports. +SMP is not part of the Matter specification. +Use `mcumgr`_ or `nRF Connect Device Manager`_ to perform the update. + +For step-by-step instructions on testing the update process, see |sample matter bt dfu testing ref|. diff --git a/docs/includes/matter_extension_bt_dfu_testing.txt b/docs/includes/matter_extension_bt_dfu_testing.txt new file mode 100644 index 00000000..156a5417 --- /dev/null +++ b/docs/includes/matter_extension_bt_dfu_testing.txt @@ -0,0 +1,49 @@ +To test DFU over Bluetooth LE SMP, complete the following steps: + +1. Build and flash the sample with the Matter extension (see |sample matter activating variants ref|). +#. Confirm the device is running the Matter stack (see |sample matter testing ref|). +#. Briefly press **Button 0** to start Bluetooth LE advertising for SMP. + + The behavior depends on the device's commissioning state: + + * If the device is not commissioned to a Matter fabric, this starts both Matter commissioning advertising and the SMP server. + * If the device is already commissioned, this re-enables only the SMP server for firmware transfer. + + **LED 0** blinks while Bluetooth LE advertising for SMP is active. + The advertised device name is |bt device name|, set by the ``CONFIG_BT_DEVICE_NAME`` Kconfig option in the :file:`prj_matter_fota.conf` file. + +#. Perform the update using one of the following methods: + + .. tabs:: + + .. group-tab:: Smartphone + + a. Install `nRF Connect Device Manager`_. + #. Use the :file:`dfu_application.zip` file from the build directory. + + For detailed instructions, see `FOTA updates on nRF54L Series devices`_ (nRF54L15 and nRF54LM20 DKs) or `FOTA updates with nRF5340 DK`_ (nRF5340 DK) depending on the device you are using. + + .. group-tab:: PC (mcumgr) + + Upload the signed images from the build directory: + + * On single-core SoCs (for example, nRF54L Series), upload the application image: + + .. parsed-literal:: + :class: highlight + + |matter mcumgr smp upload| + + * On dual-core SoCs (for example, nRF5340 DK), upload the application and network core images separately: + + .. parsed-literal:: + :class: highlight + + |matter mcumgr smp upload| + + |matter mcumgr net smp upload| + + After uploading, list the images, mark each new slot as pending, and reset the device. + For the full procedure, see `Performing Device Firmware Upgrade in the nRF Connect examples`_. + +After the update completes, MCUboot applies the new image on the next reboot. diff --git a/docs/includes/zigbee_bt_dfu_activation.txt b/docs/includes/zigbee_bt_dfu_activation.txt new file mode 100644 index 00000000..ef904e19 --- /dev/null +++ b/docs/includes/zigbee_bt_dfu_activation.txt @@ -0,0 +1,39 @@ +Activating optional extensions +------------------------------ + +To activate the :ref:`lib_zigbee_fota`, use the :file:`prj_fota.conf` configuration file together with the ``zigbee_fota_ext_flash`` snippet. +The snippet provides external-flash partition layouts, sysbuild MCUboot settings, and the matching MCUboot configuration (through ``zigbee_fota_mcuboot_ext_flash``). +For example, when building from the command line, use the following command: + +.. parsed-literal:: + :class: highlight + + west build |sample dir| -b *board_target* -- -DFILE_SUFFIX=fota -DSNIPPET=zigbee_fota_ext_flash + +The FOTA variant enables `MCUboot image compression`_. +The generated Zigbee update file contains a compressed MCUboot image, and MCUboot decompresses it while applying the update. +This setting reduces the size of the update image. +However, it requires MCUboot to run in overwrite-only mode, which means the device cannot revert to the previous image after an update is applied. + +Alternatively, you can :ref:`configure Zigbee FOTA manually `. + +.. note:: + The decompression support increases the size of the MCUboot image. + When adapting this FOTA configuration to a custom board or application, make sure that the MCUboot partition is large enough for the generated bootloader image. + The FOTA variant uses devicetree-based partitioning with Partition Manager disabled; see :ref:`zigbee_ug_static_partition` for the partition layout requirements. + +Device firmware upgrade over Bluetooth SMP (Zigbee-only builds) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To additionally enable Device Firmware Upgrade (DFU) over Bluetooth LE using the Simple Management Protocol (SMP) in a Zigbee-only build, add ``CONFIG_ZIGBEE_BT_DFU=y`` to the FOTA build command: + +.. parsed-literal:: + :class: highlight + + west build |sample dir| -b *board_target* -- -DFILE_SUFFIX=fota -DSNIPPET=zigbee_fota_ext_flash -DCONFIG_ZIGBEE_BT_DFU=y + +This option enables the MCUmgr SMP server over Bluetooth LE alongside :ref:`lib_zigbee_fota`. +It cannot be combined with the |sample matter ref| (``CONFIG_CHIP``). +For Matter extension builds, SMP DFU is provided through ``CONFIG_CHIP_DFU_OVER_BT_SMP`` instead. + +See |sample zigbee bt dfu testing ref| for step-by-step testing instructions. diff --git a/docs/includes/zigbee_bt_dfu_testing.txt b/docs/includes/zigbee_bt_dfu_testing.txt new file mode 100644 index 00000000..4670edfd --- /dev/null +++ b/docs/includes/zigbee_bt_dfu_testing.txt @@ -0,0 +1,36 @@ +To test DFU over Bluetooth SMP in a Zigbee-only build, complete the following steps: + +1. Build and flash the sample with the ``CONFIG_ZIGBEE_BT_DFU=y`` Kconfig option (see |sample activating variants ref|). +#. Wait for the device to boot. + + After booting, the device automatically starts Bluetooth LE connectable advertising for the SMP server. + The advertised device name is |zigbee bt device name|, set by ``CONFIG_BT_DEVICE_NAME`` when ``CONFIG_ZIGBEE_BT_DFU`` is enabled. + +#. Perform the update using one of the following methods: + + .. tabs:: + + .. group-tab:: Smartphone + + a. Install `nRF Connect Device Manager`_. + #. Use the :file:`dfu_application.zip` file from the build directory. + + For detailed instructions, see `FOTA updates on nRF54L Series devices`_ (nRF54L15 and nRF54LM20 DKs) or `FOTA updates with nRF5340 DK`_ (nRF5340 DK). + + .. group-tab:: PC (mcumgr) + + Upload the signed application image from the build directory: + + .. parsed-literal:: + :class: highlight + + |zigbee mcumgr smp upload| + + After uploading, list the images, mark the new slot as pending, and reset the device. + For the full procedure (image upload, list, test, and reset), see the `MCUmgr Command-line tool`_ page. + +After the update completes, MCUboot applies the new image on the next reboot. + +.. note:: + Zigbee OTA and SMP DFU are independent transports, and SMP is not part of the Zigbee specification. + You can use either `mcumgr`_ or `nRF Connect Device Manager`_ to perform the update over Bluetooth LE. diff --git a/docs/links.txt b/docs/links.txt index 6b64c77b..86d7156a 100644 --- a/docs/links.txt +++ b/docs/links.txt @@ -48,6 +48,13 @@ .. _`Release notes for the nRF Connect SDK`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/nrf/releases_and_maturity/release_notes.html .. _`CHIP Tool`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/matter/chip_tool_guide.html +.. _`mcumgr`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/zephyr/services/device_mgmt/mcumgr.html +.. _`Simple Management Protocol`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/zephyr/services/device_mgmt/smp_protocol.html +.. _`nRF Connect Device Manager`: https://www.nordicsemi.com/Products/Development-tools/nrf-connect-device-manager +.. _`FOTA updates on nRF54L Series devices`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/nrf/app_dev/device_guides/nrf54l/fota_update.html +.. _`FOTA updates with nRF5340 DK`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/nrf/app_dev/device_guides/nrf53/fota_update_nrf5340.html +.. _`MCUmgr Command-line tool`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/nrf/app_dev/bootloaders_dfu/dfu_tools_mcumgr_cli.html +.. _`Performing Device Firmware Upgrade in the nRF Connect examples`: https://docs.nordicsemi.com/bundle/ncs-3.2.0/page/matter/nrfconnect_examples_software_update.html .. _`DFU over Zigbee`: https://docs.nordicsemi.com/bundle/nrfutil/page/guides-nrf5sdk/dfu_performing.html#dfu-over-zigbee diff --git a/samples/light_bulb/Kconfig b/samples/light_bulb/Kconfig index a1d4db95..d0c40508 100644 --- a/samples/light_bulb/Kconfig +++ b/samples/light_bulb/Kconfig @@ -17,6 +17,13 @@ endchoice endif # OPENTHREAD +if ZIGBEE_BT_DFU + +config BT_DEVICE_NAME + default "Zigbee_Bulb" + +endif # ZIGBEE_BT_DFU + config MPSL_THREAD_COOP_PRIO default 8 diff --git a/samples/light_bulb/Kconfig.sysbuild b/samples/light_bulb/Kconfig.sysbuild index b0b41c4c..d87117b7 100644 --- a/samples/light_bulb/Kconfig.sysbuild +++ b/samples/light_bulb/Kconfig.sysbuild @@ -20,4 +20,39 @@ endchoice endif # MATTER +if BOOTLOADER_MCUBOOT + +#### DFU multi-image support +config DFU_MULTI_IMAGE_PACKAGE_BUILD + default y + +config DFU_MULTI_IMAGE_PACKAGE_APP + default y + +#### DFU dual core configuration +if SOC_SERIES_NRF53 + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y + +config MCUBOOT_UPDATEABLE_IMAGES + default 2 + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y + +config DFU_MULTI_IMAGE_PACKAGE_NET + default y + +endif # SOC_SERIES_NRF53 + +endif # BOOTLOADER_MCUBOOT + source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/light_bulb/README.rst b/samples/light_bulb/README.rst index 463bd118..6aca4a07 100644 --- a/samples/light_bulb/README.rst +++ b/samples/light_bulb/README.rst @@ -82,6 +82,17 @@ Configuration |config| +Source file setup +================= + +This sample is split into the following source files: + +* The :file:`main` file is the application entry point only. +* The :file:`app_task_zigbee` file manages the application task flow, user input handling, and Zigbee-specific startup and control logic. + It also implements the dimmable light device behavior, including cluster handling and PWM-based brightness control. +* The :file:`app_task_matter` file is used in the Matter extension build only. + It implements the Matter application task flow, button input, and On/Off and Level Control cluster state for the dimmable light endpoint. + .. FEM support =========== @@ -93,10 +104,20 @@ Configuration Configuration files for sample extensions ========================================= +The sample provides predefined configuration files for optional extensions. +You can find the configuration files in the :file:`samples/light_bulb` directory. + .. |sample matter ref| replace:: :ref:`zigbee_light_bulb_sample_matter` .. |sample matter limitations ref| replace:: :ref:`zigbee_light_bulb_matter_limitations` +.. |sample matter bt dfu testing ref| replace:: :ref:`zigbee_light_bulb_testing_matter_bt_dfu` +.. |sample matter testing ref| replace:: :ref:`zigbee_light_bulb_testing_matter` +.. |sample matter activating variants ref| replace:: :ref:`zigbee_light_bulb_activating_variants` +.. |sample activating variants ref| replace:: :ref:`zigbee_light_bulb_activating_variants` +.. |sample zigbee bt dfu testing ref| replace:: :ref:`zigbee_light_bulb_testing_zigbee_bt_dfu` .. |sample dir| replace:: samples/light_bulb +.. include:: /includes/zigbee_bt_dfu_activation.txt + .. include:: /includes/matter_extension_activation.txt User interface @@ -263,6 +284,28 @@ Complete the following steps to exercise the full Zigbee-to-Matter flow: * Or trigger a Matter factory reset from the controller (for example, ``chip-tool pairing unpair …``). The device reboots as a fresh Zigbee Router with Matter Bluetooth LE advertising active again, and Matter storage is cleared. +.. _zigbee_light_bulb_testing_matter_bt_dfu: + +Testing Matter extension DFU over Bluetooth SMP +----------------------------------------------- + +.. |bt device name| replace:: MatterZigbeeLb +.. |app name| replace:: light_bulb +.. |matter mcumgr smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='MatterZigbeeLb' image upload build/light_bulb/zephyr/zephyr.signed.bin -n 0 -w 1 +.. |matter mcumgr net smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='MatterZigbeeLb' image upload build/signed_by_mcuboot_and_b0_ipc_radio.bin -n 1 -w 1 + +.. include:: /includes/matter_extension_bt_dfu_testing.txt + +.. _zigbee_light_bulb_testing_zigbee_bt_dfu: + +Testing Zigbee FOTA DFU over Bluetooth SMP +------------------------------------------ + +.. |zigbee bt device name| replace:: Zigbee_Bulb +.. |zigbee mcumgr smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='Zigbee_Bulb' image upload build/light_bulb/zephyr/zephyr.signed.bin + +.. include:: /includes/zigbee_bt_dfu_testing.txt + Dependencies ************ diff --git a/samples/light_bulb/boards/nrf52840dk_nrf52840_fota.overlay b/samples/light_bulb/boards/nrf52840dk_nrf52840_fota.overlay new file mode 100644 index 00000000..59257ea3 --- /dev/null +++ b/samples/light_bulb/boards/nrf52840dk_nrf52840_fota.overlay @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + pwmleds { + pwm_led3: pwm_led_3 { + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + }; + + chosen { + ncs,zigbee-timer = &timer2; + }; +}; + +&pwm0 { + 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; + }; + }; +}; + +&timer2 { + status = "okay"; +}; diff --git a/samples/light_bulb/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay b/samples/light_bulb/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay new file mode 100644 index 00000000..c535139f --- /dev/null +++ b/samples/light_bulb/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + pwmleds { + compatible = "pwm-leds"; + + pwm_led3: pwm_led_3 { + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + }; + + chosen { + ncs,zigbee-timer = &timer2; + }; +}; + +&pwm0 { + status = "okay"; + 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; + }; + }; +}; + +&timer2 { + status = "okay"; +}; diff --git a/samples/light_bulb/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay b/samples/light_bulb/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay new file mode 100644 index 00000000..6d49f155 --- /dev/null +++ b/samples/light_bulb/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include diff --git a/samples/light_bulb/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay b/samples/light_bulb/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay new file mode 100644 index 00000000..7b7eefb1 --- /dev/null +++ b/samples/light_bulb/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include diff --git a/samples/light_bulb/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay b/samples/light_bulb/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay new file mode 100644 index 00000000..121c17a5 --- /dev/null +++ b/samples/light_bulb/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + chosen { + ncs,zigbee-timer = &timer23; + }; + + pwmleds { + compatible = "pwm-leds"; + pwm_led3: pwm_led_3 { + pwms = <&pwm20 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; + +&pwm20 { + status = "okay"; + pinctrl-0 = <&pwm_default>; + pinctrl-1 = <&pwm_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&pinctrl { + pwm_default: pwm_default { + group1 { + psels = ; + }; + }; + + pwm_sleep: pwm_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&timer23 { + status = "okay"; +}; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.overlay b/samples/light_bulb/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.overlay similarity index 100% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.overlay rename to samples/light_bulb/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.overlay diff --git a/samples/light_bulb/prj_fota.conf b/samples/light_bulb/prj_fota.conf new file mode 100644 index 00000000..b3782ebe --- /dev/null +++ b/samples/light_bulb/prj_fota.conf @@ -0,0 +1,47 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_NCS_SAMPLES_DEFAULTS=y + +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_SERIAL=y +CONFIG_GPIO=y +CONFIG_PWM=y + +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_HEAP_MEM_POOL_SIZE=2048 +CONFIG_MAIN_THREAD_PRIORITY=7 + +CONFIG_ZIGBEE_ADD_ON=y +CONFIG_ZIGBEE_APP_UTILS=y +CONFIG_ZIGBEE_ROLE_ROUTER=y + +CONFIG_DK_LIBRARY=y + +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +CONFIG_ZIGBEE_SCENES=y + +####################### +# Zigbee FOTA overlay # +####################### + +CONFIG_ZIGBEE_FOTA=y +CONFIG_ZIGBEE_FOTA_HW_VERSION=52 +CONFIG_ZIGBEE_FOTA_ENDPOINT=11 +CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.0.0" +CONFIG_ZIGBEE_FOTA_COMMENT="light_bulb" +CONFIG_ZIGBEE_FOTA_DOWNLOAD_RESUME=y + +CONFIG_IMG_MANAGER=y +CONFIG_STREAM_FLASH=y +CONFIG_DFU_TARGET_MCUBOOT=y +CONFIG_IMG_ERASE_PROGRESSIVELY=y +CONFIG_ZIGBEE_FOTA_PROGRESS_EVT=y + +CONFIG_NRF_802154_RX_BUFFERS=32 diff --git a/samples/light_bulb/prj_matter_fota.conf b/samples/light_bulb/prj_matter_fota.conf index b4f819d4..2f0dc9a3 100644 --- a/samples/light_bulb/prj_matter_fota.conf +++ b/samples/light_bulb/prj_matter_fota.conf @@ -91,7 +91,7 @@ CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y CONFIG_CHIP_BLE_EXT_ADVERTISING=y CONFIG_CHIP_BLE_ADVERTISING_DURATION=60 -CONFIG_BT_DEVICE_NAME="MatterZigbee" +CONFIG_BT_DEVICE_NAME="MatterZigbeeLb" # Other settings CONFIG_THREAD_NAME=y @@ -131,3 +131,6 @@ CONFIG_NRF_802154_CALLBACKS_DISPATCHER=y CONFIG_ZIGBEE_DEBUG_FUNCTIONS=y CONFIG_CHIP_FACTORY_DATA_BUILD=y + +# DFU over Bluetooth LE SMP +CONFIG_CHIP_DFU_OVER_BT_SMP=y diff --git a/samples/light_bulb/sample.yaml b/samples/light_bulb/sample.yaml index e3f7291e..fd603caf 100644 --- a/samples/light_bulb/sample.yaml +++ b/samples/light_bulb/sample.yaml @@ -59,6 +59,18 @@ tests: - nrf54l15dk/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp + sample.zigbee.light_bulb.fota_and_bt_dfu: + sysbuild: true + build_only: true + extra_args: + - FILE_SUFFIX=fota + - SNIPPET=zigbee_fota_ext_flash + - CONFIG_ZIGBEE_BT_DFU=y + integration_platforms: + - nrf54lm20dk/nrf54lm20b/cpuapp + platform_allow: + - nrf54lm20dk/nrf54lm20a/cpuapp + - nrf54lm20dk/nrf54lm20b/cpuapp sample.zigbee.light_bulb.with_shell: sysbuild: true build_only: true diff --git a/samples/light_bulb/src/app_task_zigbee.cpp b/samples/light_bulb/src/app_task_zigbee.cpp index b0e12e9e..44973dcc 100644 --- a/samples/light_bulb/src/app_task_zigbee.cpp +++ b/samples/light_bulb/src/app_task_zigbee.cpp @@ -27,6 +27,12 @@ #endif #include +#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU) +#include +#endif + +#include + extern "C" { #include "zb_dimmable_light.h" #include @@ -39,8 +45,18 @@ extern "C" { #ifdef CONFIG_ZIGBEE_SCENES #include #endif +#if CONFIG_ZIGBEE_FOTA +#include +#endif +#ifdef CONFIG_ZIGBEE_BT_DFU +#include +#endif } +#if CONFIG_ZIGBEE_FOTA +#include +#endif + #define RUN_STATUS_LED DK_LED1 #define RUN_LED_BLINK_INTERVAL 1000 @@ -90,6 +106,10 @@ extern "C" { */ #define BULB_LED DK_LED4 +#if CONFIG_ZIGBEE_FOTA +#define OTA_ACTIVITY_LED DK_LED2 +#endif + #if defined(CONFIG_ZIGBEE_MATTER_COEXISTENCE_BUTTON_SWITCH) /* Long-press to switch active protocol. */ #define PROTOCOL_SWITCH_BUTTON DK_BTN3_MSK @@ -177,7 +197,18 @@ ZB_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST(dimmable_light_clusters, basic_attr_list, ZB_DECLARE_DIMMABLE_LIGHT_EP(dimmable_light_ep, DIMMABLE_LIGHT_ENDPOINT, dimmable_light_clusters); +#ifndef CONFIG_ZIGBEE_FOTA ZBOSS_DECLARE_DEVICE_CTX_1_EP(dimmable_light_ctx, dimmable_light_ep); +#else + +#if DIMMABLE_LIGHT_ENDPOINT == CONFIG_ZIGBEE_FOTA_ENDPOINT +#error "Light bulb and Zigbee OTA endpoints should be different." +#endif + +extern zb_af_endpoint_desc_t zigbee_fota_client_ep; +ZBOSS_DECLARE_DEVICE_CTX_2_EP(dimmable_light_ctx, zigbee_fota_client_ep, + dimmable_light_ep); +#endif /* CONFIG_ZIGBEE_FOTA */ /**@brief Starts identifying the device. * @@ -431,6 +462,46 @@ static void bulb_clusters_attr_init(void) { (zb_uint8_t *)&dev_ctx.level_control_attr.current_level, ZB_FALSE); } +#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU) +static void confirm_image(void) { + if (!boot_is_img_confirmed()) { + int ret = boot_write_img_confirmed(); + + if (ret) { + LOG_ERR("Couldn't confirm image: %d", ret); + } else { + LOG_INF("Marked image as OK"); + } + } +} +#endif + +#ifdef CONFIG_ZIGBEE_FOTA +static void ota_evt_handler(const struct zigbee_fota_evt *evt) { + switch (evt->id) { + case ZIGBEE_FOTA_EVT_PROGRESS: + dk_set_led(OTA_ACTIVITY_LED, evt->dl.progress % 2); + break; + + case ZIGBEE_FOTA_EVT_FINISHED: + LOG_INF("Reboot application."); + if (IS_ENABLED(CONFIG_RAM_POWER_DOWN_LIBRARY)) { + power_up_unused_ram(); + } + + sys_reboot(SYS_REBOOT_COLD); + break; + + case ZIGBEE_FOTA_EVT_ERROR: + LOG_ERR("OTA image transfer failed."); + break; + + default: + break; + } +} +#endif /* CONFIG_ZIGBEE_FOTA */ + /**@brief Callback function for handling ZCL commands. * * @param[in] bufid Reference to Zigbee stack buffer @@ -448,6 +519,14 @@ static void zcl_device_cb(zb_bufid_t bufid) { device_cb_param->status = RET_OK; switch (device_cb_param->device_cb_id) { + case ZB_ZCL_OTA_UPGRADE_VALUE_CB_ID: +#ifdef CONFIG_ZIGBEE_FOTA + zigbee_fota_zcl_cb(bufid); +#else + device_cb_param->status = RET_NOT_IMPLEMENTED; +#endif + break; + case ZB_ZCL_LEVEL_CONTROL_SET_VALUE_CB_ID: LOG_INF("Level control setting to %d", device_cb_param->cb_param.level_control_set_value_param.new_value); @@ -502,6 +581,10 @@ static void zcl_device_cb(zb_bufid_t bufid) { * used to pass signal. */ void zboss_signal_handler(zb_bufid_t bufid) { +#ifdef CONFIG_ZIGBEE_FOTA + zigbee_fota_signal_handler(bufid); +#endif + /* Update network status LED. */ zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED); @@ -549,8 +632,23 @@ extern "C" int ZigbeeStart(void) { bulb_clusters_attr_init(); level_control_set_value(dev_ctx.level_control_attr.current_level); +#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU) + confirm_image(); +#endif + +#ifdef CONFIG_ZIGBEE_FOTA + zigbee_fota_init(ota_evt_handler); +#endif + +#ifdef CONFIG_ZIGBEE_BT_DFU + zigbee_bt_dfu_init(); +#endif + /* Register handler to identify notifications. */ ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(DIMMABLE_LIGHT_ENDPOINT, identify_cb); +#ifdef CONFIG_ZIGBEE_FOTA + ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(CONFIG_ZIGBEE_FOTA_ENDPOINT, identify_cb); +#endif #ifdef CONFIG_ZIGBEE_SCENES /* Initialize ZCL scene table */ diff --git a/samples/light_bulb/sysbuild/b0n/boards/nrf5340dk_nrf5340_cpunet.overlay b/samples/light_bulb/sysbuild/b0n/boards/nrf5340dk_nrf5340_cpunet.overlay new file mode 100644 index 00000000..f55ba10a --- /dev/null +++ b/samples/light_bulb/sysbuild/b0n/boards/nrf5340dk_nrf5340_cpunet.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +/ { + chosen { + zephyr,code-partition = &b0n_partition; + }; +}; diff --git a/samples/light_bulb/sysbuild/b0n/prj.conf b/samples/light_bulb/sysbuild/b0n/prj.conf new file mode 100644 index 00000000..c6efcbd0 --- /dev/null +++ b/samples/light_bulb/sysbuild/b0n/prj.conf @@ -0,0 +1,37 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_NCS_SAMPLES_DEFAULTS=n + +CONFIG_IS_SECURE_BOOTLOADER=y +CONFIG_MULTITHREADING=n +CONFIG_GPIO=n +CONFIG_ARM_MPU=n +CONFIG_TICKLESS_KERNEL=n +CONFIG_ERRNO=n +CONFIG_SYS_CLOCK_EXISTS=y +CONFIG_FPROTECT=y +CONFIG_FW_INFO=y +CONFIG_SECURE_BOOT_CRYPTO=y +CONFIG_SECURE_BOOT_VALIDATION=y +CONFIG_SECURE_BOOT_STORAGE=y +CONFIG_PCD_NET=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_USE_DT_CODE_PARTITION=y + +CONFIG_LOG=n +CONFIG_BOOT_BANNER=n +CONFIG_NCS_BOOT_BANNER=n +CONFIG_PRINTK=n +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n +CONFIG_SERIAL=n +CONFIG_ASSERT=n +CONFIG_NRF_RTC_TIMER=n +CONFIG_RESET_ON_FATAL_ERROR=n +CONFIG_REBOOT=n +CONFIG_SYS_CLOCK_EXISTS=n +CONFIG_TIMEOUT_64BIT=n diff --git a/samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.conf b/samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.conf new file mode 100644 index 00000000..d98f9b33 --- /dev/null +++ b/samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.conf @@ -0,0 +1,33 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +## Disable serial and UART interface. +CONFIG_SERIAL=n +CONFIG_UART_CONSOLE=n + +CONFIG_LOG=n + +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_CTLR_ASSERT_HANDLER=y +CONFIG_BT_CENTRAL=n + +CONFIG_ASSERT=y +CONFIG_EXCEPTION_STACK_TRACE=y + +CONFIG_NRF_802154_SER_RADIO=y +CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=2 + +CONFIG_MBOX=y +CONFIG_IPC_SERVICE=y + +CONFIG_IPC_RADIO_BT=y +CONFIG_IPC_RADIO_BT_HCI_IPC=y +CONFIG_IPC_RADIO_802154=y diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay b/samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.overlay similarity index 64% rename from samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay rename to samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.overlay index cc09c036..b46ec7b6 100644 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay +++ b/samples/light_bulb/sysbuild/ipc_radio/boards/nrf5340dk_nrf5340_cpunet_fota.overlay @@ -4,4 +4,4 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#include "nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay" +#include diff --git a/samples/light_bulb/sysbuild/ipc_radio/prj.conf b/samples/light_bulb/sysbuild/ipc_radio/prj.conf new file mode 100644 index 00000000..799deb88 --- /dev/null +++ b/samples/light_bulb/sysbuild/ipc_radio/prj.conf @@ -0,0 +1,33 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +## Disable serial and UART interface. +CONFIG_SERIAL=n +CONFIG_UART_CONSOLE=n + +CONFIG_LOG=n + +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_MAX_CONN=4 +CONFIG_BT_CTLR_ASSERT_HANDLER=y + +CONFIG_ASSERT=y +CONFIG_EXCEPTION_STACK_TRACE=y + +CONFIG_NRF_802154_SER_RADIO=y +CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=2 + +CONFIG_MBOX=y +CONFIG_IPC_SERVICE=y + +CONFIG_IPC_RADIO_BT=y +CONFIG_IPC_RADIO_BT_HCI_IPC=y +CONFIG_IPC_RADIO_802154=y diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 00000000..28da253a --- /dev/null +++ b/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,34 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_HW_STACK_PROTECTION=n +CONFIG_BOOT_WATCHDOG_FEED=n + +# Disable all debug features +CONFIG_ASSERT_VERBOSE=n +CONFIG_ASSERT_NO_FILE_INFO=y +CONFIG_PRINTK=n + +CONFIG_MAIN_STACK_SIZE=8192 + +# Configure MCUboot features +CONFIG_NRF53_MULTI_IMAGE_UPDATE=y +CONFIG_BOOT_UPGRADE_ONLY=y +CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y +CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS=n + +# Enable flash simulator +CONFIG_PCD_APP=y +CONFIG_FLASH_SIMULATOR=y +CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y +CONFIG_FLASH_SIMULATOR_STATS=n + +# Configure QSPI for external flash +CONFIG_FLASH=y +CONFIG_FPROTECT=y +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/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay b/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay new file mode 100644 index 00000000..cd39f476 --- /dev/null +++ b/samples/light_bulb/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.conf b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp.conf similarity index 77% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.conf rename to samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp.conf index 8e83f517..c8b2ea1b 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.conf +++ b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp.conf @@ -5,6 +5,7 @@ # CONFIG_HW_STACK_PROTECTION=n +CONFIG_FPROTECT=n CONFIG_BOOT_WATCHDOG_FEED=n # Disable all debug features @@ -12,11 +13,16 @@ CONFIG_ASSERT_VERBOSE=n CONFIG_ASSERT_NO_FILE_INFO=y CONFIG_PRINTK=n +# nRF54L15 DK uses SPI NOR external flash CONFIG_GPIO=y CONFIG_SPI=y CONFIG_SPI_NOR=y CONFIG_SPI_NOR_SFDP_DEVICETREE=y CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR=n + +# required by SPI driver +CONFIG_MULTITHREADING=y # Currently, without tickless kernel, the SYSCOUNTER value after the software # reset is not set properly and due to that the first system interrupt is not called @@ -24,3 +30,6 @@ CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 # reset + 1. Hence, the reboot time increases more and more. # To avoid it enable tickless kernel for mcuboot. CONFIG_TICKLESS_KERNEL=y + +# Ensure the fastest RRAM write operations +CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32 diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf deleted file mode 100644 index 5872b98b..00000000 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_FPROTECT=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into the internal boot partition. -# The secondary slot resides in internal RRAM, so external flash is not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y - -# Ensure the fastest RRAM write operations -CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32 diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay deleted file mode 100644 index 21ef390d..00000000 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2026 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -/ { - chosen { - zephyr,code-partition = &boot_partition; - }; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1524)>; -}; diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf deleted file mode 100644 index 0759b318..00000000 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into 40 KB partition. -# These options can be safely disabled because in this configuration, -# the secondary slot resides in the internal RRAM, so features -# needed to handle the external flash are not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay deleted file mode 100644 index 386c9fbf..00000000 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2026 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include -#include - -/ { - chosen { - zephyr,code-partition = &boot_partition; - }; -}; diff --git a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf b/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf deleted file mode 100644 index 0759b318..00000000 --- a/samples/light_bulb/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into 40 KB partition. -# These options can be safely disabled because in this configuration, -# the secondary slot resides in the internal RRAM, so features -# needed to handle the external flash are not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/samples/light_switch/Kconfig b/samples/light_switch/Kconfig index 19971527..dbda1359 100644 --- a/samples/light_switch/Kconfig +++ b/samples/light_switch/Kconfig @@ -19,6 +19,13 @@ config CHIP_ENABLE_ICD_SUPPORT endif # OPENTHREAD +if ZIGBEE_BT_DFU + +config BT_DEVICE_NAME + default "Zigbee_Switch" + +endif # ZIGBEE_BT_DFU + config MPSL_THREAD_COOP_PRIO default 8 @@ -57,10 +64,3 @@ config LIGHT_SWITCH_LOW_POWER help Enable low power mode for the Light Switch sample. This enables sleepy behavior and disables LEDs for power savings. - -if ZIGBEE_BT_DFU - -config BT_DEVICE_NAME - default "Zigbee_Switch" - -endif # ZIGBEE_BT_DFU diff --git a/samples/light_switch/README.rst b/samples/light_switch/README.rst index 124df2fe..a611c421 100644 --- a/samples/light_switch/README.rst +++ b/samples/light_switch/README.rst @@ -169,28 +169,11 @@ You can find the configuration files in the :file:`samples/light_switch` directo Activating optional extensions ------------------------------ -To activate the :ref:`lib_zigbee_fota`, use the :file:`prj_fota.conf` configuration file. -For example, when building from the command line, use the following command: - -.. parsed-literal:: - :class: highlight - - west build samples/light_switch -b *board_target* -- -DFILE_SUFFIX=fota - -The FOTA variant enables `MCUboot image compression`_. -The generated Zigbee update file contains a compressed MCUboot image, and MCUboot decompresses it while applying the update. -This setting reduces the update image size, but the MCUboot must run in the overwrite-only mode, so the device cannot revert to the previous image after the update is applied. - -Alternatively, you can :ref:`configure Zigbee FOTA manually `. - -.. note:: - You can use the :file:`prj_fota.conf` file only with a development kit that contains the nRF52840, nRF5340, nRF54L15 or nRF54L10 SoC. +.. |sample activating variants ref| replace:: :ref:`zigbee_light_switch_activating_variants` +.. |sample zigbee bt dfu testing ref| replace:: :ref:`zigbee_light_switch_testing_zigbee_bt_dfu` +.. |sample dir| replace:: samples/light_switch -.. note:: - The decompression support increases the size of the MCUboot image. - When adapting this FOTA configuration to a custom board or application, make sure that the MCUboot partition is large enough for the generated bootloader image. - The sample keeps the primary and secondary application slots the same size; resizing the secondary slot is optional and depends on the compression ratio of your application image. - The FOTA variant uses devicetree-based partitioning with Partition Manager disabled; see :ref:`zigbee_ug_static_partition` for the partition layout requirements. +.. include:: /includes/zigbee_bt_dfu_activation.txt To activate the Multiprotocol Bluetooth LE extension, set :makevar:`EXTRA_CONF_FILE` to the :file:`overlay-multiprotocol_ble.conf`. For example, when building from the command line, use the following command: @@ -202,7 +185,9 @@ For example, when building from the command line, use the following command: .. |sample matter ref| replace:: :ref:`zigbee_light_switch_sample_matter` .. |sample matter limitations ref| replace:: :ref:`zigbee_light_switch_matter_limitations` -.. |sample dir| replace:: samples/light_switch +.. |sample matter bt dfu testing ref| replace:: :ref:`zigbee_light_switch_testing_matter_bt_dfu` +.. |sample matter testing ref| replace:: :ref:`zigbee_light_switch_testing_matter` +.. |sample matter activating variants ref| replace:: :ref:`zigbee_light_switch_activating_variants` .. include:: /includes/matter_extension_activation.txt @@ -562,6 +547,28 @@ Complete the following steps to exercise the full Zigbee-to-Matter flow: * Or trigger a Matter factory reset from the controller (for example, ``chip-tool pairing unpair …``). The device reboots as a fresh Zigbee End Device with Matter Bluetooth LE advertising active again, and Matter storage is cleared. +.. _zigbee_light_switch_testing_zigbee_bt_dfu: + +Testing Zigbee FOTA DFU over Bluetooth SMP +------------------------------------------ + +.. |zigbee bt device name| replace:: Zigbee_Switch +.. |zigbee mcumgr smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='Zigbee_Switch' image upload build/light_switch/zephyr/zephyr.signed.bin + +.. include:: /includes/zigbee_bt_dfu_testing.txt + +.. _zigbee_light_switch_testing_matter_bt_dfu: + +Testing Matter extension DFU over Bluetooth SMP +----------------------------------------------- + +.. |bt device name| replace:: MatterZigbeeSw +.. |app name| replace:: light_switch +.. |matter mcumgr smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='MatterZigbeeSw' image upload build/light_switch/zephyr/zephyr.signed.bin -n 0 -w 1 +.. |matter mcumgr net smp upload| replace:: mcumgr --conntype ble --hci 0 --connstring peer_name='MatterZigbeeSw' image upload build/signed_by_mcuboot_and_b0_ipc_radio.bin -n 1 -w 1 + +.. include:: /includes/matter_extension_bt_dfu_testing.txt + Sample output ------------- diff --git a/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay b/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay index 5441a4a9..ffd74003 100644 --- a/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay +++ b/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay @@ -9,7 +9,6 @@ / { chosen { - nordic,pm-ext-flash = &mx25r64; ncs,zigbee-timer = &timer2; }; }; diff --git a/samples/light_switch/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay b/samples/light_switch/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay index 17e90a3c..6d49f155 100644 --- a/samples/light_switch/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay +++ b/samples/light_switch/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay @@ -1,48 +1,8 @@ /* - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2026 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include -#include - -/ { - chosen { - ncs,zigbee-timer = &timer20; - }; - - pwmleds { - compatible = "pwm-leds"; - - pwm_led3: pwm_led_3 { - pwms = <&pwm20 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; - }; - }; -}; - -&pwm20 { - status = "okay"; - pinctrl-0 = <&pwm_default>; - pinctrl-1 = <&pwm_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&pinctrl { - pwm_default: pwm_default { - group1 { - psels = ; - }; - }; - - pwm_sleep: pwm_sleep { - group1 { - psels = ; - low-power-enable; - }; - }; -}; - -&timer20 { - status = "okay"; -}; +#include diff --git a/samples/light_switch/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay b/samples/light_switch/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay index 5005d916..7b7eefb1 100644 --- a/samples/light_switch/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay +++ b/samples/light_switch/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay @@ -1,48 +1,8 @@ /* - * Copyright (c) 2025 Nordic Semiconductor ASA + * Copyright (c) 2026 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include #include - -/ { - chosen { - ncs,zigbee-timer = &timer20; - }; - - pwmleds { - compatible = "pwm-leds"; - - pwm_led3: pwm_led_3 { - pwms = <&pwm20 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; - }; - }; -}; - -&pwm20 { - status = "okay"; - pinctrl-0 = <&pwm_default>; - pinctrl-1 = <&pwm_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&pinctrl { - pwm_default: pwm_default { - group1 { - psels = ; - }; - }; - - pwm_sleep: pwm_sleep { - group1 { - psels = ; - low-power-enable; - }; - }; -}; - -&timer20 { - status = "okay"; -}; diff --git a/samples/light_switch/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay b/samples/light_switch/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay index cb54d49e..c4ee92be 100644 --- a/samples/light_switch/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay +++ b/samples/light_switch/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay @@ -14,8 +14,6 @@ chosen { zephyr,zigbee-timer = &timer24; - zephyr,code-partition = &slot0_partition; - zephyr,ieee802154 = &ieee802154; }; pwmleds { @@ -48,18 +46,6 @@ }; }; -/* Restore full RRAM and SRAM (cpuapp_sram is 511K per SoC DTSI). */ -&rram_controller { - cpuapp_rram: rram@0 { - reg = <0x0 DT_SIZE_K(2036)>; - ranges = <0x0 0x0 DT_SIZE_K(2036)>; - }; -}; - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(511)>; -}; - &timer24 { status = "okay"; }; diff --git a/samples/light_switch/nrf52840dk_nrf52840.overlay b/samples/light_switch/nrf52840dk_nrf52840.overlay deleted file mode 100644 index f0cba3de..00000000 --- a/samples/light_switch/nrf52840dk_nrf52840.overlay +++ /dev/null @@ -1,40 +0,0 @@ -&flash0 { - partitions { - boot_partition: partition@0 { - compatible = "zephyr,mapped-partition"; - label = "mcuboot"; - reg = <0x0 0xc000>; - }; - - slot0_partition: partition@c000 { - compatible = "zephyr,mapped-partition"; - label = "image-0"; - reg = <0xc000 0x74000>; - }; - - slot1_partition: partition@80000 { - compatible = "zephyr,mapped-partition"; - label = "image-1"; - reg = <0x80000 0x74000>; - }; - - zboss_nvram: partition@f5000 { - compatible = "zephyr,mapped-partition"; - label = "zboss-nvram"; - reg = <0xf5000 0x8000>; - }; - - zboss_product_config: partition@fd000 { - compatible = "zephyr,mapped-partition"; - label = "zboss-product-config"; - reg = <0xfd000 0x1000>; - }; - - storage_partition: partition@fe000 { - compatible = "zephyr,mapped-partition"; - label = "storage"; - reg = <0xfe000 0x2000>; - }; - }; -}; - diff --git a/samples/light_switch/prj_matter_fota.conf b/samples/light_switch/prj_matter_fota.conf index a38601a7..be8e7f3e 100644 --- a/samples/light_switch/prj_matter_fota.conf +++ b/samples/light_switch/prj_matter_fota.conf @@ -93,3 +93,6 @@ CONFIG_NRF_802154_DRV_REINIT_ENABLED=y CONFIG_ZIGBEE_DEBUG_FUNCTIONS=y CONFIG_CHIP_FACTORY_DATA_BUILD=y + +# DFU over Bluetooth LE SMP +CONFIG_CHIP_DFU_OVER_BT_SMP=y diff --git a/samples/light_switch/sample.yaml b/samples/light_switch/sample.yaml index e7b71189..bae90431 100644 --- a/samples/light_switch/sample.yaml +++ b/samples/light_switch/sample.yaml @@ -44,17 +44,6 @@ tests: - nrf54lm20dk/nrf54lm20b/cpuapp tags: - no_integration - sample.zigbee.light_switch.matter.bt_dfu: - sysbuild: true - build_only: true - extra_args: - - FILE_SUFFIX=matter_fota - - CONFIG_CHIP_DFU_OVER_BT_SMP=y - integration_platforms: - - nrf54lm20dk/nrf54lm20b/cpuapp - platform_allow: - - nrf54lm20dk/nrf54lm20a/cpuapp - - nrf54lm20dk/nrf54lm20b/cpuapp sample.zigbee.light_switch: sysbuild: true build_only: true @@ -107,6 +96,7 @@ tests: build_only: true extra_args: - FILE_SUFFIX=fota + - SNIPPET=zigbee_fota_ext_flash integration_platforms: - nrf52840dk/nrf52840 - nrf54l15dk/nrf54l15/cpuapp @@ -123,6 +113,7 @@ tests: build_only: true extra_args: - FILE_SUFFIX=fota + - SNIPPET=zigbee_fota_ext_flash - OVERLAY_CONFIG=overlay-multiprotocol_ble.conf integration_platforms: - nrf5340dk/nrf5340/cpuapp @@ -133,25 +124,6 @@ tests: - nrf54l15dk/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - sample.zigbee.light_switch.fota_and_bt_dfu: - sysbuild: true - build_only: true - extra_args: - - FILE_SUFFIX=fota - - CONFIG_ZIGBEE_BT_DFU=y - integration_platforms: - - nrf52840dk/nrf52840 - - nrf5340dk/nrf5340/cpuapp - - nrf54l15dk/nrf54l10/cpuapp - - nrf54l15dk/nrf54l15/cpuapp - - nrf54lm20dk/nrf54lm20b/cpuapp - platform_allow: - - nrf52840dk/nrf52840 - - nrf5340dk/nrf5340/cpuapp - - nrf54l15dk/nrf54l10/cpuapp - - nrf54l15dk/nrf54l15/cpuapp - - nrf54lm20dk/nrf54lm20a/cpuapp - - nrf54lm20dk/nrf54lm20b/cpuapp sample.zigbee.light_switch.low_power: sysbuild: true build_only: true diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf b/samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf deleted file mode 100644 index 8a7cafe4..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840.conf +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2025 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -CONFIG_NORDIC_QSPI_NOR=y -CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 -CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay b/samples/light_switch/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay index 276e4546..cd39f476 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay +++ b/samples/light_switch/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp_fota.overlay @@ -1,15 +1,8 @@ /* - * Copyright (c) 2025 Nordic Semiconductor ASA + * Copyright (c) 2026 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include #include - -/ { - chosen { - zephyr,code-partition = &boot_partition; - nordic,pm-ext-flash = &mx25r64; - }; -}; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf b/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf deleted file mode 100644 index 5872b98b..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.conf +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_FPROTECT=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into the internal boot partition. -# The secondary slot resides in internal RRAM, so external flash is not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y - -# Ensure the fastest RRAM write operations -CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32 diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay b/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay deleted file mode 100644 index 21ef390d..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_matter_fota.overlay +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2026 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -/ { - chosen { - zephyr,code-partition = &boot_partition; - }; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1524)>; -}; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf b/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf deleted file mode 100644 index 0759b318..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.conf +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into 40 KB partition. -# These options can be safely disabled because in this configuration, -# the secondary slot resides in the internal RRAM, so features -# needed to handle the external flash are not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.conf b/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.conf deleted file mode 100644 index 8e83f517..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_fota.conf +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -CONFIG_GPIO=y -CONFIG_SPI=y -CONFIG_SPI_NOR=y -CONFIG_SPI_NOR_SFDP_DEVICETREE=y -CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf b/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf deleted file mode 100644 index 0759b318..00000000 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.conf +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2026 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_HW_STACK_PROTECTION=n -CONFIG_BOOT_WATCHDOG_FEED=n - -# Disable all debug features -CONFIG_ASSERT_VERBOSE=n -CONFIG_ASSERT_NO_FILE_INFO=y -CONFIG_PRINTK=n - -# Bootloader size optimization to fit into 40 KB partition. -# These options can be safely disabled because in this configuration, -# the secondary slot resides in the internal RRAM, so features -# needed to handle the external flash are not needed. -CONFIG_SPI_NOR=n -CONFIG_SPI=n - -# Currently, without tickless kernel, the SYSCOUNTER value after the software -# reset is not set properly and due to that the first system interrupt is not called -# in the proper time - the SYSCOUNTER value is set to the value from before -# reset + 1. Hence, the reboot time increases more and more. -# To avoid it enable tickless kernel for mcuboot. -CONFIG_TICKLESS_KERNEL=y diff --git a/snippets/zigbee_fota_ext_flash/boards/nrf52840dk_nrf52840.overlay b/snippets/zigbee_fota_ext_flash/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 00000000..033db7f4 --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include diff --git a/snippets/zigbee_fota_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay b/snippets/zigbee_fota_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 00000000..cd39f476 --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include diff --git a/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay b/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay new file mode 100644 index 00000000..c1ad538f --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + chosen { + ncs,zigbee-timer = &timer20; + }; + + pwmleds { + compatible = "pwm-leds"; + + pwm_led3: pwm_led_3 { + pwms = <&pwm20 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; + +&pwm20 { + status = "okay"; + pinctrl-0 = <&pwm_default>; + pinctrl-1 = <&pwm_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&pinctrl { + pwm_default: pwm_default { + group1 { + psels = ; + }; + }; + + pwm_sleep: pwm_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&timer20 { + status = "okay"; +}; diff --git a/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 00000000..e48502ca --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + chosen { + ncs,zigbee-timer = &timer20; + }; + + pwmleds { + compatible = "pwm-leds"; + + pwm_led3: pwm_led_3 { + pwms = <&pwm20 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; + +&pwm20 { + status = "okay"; + pinctrl-0 = <&pwm_default>; + pinctrl-1 = <&pwm_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&pinctrl { + pwm_default: pwm_default { + group1 { + psels = ; + }; + }; + + pwm_sleep: pwm_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&timer20 { + status = "okay"; +}; diff --git a/snippets/zigbee_fota_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay b/snippets/zigbee_fota_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay new file mode 100644 index 00000000..1949bc5b --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/ { + chosen { + zephyr,code-partition = &slot0_partition; + zephyr,ieee802154 = &ieee802154; + }; +}; + +&rram_controller { + cpuapp_rram: rram@0 { + reg = <0x0 DT_SIZE_K(2036)>; + ranges = <0x0 0x0 DT_SIZE_K(2036)>; + }; +}; + +&cpuapp_sram { + reg = <0x20000000 DT_SIZE_K(511)>; +}; diff --git a/snippets/zigbee_fota_ext_flash/snippet.yml b/snippets/zigbee_fota_ext_flash/snippet.yml new file mode 100644 index 00000000..913a75e4 --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/snippet.yml @@ -0,0 +1,30 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +name: zigbee_fota_ext_flash +append: + SB_EXTRA_CONF_FILE: zigbee_fota_sysbuild.conf +boards: + nrf52840dk/nrf52840: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf52840dk_nrf52840.overlay + EXTRA_CONF_FILE: zigbee_fota_nrf52840.conf + nrf5340dk/nrf5340/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf5340dk_nrf5340_cpuapp.overlay + EXTRA_CONF_FILE: zigbee_fota_nrf5340.conf + nrf54l15dk/nrf54l15/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l15_cpuapp.overlay + EXTRA_CONF_FILE: zigbee_fota_spi_nor.conf + nrf54l15dk/nrf54l10/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l10_cpuapp.overlay + EXTRA_CONF_FILE: zigbee_fota_spi_nor.conf + /nrf54lm20dk/nrf54lm20[ab]/cpuapp/: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay + EXTRA_CONF_FILE: zigbee_fota_spi_nor.conf diff --git a/samples/light_switch/boards/nrf52840dk_nrf52840_fota.conf b/snippets/zigbee_fota_ext_flash/zigbee_fota_nrf52840.conf similarity index 65% rename from samples/light_switch/boards/nrf52840dk_nrf52840_fota.conf rename to snippets/zigbee_fota_ext_flash/zigbee_fota_nrf52840.conf index 176c006f..84b05bf1 100644 --- a/samples/light_switch/boards/nrf52840dk_nrf52840_fota.conf +++ b/snippets/zigbee_fota_ext_flash/zigbee_fota_nrf52840.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 Nordic Semiconductor ASA +# Copyright (c) 2026 Nordic Semiconductor ASA # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # diff --git a/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.conf b/snippets/zigbee_fota_ext_flash/zigbee_fota_nrf5340.conf similarity index 71% rename from samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.conf rename to snippets/zigbee_fota_ext_flash/zigbee_fota_nrf5340.conf index a878aaf9..cc78f116 100644 --- a/samples/light_switch/boards/nrf5340dk_nrf5340_cpuapp_fota.conf +++ b/snippets/zigbee_fota_ext_flash/zigbee_fota_nrf5340.conf @@ -1,13 +1,9 @@ # -# Copyright (c) 2025 Nordic Semiconductor ASA +# Copyright (c) 2026 Nordic Semiconductor ASA # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -####################### -# Zigbee FOTA overlay # -####################### - # Configure QSPI for external flash CONFIG_NORDIC_QSPI_NOR=y CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 diff --git a/snippets/zigbee_fota_ext_flash/zigbee_fota_spi_nor.conf b/snippets/zigbee_fota_ext_flash/zigbee_fota_spi_nor.conf new file mode 100644 index 00000000..82320973 --- /dev/null +++ b/snippets/zigbee_fota_ext_flash/zigbee_fota_spi_nor.conf @@ -0,0 +1,12 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# SPI NOR external flash for MCUboot secondary slot (Zigbee FOTA / SMP DFU writes) +CONFIG_SPI=y +CONFIG_SPI_NOR=y +CONFIG_SPI_NOR_SFDP_DEVICETREE=y +CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR=n diff --git a/samples/light_switch/sysbuild_fota.conf b/snippets/zigbee_fota_ext_flash/zigbee_fota_sysbuild.conf similarity index 83% rename from samples/light_switch/sysbuild_fota.conf rename to snippets/zigbee_fota_ext_flash/zigbee_fota_sysbuild.conf index 7e2f3281..f1186b66 100644 --- a/samples/light_switch/sysbuild_fota.conf +++ b/snippets/zigbee_fota_ext_flash/zigbee_fota_sysbuild.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2024 Nordic Semiconductor ASA +# Copyright (c) 2026 Nordic Semiconductor ASA # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf52840dk_nrf52840.overlay similarity index 88% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf52840dk_nrf52840.overlay index b1ca9b00..01aa9b31 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf52840dk_nrf52840_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf52840dk_nrf52840.overlay @@ -10,6 +10,5 @@ / { chosen { zephyr,code-partition = &boot_partition; - nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 64% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay index 386c9fbf..06b92c43 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -4,8 +4,8 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#include -#include +#include +#include / { chosen { diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay similarity index 73% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay index 32029860..aa4b6e12 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l10_cpuapp_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l10_cpuapp.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2026 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ @@ -10,6 +10,5 @@ / { chosen { zephyr,code-partition = &boot_partition; - nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay similarity index 73% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index d215b9b5..c9883c6e 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54l15dk_nrf54l15_cpuapp_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Nordic Semiconductor ASA + * Copyright (c) 2026 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ @@ -10,6 +10,5 @@ / { chosen { zephyr,code-partition = &boot_partition; - nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay similarity index 89% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay index 809d5aea..44499f9e 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20a_cpuapp_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay @@ -10,6 +10,5 @@ / { chosen { zephyr,code-partition = &boot_partition; - nordic,pm-ext-flash = &mx25r64; }; }; diff --git a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay similarity index 64% rename from samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay rename to snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay index cc09c036..02a3f8ab 100644 --- a/samples/light_switch/sysbuild/mcuboot/boards/nrf54lm20dk_nrf54lm20b_cpuapp_matter_fota.overlay +++ b/snippets/zigbee_fota_mcuboot_ext_flash/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay @@ -4,4 +4,4 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#include "nrf54lm20dk_nrf54lm20a_cpuapp_matter_fota.overlay" +#include "nrf54lm20dk_nrf54lm20a_cpuapp.overlay" diff --git a/snippets/zigbee_fota_mcuboot_ext_flash/nrf52840dk_nrf52840.conf b/snippets/zigbee_fota_mcuboot_ext_flash/nrf52840dk_nrf52840.conf new file mode 100644 index 00000000..4a2d230a --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/nrf52840dk_nrf52840.conf @@ -0,0 +1,9 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +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/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l10_cpuapp.conf b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l10_cpuapp.conf new file mode 100644 index 00000000..7b7cb658 --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l10_cpuapp.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_FPROTECT=n +CONFIG_NORDIC_QSPI_NOR=n +CONFIG_MULTITHREADING=y +CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32 diff --git a/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l15_cpuapp.conf b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l15_cpuapp.conf new file mode 100644 index 00000000..7b7cb658 --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54l15dk_nrf54l15_cpuapp.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_FPROTECT=n +CONFIG_NORDIC_QSPI_NOR=n +CONFIG_MULTITHREADING=y +CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32 diff --git a/snippets/zigbee_fota_mcuboot_ext_flash/nrf54lm20dk_nrf54lm20a_cpuapp.conf b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54lm20dk_nrf54lm20a_cpuapp.conf new file mode 100644 index 00000000..e70d95d9 --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/nrf54lm20dk_nrf54lm20a_cpuapp.conf @@ -0,0 +1,11 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_GPIO=y +CONFIG_SPI=y +CONFIG_SPI_NOR=y +CONFIG_SPI_NOR_SFDP_DEVICETREE=y +CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 diff --git a/snippets/zigbee_fota_mcuboot_ext_flash/snippet.yml b/snippets/zigbee_fota_mcuboot_ext_flash/snippet.yml new file mode 100644 index 00000000..561d408a --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/snippet.yml @@ -0,0 +1,29 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +name: zigbee_fota_mcuboot_ext_flash +append: + EXTRA_CONF_FILE: zigbee_fota_mcuboot_ext_flash.conf +boards: + nrf52840dk/nrf52840: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf52840dk_nrf52840.overlay + EXTRA_CONF_FILE: nrf52840dk_nrf52840.conf + nrf5340dk/nrf5340/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf5340dk_nrf5340_cpuapp.overlay + nrf54l15dk/nrf54l15/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l15_cpuapp.overlay + EXTRA_CONF_FILE: nrf54l15dk_nrf54l15_cpuapp.conf + nrf54l15dk/nrf54l10/cpuapp: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l10_cpuapp.overlay + EXTRA_CONF_FILE: nrf54l15dk_nrf54l10_cpuapp.conf + /nrf54lm20dk/nrf54lm20[ab]/cpuapp/: + append: + EXTRA_DTC_OVERLAY_FILE: boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay + EXTRA_CONF_FILE: nrf54lm20dk_nrf54lm20a_cpuapp.conf diff --git a/snippets/zigbee_fota_mcuboot_ext_flash/zigbee_fota_mcuboot_ext_flash.conf b/snippets/zigbee_fota_mcuboot_ext_flash/zigbee_fota_mcuboot_ext_flash.conf new file mode 100644 index 00000000..1ae557d4 --- /dev/null +++ b/snippets/zigbee_fota_mcuboot_ext_flash/zigbee_fota_mcuboot_ext_flash.conf @@ -0,0 +1,15 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_HW_STACK_PROTECTION=n +CONFIG_BOOT_WATCHDOG_FEED=n + +# Disable all debug features +CONFIG_ASSERT_VERBOSE=n +CONFIG_ASSERT_NO_FILE_INFO=y +CONFIG_PRINTK=n + +CONFIG_TICKLESS_KERNEL=y diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt index 5142bf47..9796563e 100644 --- a/sysbuild/CMakeLists.txt +++ b/sysbuild/CMakeLists.txt @@ -24,6 +24,7 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) # Extend this list as needed. set(app_mcuboot_snippet_pairs matter_fota_ext_flash matter_fota_mcuboot_ext_flash + zigbee_fota_ext_flash zigbee_fota_mcuboot_ext_flash ) set(mcuboot_snippets ${global_snippets})