-
Notifications
You must be signed in to change notification settings - Fork 22
Added support for DFU over Bluetooth LE SMP #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| /** | ||
| * @file zigbee_bt_dfu.h | ||
| * | ||
| * @brief DFU over Bluetooth LE SMP helpers for Zigbee applications. | ||
| */ | ||
|
|
||
| #ifndef ZIGBEE_BT_DFU_H_ | ||
| #define ZIGBEE_BT_DFU_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| void zigbee_bt_dfu_init(void); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* ZIGBEE_BT_DFU_H_ */ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,12 +36,21 @@ | |||||
| #if CONFIG_ZIGBEE_FOTA | ||||||
| #include <zigbee/zigbee_fota.h> | ||||||
| #include <zephyr/sys/reboot.h> | ||||||
| #endif /* CONFIG_ZIGBEE_FOTA */ | ||||||
|
|
||||||
| #if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT, AFAIR we've not used IS_ENABLED anywhere.
Suggested change
|
||||||
| #include <zephyr/dfu/mcuboot.h> | ||||||
| #endif | ||||||
|
|
||||||
| #if CONFIG_ZIGBEE_FOTA | ||||||
| /* LED indicating OTA Client Activity. */ | ||||||
| #define OTA_ACTIVITY_LED DK_LED2 | ||||||
| #endif /* CONFIG_ZIGBEE_FOTA */ | ||||||
|
|
||||||
| #if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| #include <zigbee/zigbee_bt_dfu.h> | ||||||
| #endif | ||||||
|
|
||||||
| #if CONFIG_BT_NUS | ||||||
| #include "nus_cmd.h" | ||||||
|
|
||||||
|
|
@@ -623,7 +632,7 @@ static void light_switch_button_handler(struct k_timer *timer) | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| #ifdef CONFIG_ZIGBEE_FOTA | ||||||
| #if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| static void confirm_image(void) | ||||||
| { | ||||||
| if (!boot_is_img_confirmed()) { | ||||||
|
|
@@ -636,7 +645,9 @@ static void confirm_image(void) | |||||
| } | ||||||
| } | ||||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| #ifdef CONFIG_ZIGBEE_FOTA | ||||||
| static void ota_evt_handler(const struct zigbee_fota_evt *evt) | ||||||
| { | ||||||
| switch (evt->id) { | ||||||
|
|
@@ -940,17 +951,23 @@ int ZigbeeStart(void) | |||||
| power_down_unused_ram(); | ||||||
| } | ||||||
|
|
||||||
| #if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /* Mark the current firmware as valid. */ | ||||||
| confirm_image(); | ||||||
| #endif | ||||||
|
|
||||||
| #ifdef CONFIG_ZIGBEE_FOTA | ||||||
| /* Initialize Zigbee FOTA download service. */ | ||||||
| zigbee_fota_init(ota_evt_handler); | ||||||
|
|
||||||
| /* Mark the current firmware as valid. */ | ||||||
| confirm_image(); | ||||||
|
|
||||||
| /* Register callback for handling ZCL commands. */ | ||||||
| ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb); | ||||||
| #endif /* CONFIG_ZIGBEE_FOTA */ | ||||||
|
|
||||||
| #if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| zigbee_bt_dfu_init(); | ||||||
| #endif | ||||||
|
|
||||||
| /* Register dimmer switch device context (endpoints). */ | ||||||
| ZB_AF_REGISTER_DEVICE_CTX(&dimmer_switch_ctx); | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| zephyr_library() | ||
| zephyr_library_sources(zigbee_bt_dfu.c) | ||
|
|
||
| zephyr_library_link_libraries(MCUBOOT_BOOTUTIL) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor ASA | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar suggestion for |
||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| config ZIGBEE_BT_DFU | ||
| bool "Enable DFU over Bluetooth LE SMP feature set" | ||
| depends on !CHIP | ||
| imply BOOTLOADER_MCUBOOT | ||
|
|
||
| select BT | ||
| select BT_PERIPHERAL | ||
| select MCUMGR | ||
| select MCUMGR_TRANSPORT_BT | ||
| select IMG_MANAGER | ||
| select STREAM_FLASH | ||
| select ZCBOR | ||
| select MCUMGR_GRP_IMG | ||
| select MCUMGR_GRP_OS | ||
| select MCUMGR_GRP_IMG_STATUS_HOOKS | ||
| # Enable custom SMP request to erase settings partition. | ||
| select MCUMGR_GRP_ZBASIC | ||
| select MCUMGR_GRP_ZBASIC_STORAGE_ERASE | ||
| select MCUMGR_TRANSPORT_BT_REASSEMBLY | ||
| help | ||
| Enables Device Firmware Upgrade over Bluetooth LE with SMP and configures | ||
| the set of options related to that feature. | ||
|
|
||
| Cannot be combined with Matter (CONFIG_CHIP), as it requires different Bluetooth LE orchestration. | ||
| Use Matter's CONFIG_CHIP_DFU_OVER_BT_SMP instead. | ||
|
|
||
| if ZIGBEE_BT_DFU | ||
|
|
||
| config BT_MAX_CONN | ||
| default 1 | ||
|
|
||
| # MCU Manager and SMP configuration | ||
| choice MCUMGR_TRANSPORT_BT_PERM | ||
| default MCUMGR_TRANSPORT_BT_PERM_RW | ||
| endchoice | ||
|
|
||
| config MCUMGR_TRANSPORT_NETBUF_COUNT | ||
| default 6 | ||
|
|
||
| config MCUMGR_MGMT_NOTIFICATION_HOOKS | ||
| bool | ||
| default y | ||
|
|
||
| config MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK | ||
| bool | ||
| default y | ||
|
|
||
| config MCUMGR_SMP_COMMAND_STATUS_HOOKS | ||
| bool | ||
| default y | ||
|
|
||
| # Increase BT MTU and RX buffer sizes to improve DFU throughput on non-RAM-constrained devices | ||
| config BT_L2CAP_TX_MTU | ||
| default 498 if !SOC_NRF54L10 | ||
|
|
||
| config BT_BUF_ACL_RX_SIZE | ||
| default 502 if !SOC_NRF54L10 | ||
|
|
||
| # 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 | ||
| config MCUMGR_TRANSPORT_NETBUF_SIZE | ||
| default 1024 | ||
|
|
||
| # Increase system workqueue size, as SMP is processed within it | ||
| config SYSTEM_WORKQUEUE_STACK_SIZE | ||
| default 2800 | ||
|
|
||
| if SOC_SERIES_NRF53 | ||
|
|
||
| # Enable custom SMP request to erase settings partition. | ||
| config MCUMGR_GRP_ZBASIC | ||
| default y | ||
|
|
||
| config MCUMGR_GRP_ZBASIC_STORAGE_ERASE | ||
| default y | ||
|
|
||
| endif # SOC_SERIES_NRF53 | ||
|
|
||
| module = ZIGBEE_BT_DFU | ||
| module-str = Zigbee Bluetooth LE DFU | ||
| source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" | ||
|
|
||
| endif # ZIGBEE_BT_DFU | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should start using
configdefaultto not remove dependencies from the original kconfigs, but I will not push you to do it :)