From 72f2cee3bb99e2f41ca56a079d3d634c6ed03cac Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Mon, 1 Dec 2025 17:04:25 +0100 Subject: [PATCH] [nrf noup] mcumgr: Disable BT before reset Disable BT stack as well as MPSL before resetting the SoC. Ref: NCSDK-36564 Signed-off-by: Tomasz Chyrowicz --- subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c index 360385a1b95c..cdc4a92aa95b 100644 --- a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c @@ -27,6 +27,12 @@ #ifdef CONFIG_REBOOT #include +#ifdef CONFIG_BT +#include +#endif +#ifdef CONFIG_MPSL +#include +#endif #endif #ifdef CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS @@ -362,6 +368,16 @@ static int os_mgmt_taskstat_read(struct smp_streamer *ctxt) #ifdef CONFIG_MULTITHREADING static void os_mgmt_reset_work_handler(struct k_work *work) { +#ifdef CONFIG_BT + int ret = bt_disable(); + + if (ret) { + LOG_ERR("BT disable failed before reboot: %d\n", ret); + } +#endif +#ifdef CONFIG_MPSL + mpsl_uninit(); +#endif ARG_UNUSED(work); sys_reboot(SYS_REBOOT_WARM); @@ -454,6 +470,16 @@ static int os_mgmt_reset(struct smp_streamer *ctxt) /* Reboot the system from the system workqueue thread. */ k_work_schedule(&os_mgmt_reset_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS)); #else +#ifdef CONFIG_BT + err_rc = bt_disable(); + if (err_rc) { + LOG_ERR("BT disable failed before reboot: %d\n", err_rc); + } +#endif +#ifdef CONFIG_MPSL + mpsl_uninit(); +#endif + sys_reboot(SYS_REBOOT_WARM); #endif