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.




  • 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;
    	}

  • I see. That means that you are out of memory for some reason. Have you tried increasing the size of the slab? In main.c you have K_MEM_SLAB_DEFINE_STATIC, where you pass the block size and number of blocks. Can you increase it and see? Also, make sure you free with k_mem_slab_free() as in the example.

  • I am not trying to increase the block size because the macro blocksize calculates its own size. Even if I manually increase the block size, the same error occurs
  • It is calculated based on input parameters. From your main.c:

    #define BLOCK_SIZE (BYTES_PER_SAMPLE * SAMPLES_PER_BLOCK)
    #define BLOCK_COUNT (INITIAL_BLOCKS + 2)
    K_MEM_SLAB_DEFINE_STATIC(mem_slab, BLOCK_SIZE, BLOCK_COUNT, 4);

    There seems to be an issue related to memory allocation or freeing. So either you need to debug further to understand just from that, or you can combine it with some experimentation like this (increasing the memory slab). I don't have ES8388 so I am not able to test your code so I am not able to be more specific at this point, but please share the results of  your debugging and experiments so that we can consider the new information as you find it.

Reply
  • It is calculated based on input parameters. From your main.c:

    #define BLOCK_SIZE (BYTES_PER_SAMPLE * SAMPLES_PER_BLOCK)
    #define BLOCK_COUNT (INITIAL_BLOCKS + 2)
    K_MEM_SLAB_DEFINE_STATIC(mem_slab, BLOCK_SIZE, BLOCK_COUNT, 4);

    There seems to be an issue related to memory allocation or freeing. So either you need to debug further to understand just from that, or you can combine it with some experimentation like this (increasing the memory slab). I don't have ES8388 so I am not able to test your code so I am not able to be more specific at this point, but please share the results of  your debugging and experiments so that we can consider the new information as you find it.

Children
No Data
Related