Set nRF5340 Audio DK as I2S slave over external bus

Hello! I am attempting to use my nRF5340 Audio DK as a gateway to broadcast audio from an external I2S source.

I have added the `CONFIG_AUDIO_SOURCE_I2S=y` line to my project .conf file as described in the README for the nrf5340_audio project.

I also have followed the instructions in this DevZone post to configure the board to use the external I2S connections on the P10 header.

The issue that I am encountering now is that the nRF board is still acting as the I2S master. The other device I want to connect I am not in control of and is configured as an I2S master. I need the nRF board to act as I2S slave and transmit the audio the other device is sending it over the Bluetooth link (in my case as a BIS broadcast). How can I configure the nRF as I2S slave?

  • Hi, 

    When you set ADK as I2S slave, you may run into the issue as my colleague's explanation in this post. It is strongly recommended to have nRF5340-gateway audio as I2S master, and your custom board can be I2S slave.

    It would be possible to configure the ADK as I2S slave, but we don't have official support for this feature now. Enabling CONFIG_AUDIO_SOURCE_I2S only switches the audio source interface from USB to I2S since that will break the drift/presentation compensation mechanism in the project. If you really want the nRF5340 gateway to run as the I2S slave (which we won't recommend). You have to modify the audio_datapath module to bypass all the compensation mechanisms, and also modify the audio_i2s module for turning the I2S from master into slave.

    Regards,
    Amanda H.

  • Hi Amanda! We've investigated a couple approaches and would like to try running the nRF as a follower. We know that this is not recommended and can result in audio degradation but we think its worth evaluating since the audio degradation may be acceptable for our application. I've attempted to implement the changes that you've indicated above but it does not appear to be working, I'm sure I'm just missing something.

    in src/modules/audio_i2s.c:41:

    static nrfx_i2s_config_t cfg = {
        /* Pins are configured by pinctrl. */
        .skip_gpio_cfg = true,
        .skip_psel_cfg = true,
        .irq_priority = DT_IRQ(I2S_NL, priority),
        .mode = NRF_I2S_MODE_SLAVE,
        .format = NRF_I2S_FORMAT_ALIGNED,
        .alignment = NRF_I2S_ALIGN_LEFT,
        .ratio = NRF_I2S_RATIO_256X,
        .mck_setup = NRF_I2S_MCK_DISABLED,
        .sample_width = NRF_I2S_SWIDTH_16BIT_IN32BIT,
        .channels = NRF_I2S_CHANNELS_STEREO,
        .clksrc = NRF_I2S_CLKSRC_PCLK32M,
        .enable_bypass = true,
    };

    The device we're attempting to link with uses 16bit samples left aligned in 32bit wide frames

    Next, to disable the compensation mechanisms, I've commented out the call to

    audio_datapath_drift_compensation(frame_start_ts);

    within src/audio/audio_datapath.c:699 which is the

    audio_datapath_i2s_blk_complete

    function.

    This feels like the area I might be missing something. Any assistance would be greatly appreciated! Thanks!

  • Hi, 

    There's a new feature to disable drift/pres compensation, and now it is merged to NCS main now.

    Please disable the following two configs (drift_comp and pres_comp) for a trial, https://github.com/nrfconnect/sdk-nrf/blob/c9f46d54b472f66596b50dd09c392f5b067243c2/applications/nrf5340_audio/src/audio/audio_datapath.c#L943

    -Amanda H.

  • What version of the SDK is this using? I've cloned that entire repo at the commit SHA you linked, but it's not building. It appears to be defaulting to my local SDK install (2.3.0)

    PS C:\Projects\sdk-nrf\applications\nrf5340_audio> python .\tools\buildprog\buildprog.py -c both -b debug -d gateway -p
    +------------+----------+---------+--------------+---------------------+---------------------+
    |    snr     | snr conn |  device | only reboot  | core app programmed | core net programmed |
    +------------+----------+---------+--------------+---------------------+---------------------+
    | 1050131509 |   True   | gateway | Not selected |     Selected TBD    |     Selected TBD    |
    +------------+----------+---------+--------------+---------------------+---------------------+
    Invoking build step
    Net core uses precompiled hex
    Run: west build C:\Projects\sdk-nrf\applications\nrf5340_audio -b nrf5340_audio_dk_nrf5340_cpuapp -d C:\Projects\sdk-nrf\applications\nrf5340_audio\build\dev_gateway\build_debug -DCONFIG_AUDIO_DEV=2
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Projects/sdk-nrf/applications/nrf5340_audio
    -- Using NCS Toolchain 2.3.0 for building. (C:/ncs/toolchains/v2.3.0/cmake)
    -- Found Python3: C:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Cache files will be written to: C:/ncs/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf5340_audio_dk_nrf5340_cpuapp
    -- Found host-tools: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
    -- Found BOARD.dts: C:/ncs/v2.3.0/nrf/boards/arm/nrf5340_audio_dk_nrf5340/nrf5340_audio_dk_nrf5340_cpuapp.dts
    -- Generated zephyr.dts: C:/Projects/sdk-nrf/applications/nrf5340_audio/build/dev_gateway/build_debug/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Projects/sdk-nrf/applications/nrf5340_audio/build/dev_gateway/build_debug/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Projects/sdk-nrf/applications/nrf5340_audio/build/dev_gateway/build_debug/zephyr/dts.cmake
    
    warning: Experimental symbol NRF5340_AUDIO is enabled.
    
    
    warning: Experimental symbol BT_AUDIO is enabled.
    
    
    warning: Experimental symbol BT_VCP_VOL_CTLR is enabled.
    
    
    warning: Experimental symbol BT_MCS is enabled.
    
    
    warning: Experimental symbol BT_MPL is enabled.
    
    
    warning: Experimental symbol MCTL is enabled.
    
    
    warning: BT_LL_ACS_NRF53 (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\Kconfig.defaults:145) defined without a type
    
    warning: BT_BAP_UNICAST_SERVER (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:84) defined without a type
    
    warning: BT_AUDIO_TX (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:134, C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:201, C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.deParsing C:/Projects/sdk-nrf/applications/nrf5340_audio/Kconfig
    Loaded configuration 'C:/ncs/v2.3.0/nrf/boards/arm/nrf5340_audio_dk_nrf5340/nrf5340_audio_dk_nrf5340_cpuapp_defconfig'
    Merged configuration 'C:/Projects/sdk-nrf/applications/nrf5340_audio/prj.conf'
    Merged configuration 'C:/Projects/sdk-nrf/applications/nrf5340_audio/build/dev_gateway/build_debug/zephyr/misc/generated/extra_kconfig_options.conf'
    faults:280) defined without a type
    
    warning: BT_AUDIO_RX (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:137, C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:204, C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:250) defined without a type       
    
    warning: BT_BAP_UNICAST_CLIENT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:145) defined without a type
    
    warning: BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:165) defined without a type  
    
    warning: BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:169) defined without a type       
    
    warning: BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:172) defined without a type       
    
    warning: BT_BAP_BROADCAST_SINK (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:232) defined without a type
    
    warning: BT_BAP_BROADCAST_SNK_STREAM_COUNT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:238) defined without a type
    
    warning: BT_BAP_BROADCAST_SOURCE (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:268) defined without a type
    
    warning: BT_BAP_BROADCAST_SRC_STREAM_COUNT (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:274) defined without a type
    
    warning: BT_GATT_AUTO_DISCOVER_CCC (defined at C:/ncs/v2.3.0/zephyr/subsys/bluetooth/host\Kconfig.gatt:177, subsys/bluetooth\host\Kconfig.gatt:177) has direct dependencies (BT_GATT_CLIENT && BT_CONN && BT_HCI_HOST && BT_RPC_STACK) || (BT_GATT_CLIENT && BT_CONN && BT_HCI_HOST && BT_HCI && BT) with value n, but is currently being y-selected by the following symbols:
     - BT_VCP_VOL_CTLR (defined at C:/Projects/sdk-nrf/applications/nrf5340_audio\src/bluetooth\Kconfig.defaults:176, C:/ncs/v2.3.0/zephyr/subsys/bluetooth/host\../audio\Kconfig.vcp:67, subsys/bluetooth\host\../audio\Kconfig.vcp:67), with value y, direct dependencies (AUDIO_DEV = 2 && TRANSPORT_CIS && NRF5340_AUDIO) || (BT_AUDIO && BT_HCI_HOST && BT_RPC_STACK) || (BT_AUDIO && BT_HCI_HOST && BT_HCI && BT) (value: y), and select condition BT_AUDIO && BT_HCI_HOST && BT_HCI && BT (value: y)
    
    error: Aborting due to Kconfig warnings
    
    CMake Error at C:/ncs/v2.3.0/zephyr/cmake/modules/kconfig.cmake:328 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v2.3.0/nrf/cmake/modules/kconfig.cmake:29 (include)
      C:/ncs/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:46 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\ncs\toolchains\v2.3.0\opt\bin\python.exe' '-BC:\Projects\sdk-nrf\applications\nrf5340_audio\build\dev_gateway\build_debug' -GNinja -DBOARD=nrf5340_audio_dk_nrf5340_cpuapp -DCONFIG_AUDIO_DEV=2 '-SC:\Projects\sdk-nrf\applications\nrf5340_audio'
    Traceback (most recent call last):
      File ".\tools\buildprog\buildprog.py", line 404, in <module>
        __main()
      File ".\tools\buildprog\buildprog.py", line 387, in __main
        __build_module(build_cfg, options)
      File ".\tools\buildprog\buildprog.py", line 150, in __build_module
        raise Exception("cmake error: " + str(ret_val))
    Exception: cmake error: 1

  • Hi, 

    NCS v2.4.0 is released today. Please try it. Thanks. 

    -Amanda H. 

Related