I2S malloc failed after ble initial

HuyYuh
Posts: 2
Joined: Tue Mar 22, 2022 2:31 am

I2S malloc failed after ble initial

Postby HuyYuh » Tue Mar 22, 2022 2:50 am

Hello, I'm working with ESP32 which collect data from INMP441 microphone. After run inference it will send status to another esp32.
My code crashed in setup when I call i2s init function after ble init function even though I run them separately successfully.
Here is my i2s init function:

Code: Select all

static void i2s_init(void){
  i2s_config_t i2s_config = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = I2S_SAMPLE_RATE,
    .bits_per_sample = i2s_bits_per_sample_t(I2S_SAMPLE_BITS),
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
    .intr_alloc_flags = 0,
    .dma_buf_count = 64,
    .dma_buf_len = 1024,
    .use_apll = 1
  };

  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);

  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_SCK,
    .ws_io_num = I2S_WS,
    .data_out_num = -1,
    .data_in_num = I2S_SD
  };

  i2s_set_pin(I2S_NUM_0, &pin_config);
}
Here is my ble init function:

Code: Select all

void ble_init() 
{

  Serial.println("Starting Arduino BLE Client application...");
  BLEDevice::init("ESP32-BLE-Client");

  /* Retrieve a Scanner and set the callback we want to use to be informed when we
     have detected a new device.  Specify that we want active scanning and start the
     scan to run for 5 seconds. */
  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setInterval(1349);
  pBLEScan->setWindow(449);
  pBLEScan->setActiveScan(true);
  pBLEScan->start(5, false);
}
And this is my error log:
Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
Starting Arduino BLE Client application...
BLE Advertised Device found: Name: ESP32-BLE-Server, Address: 9c:9c:1f:e3:95:ce, serviceUUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, txPower: 3
E (778) I2S: Error malloc dma buffer
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1796 (vQueueDelete)- assert failed!
abort() was called at PC 0x40090018 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x4008ede8:0x3ffd7ac0 0x4008f065:0x3ffd7ae0 0x40090018:0x3ffd7b00 0x401681a9:0x3ffd7b20 0x4016829b:0x3ffd7b40 0x40169d39:0x3ffd7b70 0x4016a4e9:0x3ffd7bd0 0x400d3104:0x3ffd7c00 0x400dd376:0x3ffd7c70 0x4009011a:0x3ffd7c90
I don't know where is the problem, please help me.
Thanks in advance

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: I2S malloc failed after ble initial

Postby ESP_Sprite » Wed Mar 23, 2022 2:02 am

.dma_buf_count = 64,
.dma_buf_len = 1024,
This means you're asking the I2S driver to allocate 64 buffers of 1K-samples, a sample being 2 or 4 bytes each (can't tell from your code). This means the I2S driver will request 128K or 256K of internal memory for those buffers. Your ESP32 likely does not have that amount of memory left. Suggest you lower those numbers.

Who is online

Users browsing this forum: No registered users and 71 guests