Failed to allocate dma buffer

lladam
Posts: 44
Joined: Tue Jul 20, 2021 12:14 am

Failed to allocate dma buffer

Postby lladam » Thu Dec 07, 2023 3:22 am

Hi all.
the ESP32 second I2S problem need help.

Code: Select all


void i2sInitOUT()
{
  i2s_config_t i2s_config_OUT = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
    .sample_rate = I2S_SAMPLE_RATE,
    .bits_per_sample = i2s_bits_per_sample_t(I2S_SAMPLE_BITS),
    //  .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .channel_format = I2S_CHANNEL_FMT_RIGHT_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_PORT_OUT, &i2s_config_OUT, 0, NULL);

  err = i2s_driver_install(I2S_PORT_OUT, &i2s_config_OUT, 0, NULL);
  if (err != ESP_OK) {
    Serial.printf("Failed installing OUTPUT driver: %d\n", err);
    while (true);
  }

  //i2s_driver_install(I2S_DAC_PORT, &i2s_dac_config, 0, NULL);
  
  const i2s_pin_config_t pin_config_OUT = {
    .bck_io_num =   I2S_BCLK, //I2S_SCK,
    .ws_io_num =    I2S_LRC,  //I2S_WS,
    .data_out_num = -1,
    .data_in_num =  I2S_DOUT  //I2S_SD
  };
  i2s_set_pin(I2S_PORT_OUT, &pin_config_OUT);

}
ERROR:

Code: Select all


22:06:09.983 -> E (11471) I2S: i2s_alloc_dma_buffer(741): Error malloc dma buffer
22:06:09.983 -> E (11472) I2S: i2s_realloc_dma_buffer(788): Failed to allocate dma buffer
22:06:10.016 -> E (11473) I2S: i2s_set_clk(1729): I2S1 tx DMA buffer malloc failed
22:06:10.016 -> E (11479) I2S: i2s_driver_install(2027): I2S set clock failed
22:06:10.016 -> Failed installing OUTPUT driver: 257


liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: Failed to allocate dma buffer

Postby liaifat85 » Thu Dec 07, 2023 2:26 pm

Try to decrease the dma_buf_count and dma_buf_len values in i2s_config_OUT. See if it helps.

Who is online

Users browsing this forum: Google [Bot] and 60 guests