Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

Hello,

My code crashes when I’m trying to open a file from SPIFFS. The function where SPIFFS.open is called was dispatched on thread 0 using xTaskCreatePinnedToCore.

Function:

void saveMqttConfigFile(String payload)
{
  File configFile = SPIFFS.open("/config.json", "w");

  if (!configFile) {
    Serial.println("Failed to open mqtt config file for writing");
    return;
  }
//....
}

Full exception below:

19:21:54.764 > Guru Meditation Error: Core  1 panic'ed (Cache disabled but cached memory region accessed)
19:21:54.768 > Core 1 register dump:
19:21:54.769 > PC      : 0x4017e868  PS      : 0x00060034  A0      : 0x80081c38  A1      : 0x3ffbe780  
19:21:54.773 > A2      : 0x3ffc3208  A3      : 0x00000001  A4      : 0x563d3e47  A5      : 0x00001000  
19:21:54.777 > A6      : 0x3ffc3a8c  A7      : 0xffffefff  A8      : 0x80081b25  A9      : 0x00000000  
19:21:54.781 > A10     : 0x3ffb8388  A11     : 0x3ffbe78c  A12     : 0x3ffba264  A13     : 0x0000abab  
19:21:54.783 > A14     : 0x3ffc5748  A15     : 0x3ffba264  SAR     : 0x00000003  EXCCAUSE: 0x00000007  
19:21:54.787 > EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
19:21:54.791 > Core 1 was running in ISR context:
19:21:54.792 > EPC1    : 0x4008bb5d  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4017e868
19:21:54.796 > 
19:21:54.796 > Backtrace: 0x4017e868:0x3ffbe780 0x40081c35:0x3ffbe7b0 0x40088255:0x3ffbe7d0 0x4008bb5a:0x3ffba190 0x40086673:0x3ffba1b0 0x4008d9f5:0x3ffba1d0
19:21:54.875 >   #0  0x4017e868:0x3ffbe780 in circular_queue<unsigned int, void>::push(unsigned int&&) at /home/radu/.platformio/lib/EspSoftwareSerial_ID168/src/circular_queue/circular_queue.h:269
19:21:54.875 >   #1  0x40081c35:0x3ffbe7b0 in __onPinInterrupt at /home/radu/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-gpio.c:278
19:21:54.875 >   #2  0x40088255:0x3ffbe7d0 in _xt_lowint1 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S:1154
19:21:54.875 >   #3  0x4008bb5a:0x3ffba190 in spi_flash_op_block_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/spi_flash/cache_utils.c:81
19:21:54.875 >   #4  0x40086673:0x3ffba1b0 in ipc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/ipc.c:62
19:21:54.875 >   #5  0x4008d9f5:0x3ffba1d0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
19:21:54.875 > 
19:21:54.875 > Rebooting...

What I have to do to solve this issue?

Thank you.

Though the error seems like when the EspSoftwareSerial executes an ISR on core 1. Usually the error Cache disabled but cached memory region accessed means that an ISR has executed a function which has not been put in IRAM (see Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed) ESP32 ARDUINO IDE · Issue #855 · espressif/arduino-esp32 · GitHub).

However there is the IRAM_ATTR in the push() function of the circular queue used by the library

Do you use the EspSoftSerial library? Can you give a platformio.ini and code which reproduces the problem in a minimal way?

1 Like

Hi maxgerhardt.

Thank you for your answer.

Yes, I’m using EspSoftwareSerial.

platformio.ini

[env:esp32-gateway]
platform = espressif32
board = esp32-gateway-rev-f
build_flags = 
  -DMQTT_MAX_PACKET_SIZE=8192 
  -DBOARD_HAS_PSRAM
  -mfix-esp32-psram-cache-issue
framework = arduino
monitor_speed = 256000
monitor_filters = time, log2file, esp32_exception_decoder, default
; monitor_port = COM[6]
lib_deps =
  RTC
  ArduinoJson
  PubSubClient
  EspSoftwareSerial

I wil try to create a code that reporudces this error in a minimal way. This function is part from a big project but I will try to give you some sketch.

Where I have to add IRAM_ATTR attribute? to void saveMqttConfigFile or to function that was dispatched to thread 0?

functions order:

  1. main.cpp dispatch from thread 1 function networkAuthDispatch() which runs networkAuthCode on thread 0
  2. function networkAuthCode send an http request to internal api
  3. if the http request has code 200, I’m calling saveMqttConfigFile
    functions from 2 and 3 runs on thread 0.

Thanks

I should need none if it isn’t called within an ISR. I don’t understand how calling a SPIFFS function can trigger such an error. Do you write to the software serial in this function by any chance?

Yes, I’m writing and reading to the serial with EspSoftwareSerial.

Oh, that’s interesting! I got exactly the same issue and wondering why using SPIFFS in combination with softwareserial. I created an issue on Github already including some code to reproduce the error.

Maybe someone can help with that? Thanks a lot!

Any progress on this? I’m getting the same crash, but I’m not using SPIFFS. I am using ESP SoftwareSerial, Wifi and Bluetooth however. My flash partition does include a SPIFFS section, and OTA is enabled.
I confirmed I do have the IRAM_ADDR prefix on the push routine, same code as was pasted earlier.

Problem is:

He must create a file in main project folder C:\Users\Computer\Documents\PlatformIO\Projects\ProjectTest\config.json

i think thats solve a problem…