Help Needed: Resolving I2S RX Overrun Issue with nRF5340 Audio Application

Hello,

I am dealing with a persistent I2S RX overrun issue in the nRF5340 audio application that is impacting data reception and disrupting communications between the gateway and headsets. I have provided logs below that illustrate the problem, and I am seeking advice on possible solutions.

Issue Summary: The nRF5340 appears to not receive data correctly from the I2S, resulting in no data being sent from the gateway. As a result, the headsets receive nothing, which interrupts the compensation mechanism and perpetually triggers the presentation compensation due to the lack of reference packets.

Steps to Reproduce:

  1. Initial Setup:

    • Utilize the nRF5340 audio application version v2.6.0.
  2. Modifications Made:

    • Adjustments have been made to the sw_codec_select.c and audio_system.c files.
  3. Configuration Adjustments:

    • pri.conf File Updates:
      • CONFIG_TRANSPORT_CIS=y: Enable CIS transport.
      • CONFIG_AUDIO_SOURCE_I2S=y: Set the audio source to I2S.
      • CONFIG_BT_BAP_UNICAST_16_2_1=y: Enable Bluetooth Audio Profile Unicast 16.2.1.
      • CONFIG_SW_CODEC_LC3=y: Integrate software codec LC3.
      • CONFIG_LE_AUDIO_MSG_SUB_STACK_SIZE=51200: Increase LE Audio Message Subscription stack size to 51200.
    • konfig File Changes:
      • Adjusted stack sizes under the menu "Stack sizes":
        • config ENCODER_STACK_SIZE: 15000 for AUDIO_BIT_DEPTH_16 and 22528 for AUDIO_BIT_DEPTH_32.
        • config AUDIO_DATAPATH_STACK_SIZE: 38000 for AUDIO_BIT_DEPTH_16 and 73500 for AUDIO_BIT_DEPTH_32.
  4. Triggering the Issue:

    • Power on the devices and start data transmission.
    • Monitor LED statuses: Gateway (LED1 blue blinking, LED3 green blinking); Headsets (LED1 blue blinking, LED2 green constant, LED3 green blinking).
  5. Observing the Error:

    • Logs from headsets show early signs of configuration but stop updating shortly after.

Logs of gateway:

GW [00:00:00.320,404] <inf> fw_info: 
         nRF5340 Audio nRF5340 Audio DK cpuapp                      
         NCS base version: 2.6.0                            
         Cmake run : Tue Apr 16 13:21:10 2024
GW [00:00:00.320,434] <inf> fw_info: ------- DEBUG BUILD -------
GW [00:00:00.320,434] <inf> fw_info: Compiled for GATEWAY device
GW [00:00:00.341,400] <inf> bt_mgmt_ctlr_cfg: Controller: SoftDevice: Version 5.4 (0x0d), Revision 8591
GW [00:00:00.341,644] <inf> bt_mgmt: Local identity addr: F1:53:CB:A1:37:61 (random)
GW [00:00:00.352,783] <inf> bt_mgmt_scan: All bonded slots filled, will not accept new devices
GW [00:00:00.355,102] <inf> bt_mgmt_scan: Local addr: 51:DF:06:55:F6:F3 (random). May time out. Updates not printed
GW [00:00:00.355,102] <inf> bt_mgmt_scan: Scanning successfully started
GW [00:00:00.791,046] <inf> bt_mgmt_scan: Creating connection to bonded device: E4:0A:37:69:AE:56 (random)
GW [00:00:00.798,828] <inf> bt_mgmt: Connected: E4:0A:37:69:AE:56 (random)
GW [00:00:00.798,950] <inf> bt_mgmt_scan: All bonded slots filled, will not accept new devices
GW [00:00:00.800,018] <inf> bt_mgmt_scan: Local addr: 51:DF:06:55:F6:F3 (random). May time out. Updates not printed
GW [00:00:00.800,048] <inf> bt_mgmt_scan: Scanning successfully started
GW [00:00:00.800,048] <inf> main: Device connected
GW [00:00:00.817,413] <inf> bt_mgmt_scan: Creating connection to bonded device: D4:3B:14:F0:11:28 (random)
GW [00:00:00.871,307] <inf> bt_mgmt: Connected: D4:3B:14:F0:11:28 (random)
GW [00:00:00.871,337] <inf> main: Device connected
GW [00:00:01.118,804] <inf> main: Security changed
GW [00:00:01.188,812] <inf> main: Security changed
GW [00:00:01.718,750] <inf> bt_rend_vol: VCS discover finished
GW [00:00:01.828,765] <inf> bt_rend_vol: VCS discover finished
GW [00:00:03.480,255] <inf> unicast_client: LEFT sink stream configured
GW [00:00:03.521,148] <inf> unicast_client: Enable stream 0x20004988
GW [00:00:03.710,266] <inf> unicast_client: RIGHT sink stream configured
GW [00:00:03.789,764] <inf> unicast_client: Enable stream 0x20004bf0
GW [00:00:03.839,080] <inf> unicast_client: Stream 0x20004988 started
--- 1 messages dropped ---
GW [00:00:03.968,719] <wrn> audio_datapath: I2S RX continuing stream
--- 12 messages dropped ---
GW [00:00:04.099,731] <inf> audio_datapath: Drft comp state: CALIB
--- 10 messages dropped ---
GW [00:00:04.200,714] <inf> audio_datapath: Drft comp state: CALIB
--- 8 messages dropped ---
GW [00:00:04.333,709] <wrn> audio_datapath: I2S RX continuing stream
--- 7 messages dropped ---
GW [00:00:04.455,718] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 8 messages dropped ---
GW [00:00:04.564,697] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 5 messages dropped ---
GW [00:00:04.674,713] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 6 messages dropped ---
GW [00:00:04.774,719] <wrn> audio_datapath: I2S RX continuing stream
--- 6 messages dropped ---
GW [00:00:04.820,709] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 6 messages dropped ---
GW [00:00:04.927,703] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 6 messages dropped ---
GW [00:00:05.062,713] <wrn> audio_datapath: I2S RX continuing stream
--- 6 messages dropped ---
GW [00:00:05.182,708] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 5 messages dropped ---
GW [00:00:05.327,697] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 8 messages dropped ---
GW [00:00:05.463,714] <wrn> audio_datapath: I2S RX continuing stream
--- 6 messages dropped ---
GW [00:00:05.584,716] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 6 messages dropped ---
GW [00:00:05.720,703] <wrn> audio_datapath: I2S RX continuing stream
--- 6 messages dropped ---
GW [00:00:05.839,721] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 6 messages dropped ---
GW [00:00:05.948,699] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 5 messages dropped ---
GW [00:00:06.091,705] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 7 messages dropped ---
GW [00:00:06.200,714] <wrn> audio_datapath: I2S RX overrun. Single msg
--- 5 messages dropped ---
GW [00:00:06.336,700] <wrn> audio_datapath: I2S RX continuing stream

Logs of headsets:

HL [00:00:00.319,488] <inf> fw_info: 
         nRF5340 Audio nRF5340 Audio DK cpuapp                      
         NCS base version: 2.6.0                            
         Cmake run : Tue Apr 16 13:20:42 2024
HL [00:00:00.319,519] <inf> fw_info: ------- DEBUG BUILD -------
HL [00:00:00.319,519] <inf> fw_info: HEADSET left device
HL [00:00:00.339,294] <inf> bt_mgmt_ctlr_cfg: Controller: SoftDevice: Version 5.4 (0x0d), Revision 8591
HL [00:00:00.339,477] <inf> bt_mgmt: Local identity addr: E4:0A:37:69:AE:56 (random)
HL [00:00:00.354,064] <inf> bt_mgmt_adv: Local addr: 69:AA:C0:29:40:AF (random)
HL [00:00:00.354,125] <inf> bt_mgmt_adv: Adv directed to: F1:53:CB:A1:37:61 (random).
HL [00:00:00.354,736] <inf> bt_mgmt_adv: Advertising successfully started
HL [00:00:00.885,070] <inf> bt_mgmt: Connected: F1:53:CB:A1:37:61 (random)
HL [00:00:00.885,101] <inf> main: Connected
HL [00:00:00.885,498] <inf> bt_mgmt_adv: RPA (Resolvable Private Address) expired.
HL [00:00:00.885,589] <inf> bt_mgmt_adv: Local addr: 69:AA:C0:29:40:AF (random)
HL [00:00:01.412,200] <inf> main: Security changed
HL [00:00:01.412,445] <wrn> bt_gatt: Device is not subscribed to characteristic
HL [00:00:01.412,445] <wrn> bt_pacs: PACS notify failed: -22
HL [00:00:05.412,048] <inf> bt_content_ctrl_media: Discovery of MCS finished
HL [00:00:05.812,835] <inf> unicast_server: LC3 codec config for sink:
HL [00:00:05.812,835] <inf> unicast_server:     Frequency: 48000 Hz
HL [00:00:05.812,835] <inf> unicast_server:     Duration: 10000 us
HL [00:00:05.812,835] <inf> unicast_server:     Channel allocation: 0x1
HL [00:00:05.812,835] <inf> unicast_server:     Octets per frame: 120 (96000 bps)
HL [00:00:05.812,835] <inf> unicast_server:     Frames per SDU: 1
HL [00:00:05.972,747] <inf> main: Presentation delay 10000 us is set by initiator
HL [00:00:06.539,276] <inf> unicast_server: Stream 0x2000f850 started
HL [00:00:06.549,987] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
HL [00:00:06.559,997] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
HL [00:00:06.569,976] <wrn> le_audio_rx: Not in streaming state, throwing data: 1
HL [00:00:06.581,237] <wrn> audio_datapath: Data received, total under-runs: 4
HL [00:00:06.639,221] <inf> audio_datapath: Drft comp state: CALIB
HL [00:00:06.739,227] <inf> audio_datapath: Drft comp state: INIT
HL [00:00:06.740,234] <inf> audio_datapath: Drft comp state: CALIB
HL [00:00:06.840,240] <inf> audio_datapath: Drft comp state: OFFSET
HL [00:00:07.071,960] <wrn> audio_datapath: Data received, total under-runs: 5
HL [00:00:07.439,788] <inf> audio_datapath: Drft comp state: LOCKED
HL [00:00:07.440,490] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:07.550,506] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:07.698,516] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:07.700,500] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:07.810,485] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:07.949,951] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:07.959,075] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:08.069,061] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:08.210,479] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:08.230,072] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:08.340,179] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:08.469,085] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:08.490,051] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:08.600,067] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:08.740,081] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:08.749,969] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:08.858,520] <inf> audio_datapath: Pres comp state: WAIT
HL [00:00:09.000,061] <inf> audio_datapath: Pres comp state: INIT
HL [00:00:09.008,544] <inf> audio_datapath: Pres comp state: MEAS
HL [00:00:09.118,530] <inf> audio_datapath: Pres comp state: LOCKED

Questions and Insights: Is the I2S RX overrun issue potentially caused by the sw_codec_encode function processing PCM data slower than I2S reads it? Could a mismatch in the data processing speed of the software codec and the I2S data read rate be the root cause of these overruns? I welcome any insights or experiences related to similar issues, especially any adjustments or configurations that have been effective in preventing I2S RX overrun.

I am also considering whether modifying the size of pcm_raw_data in the source code found at encoder_thread could help stabilize the input size and potentially resolve the I2S RX overrun issue. Would fixing the size of pcm_raw_data to a constant value be a feasible solution? I would appreciate any thoughts on this approach or experiences with similar adjustments.

Thank you in advance for your assistance.

Best regards,

Runqi

  • Hello Runqi,

    Thank you for your patience with this.

    Modifications Made:

    • Adjustments have been made to the sw_codec_select.c and audio_system.c files.

    Which modifications have you made to these files, could you elaborate on the modifications themselves and the intentions behind them?

    Questions and Insights: Is the I2S RX overrun issue potentially caused by the sw_codec_encode function processing PCM data slower than I2S reads it? Could a mismatch in the data processing speed of the software codec and the I2S data read rate be the root cause of these overruns? I welcome any insights or experiences related to similar issues, especially any adjustments or configurations that have been effective in preventing I2S RX overrun.

    A mismatch in the reading and encoder speed could indeed cause I2S over- and underruns.
    Are you working with the nRF5340 LE Audio DK, or custom hardware? In either case, which hardware codec are you using on your board, and have you made sure that your I2S configuration matches the hardware codec's?

    Best regards,
    Karl

Related