Unable to interface ES8388 with nrf5340DK.

HI, Developers.

  i am trying to interface ES8388 codec with nrf5340DK. but unfortunately i can't understand how to interface with this board. The ES8388 is successfully interface with i2c protocol and i able to read and write register. but in case of i2s i can't understand why it is not working, here IRQ- EVENT is worked !.  

Here i Already tried 1] SAMPLE/DRIVER/I2S/ECHO example, 2] NCS_I2S_nrfx_driver example,  3] the test example I2S-speed and I2S-api test. 4] LOOPBACK .

  1. now in ECHO example i got this error : 

[00:00:01.960,235] <err> i2s_nrfx: Failed to allocate next RX buffer: -12
Failed to read data: -11

 here is project file :  echo_ESP.zip

       2. Now in NCS_I2S_nrfx_driver by siguhe example :  i got print sound is " 0,0,0,0,0,0,0,0,0"  and also i find the in 

data_handler() function p_rx_buffer is null.  

 

if (p_released)
	{
		if (p_released->p_rx_buffer != NULL)
		{
			data_ready_flag = true; //This is used in print_sound()
		}
	}
	

>>> one more thing in this project is suggested its configure as Non-Secure peripherals. so they edited nrf/subsys/spm/Kconfig, inside the menu  "Configure Non-Secure peripherals": 

config SPM_NRF_I2S0_NS
	bool "I2S0 is Non-Secure"
	default y

and  nrf/subsys/spm/spm.c: 

#ifdef NRF_I2S0
        PERIPH("NRF_I2S0", NRF_I2S0, CONFIG_SPM_NRF_I2S0_NS),
#endif
  but this file is no longer available in current NCS version.

    3.  Now in i2s test api  example : i got this errors: 

 4] . now in loopback example : i got 

 

 here the received sample right /left  data is always got ffff/ffff  and mismatch with send data !. 

 here is the project file : loopback.zip 

 

Finally I am a current beginner in this embedded system. So I apologize if I have made many mistakes in this project. 

if i make mistake in interfacing peripheral or i misunderstand processes of interfacing peripheral. so please right processes of interfacing unknown peripheral.
and also give me a tutorial or reference of it So that I can correct my mistakes well.

Thank you.

Parents
  • i already did it. i am able to start-up es8388 in project.  but i can't  able to interface or read mic data and  transmit  data over i2s. 

    As mentioned above I am in trouble.




  • Hi Einar,  i accidentally closed my ticket,  do you have any suggestion of my question or solution about it ?

  • Hi,

    Ajaysinh said:
    And if you have any code of working or test code or example ES8388 with nrf board, then share with me. 

    I am a bit confused about the applications. Is there a direct link between the ECHO sample and the loopback sample that I am overlooking? If not, it would be better to split this in separate cases to avoid confusion.

    Ajaysinh said:
    ERROR : Streams started , Failed to read data: -5

    This (-5 = -EIO) comes from i2s_nrfx_read() in zephyr/drivers/i2s/i2s_nrfx.c, due to -ENOMSG returned from k_msgq_get(). So this is either a timeout waiting for I2S data, or the internal state is I2S_STATE_ERROR. Can you check with a debugger which is the case?

    Ajaysinh said:
    the board is continuously booting :: 

    It is booting because this assert in the implementation of nrfx_i2s_start() in nrfx_i2s.c is failing:

        NRFX_ASSERT(p_initial_buffers->p_rx_buffer != NULL ||
                    p_initial_buffers->p_tx_buffer != NULL);

    So there is something wrong with the buffers you provide. Looking at your code I see this:

    		void *buffer;
    		uint32_t size;
    		int ret;
    
    		ret = dmic_read(dmic_dev, 0, &buffer, &size, READ_TIMEOUT);
    		if (ret < 0) {
    			LOG_ERR("%d - read failed: %d", i, ret);
    			return ret;
    		}

    You are declaring a pointer (buffer) to nowhere, and using it directly. So the assert is expected, and you need to fix your buffer handling.

    Ajaysinh said:
    And if you have any code of working or test code or example ES8388 with nrf board, then share with me. 

    Unfortunately no, I don't have any code for ES8388 (nor the device itself).

    Ajaysinh said:
    the line  out of the box and on your desk what does that mean ? 

    "out of the box" refers to using the example from the SDK without any modifications at all, and "on my desk" refers to my testing on my desk.

  • This (-5 = -EIO) comes from i2s_nrfx_read() in zephyr/drivers/i2s/i2s_nrfx.c, due to -ENOMSG returned from k_msgq_get(). So this is either a timeout waiting for I2S data, or the internal state is I2S_STATE_ERROR. Can you check with a debugger which is the case?

    yes it is due to internal state :

    I2S_STATE_ERROR.
  • I see. Then the next question is why is that? There is a few places in the driver implementation where the state is set to I2S_STATE_ERROR. Which is it? And if you keep backtracking, what do you find out about the origin of the error?

  • After backtracking, 

     i got this error : [00:00:00.429,870] <err> i2s_nrfx: Failed to allocate next RX buffer: -12 


    and in debugger, its  got from : k_mem_slab_alloc() function.

     

    static bool get_next_rx_buffer(struct i2s_nrfx_drv_data *drv_data,
    			       nrfx_i2s_buffers_t *buffers)
    {
    	int ret = k_mem_slab_alloc(drv_data->rx.cfg.mem_slab,
    				   (void **)&buffers->p_rx_buffer,
    				   K_NO_WAIT);
    
    	if (ret < 0) {
    		LOG_ERR("Failed to allocate next RX buffer: %d",
    			ret);
    		return false;
    	}
    
    	return true;
    }

    and in k_mem_alloc() function  its come from : 

    else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT) ||
    !IS_ENABLED(CONFIG_MULTITHREADING)) {
    /* don't wait for a free block to become available */
    *mem = NULL;
    result = -ENOMEM; << 

    int k_mem_slab_alloc(struct k_mem_slab *slab, void **mem, k_timeout_t timeout)
    {
    	k_spinlock_key_t key = k_spin_lock(&slab->lock);
    	int result;
    
    	SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_mem_slab, alloc, slab, timeout);
    
    	if (slab->free_list != NULL) {
    		/* take a free block */
    		*mem = slab->free_list;
    		slab->free_list = *(char **)(slab->free_list);
    		slab->num_used++;
    
    #ifdef CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION
    		slab->max_used = MAX(slab->num_used, slab->max_used);
    #endif
    
    		result = 0;
    	} else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT) ||
    		   !IS_ENABLED(CONFIG_MULTITHREADING)) {
    		/* don't wait for a free block to become available */
    		*mem = NULL;
    		result = -ENOMEM;
    	}

Reply
  • After backtracking, 

     i got this error : [00:00:00.429,870] <err> i2s_nrfx: Failed to allocate next RX buffer: -12 


    and in debugger, its  got from : k_mem_slab_alloc() function.

     

    static bool get_next_rx_buffer(struct i2s_nrfx_drv_data *drv_data,
    			       nrfx_i2s_buffers_t *buffers)
    {
    	int ret = k_mem_slab_alloc(drv_data->rx.cfg.mem_slab,
    				   (void **)&buffers->p_rx_buffer,
    				   K_NO_WAIT);
    
    	if (ret < 0) {
    		LOG_ERR("Failed to allocate next RX buffer: %d",
    			ret);
    		return false;
    	}
    
    	return true;
    }

    and in k_mem_alloc() function  its come from : 

    else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT) ||
    !IS_ENABLED(CONFIG_MULTITHREADING)) {
    /* don't wait for a free block to become available */
    *mem = NULL;
    result = -ENOMEM; << 

    int k_mem_slab_alloc(struct k_mem_slab *slab, void **mem, k_timeout_t timeout)
    {
    	k_spinlock_key_t key = k_spin_lock(&slab->lock);
    	int result;
    
    	SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_mem_slab, alloc, slab, timeout);
    
    	if (slab->free_list != NULL) {
    		/* take a free block */
    		*mem = slab->free_list;
    		slab->free_list = *(char **)(slab->free_list);
    		slab->num_used++;
    
    #ifdef CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION
    		slab->max_used = MAX(slab->num_used, slab->max_used);
    #endif
    
    		result = 0;
    	} else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT) ||
    		   !IS_ENABLED(CONFIG_MULTITHREADING)) {
    		/* don't wait for a free block to become available */
    		*mem = NULL;
    		result = -ENOMEM;
    	}

Children
Related