Skip to content

Conversation

@nvlsianpu
Copy link
Contributor

@nvlsianpu nvlsianpu commented Dec 9, 2025

Added hook implementation for disabling Bluetooth in the hook of MCUmgr OS reboot command.
Disabling of bluetooth allow to restart it properly after the warm boot.

Refs: NCSDK-36564, #28118

This is backport of v3.2.0 bugfix

Added hook implementation for disabling Bluetooth in the hook
of MCUmgr OS reboot command.
Disabling of bluetooth allow to restart it properly after the
warm boot.

Ref: NCSDK-36564

Signed-off-by: Andrzej Puzdrowski <[email protected]>
Postpone disabling till half of waiting of reset time.

Ref: NCSDK-36564

Signed-off-by: Andrzej Puzdrowski <[email protected]>
Copilot AI review requested due to automatic review settings December 9, 2025 10:46
@nvlsianpu nvlsianpu requested review from a team as code owners December 9, 2025 10:46
@NordicBuilder NordicBuilder added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a hook for the MCUmgr OS reboot command to properly disable Bluetooth before warm boot on nRF54LX devices. This ensures Bluetooth can restart correctly after reboot.

Key Changes:

  • Added hook implementation that disables Bluetooth and uninitializes MPSL before system reboot
  • Configured the hook to be automatically enabled for nRF54LX devices when Bluetooth or MPSL is present
  • Integrated the new source file into the build system

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt_reboot_bt.c New hook implementation that disables Bluetooth/MPSL before reboot, with delayed work handler for multithreading support
subsys/mgmt/mcumgr/grp/os_mgmt/Kconfig Added configuration option to enable the reboot hook for nRF54LX devices with BT/MPSL
subsys/mgmt/mcumgr/grp/os_mgmt/CMakeLists.txt Added build rule to include the new source file when the feature is enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return MGMT_CB_ERROR_RC;
}
#ifdef CONFIG_MULTITHREADING
/* disable bluetooth from the system workqueue thread. */
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number division by 2 lacks explanation. Add a comment explaining why half the reset timeout is used for scheduling Bluetooth disable, or define it as a named constant like CONFIG_MCUMGR_GRP_OS_RESET_MS_HALF to improve code clarity.

Suggested change
/* disable bluetooth from the system workqueue thread. */
/* disable bluetooth from the system workqueue thread. */
/*
* Schedule Bluetooth disable at half the reset timeout.
* This ensures Bluetooth is disabled well before the actual reset occurs,
* allowing time for clean shutdown and resource release.
*/

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +80
static struct mgmt_callback cmd_reboot_bt_info_cb = {
.callback = reboot_bt_hook,
.event_id = MGMT_EVT_OP_OS_MGMT_RESET,
};

static int os_mgmt_register_reboot_bt(void)
{
mgmt_callback_register(&cmd_reboot_bt_info_cb);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The variable name cmd_reboot_bt_info_cb is misleading as it suggests an info callback, but this handles the reboot hook. Consider renaming to reboot_bt_hook_cb or os_mgmt_reboot_bt_cb for clarity.

Suggested change
static struct mgmt_callback cmd_reboot_bt_info_cb = {
.callback = reboot_bt_hook,
.event_id = MGMT_EVT_OP_OS_MGMT_RESET,
};
static int os_mgmt_register_reboot_bt(void)
{
mgmt_callback_register(&cmd_reboot_bt_info_cb);
static struct mgmt_callback reboot_bt_hook_cb = {
.callback = reboot_bt_hook,
.event_id = MGMT_EVT_OP_OS_MGMT_RESET,
};
static int os_mgmt_register_reboot_bt(void)
{
mgmt_callback_register(&reboot_bt_hook_cb);

Copilot uses AI. Check for mistakes.
}
#ifdef CONFIG_MULTITHREADING
/* disable bluetooth from the system workqueue thread. */
k_work_schedule(&bt_disable_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS/2));
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parentheses around the division operation: K_MSEC((CONFIG_MCUMGR_GRP_OS_RESET_MS/2)). This improves readability and prevents potential issues with macro expansion.

Suggested change
k_work_schedule(&bt_disable_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS/2));
k_work_schedule(&bt_disable_work, K_MSEC((CONFIG_MCUMGR_GRP_OS_RESET_MS/2)));

Copilot uses AI. Check for mistakes.
@nvlsianpu nvlsianpu added the bugfix Fixes a known bug label Dec 9, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 9, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 2

Inputs:

Sources:

sdk-nrf: PR head: 641b87d9863ddc078cfdaef6ba0db37e85533868

more details

sdk-nrf:

PR head: 641b87d9863ddc078cfdaef6ba0db37e85533868
merge base: bc8a0958edc764ed708f5f72b9e158855fb52f70
target head (main): 6756485f1f0184a6420ffc90bfd228fc533335ab
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (3)
subsys
│  ├── mgmt
│  │  ├── mcumgr
│  │  │  ├── grp
│  │  │  │  ├── os_mgmt
│  │  │  │  │  ├── CMakeLists.txt
│  │  │  │  │  ├── Kconfig
│  │  │  │  │  ├── src
│  │  │  │  │  │  │ os_mgmt_reboot_bt.c

Outputs:

Toolchain

Version: 43683a87ea
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:43683a87ea_5ea73affbf

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 307
  • ✅ Integration tests
    • ✅ test-sdk-mcuboot
    • ✅ test-sdk-dfu
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_mosh
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_cloud
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-audio
    • test-sdk-find-my
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 9, 2025

Memory footprint analysis revealed the following potential issues

applications.nrf_desktop.zdebug_fast_pair.gmouse.uart[nrf54l15dk/nrf54l15/cpuapp]: ROM size increased by 1392[B] in comparison to the main[4cefdfc] branch. - link (cc: @nrfconnect/ncs-si-bluebagel)

Note: This message is automatically posted and updated by the CI (latest/sdk-nrf/PR-26163/2)

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

CONFIG_BT_UNINIT_MPSL_ON_DISABLE is enabled MPSL is
uninitialized automatically once BT get uninitialized.

This patch ensure that MPSL is uninitialized only once.

Signed-off-by: Andrzej Puzdrowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a known bug changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants