Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in I2S when use ESP_INTR_FLAG_IRAM flag in the driver config (IDFGH-2432) #4545

Closed
phonec opened this issue Dec 26, 2019 · 7 comments
Closed
Assignees

Comments

@phonec
Copy link
Contributor

phonec commented Dec 26, 2019

Environment

  • Development Kit: WEMOS LOLIN32 Pro
  • Module: ESP32-WROVER chip rev1
  • IDF version: v3.3.1
  • Operating System: Linux Ubuntu
  • Build System: Make
  • Power Supply: USB

Problem Description

When adding a flag ESP_INTR_FLAG_IRAM to the .intr_alloc_flags configuration of i2s driver leads to a crash, because at runtime not all of the data from the i2s_intr_handler_default() interrupt handler function can be found in IRAM, although the function itself has such an attribute: IRAM_ATTR.
In particular, the array of pointers I2S[] does not have an IRAM_ATTR attribute and may not be available when the cache is disabled during such an interrupt.

Solving

Adding this attribute to the I2S pointer on line 102: esp-idf/components/driver/i2s.c

102    static IRAM_ATTR i2s_dev_t * I2S [I2S_NUM_MAX] = {&I2S0, &I2S1};

perhaps it should completely solve this problem, at least it works for me.

Steps to repropduce

Just add this flag to the configuration, for example in the esp-idf/examples/ peripherals/i2s/main/i2s_example_main.c

Debug Logs

Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed)
Core 0 register dump:
PC      : 0x4008753c  PS      : 0x00050034  A0      : 0x40083e10  A1      : 0x3ffb0670
...
(gdb) list *0x4008753c
0x4008753c is in i2s_intr_handler_default (/home/ESP32/esp-idf/components/driver/i2s.c:520).
515
516         portBASE_TYPE high_priority_task_awoken = 0;
517
518         lldesc_t *finish_desc;
519
520         if (i2s_reg->int_st.out_dscr_err || i2s_reg->int_st.in_dscr_err) {
521             ESP_EARLY_LOGE(I2S_TAG, "dma error, interrupt status: 0x%08x", i2s_reg->int_st.val);
522             if (p_i2s->i2s_queue) {
523                 i2s_event.type = I2S_EVENT_DMA_ERROR;
524                 if (xQueueIsQueueFullFromISR(p_i2s->i2s_queue)) {
@github-actions github-actions bot changed the title Crash in I2S when use ESP_INTR_FLAG_IRAM flag in the driver config Crash in I2S when use ESP_INTR_FLAG_IRAM flag in the driver config (IDFGH-2432) Dec 26, 2019
@xiongyumail
Copy link
Contributor

@phonec

Thanks for the problem you found, it may be better to use DRAM_ATTR. We will merge the changes into the corresponding branches later.

@phonec
Copy link
Contributor Author

phonec commented Jan 6, 2020

Great. The placement of the I2S interrupt handler in IRAM is necessary to avoid sound distortion during other long-term SPI FLASH operations.

espressif-bot pushed a commit that referenced this issue Jan 7, 2020
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

* Closes #4545

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes #4557
@phonec
Copy link
Contributor Author

phonec commented Jan 11, 2020

it would be nice to see it also in the 3.3.x

@ctag-fh-kiel
Copy link

ctag-fh-kiel commented Jan 16, 2020

I have similar issues. The fix is great, but I haven't been able to run my external codec (WM8731) glitch free when reading a file from spiffs flash and serving the file's content with the http server...
Played with the i2s buffers -> no success, played with the i2s INTR flags --> no success
Any advice is much appreciated. WM8731 running at 44.1kHz...

@Alvin1Zhang
Copy link
Collaborator

@phonec Thanks for reporting and updates. We have back ported the fixes to IDF v3.3 and is now under internal review, would update once the fix is available on GitHub. Thanks.

@ctag-fh-kiel
Copy link

My issue was in fact related to the http server core id. I configured the httpd to use core 0 and i2s core 1. It was unrelated to flash access.

espressif-bot pushed a commit that referenced this issue Feb 19, 2020
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

* Closes #4545

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes #4557
espressif-bot pushed a commit that referenced this issue Feb 22, 2020
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

* Closes #4545

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes #4557
espressif-bot pushed a commit that referenced this issue Feb 23, 2020
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

* Closes #4545

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes #4557
@Alvin1Zhang
Copy link
Collaborator

@phonec @ctag-fh-kiel The issue has been fixed and fix available on GitHub. Please help try if the issue still happens, feel free to reopen if the issue persists. Thanks.

jack0c pushed a commit that referenced this issue Jul 29, 2020
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

* Closes #4545

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes #4557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants