nRF5340 LE Audio "sw_codec_lc3: LC3 enc_bitrate is 0" error

Hey!

I'm working on a LE Audio project utilizing the nRF5340, where I need to stream audio both from and to the nRF and I have encountered the error "sw_codec_lc3: LC3 enc_bitrate is 0". It only occurs when I enable bidirectional communication ("CONFIG_STREAM_BIDIRECTIONAL=y") and when my phone tries to output sound via BLE. If configured to use unidirectional communication, everything works fine, there is audio playback through the nRF. (Which is great! Thanks to everyone who worked on zephyr and the sdk, it is really pleasant to use!)


Given this is is an application specific project, I couldn't simply re-use the DK pinout and set of ICs. All notable hardware changes are:

- Exchanged Codec to: DA7212 (uses I2C instead of SPI), wrote a hardware driver lib that replaces the cirrus one
- Removed most LEDs, except for one RGB one, removed all instances of other LEDs being used
- Removed all power monitoring (INAxx), the SD card and USB
- Removed all buttons and all instances of them being used in software
- Different UART pinout.

To implement these I've adapted the nRF5340 Audio DK devicetree, this has worked well. I don't think my error lies in here. Same goes with the DA7212 codec lib, it just configures the HW codec, not the LC3. Anyhow, here is the UART log:

HL [00:07:20.494,445] <inf> main: Connected
HL [00:07:22.662,994] <inf> main: Security changed
HL [00:07:25.482,543] <inf> bt_content_ctrl_media: Discovery of MCS finished
HL [00:07:29.442,047] <inf> bt_rend_vol: Volume = 153, mute state = 0
HL [00:07:31.632,415] <inf> unicast_server: LC3 codec config for sink:
HL [00:07:31.632,415] <inf> unicast_server:     Frequency: 48000 Hz
HL [00:07:31.632,415] <inf> unicast_server:     Duration: 10000 us
HL [00:07:31.632,415] <inf> unicast_server:     Channel allocation: 0x1
HL [00:07:31.632,415] <inf> unicast_server:     Octets per frame: 120 (96000 bps)
HL [00:07:31.632,446] <inf> unicast_server:     Frames per SDU: 1
HL [00:07:31.632,904] <dbg> main: le_audio_msg_sub_thread: Received event = 1, current state = 1
HL [00:07:31.632,904] <dbg> main: le_audio_msg_sub_thread: LE audio config received
HL [00:07:31.632,934] <dbg> main: le_audio_msg_sub_thread:      Sampling rate: 48000 Hz
HL [00:07:31.632,934] <dbg> main: le_audio_msg_sub_thread:      Bitrate (compressed): 96000 bps
HL [00:07:31.632,934] <dbg> main: le_audio_msg_sub_thread:      Direction: 1
HL [00:07:31.632,965] <dbg> audio_system: audio_system_config_set: Encoder: 0, Decoder: 48000, Bits: 0
HL [00:07:31.692,413] <dbg> main: le_audio_msg_sub_thread: Received event = 2, current state = 1
HL [00:07:31.692,413] <dbg> main: le_audio_msg_sub_thread: Set presentation delay
HL [00:07:31.692,413] <inf> main: Presentation delay 10000 us is set by initiator
HL [00:07:31.751,953] <wrn> bt_ascs: CCID 2 is unknown
HL [00:07:31.954,681] <inf> unicast_server: Stream 0x20009dc4 started
HL [00:07:31.954,864] <dbg> main: le_audio_msg_sub_thread: Received event = 3, current state = 1
HL [00:07:31.954,864] <dbg> main: le_audio_msg_sub_thread: LE audio evt streaming
HL [00:07:31.959,136] <dbg> sw_codec_select: sw_codec_init: Encode: 0Hz 16bits 10000us 0bps 1 channel(s)
HL [00:07:31.959,136] <err> sw_codec_lc3: LC3 enc_bitrate is 0
HL [00:07:31.959,136] <err> audio_system: Failed to set up codec
HL [00:07:31.959,136] <err> audio_system: ERR_CHK Err_code: [-22] @ line: 396
HL [00:07:31.959,167] <err> os: r0/a1:  0x00000003  r1/a2:  0x00000008  r2/a3:  0x00000007
HL [00:07:31.959,167] <err> os: r3/a4:  0x0005557b r12/ip:  0x20002510 r14/lr:  0x00055605
HL [00:07:31.959,167] <err> os:  xpsr:  0x41100000
HL [00:07:31.959,197] <err> os: s[ 0]:  0x200012f0  s[ 1]:  0x0005579f  s[ 2]:  0xffffffea  s[ 3]:  0x00000004
HL [00:07:31.959,197] <err> os: s[ 4]:  0x2000c730  s[ 5]:  0x2000c710  s[ 6]:  0xffffffea  s[ 7]:  0x2000c710
HL [00:07:31.959,197] <err> os: s[ 8]:  0x2000c730  s[ 9]:  0x00000000  s[10]:  0x00001900  s[11]:  0x000557eb
HL [00:07:31.959,228] <err> os: s[12]:  0x2000c730  s[13]:  0x00064554  s[14]:  0xffffffea  s[15]:  0x0000018c
HL [00:07:31.959,228] <err> os: fpscr:  0x00000000
HL [00:07:31.959,228] <err> os: Faulting instruction address (r15/pc): 0x000048b6
HL [00:07:31.959,228] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
HL [00:07:31.959,259] <err> os: Current thread: 0x20001a88 (LE_AUDIO_MSG_SUB)
HL [00:07:31.959,259] <err> error_handler: Caught system error -- reason 3. Entering infinite loop



Here are the changes to my proj.conf

# Enable I2S
CONFIG_AUDIO_SOURCE_I2S=y
CONFIG_AUDIO_SOURCE_USB=n

CONFIG_TRANSPORT_BIS=n
CONFIG_TRANSPORT_CIS=y

# enable bidirectional communication
CONFIG_STREAM_BIDIRECTIONAL=y


LC3_BITRATE is set to 32000 in src/audio/Kconfig.defaults

config LC3_BITRATE
	default 32000



Oh, and I use my nRF in Unicast Server mode. West version 1.2.0, nRF SDK 2.6.0

Any ideas on why I could get this bitrate error?

  • Hello,

    Thank you for your extreme patience with this. I have been out of office for some time but now I am back.

    nya said:
    I'm afraid that I'm a rather low-level embedded developer, I usually work on the peripheral and hardware level. This is all somewhat unusual territory for me. I'm sorry for that!

    No need to apologize - we've all been new to the field, and we are happy to help! :) 

    nya said:
    It seems that in this call in unicast_server/main.c never is called with BT_AUDIO_DIR_SOURCE, this is an error on my phones side then? My goal is to have bidirectional audio to my phone, just like a headset with a microphone, am I still missing something here, some config I am missing?

    Which phone are you using for these tests, and are you using the native BLE application in the operating system, or are you making your own app on the smartphone as well?

    Best regards,
    Karl

  • Hey Karl, thank you for your answer!

    > Which phone are you using for these tests, and are you using the native BLE application in the operating system, or are you making your own app on the smartphone as well?

    Well, this is embarrassing. I was about to answer "I use YouTube for playback" when I got the thought that maybe, just very very maybe, similarly to classical Bluetooth Audio, LE Audio uses different "types of stream" (there are probably better words for that) for uni- and bidirectional audio. So, instead of firstly testing playback, I directly tested bidirectional audio by calling my other phone and, guess what, it works. I probably worked the whole time, it's just that when bidirectional audio is enabled, unidirectional audio will fail.

    That's still a bug? It's just a missing feature? Not sure, but this seems to be much more fixable and most important, usable.

    Thanks for your input! Your message was literally what got me to think about this in that way and test it differently.

Related