Skip to content

Commit b4dac24

Browse files
subsys: added support for DFU over Bluetooth LE SMP
Created a new Kconfig module that provides support for DFU over BLuetooth LE for Zigbee-only solution. Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
1 parent f4c9f66 commit b4dac24

10 files changed

Lines changed: 329 additions & 5 deletions

File tree

include/zigbee/zigbee_bt_dfu.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/**
8+
* @file zigbee_bt_dfu.h
9+
*
10+
* @brief DFU over Bluetooth LE SMP helpers for Zigbee applications.
11+
*/
12+
13+
#ifndef ZIGBEE_BT_DFU_H_
14+
#define ZIGBEE_BT_DFU_H_
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
void zigbee_bt_dfu_init(void);
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
26+
#endif /* ZIGBEE_BT_DFU_H_ */

samples/light_switch/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,10 @@ config LIGHT_SWITCH_LOW_POWER
5757
help
5858
Enable low power mode for the Light Switch sample.
5959
This enables sleepy behavior and disables LEDs for power savings.
60+
61+
if ZIGBEE_BT_DFU
62+
63+
config BT_DEVICE_NAME
64+
default "Zigbee_Switch"
65+
66+
endif # ZIGBEE_BT_DFU

samples/light_switch/sample.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ tests:
3535
- smoke
3636
- sysbuild
3737
- ci_samples_zigbee
38+
sample.zigbee.light_switch.matter.bt_dfu:
39+
sysbuild: true
40+
build_only: true
41+
extra_args:
42+
- FILE_SUFFIX=matter_fota
43+
- CONFIG_CHIP_DFU_OVER_BT_SMP=y
44+
integration_platforms:
45+
- nrf54lm20dk/nrf54lm20a/cpuapp
46+
- nrf54lm20dk/nrf54lm20b/cpuapp
47+
platform_allow:
48+
- nrf54lm20dk/nrf54lm20a/cpuapp
49+
- nrf54lm20dk/nrf54lm20b/cpuapp
50+
tags:
51+
- ci_build
52+
- smoke
53+
- sysbuild
54+
- ci_samples_zigbee
3855
sample.zigbee.light_switch:
3956
sysbuild: true
4057
build_only: true
@@ -148,6 +165,31 @@ tests:
148165
- smoke
149166
- sysbuild
150167
- ci_samples_zigbee
168+
sample.zigbee.light_switch.fota_and_bt_dfu:
169+
sysbuild: true
170+
build_only: true
171+
extra_args:
172+
- FILE_SUFFIX=fota
173+
- CONFIG_ZIGBEE_BT_DFU=y
174+
integration_platforms:
175+
- nrf52840dk/nrf52840
176+
- nrf5340dk/nrf5340/cpuapp
177+
- nrf54l15dk/nrf54l10/cpuapp
178+
- nrf54l15dk/nrf54l15/cpuapp
179+
- nrf54lm20dk/nrf54lm20a/cpuapp
180+
- nrf54lm20dk/nrf54lm20b/cpuapp
181+
platform_allow:
182+
- nrf52840dk/nrf52840
183+
- nrf5340dk/nrf5340/cpuapp
184+
- nrf54l15dk/nrf54l10/cpuapp
185+
- nrf54l15dk/nrf54l15/cpuapp
186+
- nrf54lm20dk/nrf54lm20a/cpuapp
187+
- nrf54lm20dk/nrf54lm20b/cpuapp
188+
tags:
189+
- ci_build
190+
- smoke
191+
- sysbuild
192+
- ci_samples_zigbee
151193
sample.zigbee.light_switch.low_power:
152194
sysbuild: true
153195
build_only: true

samples/light_switch/src/app_task_zigbee.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@
3838
#if CONFIG_ZIGBEE_FOTA
3939
#include <zigbee/zigbee_fota.h>
4040
#include <zephyr/sys/reboot.h>
41+
#endif /* CONFIG_ZIGBEE_FOTA */
42+
43+
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)
4144
#include <zephyr/dfu/mcuboot.h>
45+
#endif
4246

47+
#if CONFIG_ZIGBEE_FOTA
4348
/* LED indicating OTA Client Activity. */
4449
#define OTA_ACTIVITY_LED DK_LED2
4550
#endif /* CONFIG_ZIGBEE_FOTA */
4651

52+
#ifdef CONFIG_ZIGBEE_BT_DFU
53+
#include <zigbee/zigbee_bt_dfu.h>
54+
#endif
55+
4756
#if CONFIG_BT_NUS
4857
#include "nus_cmd.h"
4958

@@ -642,7 +651,7 @@ static void light_switch_button_handler(struct k_timer *timer)
642651
}
643652
}
644653

645-
#ifdef CONFIG_ZIGBEE_FOTA
654+
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)
646655
static void confirm_image(void)
647656
{
648657
if (!boot_is_img_confirmed()) {
@@ -655,7 +664,9 @@ static void confirm_image(void)
655664
}
656665
}
657666
}
667+
#endif
658668

669+
#ifdef CONFIG_ZIGBEE_FOTA
659670
static void ota_evt_handler(const struct zigbee_fota_evt *evt)
660671
{
661672
switch (evt->id) {
@@ -959,17 +970,23 @@ int ZigbeeStart(void)
959970
power_down_unused_ram();
960971
}
961972

973+
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)
974+
/* Mark the current firmware as valid. */
975+
confirm_image();
976+
#endif
977+
962978
#ifdef CONFIG_ZIGBEE_FOTA
963979
/* Initialize Zigbee FOTA download service. */
964980
zigbee_fota_init(ota_evt_handler);
965981

966-
/* Mark the current firmware as valid. */
967-
confirm_image();
968-
969982
/* Register callback for handling ZCL commands. */
970983
ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb);
971984
#endif /* CONFIG_ZIGBEE_FOTA */
972985

986+
#ifdef CONFIG_ZIGBEE_BT_DFU
987+
zigbee_bt_dfu_init();
988+
#endif
989+
973990
/* Register dimmer switch device context (endpoints). */
974991
ZB_AF_REGISTER_DEVICE_CTX(&dimmer_switch_ctx);
975992

samples/light_switch/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#ifdef CONFIG_ZIGBEE_MATTER_COEXISTENCE
1919

20-
#include "app_task.h"
20+
#include "app_task_matter.h"
2121

2222
#include <zigbee/matter_coexistence.h>
2323

subsys/lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66

77
add_subdirectory_ifdef(CONFIG_ZIGBEE_FOTA zigbee_fota)
8+
add_subdirectory_ifdef(CONFIG_ZIGBEE_BT_DFU zigbee_bt_dfu)
89
add_subdirectory_ifdef(CONFIG_ZIGBEE_APP_UTILS zigbee_app_utils)
910
add_subdirectory_ifdef(CONFIG_ZIGBEE_LOGGER_EP zigbee_logger_ep)
1011
add_subdirectory_ifdef(CONFIG_ZIGBEE_MATTER_COEXISTENCE zigbee_matter_coexistence)

subsys/lib/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
menu "Zigbee libraries"
77

88
rsource "zigbee_fota/Kconfig"
9+
rsource "zigbee_bt_dfu/Kconfig"
910
rsource "zigbee_app_utils/Kconfig"
1011
rsource "zigbee_logger_ep/Kconfig"
1112
rsource "zigbee_matter_coexistence/Kconfig"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
zephyr_library()
8+
zephyr_library_sources(zigbee_bt_dfu.c)
9+
10+
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)

subsys/lib/zigbee_bt_dfu/Kconfig

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config ZIGBEE_BT_DFU
8+
bool "Enable DFU over Bluetooth LE SMP feature set"
9+
depends on !CHIP
10+
select BOOTLOADER_MCUBOOT
11+
select BT
12+
select BT_PERIPHERAL
13+
select MCUMGR
14+
select MCUMGR_TRANSPORT_BT
15+
select IMG_MANAGER
16+
select STREAM_FLASH
17+
select ZCBOR
18+
select MCUMGR_GRP_IMG
19+
select MCUMGR_GRP_OS
20+
select MCUMGR_GRP_IMG_STATUS_HOOKS
21+
# Enable custom SMP request to erase settings partition.
22+
select MCUMGR_GRP_ZBASIC
23+
select MCUMGR_GRP_ZBASIC_STORAGE_ERASE
24+
select MCUMGR_TRANSPORT_BT_REASSEMBLY
25+
help
26+
Enables Device Firmware Upgrade over Bluetooth LE with SMP and configures
27+
the set of options related to that feature.
28+
29+
Cannot be combined with Matter (CONFIG_CHIP), as it requires different Bluetooth LE orchestration.
30+
Use Matter's CONFIG_CHIP_DFU_OVER_BT_SMP instead.
31+
32+
if ZIGBEE_BT_DFU
33+
34+
config BT_MAX_CONN
35+
default 1
36+
37+
# MCU Manager and SMP configuration
38+
choice MCUMGR_TRANSPORT_BT_PERM
39+
default MCUMGR_TRANSPORT_BT_PERM_RW
40+
endchoice
41+
42+
config MCUMGR_TRANSPORT_NETBUF_COUNT
43+
default 6
44+
45+
config MCUMGR_MGMT_NOTIFICATION_HOOKS
46+
bool
47+
default y
48+
49+
config MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK
50+
bool
51+
default y
52+
53+
config MCUMGR_SMP_COMMAND_STATUS_HOOKS
54+
bool
55+
default y
56+
57+
# Increase BT MTU and RX buffer sizes to improve DFU throughput
58+
config BT_L2CAP_TX_MTU
59+
default 498
60+
61+
config BT_BUF_ACL_RX_SIZE
62+
default 502
63+
64+
# Increase MCUMGR_TRANSPORT_NETBUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
65+
config MCUMGR_TRANSPORT_NETBUF_SIZE
66+
default 1024
67+
68+
# Increase system workqueue size, as SMP is processed within it
69+
config SYSTEM_WORKQUEUE_STACK_SIZE
70+
default 2800
71+
72+
if SOC_SERIES_NRF53
73+
74+
# Enable custom SMP request to erase settings partition.
75+
config MCUMGR_GRP_ZBASIC
76+
default y
77+
78+
config MCUMGR_GRP_ZBASIC_STORAGE_ERASE
79+
default y
80+
81+
endif # SOC_SERIES_NRF53
82+
83+
module = ZIGBEE_BT_DFU
84+
module-str = Zigbee Bluetooth LE DFU
85+
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
86+
87+
endif # ZIGBEE_BT_DFU
88+

0 commit comments

Comments
 (0)