Skip to content

Second I2S on ESP32 non-working #7111

Closed
@musteresel

Description

@musteresel

Board

ESP32 NodeMCU

Device Description

(irrelevant for issue)

Hardware Configuration

(irrelevant for issue)

Version

v2.0.4

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

When going to this part of the code

while(ESP_OK != esp_i2s::i2s_driver_install((esp_i2s::i2s_port_t) _deviceIndex, &i2s_config, _I2S_EVENT_QUEUE_LENGTH, &_i2sEventQueue)){

then it causes the value of _bitsPerSample to change to 0.

This later causes this assertion to fail:
https://github.com/espressif/esp-idf/blob/1b16ef6cfc2479a08136782f9dc57effefa86f66/components/esp_ringbuf/ringbuf.c#L874
That part of the code is called from here:

_buffer_byte_size = _i2s_dma_buffer_size * (_bitsPerSample / 8) * _I2S_DMA_BUFFER_COUNT * 2;
_input_ring_buffer = xRingbufferCreate(_buffer_byte_size, RINGBUF_TYPE_BYTEBUF);

I attached a debugger (Segger J-Link via steps defined here, basically using USBDriverTool to change J-Link driver to WinUSB, then using openocd -f interface/jlink.cfg -c "adapter_khz 1000" -f board/esp-wroom-32.cfg, then connecting using gdb supplied in esp-idf 4.4.2) to get to the root of this, and got so far as to find out that the actual change seems to happen in this function:
https://github.com/espressif/esp-idf/blob/1b16ef6cfc2479a08136782f9dc57effefa86f66/components/hal/esp32/include/hal/i2s_ll.h#L920-L930

(gdb) p/x &_bitsPerSample
$2 = 0x3ffc14f4 
(gdb) watch *0x3ffc14f4
Hardware watchpoint 2: *0x3ffc14f4
(gdb) display *((int32_t *)0x3ffc14f4)
3: *((int32_t *)0x3ffc14f4) = 24 
(gdb) c
Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
0x400de3b0 in i2s_ll_enable_builtin_adc (enable=false, hw=<optimized out>) at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/hal/esp32/include/hal/i2s_ll.h:929
929     /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/hal/esp32/include/hal/i2s_ll.h: No such file or directory.
3: *((int32_t *)0x3ffc14f4) = 24
(gdb) s
i2s_hal_config_param (hal=0x3ffb9998, hal_cfg=0x3ffb99a4) at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/hal/i2s_hal.c:299
299     /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/hal/i2s_hal.c: No such file or directory.
3: *((int32_t *)0x3ffc14f4) = 0

(this shows L929 as offender, but that's strange to me, setting to 0 seems incorrect for this? https://github.com/espressif/esp-idf/blob/1b16ef6cfc2479a08136782f9dc57effefa86f66/components/hal/esp32/include/hal/i2s_ll.h#L929)

Sketch

~~~c++
#include <I2S.h>

I2SClass I2S1(1 /*I2S1*/, 0 /*as in I2S.c*/, PIN_I2S1_SD, PIN_I2S1_SCK, PIN_I2S1_FS); // global variable

// in setup
I2S1.begin(I2S_PHILIPS_MODE, 16000, 24);
~~~

Debug Message

(None, Hard Reset)

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions