ESP32 I2s stalling processor

krish2487
Posts: 5
Joined: Fri Feb 08, 2019 9:51 am

ESP32 I2s stalling processor

Postby krish2487 » Fri Aug 16, 2019 2:04 pm

Hello,
We have a very peculiar problem that we are not able to solve.

We have a custom ESP32 board with the ESP32 wrover module. We are using the arduino framework along with platformio as a build system.
I mention the platformio only to provide complete information, it is really the same as a regular arduino esp32 installation.
The firmware does some job, makes a couple of https requests.. sleeps for a minute.. Wakes up and repeats the process ad infinitum.
If for any number of foreseeable reasons, the esp32 is unable to continue the job then the firmware calls the ESP.restart() to reboot the processor. And the peripherals we use are I2c, UART and I2S for various sensors.

The issues we are seeing is this. The firmware during one of these forced reboots stalls at the I2s_driver_install function invocation.
It is always at the same place irrespective of the prototype board we are using. To diagnose the firmware further we tried the same firmware on the ESP32-dev-kit and tried stepping the code in gdb to verify the source of the problem. No surprise, we are able to step through the code till the i2s_driver_install and the processor soon stalls and the debug session breaks.

This happens roughly about 30-40% of the time.. A manual reboot usually fixes the problem. But we would like to identify why this happens and what we can do to fix it.

I can post the relevant parts of the firmware if required.
Is there anything we can do to further isolate the issue and fix it ? Has anyone else faced a similar issue with the I2s device?

Thank you in advance for any help!! :-)

krish2487
Posts: 5
Joined: Fri Feb 08, 2019 9:51 am

Re: ESP32 I2s stalling processor

Postby krish2487 » Thu Aug 29, 2019 9:05 am

bump!!!

Any suggestions on how to fix the I2s stalling issue?
Any help on how to isolate the root cause will be equally helpful!!

Thanks in advance!

lbernstone
Posts: 827
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 I2s stalling processor

Postby lbernstone » Thu Aug 29, 2019 5:32 pm

I think if you post your i2s_config definition, you will be more likely to get a response.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: ESP32 I2s stalling processor

Postby ESP_igrr » Fri Aug 30, 2019 10:01 am

Can you try calling periph_module_reset(PERIPH_I2S0_MODULE); before i2s_driver_install? Or PERIPH_I2S1_MODULE if you are using I2S1.
The declaration of this function is in "driver/periph_ctrl.h".

krish2487
Posts: 5
Joined: Fri Feb 08, 2019 9:51 am

Re: ESP32 I2s stalling processor

Postby krish2487 » Mon Sep 02, 2019 8:11 am

My apologies for not being able to respond earlier. I was sick and did not get to a PC.

@Ibernstone.
You are right. I am sorry. I should have posted atleast the basic configuration. Please find the configuration below.

@ESP_igrr
Please find the existing configuration below. Thank you for the suggestions. I will try the patch and get back here. :-)

Code: Select all

boolean setup_microphone(void) {
  i2s_config_t i2s_config;
  static const int bytes = 1024*1000;
  i2s_config.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX);
  i2s_config.sample_rate = 16000;
  //i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_24BIT;
  i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT;
  i2s_config.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT; // left on the earlier version
  i2s_config.communication_format = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB| I2S_DATA_ENABLE_DELAY);
  i2s_config.dma_buf_count = BUF_COUNT;
  i2s_config.dma_buf_len = BUF_COUNT * 4;
  i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL3;

  i2s_pin_config_t pin_config;
  pin_config.bck_io_num = 27; 
  pin_config.ws_io_num = 2;
  pin_config.data_out_num = I2S_PIN_NO_CHANGE;
  pin_config.data_in_num = 36;
  // i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue)
  i2s_driver_install((i2s_port_t)I2S_NUM_0, &i2s_config, 0, NULL);
  i2s_set_pin((i2s_port_t)I2S_NUM_0, &pin_config);
  i2s_stop(I2S_NUM_0);
  return i2s_start(I2S_NUM_0) == ESP_OK;
}
FWIW we are trying to use the ESP32 with a ICS 43432 I2s microphone.
The firmware stalls at the i2s_driver_install line, always..

That is to say, the firmware does not stall everytime on power up, but whenever the firmware stalls, it can be traced back to this particular line.

Thank you again for the help guys!! :-)

krish2487
Posts: 5
Joined: Fri Feb 08, 2019 9:51 am

Re: ESP32 I2s stalling processor

Postby krish2487 » Mon Sep 02, 2019 1:06 pm

No improvement I m afraid, The code still stalls at exactly the same place. I have tried calling the periph_module_reset before the i2s_driver_install. It still works for sometime and then stalls.

Any further suggestions on how I can narrow down the problem and help you fine folks, help me.. :-)
ESP_igrr wrote:
Fri Aug 30, 2019 10:01 am
Can you try calling periph_module_reset(PERIPH_I2S0_MODULE); before i2s_driver_install? Or PERIPH_I2S1_MODULE if you are using I2S1.
The declaration of this function is in "driver/periph_ctrl.h".

Thanks again in advance!! :-)

Raffneck
Posts: 2
Joined: Sun Jan 12, 2020 5:52 pm

Re: ESP32 I2s stalling processor

Postby Raffneck » Sun Jan 12, 2020 5:56 pm

Hello,

have you found a solution for your problem?
I stumbled upon the same issue...
I bypassed it by initializing the audio pipe as the very first thing in the setup
but I can not realy explain why and I normaly want to know why my code does what it does.

Who is online

Users browsing this forum: No registered users and 48 guests