zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.52k stars 6.45k forks source link

bt_disable() does not work properly on nRF52 #48304

Closed watsug closed 1 year ago

watsug commented 2 years ago

Describe the bug With the latest Zephyr bt_disable() function was added to shutdown the BLE subsystem. It works properly on STM32WB55 and nRF53, but not on nRF52. After this sequence: bt_enable() / setup and start peripheral / bt_disable() / bt_enable() it is not possible to set up and start peripheral again. The API works, but the device is muted (not advertising again).

To Reproduce Steps to reproduce the behavior:

  1. bt_enable
  2. create a random identity
  3. setup and start advertisement using created identity
  4. stop and delete the advertisement
  5. delete created a random identity (the same as before)
  6. bt_disable
  7. bt_enable
  8. reply 2-3

After step 8 there is no advertisement even if from API perspective there are no errors.

Expected behavior bt_disable/bt_enable should bring BLE stack to the point where it can be used in the same way as right after the first boot.

Impact Nice to have.

Logs and console output Not available yet. I can add if needed.

Environment (please complete the following information):

Additional context I can try to prepare a demo based on official Zephyr samples.

rugeGerritsen commented 2 years ago

As part of fixing this issue, it would be nice if you could add a bsim test. For example doing the following:

for i in range 20:
    bt_enabled()
    connect()
    encrypt()
    l2cap_coc_setup()
    gatt_notify()
    bt_disable()
jori-nordic commented 1 year ago

@watsug could you test again on latest master, #50046 was supposed to fix those issues.

parthitce commented 1 year ago

@watsug could you test again on latest master, #50046 was supposed to fix those issues.

Unfortunately this didn't help with my testing in nRF52805. The device is still not able to enable and advertise again.

jori-nordic commented 1 year ago

@sem1-nordic could you add this procedure to the bsim testsuite and check if it completes successfully?

sean-madigan commented 1 year ago

Hi, I have tried to reproduce on the 52840 and seems to work fine. Can you provide any more information on your issue to try and help me see what's going wrong - an example sample that is not working, HCI logs? Is it just the nRF52805 you are having issues with now - the original ticket mentions the nRF52840 DK?

parthitce commented 1 year ago

It's working fine in my end as well for nRF52805 with CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE=y with internal RC.

carlescufi commented 1 year ago

@sem1-nordic @jori-nordic can you please test with the Zephyr LL (as it's the only one upstream) and with different clock options (RC, Crystal, etc). Thanks!

carlescufi commented 1 year ago

May be related to #52454

watsug commented 1 year ago

Hello, @jori-nordic, I will test this ASAP and let you know.

jori-nordic commented 1 year ago

Hello, @jori-nordic, I will test this ASAP and let you know.

Hi, @watsug did you find the time to test it again?

jori-nordic commented 1 year ago

Closing, feel free to re-open if it still doesn't work @watsug .