-
Notifications
You must be signed in to change notification settings - Fork 29
DFU: support for App -> Loader ADV name setup over settings retention backend #495
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
Changes from all commits
d7cf749
d4911b8
984b16a
755a9ff
7337509
5726934
8205ae8
f1c88ae
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,31 @@ | ||||||||
| .. _ug_dfu_name: | ||||||||
|
|
||||||||
| Setting up DFU Device Bluetooth name remotely | ||||||||
| ############################################# | ||||||||
|
|
||||||||
| The Device Firmware Update (DFU) over Bluetooth® Low Energy in the single bank solution uses the loader application for firmware download support. | ||||||||
| The firmware loader is separate application to which the remote Bluetooth LE DFU client connects to perform the firmware update. | ||||||||
| To identify the firmware loader application over Bluetooth LE, it uses a specific advertising name provided by the remote client to the application. | ||||||||
|
|
||||||||
| You can configure the name at application runtime using the MCUmgr settings command group. | ||||||||
|
|
||||||||
| Write the name using the MCUmgr write setting request for ``fw_loader/adv_name`` key and export the key value to retention memory using the MCUmgr save settings request. | ||||||||
| Once the device is rebooted into the firmware loader application, the name can be read back from the retention memory and used as the advertising name of the firmware loader. | ||||||||
|
|
||||||||
| Enabling the feature | ||||||||
| ******************** | ||||||||
|
|
||||||||
| To enable this feature for a sysbuild project, use the :kconfig:option:`SB_CONFIG_BM_APP_CAN_SETUP_FIRMWARE_LOADER_NAME` Kconfig option. | ||||||||
| Otherwise, enable the following Kconfig options in both the application and the firmware loader configuration: | ||||||||
|
|
||||||||
| * :kconfig:option:`CONFIG_RETAINED_MEM` - Enables the use of retained memory. | ||||||||
| * :kconfig:option:`CONFIG_RETENTION` - Allows the retention of data across device reboots. | ||||||||
| * :kconfig:option:`CONFIG_SETTINGS`- Enables the settings management subsystem. | ||||||||
| * :kconfig:option:`CONFIG_SETTINGS_RETENTION`- Enables retention backend implementation of settings subsystem. | ||||||||
| * :kconfig:option:`CONFIG_NCS_BM_SETTINGS_BLUETOOTH_NAME`- Enables setting handlers required for Bluetooth name sharing support. | ||||||||
|
|
||||||||
| Additionally, the application must enable the MCUmgr settings group using the following Kconfig options: | ||||||||
|
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
|
||||||||
| * :kconfig:option:`CONFIG_MCUMGR_GRP_SETTINGS`- Enables the MCUmgr settings group. | ||||||||
| * :kconfig:option:`CONFIG_SETTINGS_RUNTIME`- Allows runtime modification of settings. | ||||||||
|
|
||||||||
| This feature is used in the :ref:`ble_mcuboot_recovery_entry_sample`. | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright (c) 2025 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| /** | ||
| * @brief Retrieve the variable that holds the desired device advertising name. | ||
| * | ||
| * @retval Address of device name setting. | ||
| */ | ||
| const char *bluetooth_name_value_get(void); | ||
|
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.) should probably have settings in the name also |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| SB_CONFIG_BM_BOOTLOADER_MCUBOOT_FIRMWARE_LOADER_ENTRANCE_BOOT_MODE=y | ||
| SB_CONFIG_BM_APP_CAN_SETUP_FIRMWARE_LOADER_NAME=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,5 @@ | |
| rsource "img_mgmt/Kconfig" | ||
|
|
||
| rsource "os_mgmt/Kconfig" | ||
|
|
||
| rsource "settings_mgmt/Kconfig" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||
| # | ||||||
| # Copyright (c) 2023 Nordic Semiconductor ASA | ||||||
|
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
Contributor
Author
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. this was copied from zephtr-rtos. What time stamp should be there. 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.
Up to you.
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. should not be changed |
||||||
| # | ||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||
| # | ||||||
|
|
||||||
| # Settings management group public API is exposed by MCUmgr API | ||||||
| # interface, when settings management is enabled. | ||||||
| zephyr_library() | ||||||
| zephyr_library_sources(${ZEPHYR_BASE}/subsys/mgmt/mcumgr/grp/settings_mgmt/src/settings_mgmt.c) | ||||||
|
|
||||||
| if(CONFIG_MCUMGR_GRP_SETTINGS AND NOT CONFIG_MCUMGR_GRP_SETTINGS_ACCESS_HOOK) | ||||||
| message(WARNING "Note: MCUmgr settings management is enabled but settings access hooks are " | ||||||
| "disabled, this is an insecure configuration and not recommended for production " | ||||||
| "use, as all settings on the device can be manipulated by a remote device. See " | ||||||
| "https://docs.zephyrproject.org/latest/services/device_mgmt/mcumgr_callbacks.html " | ||||||
| "for details on enabling and using MCUmgr hooks.") | ||||||
| endif() | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Copyright Nordic Semiconductor ASA 2023. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| menuconfig MCUMGR_GRP_SETTINGS | ||
| bool "MCUmgr handlers for settings management" | ||
| depends on SETTINGS | ||
| depends on SETTINGS_RUNTIME | ||
| select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2 | ||
| select MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_2 if ZCBOR_CANONICAL | ||
| select MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_1 | ||
| help | ||
| Enables MCUmgr handlers for settings manipulation. | ||
|
|
||
| if MCUMGR_GRP_SETTINGS | ||
|
|
||
| choice MCUMGR_GRP_SETTINGS_BUFFER_TYPE | ||
| prompt "Buffer type" | ||
| default MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK | ||
| help | ||
| Selects if the stack or heap will be used for variables that are | ||
| needed when processing requests. | ||
|
|
||
| config MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK | ||
| bool "Stack (fixed size)" | ||
| help | ||
| Use a fixed size stack buffer, any user-supplied values longer than | ||
| this will be rejected. | ||
|
|
||
| Note that stack usage for parameter storage alone will be | ||
| MCUMGR_GRP_SETTINGS_NAME_LEN + MCUMGR_GRP_SETTINGS_VALUE_LEN, | ||
| therefore the MCUmgr stack should be appropriately sized. | ||
|
|
||
| config MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP | ||
| bool "Heap (dynamic size)" | ||
| depends on COMMON_LIBC_MALLOC_ARENA_SIZE > 0 | ||
| help | ||
| Use dynamic heap memory allocation through malloc, if there is | ||
| insufficient heap memory for the allocation then the request will be | ||
| rejected. | ||
|
|
||
| endchoice | ||
|
|
||
| config MCUMGR_GRP_SETTINGS_NAME_LEN | ||
| int "Maximum setting name length" | ||
| default 32 | ||
| help | ||
| Maximum length of a key to lookup, this will be the size of the | ||
| variable if placed on the stack or the maximum allocated size of the | ||
| variable if placed on the heap. | ||
|
|
||
| config MCUMGR_GRP_SETTINGS_VALUE_LEN | ||
| int "Maximum setting value length" | ||
| default 32 | ||
| help | ||
| Maximum length of a value to read, this will be the size of the | ||
| variable if placed on the stack or the allocated size of the | ||
| variable if placed on the heap (settings does not support getting | ||
| the size of a value prior to looking it up). | ||
|
|
||
| config MCUMGR_GRP_SETTINGS_ACCESS_HOOK | ||
| bool "Settings access hook" | ||
| depends on MCUMGR_MGMT_NOTIFICATION_HOOKS | ||
| help | ||
| Allows applications to control settings management access by | ||
| registering for a callback which is then triggered whenever a | ||
| settings read or write attempt is made. | ||
|
|
||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # | ||
| # Copyright (c) 2025 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| zephyr_sources_ifdef(CONFIG_NCS_BM_SETTINGS_BLUETOOTH_NAME src/bluetooth_name.c) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # | ||
| # Copyright (c) 2025 Nordic Semiconductor | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| menu "Settings" | ||
| depends on SETTINGS | ||
|
|
||
| config NCS_BM_SETTINGS_BLUETOOTH_NAME | ||
| bool "Bluetooth name [EXPERIMENTAL]" | ||
| select EXPERIMENTAL | ||
| help | ||
| If enabled, settings handlers for support BLE advertising name | ||
| sharing under `fw_loader/adv_name` key are included into the build. | ||
|
|
||
| endmenu |
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.