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.77k stars 6.57k forks source link

Bluetooth: Controller: Failed to establish CIS when IUT is Peripheral #60631

Closed mkasenberg closed 9 months ago

mkasenberg commented 1 year ago

Describe the bug I'm not able to setup a second CIS using nrf5340 with Zephyr Host + Zephyr Controller configuration and zephyr/test/bluetooth/tester app. In PTS BAP/USR/SCC/BV-135-C test case the IUT device in Peripheral role does not establish a second CIS when the other Bluetooth device (PTS dongle) uses Packetcraft Controller.

By lucky guess, I found out that this CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y option workarounds the issue. But I'm not sure if this is the right solution, because it is not used in any other sample application.

To Reproduce The CIS issues are easily reproducible with AutoPTS. Steps to reproduce:

  1. Have nRF5340 board and setup for testing zephyr with PTS (https://docs.zephyrproject.org/latest/connectivity/bluetooth/autopts/autopts-win10.html).
  2. Checkout your local zephyr repo to the latest version (in my case it's b9748b5377).
  3. Uncomment the CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y from zephyr/tests/bluetooth/tester/nrf5340_hci_rpmsg_cpunet.conf file, as it is already applied.
  4. In zephyr/samples/bluetooth/hci_rpmsg directory build an app for the NET core of nRF5340:
    west build -b nrf5340dk_nrf5340_cpunet -- -DOVERLAY_CONFIG='nrf5340_cpunet_iso-bt_ll_sw_split.conf;../../../tests/bluetooth/tester/nrf5340_hci_rpmsg_cpunet.conf'
    west flash --recover
  5. In zephyr/tests/bluetooth/tester directory build and flash an app for the APP core of nRF5340:
    west build -b nrf5340dk_nrf5340_cpuapp -- -DOVERLAY_CONFIG='nrf5340_hci_rpmsg.conf;overlay-le-audio.conf'
    west flash
  6. Checkout your local auto-pts repo to the latest commit (in my case it's 2db55fe2).
  7. In auto-pts repo open a first console and run the autoptsserver.py:
    python ./autoptsserver.py
  8. In auto-pts repo open a second console and run the autoptsclient-zephyr.py:
    python ./autoptsclient-zephyr.py zephyr-master -t COM3 -b nrf53 -c BAP/USR/SCC/BV-135-C

    You may have to replace the COM3 port with the actual one used by your nRF5340 board.

Expected behavior The setup Zephyr Host + Zephyr Controller do pass the BAP/USR/SCC/BV-135-C PTS test case.

Impact The setup Zephyr Host + Zephyr Controller does not pass the LE Audio Bluetooth certification tests.

Logs and console output Protocol Viewer logs:

Environment:

Additional context I described a similar issue when the IUT acts as a Central https://github.com/zephyrproject-rtos/zephyr/issues/60132, so probably it is possible to reproduce this issue with unicast audio sample apps too.

henrikbrixandersen commented 1 year ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md

Thalley commented 1 year ago

@mkasenberg please update this issue using the Bug template

Thalley commented 1 year ago

@cvinayak please have a look at this issue as it sounds to be related to the controller

Thalley commented 1 year ago

@mkasenberg is this still an issue? The Controlled has had several fixes and optimizations since this issue was created, so can you please retest?

mkasenberg commented 1 year ago

I've tested again and it seems that the CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y is still needed to pass the BAP/USR/SCC/BV-135-C test case.

cvinayak commented 9 months ago

I've tested again and it seems that the CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y is still needed to pass the BAP/USR/SCC/BV-135-C test case.

I have reviewed the implementation and confirm that CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y is needed to successfully establish CIS with peer central controllers that use low cis_offset value compared to local zephyr controller's minimum cis_offset that it can support without have overlapping ACL plus CIS that is close to each other.

The Spec minimum cis_offset is permitted by this code: https://github.com/zephyrproject-rtos/zephyr/blob/114548ef607aefd712dda7e5ea954981e778185b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c#L99-L124

@mtpr-ot can confirm my understanding.

Closing this issue, as CONFIG_BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START=y is the fix. I will try to remember to send a PR to any overlay-bt_ll_sw_split.conf that upstream samples are using for CIS support in a subsequent PR soon.