Skip to content

Conversation

cvinayak
Copy link
Contributor

@cvinayak cvinayak commented Sep 2, 2025

Fix missing ISO Receiver access address capture that caused ISO PDU reception error. Missing access address capture for subsequent subevent when prior subevent did not have an anchor point sync prevent proper drift compensation hence causing ISO PDU reception error for the entire BIG event.

Fix the jitter considered in the PDU reception in the subevents of ISO Sync Receiver to not exceed such that the reception is scheduled late (causing assertion).

Fixes #90097.

Overnight testing between bap_broadcast_source on nrf52833dk and bap_broadcast_sink on nrf54l15dk:

[2025-09-03 06:09:34.562] [00:02:52.835,401] <inf> stream_rx: [2593000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 37095 and ts 172835214: Valid 2593000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:09:34.579] [00:02:52.835,459] <inf> stream_rx: [2593000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 37095 and ts 172835214: Valid 2593000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:09:44.562] [00:03:02.835,921] <inf> stream_rx: [2594000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 38095 and ts 182835728: Valid 2594000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:09:44.579] [00:03:02.835,981] <inf> stream_rx: [2594000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 38095 and ts 182835728: Valid 2594000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:09:54.562] [00:03:12.836,436] <inf> stream_rx: [2595000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 39095 and ts 192836243: Valid 2595000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:09:54.579] [00:03:12.836,494] <inf> stream_rx: [2595000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 39095 and ts 192836243: Valid 2595000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:04.562] [00:03:22.836,945] <inf> stream_rx: [2596000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 40095 and ts 202836757: Valid 2596000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:04.579] [00:03:22.837,003] <inf> stream_rx: [2596000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 40095 and ts 202836757: Valid 2596000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:14.562] [00:03:32.837,465] <inf> stream_rx: [2597000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 41095 and ts 212837272: Valid 2597000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:14.579] [00:03:32.837,524] <inf> stream_rx: [2597000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 41095 and ts 212837272: Valid 2597000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:24.562] [00:03:42.837,979] <inf> stream_rx: [2598000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 42095 and ts 222837786: Valid 2598000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:24.580] [00:03:42.838,037] <inf> stream_rx: [2598000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 42095 and ts 222837786: Valid 2598000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:34.562] [00:03:52.838,488] <inf> stream_rx: [2599000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 43095 and ts 232838301: Valid 2599000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:34.579] [00:03:52.838,546] <inf> stream_rx: [2599000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 43095 and ts 232838301: Valid 2599000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:44.562] [00:04:02.839,008] <inf> stream_rx: [2600000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 44095 and ts 242838816: Valid 2600000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:44.580] [00:04:02.839,067] <inf> stream_rx: [2600000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 44095 and ts 242838816: Valid 2600000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:54.562] [00:04:12.839,523] <inf> stream_rx: [2601000]: Incoming audio on stream 0x2000246c len 40, flags 0x09, seq_num 45095 and ts 252839329: Valid 2601000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0
[2025-09-03 06:10:54.580] [00:04:12.839,583] <inf> stream_rx: [2601000]: Incoming audio on stream 0x200024b8 len 40, flags 0x09, seq_num 45095 and ts 252839329: Valid 2601000 | Error 0 | Loss 0 | Dup TS 0 | Dup PSN 0

Thalley
Thalley previously approved these changes Sep 2, 2025
Thalley
Thalley previously approved these changes Sep 2, 2025
Fix the jitter considered in the PDU reception in the
subevents of ISO Sync Receiver to not exceed such that the
reception is scheduled late (causing assertion).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing ISO Receiver access address capture that caused
ISO PDU reception error. Missing access address capture for
subsequent subevent when prior subevent did not have an
anchor point sync prevent proper drift compensation hence
causing ISO PDU reception error for the entire BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
@cvinayak cvinayak force-pushed the github_sync_iso_aa_capture_fix branch from e314b28 to ff7e93a Compare September 2, 2025 21:13
Copy link

sonarqubecloud bot commented Sep 2, 2025

Comment on lines +1375 to +1377

LL_ASSERT(hcto > jitter_us);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny; was about to suggest this in my last review, but noticed that it wasn't there before either, so I didn't :) Glad to see it added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I noticed that a newly added assert was caught in CI for high number of subevents which I had to convert to if-then-else; hence, decided to add a assert here as well.

Do not hesitate to leave a comment, your reviews help think differently, and hence better solutions.

That said, I do not like the calculations here for the jitter, it is always calculating for nse i.e. from the first subevent; ideally, current jitter should be from the last sync-ed subevent.

The problem to solve, active clock is permitted a +/-2 us jitter which means over the duration of the subevents, a subevent can jitter by +/- 2 us multiplied by current subevent count nse when none of the previous subevent where received (anchor point sync).

I will comeback and solve it some other day, for now, bsim is happy; my other changes does expose too little jitter or drift causing assertion... fix for that another day.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider creating a GH issue for the above so you don't forget it ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not going to forget it, listed (updated with the above problem statement now) in #82399

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes ISO Receiver functionality by ensuring proper access address capture and correcting jitter calculations in Bluetooth Low Energy controller code. The fix addresses ISO PDU reception errors that occurred when previous subevents lacked anchor point synchronization.

Key changes:

  • Add access address capture for subsequent subevents when no prior anchor point sync exists
  • Refactor jitter calculation logic to prevent reception scheduling delays and assertions
  • Remove RANGE_DELAY_US from jitter calculations to improve timing accuracy

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

jitter_max_us = (EVENT_IFS_US - overhead_us) >> 1;
jitter_max_us -= RANGE_DELAY_US + HAL_RADIO_TMR_START_DELAY_US;
jitter_max_us = (jitter_max_us * nse) / (lll->num_bis * lll->nse);
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression can be simplified to jitter_max_us = jitter_max_us / lll->num_bis since nse appears in both numerator and denominator and cancels out.

Suggested change
jitter_max_us = (jitter_max_us * nse) / (lll->num_bis * lll->nse);
jitter_max_us = jitter_max_us / lll->num_bis;

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, nse and lll->nse are different values.

overhead_us = radio_rx_chain_delay_get(lll->phy, PHY_FLAGS_S8);
overhead_us += addr_us_get(lll->phy);
overhead_us += radio_rx_ready_delay_get(lll->phy, PHY_FLAGS_S8);
overhead_us += (EVENT_CLOCK_JITTER_US << 1);

LL_ASSERT(EVENT_IFS_US > overhead_us);
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding descriptive error messages to these assertions to help with debugging when they fail. For example: LL_ASSERT_MSG(EVENT_IFS_US > overhead_us, \"IFS time insufficient for overhead\");

Suggested change
LL_ASSERT(EVENT_IFS_US > overhead_us);
LL_ASSERT_MSG(EVENT_IFS_US > overhead_us, "IFS time insufficient for overhead");

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not want a message.

@kartben kartben merged commit aefeeb9 into zephyrproject-rtos:main Sep 8, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bluetooth: iso_receive: asserts when iso_broadcast terminates BIG in /nordic/lll/lll_sync_iso.c
5 participants