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

ESP IDF GPIO mallocs gpio_isr_func in gpio_install_isr_service, which causes crashes in case of CONFIG_SPIRAM_USE_MALLOC=y (IDFGH-10644) #11876

Closed
3 tasks done
arnoutdekimo opened this issue Jul 14, 2023 · 1 comment
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@arnoutdekimo
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v4.4.4

Operating System used.

Windows

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-wrover-kit

Power Supply used.

USB

What is the expected behavior?

Expect: to have the possibility of running gpio ISR fully in IRAM/DRAM while still having mallocs go into external SPIRAM (which is not accessible in critical sections)

What is the actual behavior?

During cache locks (spi write to file system), and subsequent gpio ISR, the system cannot access anything on the SPI RAM. Hence, all structures and code in the ISR should be IRAM/DRAM

However, the function gpio_install_isr_service mallocs a structure, which is accessed in gpio_intr_service.

When CONFIG_SPIRAM_USE_MALLOC=y is set, with a small minimum size, this creates crashes like on the debuglogs

Steps to reproduce.

Make sure a gpio ISR triggers during a spi filesystem write, and make sure you have CONFIG_SPIRAM_USE_MALLOC=y
The result will be that the structure gpio_isr_func will not be accessible, and one reproduces a crash

Debug Logs.

I (3164731) MQTT_CON: MQTT_EVENT_DATA
Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed).

Core  0 register dump:
PC      : 0x40086baf  PS      : 0x00050034  A0      : 0x40085964  A1      : 0x3ffb0be0
0x40086baf: gpio_isr_loop at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/driver/gpio.c:415
 (inlined by) gpio_intr_service at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/driver/gpio.c:442

0x40085964: _xt_lowint1 at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/freertos/port/xtensa/xtensa_vectors.S:1114

A2      : 0x00000000  A3      : 0x00000008  A4      : 0x00000000  A5      : 0x4008fbf6
0x4008fbf6: _frxt_int_enter at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/freertos/port/xtensa/portasm.S:119

A6      : 0xe0000020  A7      : 0x00000000  A8      : 0x3f818b20  A9      : 0xbad00bad
A10     : 0x00000008  A11     : 0x3ffe5760  A12     : 0x800876a1  A13     : 0x3ffe5540
A14     : 0x00000006  A15     : 0x3ffbbe20  SAR     : 0x0000001d  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x4008c340  LEND    : 0x4008c35c  LCOUNT  : 0x00000000
0x4008c340: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:175

0x4008c35c: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:197



Backtrace: 0x40086bac:0x3ffb0be0 0x40085961:0x3ffb0c10 0x4008c36f:0x3ffe5530 0x400946ed:0x3ffe5540 0x40096dd8:0x3ffe5570 0x40088453:0x3ffe55f0 0x4010ac35:0x3ffe5630 0x4010c7df:0x3ffe5660 0x401af5ba:0x3ffe5680 0x4010d581:0x3ffe56a0 0x4010baa1:0x3ffe5700 0x4010c4f1:0x3ffe5750 0x4010c713:0x3ffe57b0 0x4010af4d:0x3ffe57d0 0x4010b3c5:0x3ffe5800 0x400e7bff:0x3ffe5820 0x400e963c:0x3ffe58a0 0x400ea009:0x3ffe5910 0x400e78d5:0x3ffe5950 0x400f866b:0x3ffe5990 0x400ef5db:0x3ffe5c30 0x400ef7c5:0x3ffe5cd0 0x401b9686:0x3ffe5d00 0x401b90a1:0x3ffe5d30 0x400fdf1b:0x3ffe5d70 0x400fe5f0:0x3ffe5d90 0x400fe947:0x3ffe5dd0 0x400fee92:0x3ffe5e00 0x40093825:0x3ffe5e30
0x40086bac: gpio_isr_loop at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/driver/gpio.c:415
 (inlined by) gpio_intr_service at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/driver/gpio.c:442

0x40085961: _xt_lowint1 at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/freertos/port/xtensa/xtensa_vectors.S:1114

0x4008c36f: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:208

0x400946ed: spi_flash_ll_get_buffer_data at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/hal/esp32/include/hal/spi_flash_ll.h:148
 (inlined by) spi_flash_hal_read at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/hal/spi_flash_hal_common.inc:176

0x40096dd8: spi_flash_chip_generic_read at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/spi_flash/spi_flash_chip_generic.c:230

0x40088453: esp_flash_read at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/spi_flash/esp_flash_api.c:832 (discriminator 4)

0x4010ac35: esp_partition_read at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/spi_flash/partition.c:424

0x4010c7df: nvs::NVSPartition::read(unsigned int, void*, unsigned int) at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_partition.cpp:45

0x401af5ba: nvs::Page::readEntry(unsigned int, nvs::Item&) const at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_page.cpp:879

0x4010d581: nvs::Page::findItem(unsigned char, nvs::ItemType, char const*, unsigned int&, nvs::Item&, unsigned char, nvs::VerOffset) at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_page.cpp:929

0x4010baa1: nvs::Storage::findItem(unsigned char, nvs::ItemType, char const*, nvs::Page*&, nvs::Item&, unsigned char, nvs::VerOffset) at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_storage.cpp:161

0x4010c4f1: nvs::Storage::getItemDataSize(unsigned char, nvs::ItemType, char const*, unsigned int&) at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_storage.cpp:660

0x4010c713: nvs::NVSHandleSimple::get_item_size(nvs::ItemType, char const*, unsigned int&) at C:/ESP32/esp-idf-eclipse-444/esp-idf/esp-idf-v4.4.4/components/nvs_flash/src/nvs_handle_simple.cpp:73

More Information.

No response

@arnoutdekimo arnoutdekimo added the Type: Bug bugs in IDF label Jul 14, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 14, 2023
@github-actions github-actions bot changed the title ESP IDF GPIO mallocs gpio_isr_func in gpio_install_isr_service, which causes crashes in case of CONFIG_SPIRAM_USE_MALLOC=y ESP IDF GPIO mallocs gpio_isr_func in gpio_install_isr_service, which causes crashes in case of CONFIG_SPIRAM_USE_MALLOC=y (IDFGH-10644) Jul 14, 2023
@arnoutdekimo
Copy link
Author

Presumably MALLOC_CAP_INTERNAL should be used for that malloc

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new labels Jul 19, 2023
espressif-bot pushed a commit that referenced this issue Jul 25, 2023
If CONFIG_SPIRAM_USE_MALLOC is enabled, and cache is disabled when GPIO ISR is triggered,
it would lead to Guru Meditation Error due to "Cache disabled but cached memory region accessed".

Closes #11876
espressif-bot pushed a commit that referenced this issue Jul 25, 2023
If CONFIG_SPIRAM_USE_MALLOC is enabled, and cache is disabled when GPIO ISR is triggered,
it would lead to Guru Meditation Error due to "Cache disabled but cached memory region accessed".

Closes #11876
espressif-bot pushed a commit that referenced this issue Aug 3, 2023
If CONFIG_SPIRAM_USE_MALLOC is enabled, and cache is disabled when GPIO ISR is triggered,
it would lead to Guru Meditation Error due to "Cache disabled but cached memory region accessed".

Closes #11876
espressif-bot pushed a commit that referenced this issue Aug 13, 2023
If CONFIG_SPIRAM_USE_MALLOC is enabled, and cache is disabled when GPIO ISR is triggered,
it would lead to Guru Meditation Error due to "Cache disabled but cached memory region accessed".

Closes #11876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants