Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth Ext Adv:Sync: While simultaneous advertiser are working, and skip is non-zero, sync terminates repeatedly #42518

Closed
saleh-unikie opened this issue Feb 7, 2022 · 26 comments · Fixed by #44183
Assignees
Labels
area: Bluetooth Controller area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@saleh-unikie
Copy link
Contributor

Describe the bug
Using the #41091 (force-pushed on 2 Feb), I tested 10 simultaneous advertiser (AoA tag) with one scanner (AoA locator). The source codes are based on "connection-less direction finding" examples, by adding simultaneous tag support to scanner code. The advertiser are working with extended adv interval = 80ms, legacy adv interval = 150ms. All devices are nRF52833DK board.

Successful Scenario: If at receiver side, "skip" parameter is a non-zero value, then "synchronization" is made successfully and the probability of losing the sync is low.

struct bt_le_per_adv_sync_param param;
param.skip = 1;
param.timeout = 2000;
...
bt_le_per_adv_sync_create(&param, synch);

The output log is something like this:

try to sync tag1
tag1 synced
try to sync tag2
tag2 synced
try to sync tag3
tag3 synced
try to sync tag4
tag4 synced
try to sync tag5
tag5 synced
try to sync tag6
tag6 synced
try to sync tag7
tag7 synced
try to sync tag8
tag8 synced
try to sync tag9
tag9 synced
try to sync tag10
tag10 synced

(after 30minutes no sync lost was seen)

Failure Scenario: But if, "skip" parameter is set to zero, at the beginning of the program, syncs are made normally like above condition, but after a while it start to lose the sync with tags, and it usually must retries more than once to make the sync again. in most retries, it terminate eventually exactly after calling the bt_le_per_adv_sync_create function.

struct bt_le_per_adv_sync_param param;
param.skip = 0;
param.timeout = 2000;
...
bt_le_per_adv_sync_create(&param, synch);

The output log could be:

try to sync tag1
tag1 synced
try to sync tag2
tag2 synced
try to sync tag3
tag3 synced
try to sync tag4
tag4 synced
try to sync tag5
tag5 synced
try to sync tag6
tag6 synced
try to sync tag7
tag7 synced
try to sync tag8
tag8 synced
try to sync tag9
tag9 synced
try to sync tag10
tag10 synced

tag3 sync lost
try to sync tag3

tag3 sync lost
try to sync tag3

tag3 sync lost
try to sync tag3

tag3 sync lost
try to sync tag3
tag3 synced

(the above retries occur for other tags too and it is very common to lose the sync, 
which makes the whole system functionality unstable) 

In both cases timeout value is same. I supposed that "skip" parameter can not affect on sync termination as I asked this question in nordic devzone, but seems it is not.
https://devzone.nordicsemi.com/f/nordic-q-a/84232/more-information-about-skip-and-timeout-parameters-of-ble-5-advertising

To Reproduce
Steps to reproduce the behavior:

  1. use "connection-less direction finding" examples
  2. Add simultaneous tag support to the scanner source code
  3. west build -b nrf52833dk_nrf52833
  4. west flash
  5. See error

Expected behavior
The termination is only dependent on "timoute" parameter, changing "skip" should not change the behavior of losing sync between scanner and advertiser.

Impact
System is not stable when skip=0 and multiple advertiser try to sync with the scanner.

Logs and console output
as you can see in the bug description (above)

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK
  • Commit SHA or Version used: 9749514

Additional context
In addition to the above problem, sometime this assertion failure happens too

ASSERTION FAIL [next] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c:649
@saleh-unikie saleh-unikie added the bug The issue is a bug, or the PR is fixing a bug label Feb 7, 2022
@saleh-unikie saleh-unikie changed the title Bluetooth Ext Adv:Sync: While multipler advertiser are working, sync terminates repeatedly Bluetooth Ext Adv:Sync: While simultaneous advertiser are working, and skip is non-zero, sync terminates repeatedly Feb 7, 2022
@cvinayak
Copy link
Contributor

cvinayak commented Feb 9, 2022

Could you let me know if all the 10 advertisers where powered up at the same time? (do all the periodic advertising interval overlap on every interval?) In such cases, 6 intervals to synchronized with a periodic advertiser may be facing issues, could you take air trace using a sniffer to confirm any errors due to collisions of these 10 periodic advertising?

The advertiser are working with extended adv interval = 80ms, legacy adv interval = 150ms.

Do you have 20 advertisements in total from 10 nRF52833 DKs, one Extended and one Legacy advertising instances on each of the 10 DKs? What about the periodic advertising, what are the used parameters?

  1. Add simultaneous tag support to the scanner source code

It would be best if a draft PR with samples to reproduce the issue be made available for debugging the issue.

@saleh-unikie
Copy link
Contributor Author

saleh-unikie commented Feb 9, 2022

Thanks @cvinayak for the reply.

if all the 10 advertisers where powered up at the same time?

To ensure it doesn't affect on the system, I turned on the transmitters randomly but it didn't change the output.

What about the periodic advertising, what are the used parameters?

Sorry, I used incorrect terms (ext_adv_int=80ms, per_adv_int=150ms). To make it possible for everyone interested to test this issue, I programmed direction_finding_connectionless_tx into the transmitter. Only some minor changes were made to increase the periodic interval to (BT_GAP_PER_ADV_FAST_INT_MIN_1, BT_GAP_PER_ADV_FAST_INT_MAX_1) and not to send advertising train.
for your reference, you can find the modified one here: https://github.com/saleh-unikie/direction_finding_connectionless_tx
To build and program the project:

west build -b nrf52833dk_nrf52833
west flash

samples to reproduce the issue

It was not possible to share the origin source code that I found the problem inside it. So I developed a similar app based on direction_finding_connectionless_rx sample, which now is capable of making parallel syncs with tags. Here you can find my source code: direction_finding_connectionless_rx_multiple. Please note some print lines are commented to focus only on sync issue.

The above source code, in a while(true) loop, monitors the current state of the system and then makes the proper decision:

do {
    - refresh the scan every 10s to ensure all tags will be scanned
    - if there is any sync candidate, create the sync
    - if a sync is ongoing, monitor the process and make it go forward until CTE is enabled
} while (true)

To build and program the project:

west build -b nrf52833dk_nrf52833
west flash

Results:
Scenario A) When skip was set to a non-zero value:
https://github.com/saleh-unikie/direction_finding_connectionless_rx_multiple/blob/main/src/main.c#L236

In this scenario it works normally. You can see the output log here. To understand it better, I've added these letters at first line of each print line as you can find in the source code:
C: Create Sync
S: Sync Done
T: Sync Terminated

*** Booting Zephyr OS build v3.0.0-rc1-231-g9749514d8388  ***
Starting Connectionless Locator Demo
Bluetooth initialization...success
C       Creating Sync:[DEVICE]: 00:A7:0C:07:04:80 (random) ...success.
S       PER_ADV_SYNC[0]: [DEVICE]: 00:A7:0C:07:04:80 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 24:2E:76:14:ED:7F (random) ...success.
S       PER_ADV_SYNC[1]: [DEVICE]: 24:2E:76:14:ED:7F (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.
S       PER_ADV_SYNC[2]: [DEVICE]: 06:1F:08:50:C5:C8 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 07:BC:F0:D9:52:AB (random) ...success.
S       PER_ADV_SYNC[3]: [DEVICE]: 07:BC:F0:D9:52:AB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.
S       PER_ADV_SYNC[4]: [DEVICE]: 3D:57:D7:15:84:5D (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 2C:EC:38:D7:8F:B2 (random) ...success.
S       PER_ADV_SYNC[5]: [DEVICE]: 2C:EC:38:D7:8F:B2 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 30:42:7B:FF:39:1C (random) ...success.
S       PER_ADV_SYNC[6]: [DEVICE]: 30:42:7B:FF:39:1C (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 23:42:F1:09:44:66 (random) ...success.
S       PER_ADV_SYNC[7]: [DEVICE]: 23:42:F1:09:44:66 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 0B:2D:94:C7:5B:3B (random) ...success.
S       PER_ADV_SYNC[8]: [DEVICE]: 0B:2D:94:C7:5B:3B (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.
S       PER_ADV_SYNC[9]: [DEVICE]: 36:AD:1C:8B:62:40 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
T       PER_ADV_SYNC[0]: [DEVICE]: 00:A7:0C:07:04:80 (random) sync terminated
C       Creating Sync:[DEVICE]: 00:A7:0C:07:04:80 (random) ...success.
S       PER_ADV_SYNC[0]: [DEVICE]: 00:A7:0C:07:04:80 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
T       PER_ADV_SYNC[3]: [DEVICE]: 07:BC:F0:D9:52:AB (random) sync terminated
C       Creating Sync:[DEVICE]: 07:BC:F0:D9:52:AB (random) ...success. 
S       PER_ADV_SYNC[3]: [DEVICE]: 07:BC:F0:D9:52:AB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
T       PER_ADV_SYNC[2]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.
S       PER_ADV_SYNC[2]: [DEVICE]: 06:1F:08:50:C5:C8 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M

The above output is result of running the system for about 1 hour. After a while, sync of three tags is terminated and is synced again without any problem.

Scenario B) When skip was set to Zero:
Obviously the syncs are unstable, after reboot it makes sync with all tags (10 tags) and after a short time, syncs start to terminate. Also, it tries to make the sync again but most of the time it fails exactly after when sync has created. Here you can find the logs:

*** Booting Zephyr OS build v3.0.0-rc1-231-g9749514d8388  ***                                                
Starting Connectionless Locator Demo                                                                         
Bluetooth initialization...success                                                                           
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
S       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 2C:EC:38:D7:8F:B2 (random) ...success.                                       
S       PER_ADV_SYNC[1]: [DEVICE]: 2C:EC:38:D7:8F:B2 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
S       PER_ADV_SYNC[2]: [DEVICE]: 3D:57:D7:15:84:5D (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 07:BC:F0:D9:52:AB (random) ...success.                                       
S       PER_ADV_SYNC[3]: [DEVICE]: 07:BC:F0:D9:52:AB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 24:2E:76:14:ED:7F (random) ...success.                                       
S       PER_ADV_SYNC[4]: [DEVICE]: 24:2E:76:14:ED:7F (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 00:A7:0C:07:04:80 (random) ...success.                                       
S       PER_ADV_SYNC[5]: [DEVICE]: 00:A7:0C:07:04:80 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 30:42:7B:FF:39:1C (random) ...success.                                       
S       PER_ADV_SYNC[6]: [DEVICE]: 30:42:7B:FF:39:1C (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
S       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 0B:2D:94:C7:5B:3B (random) ...success.                                       
S       PER_ADV_SYNC[8]: [DEVICE]: 0B:2D:94:C7:5B:3B (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 23:42:F1:09:44:66 (random) ...success.                                       
S       PER_ADV_SYNC[9]: [DEVICE]: 23:42:F1:09:44:66 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
T       PER_ADV_SYNC[2]: [DEVICE]: 3D:57:D7:15:84:5D (random) sync terminated                                
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 3D:57:D7:15:84:5D (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 3D:57:D7:15:84:5D (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 3D:57:D7:15:84:5D (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
T       PER_ADV_SYNC[0]: [DEVICE]: 3D:57:D7:15:84:5D (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 06:1F:08:50:C5:C8 (random) ...success.                                       
S       PER_ADV_SYNC[0]: [DEVICE]: 06:1F:08:50:C5:C8 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
C       Creating Sync:[DEVICE]: 3D:57:D7:15:84:5D (random) ...success.                                       
S       PER_ADV_SYNC[2]: [DEVICE]: 3D:57:D7:15:84:5D (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated                                
Deleting Periodic Advertising Sync...success                                                                 
C       Creating Sync:[DEVICE]: 36:AD:1C:8B:62:40 (random) ...success.                                       
T       PER_ADV_SYNC[7]: [DEVICE]: 36:AD:1C:8B:62:40 (random) sync terminated
....

The above log is generated only in 5 minutes. Finally it failed after a while

...
C       Creating Sync:[DEVICE]: 07:BC:F0:D9:52:AB (random) ...success.                                       
S       PER_ADV_SYNC[3]: [DEVICE]: 07:BC:F0:D9:52:AB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M     
ASSERTION FAIL [next] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c:649

@cvinayak
Copy link
Contributor

cvinayak commented Feb 10, 2022

@saleh-unikie , thanks for the reply, I will try to reproduce at my end today and revert back with my findings. (Most of the consolidated commits have now been merged upstream, pending a new issue #42664). I will be used the latest upstream with your copy of the sample.

Unfortunately, I only have 2 nRF5340 DK and one nRF52833 DK. With this setup I cannot reproduce, as only 2 simultaneous sync are possible.

I have a temporary change that I would like you to try for the assertion you see, I will send a draft PR and let you know here.

@cvinayak
Copy link
Contributor

@saleh-unikie could you please cherry-pick these two PRs (over latest upstream bf45055) and let me know if it helps with the assertion, #42664 and #42678.

Also, use these values (finger in the air, based on my experience that if Rx events are not processed fast enough by Host, then Controller will generate sync failed to be established if the Rx buffers have been used up by the other syncs that are receiving reports):

CONFIG_BT_BUF_EVT_RX_COUNT=15
CONFIG_BT_CTLR_RX_BUFFERS=10

saleh-unikie added a commit to saleh-unikie/direction_finding_connectionless_rx_multiple that referenced this issue Feb 10, 2022
@saleh-unikie
Copy link
Contributor Author

saleh-unikie commented Feb 10, 2022

Thanks @cvinayak, if there was another changes let me know, then I will test them as soon as possible.

Well, I switched to the latest commit of main upstream and then those two commit was cherry picked.

$ git log --oneline
bb85fe53f1 (HEAD -> test_sync_issue_42518_t1) Bluetooth: Controller: Fix to use non-discardable buffer
a9771c352e Bluetooth: Controller: Fix short prepare when many enqueued in pipeline
b68bdf20cf (origin/main, origin/HEAD, main) lib/os: fdtable: add locking to posix api
1f22a2bc3c net: tcp: Fix possible deadlock in tcp_conn_unref()
...

I ran receiver code while 10 transmitter were advertising (randomly turned on) for two rounds, each time letting it go for ~30 minutes. I couldn't see any assertion fail but after a while sync started to terminate and wasn't made again. Here you can see the log:

*** Booting Zephyr OS build v3.0.0-rc2-35-gbb85fe53f1b1  ***
Starting Connectionless Locator Demo
Bluetooth initialization...success
C       Creating Sync:[DEVICE]: 01:DA:D0:4B:79:49 (random) ...success.
S       PER_ADV_SYNC[0]: [DEVICE]: 01:DA:D0:4B:79:49 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 26:A0:DF:36:73:3D (random) ...success.                                    
S       PER_ADV_SYNC[1]: [DEVICE]: 26:A0:DF:36:73:3D (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 0A:82:4D:7C:70:37 (random) ...success.                                    
S       PER_ADV_SYNC[2]: [DEVICE]: 0A:82:4D:7C:70:37 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 3F:C4:3F:A1:E5:53 (random) ...success.                                    
S       PER_ADV_SYNC[3]: [DEVICE]: 3F:C4:3F:A1:E5:53 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 0B:63:98:30:4C:77 (random) ...success.                                    
S       PER_ADV_SYNC[4]: [DEVICE]: 0B:63:98:30:4C:77 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
T       PER_ADV_SYNC[5]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
Deleting Periodic Advertising Sync...success                                                              
C       Creating Sync:[DEVICE]: 32:8B:FA:5F:CC:48 (random) ...success.                                    
T       PER_ADV_SYNC[5]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) sync terminated                             
Deleting Periodic Advertising Sync...success                                                              
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
T       PER_ADV_SYNC[5]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
Deleting Periodic Advertising Sync...success                                                              
C       Creating Sync:[DEVICE]: 24:6B:75:54:67:02 (random) ...success.                                    
S       PER_ADV_SYNC[5]: [DEVICE]: 24:6B:75:54:67:02 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
T       PER_ADV_SYNC[6]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
Deleting Periodic Advertising Sync...success                                                              
C       Creating Sync:[DEVICE]: 2F:73:D8:80:7C:2C (random) ...success.                                    
S       PER_ADV_SYNC[6]: [DEVICE]: 2F:73:D8:80:7C:2C (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
T       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
Deleting Periodic Advertising Sync...success                                                              
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
S       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 36:61:42:F1:BB:53 (random) ...success.                                    
S       PER_ADV_SYNC[8]: [DEVICE]: 36:61:42:F1:BB:53 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
C       Creating Sync:[DEVICE]: 32:8B:FA:5F:CC:48 (random) ...success.                                    
S       PER_ADV_SYNC[9]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
T       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
T       PER_ADV_SYNC[6]: [DEVICE]: 2F:73:D8:80:7C:2C (random) sync terminated                             
T       PER_ADV_SYNC[4]: [DEVICE]: 0B:63:98:30:4C:77 (random) sync terminated                             
T       PER_ADV_SYNC[9]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) sync terminated                             
T       PER_ADV_SYNC[0]: [DEVICE]: 01:DA:D0:4B:79:49 (random) sync terminated                             
T       PER_ADV_SYNC[8]: [DEVICE]: 36:61:42:F1:BB:53 (random) sync terminated

log files:
1_sync_40min.txt,
2_sync_20min.txt,
3_sync_30min.txt

based on my experience that if Rx events are not processed fast enough by Host, then Controller will generate sync failed

According to what you've mentioned, I was thinking maybe the while loop I've implemented with busy waiting mechanism, is not a suitable mechanism to make synch. So I replaced it with a blocking mechanism in order to release CPU for other tasks (you can find updated code here). Now seems the behavior is much better, but again sync lost regularly happens and by chance I could catch an assertion failure (unfortunately its print line is corrupted). Here you can see the log, each . means waiting up to 15 seconds for a new advertiser and if it is not found, scan is disabled and enabled again:

*** Booting Zephyr OS build v3.0.0-rc2-35-gbb85fe53f1b1  ***                                              
Starting Connectionless Locator Demo                                                                      
Bluetooth initialization...success                                                                        
.                                                                                                         
C       Creating Sync:[DEVICE]: 36:61:42:F1:BB:53 (random) ...success.                                    
S       PER_ADV_SYNC[0]: [DEVICE]: 36:61:42:F1:BB:53 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:F4:07:9D:B2:BC (random) ...success.                                    
S       PER_ADV_SYNC[1]: [DEVICE]: 34:F4:07:9D:B2:BC (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 0B:63:98:30:4C:77 (random) ...success.                                    
S       PER_ADV_SYNC[2]: [DEVICE]: 0B:63:98:30:4C:77 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 13:27:93:35:6B:06 (random) ...success.                                    
S       PER_ADV_SYNC[3]: [DEVICE]: 13:27:93:35:6B:06 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 2E:8C:8D:C7:7A:7D (random) ...success.                                    
S       PER_ADV_SYNC[4]: [DEVICE]: 2E:8C:8D:C7:7A:7D (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 32:8B:FA:5F:CC:48 (random) ...success.                                    
S       PER_ADV_SYNC[5]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 29:72:AE:61:C1:6E (random) ...success.                                    
S       PER_ADV_SYNC[6]: [DEVICE]: 29:72:AE:61:C1:6E (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
S       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 19:3B:90:3B:59:C4 (random) ...success.                                    
S       PER_ADV_SYNC[8]: [DEVICE]: 19:3B:90:3B:59:C4 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:E6:17:0E:68:E8 (random) ...success.                                    
T       PER_ADV_SYNC[9]: [DEVICE]: 34:E6:17:0E:68:E8 (random) sync terminated                             
T       PER_ADV_SYNC[0]: [DEVICE]: 36:61:42:F1:BB:53 (random) sync terminated                             
XC      Creating sync timed out                                                                           
Deleting Periodic Advertising Sync...success                                                              
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:E6:17:0E:68:E8 (random) ...success.                                    
T       PER_ADV_SYNC[0]: [DEVICE]: 34:E6:17:0E:68:E8 (random) sync terminated                             
XC      Creating sync timed out                                                                           
Deleting Periodic Advertising Sync...success                                                              
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:E6:17:0E:68:E8 (random) ...success.                                    
T       PER_ADV_SYNC[0]: [DEVICE]: 34:E6:17:0E:68:E8 (random) sync terminated                             
XC      Creating sync timed out                                                                           
Deleting Periodic Advertising Sync...success                                                              
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:E6:17:0E:68:E8 (random) ...success.                                    
T       PER_ADV_SYNC[0]: [DEVICE]: 34:E6:17:0E:68:E8 (random) sync terminated                             
T       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) sync terminated                             
XC      Creating sync timed out                                                                           
Deleting Periodic Advertising Sync...success                                                              
.                                                                                                         
C       Creating Sync:[DEVICE]: 34:E6:17:0E:68:E8 (random) ...success.                                    
S       PER_ADV_SYNC[0]: [DEVICE]: 34:E6:17:0E:68:E8 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
.                                                                                                         
C       Creating Sync:[DEVICE]: 3F:87:1B:06:DA:13 (random) ...success.                                    
S       PER_ADV_SYNC[7]: [DEVICE]: 3F:87:1B:06:DA:13 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
..                                                                                                        
C       Creating Sync:[DEVICE]: 36:61:42:F1:BB:53 (random) ...success.                                    
T       PER_ADV_SYNC[5]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) sync terminated                             
S       PER_ADV_SYNC[9]: [DEVICE]: 36:61:42:F1:BB:53 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M  
..                                                                                                        
C       Creating Sync:[DEVICE]: 32:8B:FA:5F:CC:48 (random) ...success.                                    
T       PER_ADV_SYNC[5]: [DEVICE]: 32:8B:FA:5F:CC:48 (random) sync terminated                             
T       PER_ADV_SYNC[2]: [DEVICE]: 0B:63:98:30:4C:77 (random) sync terminated                             
XC      Creating sync timed out                                                                           
Deleting Periodic Advertising Sync...success                                                              
....................T   PER_ADV_SYNC[0]: [DEVICE]: 34:E6:17:0E:68:E8 (random) sync terminated             
..............ASSERTION FAIL [e] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sy8

Another test is ongoing and after ~20min, I havn't seen the failure again. I will repeat it and if failure was seen, I will report it here.

@cvinayak
Copy link
Contributor

Two things:

  1. Change the print message so that it is unique, saleh-unikie/direction_finding_connectionless_rx_multiple@5782285#r66464587
  2. Could try the Rx sample with CTE samples disabled. (Lets try to narrow down as to whether periodic sync implementation is stable).

@saleh-unikie
Copy link
Contributor Author

saleh-unikie commented Feb 11, 2022

I made some changes in print logs to make sure all of them are unique and the output is more clear. The changes are pushed to repo.
Also I commented out these lines at receiver side, in order to NOT enabling the CTE:

/*
err = enable_cte_rx(synch_info.synch_ptr);
if (err != 0) {
    printk("XC\tenable_cte_rx failed\n", err);
    delete_sync(synch_info.synch_ptr);
    scan_disable();
   continue;
}
*/

The devices are working and when a failure is seen, I will report it here (fortunately/unfortunately it doesn't happen too much)

@cvinayak
Copy link
Contributor

cvinayak commented Feb 11, 2022

@saleh-unikie This is the modified sample I have been testing under simulation #42721, and the one hour simulation log of 10 periodic advertisers to which the periodic sync sample makes upto 16 synchronizations (as advertiser change addresses, some repeat overlapping sync are established): https://github.com/zephyrproject-rtos/zephyr/files/8046922/periodic_sync_multiple_one_hour.log

There are few sync terminates that I have not analyzed yet, but there are no stall or assertions under simulation. This is without #42678 (purely upstream code with modified sample in #42721)

@saleh-unikie
Copy link
Contributor Author

saleh-unikie commented Feb 11, 2022

Thanks @cvinayak

I had similar results, after disabling reception of CTE. Here you can find the results:

Test Condition:
Receiver
Source Code: direction_finding_connectionless_rx_multiple
Zephyr: aa20d87

Transmitter:
Source code: direction_finding_connectionless_tx
Number of transmitters: 10

Results:
Scenario A) CTE reception is NOT enabled. Test duration: 1h and 20min

*** Booting Zephyr OS build v3.0.0-rc2-35-gbb85fe53f1b1  ***
Starting Connectionless Locator Demo
Bluetooth initialization...success
C       Creating Sync:[DEVICE]: 25:10:38:9F:73:BA (random) ...success.
S       PER_ADV_SYNC[0]: [DEVICE]: 25:10:38:9F:73:BA (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 27:83:C5:5E:AF:FB (random) ...success.
S       PER_ADV_SYNC[1]: [DEVICE]: 27:83:C5:5E:AF:FB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 11:84:5F:38:06:4C (random) ...success.
S       PER_ADV_SYNC[2]: [DEVICE]: 11:84:5F:38:06:4C (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 25:08:3C:63:47:08 (random) ...success.
S       PER_ADV_SYNC[3]: [DEVICE]: 25:08:3C:63:47:08 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 30:6E:A9:78:50:C1 (random) ...success.
S       PER_ADV_SYNC[4]: [DEVICE]: 30:6E:A9:78:50:C1 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 00:8B:2C:77:84:B9 (random) ...success.
S       PER_ADV_SYNC[5]: [DEVICE]: 00:8B:2C:77:84:B9 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 0D:11:A7:7B:D8:D3 (random) ...success.
S       PER_ADV_SYNC[6]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 07:F3:51:6F:C3:69 (random) ...success.
S       PER_ADV_SYNC[7]: [DEVICE]: 07:F3:51:6F:C3:69 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 19:D6:38:93:F9:7F (random) ...success.
S       PER_ADV_SYNC[8]: [DEVICE]: 19:D6:38:93:F9:7F (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
C       Creating Sync:[DEVICE]: 1A:FE:BE:D8:46:2A (random) ...success.
S       PER_ADV_SYNC[9]: [DEVICE]: 1A:FE:BE:D8:46:2A (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.............T  PER_ADV_SYNC[6]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) sync terminated                                                  
.......                                                                                                                                
........C       Creating Sync:[DEVICE]: 0D:11:A7:7B:D8:D3 (random) ...success.                                                         
S       PER_ADV_SYNC[6]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
....................
............

Obviously it is stable and only after 65min one of the sync has terminated which is established again after ~4min. (each . equal to 15second)

Scenario B) CTE reception is enabled. Test duration: 14min

*** Booting Zephyr OS build v3.0.0-rc2-41-g33c3d3db7cfb  ***                                                                           
Starting Connectionless Locator Demo                                                                                                   
Bluetooth initialization...success                                                                                                     
C       Creating Sync:[DEVICE]: 27:83:C5:5E:AF:FB (random) ...success.                                                                 
S       PER_ADV_SYNC[0]: [DEVICE]: 27:83:C5:5E:AF:FB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 11:84:5F:38:06:4C (random) ...success.                                                                 
S       PER_ADV_SYNC[1]: [DEVICE]: 11:84:5F:38:06:4C (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 1A:FE:BE:D8:46:2A (random) ...success.                                                                 
S       PER_ADV_SYNC[2]: [DEVICE]: 1A:FE:BE:D8:46:2A (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 25:10:38:9F:73:BA (random) ...success.                                                                 
S       PER_ADV_SYNC[3]: [DEVICE]: 25:10:38:9F:73:BA (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 00:8B:2C:77:84:B9 (random) ...success.                                                                 
S       PER_ADV_SYNC[4]: [DEVICE]: 00:8B:2C:77:84:B9 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 07:F3:51:6F:C3:69 (random) ...success.                                                                 
S       PER_ADV_SYNC[5]: [DEVICE]: 07:F3:51:6F:C3:69 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 0D:11:A7:7B:D8:D3 (random) ...success.                                                                 
S       PER_ADV_SYNC[6]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 30:6E:A9:78:50:C1 (random) ...success.                                                                 
S       PER_ADV_SYNC[7]: [DEVICE]: 30:6E:A9:78:50:C1 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 25:08:3C:63:47:08 (random) ...success.                                                                 
S       PER_ADV_SYNC[8]: [DEVICE]: 25:08:3C:63:47:08 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
T       PER_ADV_SYNC[0]: [DEVICE]: 27:83:C5:5E:AF:FB (random) sync terminated                                                          
.C      Creating Sync:[DEVICE]: 19:D6:38:93:F9:7F (random) ...success.                                                                 
S       PER_ADV_SYNC[0]: [DEVICE]: 19:D6:38:93:F9:7F (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 27:83:C5:5E:AF:FB (random) ...success.                                                                 
T       PER_ADV_SYNC[6]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) sync terminated                                                          
T       PER_ADV_SYNC[9]: [DEVICE]: 27:83:C5:5E:AF:FB (random) sync terminated                                                          
T       PER_ADV_SYNC[7]: [DEVICE]: 30:6E:A9:78:50:C1 (random) sync terminated                                                          
XC      Creating sync timed out                                                                                                        
Deleting Periodic Advertising Sync...success                                                                                           
C       Creating Sync:[DEVICE]: 27:83:C5:5E:AF:FB (random) ...success.                                                                 
S       PER_ADV_SYNC[6]: [DEVICE]: 27:83:C5:5E:AF:FB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 0D:11:A7:7B:D8:D3 (random) ...success.                                                                 
S       PER_ADV_SYNC[7]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
.........T      PER_ADV_SYNC[4]: [DEVICE]: 00:8B:2C:77:84:B9 (random) sync terminated                                                  
.C      Creating Sync:[DEVICE]: 00:8B:2C:77:84:B9 (random) ...success.                                                                 
S       PER_ADV_SYNC[4]: [DEVICE]: 00:8B:2C:77:84:B9 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
C       Creating Sync:[DEVICE]: 30:6E:A9:78:50:C1 (random) ...success.                                                                 
S       PER_ADV_SYNC[9]: [DEVICE]: 30:6E:A9:78:50:C1 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
.T      PER_ADV_SYNC[7]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) sync terminated 
(termination and resync continues)

The full log is attached: 8_cte_enabled.txt


Well, obviously enabling the CTE reception affects on the syncs, what could be the next step?

@cvinayak
Copy link
Contributor

@saleh-unikie Thanks for your quick response.

  1. Could you please confirm that you are using the vanilla upstream/main without Bluetooth: Controller: Fix short prepare when many enqueued in pipeline #42678? If using, does it make a difference?
  2. In Scenario B, does it not stall (i.e. even after sync terminated it will continue to discover extended advertisers, and re-establish synchronization) ?

I will switch my focus towards review of code for possible bugs when periodic sync has CTE reporting enabled, will post here if I have some thing.

@saleh-unikie
Copy link
Contributor Author

Could you please confirm that you are using the vanilla upstream/main

To ensure the results are true, I did the test again. One time with the latest upstream/main (5094a6e) and one time with #42678. In both cases, CTE reception was disabled. The result was similar, stable in both after running for ~1h. Here you can see the logs:
9_cte_disabled_42678.txt
9_cte_disabled_main.txt

In Scenario B, does it not stall (i.e. even after sync terminated it will continue to discover extended advertisers, and re-establish synchronization) ?

Yes it didn't stall at any point. The termination->creat sync->synced loop was ongoing. Anyway, I will try to execute this scenario for several times to ensure the behavior is same in all rounds. I'll update here if there was any new findings.

@cvinayak
Copy link
Contributor

Thank you, once again.

We are going in the right direction. (I believe the assertion could still happen, as I have done nothing to fix it, if it is a bug, it will recur). I have switch my focus to reviewing implementation when CTE enabled.

(I wish I had 11 nRF52833 DKs)

@saleh-unikie
Copy link
Contributor Author

saleh-unikie commented Feb 11, 2022

Thanks for your time!

I tried to run above tests for several times and these "assertion failures" were seen:

Test Condition:
Receiver
Source Code: direction_finding_connectionless_rx_multiple
Zephyr: 64c2633c90 on top of 5094a6e

Transmitter:
Source code: direction_finding_connectionless_tx
Number of transmitters: 10

Failures:

C       Creating Sync:[DEVICE]: 27:83:C5:5E:AF:FB (random) ...success.                                                                 
S       PER_ADV_SYNC[7]: [DEVICE]: 27:83:C5:5E:AF:FB (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
ASSERTION FAIL [(ret == 0) || (ret == 2)] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c:728

Full log: 10_cte_enabled_42678.txt

After the above log, I added a print line before when it tries to make enable reception of CTE.

XC      Creating sync timed out                                                                                                        
Deleting Periodic Advertising Sync...success                                                                                           
ASSERTION FAIL [e] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c:938

Full log: 12_cte_enabled_42678.txt

............T   PER_ADV_SYNC[7]: [DEVICE]: 0D:11:A7:7B:D8:D3 (random) sync terminated                                                  
........                                                                                                                               
ASSERTION FAIL [e] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c:938 

Full log: 13_cte_enabled_42678.txt

S       PER_ADV_SYNC[6]: [DEVICE]: 30:6E:A9:78:50:C1 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
E       Enabling reception of CTE                                                                                                      
...ASSEASSERTION FAIL [err >= 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c:578

Full log: 14_cte_enabled_42678.txt

S       PER_ADV_SYNC[9]: [DEVICE]: 19:D6:38:93:F9:7F (random) synced, Interval 0x0030 (60 ms), PHY LE 2M                               
E       Enabling reception of CTE                                                                                                      
ASSERTION FAIL [next] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c:653

Full log: 15_cte_enabled_42678.txt

@cvinayak
Copy link
Contributor

@saleh-unikie Based on code inspection, not sure if this is required, @ppryga can confirm whether these changes would help: #42757

@ppryga-nordic
Copy link
Collaborator

I've run tests with 3DKs advertising and one receiving.
image
It was working for quite some time without synchronization lost.

When I run 4th DK strange things start to happen. I'll get back with it when I collect some logs.

@ppryga-nordic
Copy link
Collaborator

ppryga-nordic commented Feb 15, 2022

After some time of running with 4DKs TX and single RX (based on code from @saleh-unikie repo) I start to observe this:
image

Then RX starts to lose synchronization. I'll check it with DF functionality disabled. I'll do that tomorrow.
unexpected-LE_BIS-while-per-adv-sync.zip

@ppryga-nordic
Copy link
Collaborator

I observe LE-BIS Transfer PDUs also without enabled CTE TX:
image
unexpected-LE_BIS-while-per-adv-sync-no-cte.zip

@ppryga-nordic
Copy link
Collaborator

ppryga-nordic commented Feb 18, 2022

UPDATE! It was false alarm with LE-BIS. I've just run a sniffer in the same environment without DKs exercising periodic advertising and still observe LE-BIS PDUs. So there is no issues in regard of periodic advertising.

@saleh-unikie could you check if the issue is still available with code in current main branch?

@saleh-unikie
Copy link
Contributor Author

I tested it again using 22c0843 and the problem still exist.

Test Scenario:
Receiver
Source Code: direction_finding_connectionless_rx_multiple
Zephyr: 22c0843
Note: skip is set to zero --> sync_create_param.skip = 0;

Transmitter:
Source code: direction_finding_connectionless_tx
Number of transmitters: 10

Results:
There are two different problem visible:

  • Syncs are not stable and termination/re-sync is done repeatedly
  • Sometime assertion failure is seen (it happens randomly, I can't see any pattern)

Round 1 (failed after a long time)

(Only last lines are copied)
.C      Creating Sync:[DEVICE]: 1B:13:48:CF:78:3B (random) ...success.
T       PER_ADV_SYNC[8]: [DEVICE]: 1B:13:48:CF:78:3B (random) sync terminated
XT      Creating sync [DEVICE]: 1B:13:48:CF:78:3B (random)  terminated
D       Deleting Sync of [DEVICE]:B:13:48:CF:78:3B (random)
.ASSERTION FAIL [e] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c:938

Full log: 10tag_skip0_assertfailed.txt

Round 2 (failed after a long time)

(Only last lines are copied)
.C      Creating Sync:[DEVICE]: 0E:F8:A2:1E:8D:64 (random) ...success.
S       PER_ADV_SYNC[0]: [DEVICE]: 0E:F8:A2:1E:8D:64 (random) synced, Interval 0x0030 (60 ms), PHY LE 2M
E       [DEVICE]: 0E:F8:A2:1E:8D:64 (random)....................
ASSERTION FAIL [e] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c:938

Full log: 10tag_skip0_assertfailed(2).txt

@carlescufi
Copy link
Member

@saleh-unikie we will address this as soon as possible.

@cvinayak
Copy link
Contributor

@saleh-unikie and @jakkra after some delays, I now have 10 nRF52833 DKs.

Please confirm that I need to use these for debugging:
direction_finding_connectionless_rx_multiple
direction_finding_connectionless_tx

@saleh-unikie
Copy link
Contributor Author

@saleh-unikie and @jakkra after some delays, I now have 10 nRF52833 DKs.

Please confirm that I need to use these for debugging: direction_finding_connectionless_rx_multiple direction_finding_connectionless_tx

Good news!
I've used these two projects for generating the above logs. Let me know if there was any problem or any help needed. Good luck!

@cvinayak
Copy link
Contributor

@saleh-unikie During code inspection, something that could be related to the ASSERTION FAIL is related to fixes in this PR: #44183. I will do more testing tomorrow to confirm if this PR fixes the assertions reported by you here: #42518 (comment)

Could please try your samples with ZEPHYR_BASE set to the changes in the PR #44183

@saleh-unikie
Copy link
Contributor Author

Sure, I will do it tomorrow and will report here.

@saleh-unikie
Copy link
Contributor Author

@cvinayak I've tested #44183 and the reported problems are not seen any more. Thanks a lot! 🙏

Anyway, there is another problem to receive IQ samples properly which has seen also at main repository of Zephyr (But I've not reported yet). So I think these are completely different and we can consider it as solved.

@cvinayak
Copy link
Contributor

cvinayak commented Mar 25, 2022

@saleh-unikie Thank you and appreciate the quick responses in helping me slowly resolve a few memory leaks and implementation defects on the way to here!

I have run your rx_multiple sample for over 8 hours today without terminates or assertions. I believe the terminate issue is resolved. I will keep an open mind on assertions, and will let my boards continue to maintain the sync over the weekend.

I have noticed that if you enable CONFIG_LOG=y in your rx multiple sample, the stack logs error preparing the CTE samples. We are looking into possible uninitialized values in host around the cte_types filtering. Will post PRs after further investigations.

Please close this PR, you can re-open or create new issue if you discover the original problem reported in this issue being not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Controller area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants