Crash when using ESP-ADF and I2S, along with wifi? (resolved)

tpbedford
Posts: 31
Joined: Mon Feb 14, 2022 4:16 am

Crash when using ESP-ADF and I2S, along with wifi? (resolved)

Postby tpbedford » Wed Dec 20, 2023 1:00 am

Can anyone shed some light on a crash I'm seeing? It seems to be a NULL exception error. I'm using ESP-ADF 2.6 and ESP-IDF 5.1

I don't understand why there would be any interaction between spi_flash_ll_cmd_is_done() and _xt_medint2() and i2s_intr_handler_default() as seen in the stack trace.

It occurs when I start a wifi task to connect as client, while also having an audio pipeline started. The pipeline uses I2S for audio to an external codec.

If I don't start wifi there is no crash. The crash occurs when the wifi driver calls some NVS operation and SPI flash read/write on an ESP32-WROVER-IE

Code: Select all

I (3593) AUDIO_ELEMENT: [hfpr] AEL_MSG_CMD_RESUME,state:1
I (3593) hfpr: Open
I (3593) hfpr: HFP ringbuf in = 0B, out = 4096B
I (3603) wifi:wifi driver task: 3ffef7e0, prio:23, stack:6656, core=0
I (3613) AUDIO_ELEMENT: [gate] AEL_MSG_CMD_RESUME,state:1
I (3613) gate: Open
I (3613) gate: ringbuf in =Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed).

Core  0 register dump:
PC      : 0x4008d699  PS      : 0x00050035  A0      : 0x40083320  A1      : 0x3ffc01c0
A2      : 0x3f805ff0  A3      : 0xbad00bad  A4      : 0x3ff42000  A5      : 0x400949b2
A6      : 0x3ff42000  A7      : 0x01002000  A8      : 0x00000000  A9      : 0x00000002
A10     : 0x0000007e  A11     : 0x3ffef504  A12     : 0x01000000  A13     : 0x00002000
A14     : 0x00000001  A15     : 0x3ffcf91c  SAR     : 0x00000018  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000


Backtrace: 0x4008d696:0x3ffc01c0 0x4008331d:0x3ffc01f0 0x40096f69:0x3ffef320 0x40096d86:0x3ffef340 0x4009a231:0x3ffef360 0x4008e7ef:0x3ffef3e0 0x40129872:0x3ffef420 0x4012f8b7:0x3ffef450 0x401a6aa6:0x3ffef470 0x40130612:0x3ffef490 0x4013088e:0x3ffef4f0 0x4012ed29:0x3ffef580 0x4012f735:0x3ffef5e0 0x401a66a9:0x3ffef600 0x4012e77f:0x3ffef620 0x4012e795:0x3ffef650 0x40159411:0x3ffef670 0x401596cf:0x3ffef6b0 0x40156ab6:0x3ffef6d0 0x40154ef2:0x3ffef700 0x401ab32d:0x3ffef720 0x40094e8e:0x3ffef750

Code: Select all

0x4008d696: i2s_ll_get_intr_status at C:/Espressif/frameworks/esp-idf/components/hal/esp32/include/hal/i2s_ll.h:428
 (inlined by) i2s_intr_handler_default at C:/Espressif/frameworks/esp-idf/components/driver/deprecated/i2s_legacy.c:230
0x4008331d: _xt_medint2 at C:/Espressif/frameworks/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:1325
0x40096f69: spi_flash_ll_cmd_is_done at C:/Espressif/frameworks/esp-idf/components/hal/esp32/include/hal/spi_flash_ll.h:77 (discriminator 1)
 (inlined by) spi_flash_hal_poll_cmd_done at C:/Espressif/frameworks/esp-idf/components/hal/spi_flash_hal_common.inc:38 (discriminator 1)
0x40096d86: spi_flash_hal_read at C:/Espressif/frameworks/esp-idf/components/hal/spi_flash_hal_common.inc:190
0x4009a231: spi_flash_chip_winbond_read at C:/Espressif/frameworks/esp-idf/components/spi_flash/spi_flash_chip_winbond.c:69
0x4008e7ef: esp_flash_read at C:/Espressif/frameworks/esp-idf/components/spi_flash/esp_flash_api.c:898 (discriminator 4)
0x40129872: esp_partition_read at C:/Espressif/frameworks/esp-idf/components/esp_partition/partition_target.c:38
0x4012f8b7: nvs::NVSPartition::read(unsigned int, void*, unsigned int) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_partition.cpp:45
0x401a6aa6: nvs::Page::readEntry(unsigned int, nvs::Item&) const at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_page.cpp:853
0x40130612: nvs::Page::findItem(unsigned char, nvs::ItemType, char const*, unsigned int&, nvs::Item&, unsigned char, nvs::VerOffset) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_page.cpp:903
0x4013088e: nvs::Page::readItem(unsigned char, nvs::ItemType, char const*, void*, unsigned int, unsigned char, nvs::VerOffset) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_page.cpp:258
0x4012ed29: nvs::Storage::readItem(unsigned char, nvs::ItemType, char const*, void*, unsigned int) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_storage.cpp:570
0x4012f735: nvs::NVSHandleSimple::get_typed_item(nvs::ItemType, char const*, void*, unsigned int) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_handle_simple.cpp:36
0x401a66a9: int nvs::NVSHandle::get_item<unsigned char>(char const*, unsigned char&) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/include/nvs_handle.hpp:275
0x4012e77f: int nvs_get<unsigned char>(unsigned long, char const*, unsigned char*) at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_api.cpp:440
0x4012e795: nvs_get_u8 at C:/Espressif/frameworks/esp-idf/components/nvs_flash/src/nvs_api.cpp:450
0x40159411: wifi_nvs_validate_sta_listen_interval at ??:?
0x401596cf: wifi_nvs_init at ??:?
0x40156ab6: wifi_init_process at ??:?
0x40154ef2: ieee80211_ioctl_process at ??:?
0x401ab32d: ppTask at ??:?
0x40094e8e: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

tpbedford
Posts: 31
Joined: Mon Feb 14, 2022 4:16 am

Re: Crash when using ESP-ADF and I2S, along with wifi? (resolved)

Postby tpbedford » Wed Dec 20, 2023 1:54 am

Resolved by ensuring the i2s_obj instances are alloc'd in internal RAM (not PSRAM):

Code: Select all

esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue)
{
    ...
    /* Step 2: Allocate driver object and register to platform */
    //i2s_obj_t *i2s_obj = calloc(1, sizeof(i2s_obj_t));
    i2s_obj_t *i2s_obj = heap_caps_calloc(1, sizeof(i2s_obj_t), (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));

Who is online

Users browsing this forum: No registered users and 173 guests