Skip to content

Commit 72f2cee

Browse files
tomchynvlsianpu
authored andcommitted
[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 <[email protected]>
1 parent 64534d3 commit 72f2cee

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727

2828
#ifdef CONFIG_REBOOT
2929
#include <zephyr/sys/reboot.h>
30+
#ifdef CONFIG_BT
31+
#include <zephyr/bluetooth/bluetooth.h>
32+
#endif
33+
#ifdef CONFIG_MPSL
34+
#include <mpsl.h>
35+
#endif
3036
#endif
3137

3238
#ifdef CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS
@@ -362,6 +368,16 @@ static int os_mgmt_taskstat_read(struct smp_streamer *ctxt)
362368
#ifdef CONFIG_MULTITHREADING
363369
static void os_mgmt_reset_work_handler(struct k_work *work)
364370
{
371+
#ifdef CONFIG_BT
372+
int ret = bt_disable();
373+
374+
if (ret) {
375+
LOG_ERR("BT disable failed before reboot: %d\n", ret);
376+
}
377+
#endif
378+
#ifdef CONFIG_MPSL
379+
mpsl_uninit();
380+
#endif
365381
ARG_UNUSED(work);
366382

367383
sys_reboot(SYS_REBOOT_WARM);
@@ -454,6 +470,16 @@ static int os_mgmt_reset(struct smp_streamer *ctxt)
454470
/* Reboot the system from the system workqueue thread. */
455471
k_work_schedule(&os_mgmt_reset_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS));
456472
#else
473+
#ifdef CONFIG_BT
474+
err_rc = bt_disable();
475+
if (err_rc) {
476+
LOG_ERR("BT disable failed before reboot: %d\n", err_rc);
477+
}
478+
#endif
479+
#ifdef CONFIG_MPSL
480+
mpsl_uninit();
481+
#endif
482+
457483
sys_reboot(SYS_REBOOT_WARM);
458484
#endif
459485

0 commit comments

Comments
 (0)