Cannot build I2S echo application for NRF5340

Hi, I am a beginner into the embedded audio space, and happened upon this board to use for our university project. Our team's current plan would be to produce audio directly on the board and play it through the headphone jack, but have not found much success with the NRF5340 Audio application, as it has a lot of integration with Bluetooth (which we don't need for now). Right now we just need a simple application that plays a tune on the board.

In my search I have found the I2S echo application, which seems like a simple start for our use case. However, when trying to build the application we encountered the following error:

-- Found BOARD.dts: C:/ncs/v2.6.2/zephyr/boards/arm/nrf5340_audio_dk_nrf5340/nrf5340_audio_dk_nrf5340_cpuapp.dts
-- Found devicetree overlay: boards/nrf5340dk_nrf5340_cpuapp.overlay
devicetree error: pinctrl-names property in /soc/peripheral@50000000/i2s@28000 in C:/ncs/v2.6.2/zephyr/misc/empty_file.c has 1 strings, expected 2 strings

This is our build configuration (all other options left as default):

SDK version:

Any help would be appreciated! Thanks!

  • Hi Dejan, I've added it to my overlay file but am still facing the same issue. Please see below my full overlay file:

    /*
     * Copyright (c) 2021 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    &pinctrl {
    	i2c0_default_alt: i2c0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
    				<NRF_PSEL(TWIM_SCL, 0, 26)>;
    		};
    	};
    
    	i2c0_sleep_alt: i2c0_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
    				<NRF_PSEL(TWIM_SCL, 0, 26)>;
    			low-power-enable;
    		};
    	};
    
    	i2s0_default_alt: i2s0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(I2S_SCK_M, 1, 15)>,
    				<NRF_PSEL(I2S_LRCK_M, 1, 12)>,
    				<NRF_PSEL(I2S_SDOUT, 1, 13)>,
    				<NRF_PSEL(I2S_SDIN, 1, 14)>;
    		};
    	};
    };
    
    &i2c1 {
    	status = "okay";
    	pinctrl-0 = <&i2c0_default_alt>;
    	pinctrl-1 = <&i2c0_sleep_alt>;
    	pinctrl-names = "default", "sleep";
    
    	wm8731: wm8731@1a {
    		compatible = "wolfson,wm8731";
    		reg = <0x1a>;
    	};
    };
    
    &clock {
    	hfclkaudio-frequency = <11289600>;
    };
    
    i2s_rxtx: &i2s0 {
    	status = "okay";
    	pinctrl-0 = <&i2s0_default_alt>;
    	pinctrl-names = "default", "sleep";
    	clock-source = "ACLK";
    };
    
    &spi4 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>, <&gpio0 17 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi4_default>;
    	pinctrl-1 = <&spi4_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	cs47l63: cs47l63@1 {
    		compatible = "cirrus,cs47l63";
    		reg = <1>;
    		spi-max-frequency = <8000000>;
    		irq-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
    		reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
    		gpio9-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
    	};
    };
    

    All other files remain untouched. Any ideas on how to proceed? It's still erroring out inside the init_wm8731_i2c function. Thanks!

  • Hi,

    You could try to remove wm8731 section from &i2c1 in your overlay file.

    Best regards,
    Dejan

  • Hi I removed the wm8731 section from my overlay file. It now looks like this:

    /*
     * Copyright (c) 2021 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    &pinctrl {
    	i2c0_default_alt: i2c0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
    				<NRF_PSEL(TWIM_SCL, 0, 26)>;
    		};
    	};
    
    	i2c0_sleep_alt: i2c0_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
    				<NRF_PSEL(TWIM_SCL, 0, 26)>;
    			low-power-enable;
    		};
    	};
    
    	i2s0_default_alt: i2s0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(I2S_SCK_M, 1, 15)>,
    				<NRF_PSEL(I2S_LRCK_M, 1, 12)>,
    				<NRF_PSEL(I2S_SDOUT, 1, 13)>,
    				<NRF_PSEL(I2S_SDIN, 1, 14)>;
    		};
    	};
    };
    
    &i2c1 {
    	status = "okay";
    	pinctrl-0 = <&i2c0_default_alt>;
    	pinctrl-1 = <&i2c0_sleep_alt>;
    	pinctrl-names = "default", "sleep";
    };
    
    &clock {
    	hfclkaudio-frequency = <11289600>;
    };
    
    i2s_rxtx: &i2s0 {
    	status = "okay";
    	pinctrl-0 = <&i2s0_default_alt>;
    	pinctrl-names = "default", "sleep";
    	clock-source = "ACLK";
    };
    
    &spi4 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>, <&gpio0 17 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi4_default>;
    	pinctrl-1 = <&spi4_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	cs47l63: cs47l63@1 {
    		compatible = "cirrus,cs47l63";
    		reg = <1>;
    		spi-max-frequency = <8000000>;
    		irq-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
    		reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
    		gpio9-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
    	};
    };
    

    I was able to build the board (seems like now it just skipped the init_wm8731_i2c function). Since I do not have a microphone, I am filling in the bytes of the ring buffer manually like below: 

    int alt = 0;
    while (k_sem_take(&toggle_transfer, K_NO_WAIT) != 0) {
    	void *mem_block;
    	uint32_t block_size;
    	int ret;
    
    	ret = i2s_read(i2s_dev_rx, &mem_block, &block_size);
    	if (ret < 0) {
    		printk("Failed to read data: %d\n", ret);
    		break;
    	}
    
    	alt = 10 - alt;
    	//process_block_data(mem_block, SAMPLES_PER_BLOCK);
    	for (int i = 0; i < SAMPLES_PER_BLOCK; ++i) {
    		int16_t *sample = &((int16_t *)mem_block)[i];
    		*sample = alt;
    	}
    
    	ret = i2s_write(i2s_dev_tx, mem_block, block_size);
    	if (ret < 0) {
    		printk("Failed to write data: %d\n", ret);
    		break;
    	}
    }

    However, I am not hearing anything when I plug my headphones in. I suspect it has something to do with the hardware codec? Any support would be appreciated! 

  • Hi,

    After successful flashing, you should be able to use Button 1 and Button 2 on the board as described in the I2S_echo sample documentation - "Press Button 1 to toggle the echo effect and Button 2 to stop the streams." What happens when you press Button 1 and Button 2?

    Best regards,
    Dejan

  • Hi, when I press the buttons I can see on the serial console stream/echo is toggled on/off, but I cannot hear anything over my headphones. 

Related