LittleFS, WiFi and GPxMatrix conflicts on ESP32

I use ESP32 for a project that uses WiFi, WebServer, WiFiManger, LittleFS and GPxMatrix libraries.

Uses two json files , one to store WiFi related details and another to store data received through WebServer HTML page.

On uploading the code, WiFiManager firesup wm.autoConnet() and received the WiFI credentials . It is stored in one file using LittleFS.

It then gathers the data from the served HTML page and stores in another file. After which matrix board is started to display this data.
Everything works nicely as expected upto this point.

However when I try to change the displayed info on the matrix board, by sending fresh data, It receives the data but on attempt to save it using the LittleFS, ESp32 fire "Core 1 panic'ed (Cache disabled but cached memory region accessed)."

This happens when File file = LittleFS.open(filename, "w", true) ;

At this point matrix display is working.

Note: after uploading the code LttleFS worked since matrix was not working. During second call, matrix is working and LittleFS failed.

I think this is due to GPXmatrix disabling cache in some manner and LittleFS needs cache enabled to open file.

Hope anyone as encountered similar issue and solved it. If this cannot be solved I may have to move to Raspberry pi w and create everything from ground up.

Is there any way to go around this issue ? Thanks to all. ( I am not sure if I had posted in the correct subcategory).

It's kinda narrow as the issue might be more general. I think it would be better in the Programming Question category (you can move it there by clicking the little pencil next to the title of your first post and changing the category)


For your question we would need to see the source code (use code tags).


Did you try to remove the code for the GPXmatrix and just print on the serial monitor?

Yes I get the data on Serial Monitor. I have put Serial.print under / above every relevant code to see exactly which code is firing error. It fires exactly when the above code (opening the file) Second time when matrix is working. I had checked disabling matrix and the code works fine.

OK - so your guess that it might be the culprit is very likely.

what's the link to the GPxMatrix library - is it that one ?

Yes. that is the one.

You have not yet provided basic info like ALL source code, any error logs, hand drawn circuit, datasheets may be required at some point.

As explained in my post, code works (LittleFS, save, read ) till I activate matrix display (HUB75). After it starts displaying, LittleFS raises the said error "Cache disabled.....") .

That means LittleFS is not able to access cache.

For you info,
In the setup
WiFi.Mode(WIFI_STA) is set
Then LittleFS.begin() is set.
Then wm.autoConnect() is used to connect to WiFi and credentials obtained.
Then this info is saved to a json file.
Then sever sends an html page to get user inputs.
This info is saved to json file and displayed on matrix. (matrix->begin() is done only at this point , not in setup.
If I want to change the user input again , it is received but cannot save to json file , because cache gets disabled when matrix got initiated. Hub75 14 pins to work. So I have to use both ADC1 and ADC2 pins too. ADC2 is used by WiFi too. So there is are issues regarding WiFi etc which was taken care off.

I am stuck with cache being disabled. Unless it gets enabled , LittleFS cannot function.
The question is why is GPxMatrix disabling cache ?
Can it be enabled again in midoperation?
is there any method using CONFIG_ (sdkconfig) to enable cache or prevent it being disabled.

The funny matter is the whole setup works nicely when I used OLED 4 pin display without any glitch. Problems raise only when the display part is moved to matrix instead of OLED. That is GpxMatrix.h vs Adafruit_SH110X.h (both using Adafruit_GFX.h ).

I hope you understand the logic and the issue.

I even tried using IRAM_ATTR for both LittleFS and matrix ( I must say I am yet to grasp full functionality of this) , but it is of no use. It still raises the same error.

The file that was already in the system exist and it is read too. After raising the cache disabled error, ESP32 reboots and the existing file is read and displayed on the matrix ( matrix is loaded only after LittleFS is initiated and file is read. ).

In a nutshell, LittleFS stops working once matrix is initiated. If I don't initiate matrix , everything else works fine and output could be sent to Serial Monitor.

Ok, from some of what you said it is clear you are in over your head and need to do a lot of research. Good luck.

I don’t know this library but if I had this issue I would go read the source code and see what it’s doing and if there is a end() function canceling whatever begin() did for example …

You could also write a very minimal example using littleFS and the library demonstrating the issue and post it here or raise an issue in GitHub

There is no end function in GPxMatrix.h
if it was there, I would not had to post a question here.

I didn't find any facility to re- cache in ESP32 sdkconfig too, or atleast that to my understanding.

anyways thanks.

that was easy. thanks for the good luck

Did you find what possibly disables the cache ?

As discussed, write a smaller program demonstrating the issue. May be it's something else in your code (you mentioned dealing with ADC 1 and 2 and WiFi) that creates the issue ?

Certain things is Boon in disguise. I had left my computer running with Arduino IDE open. and for unknown reason, it hanged. After starting it again by removing power, the whole sketch was blank. All the code got erased. I had re-write 5 pages of code , re-arranging some of the process . I also changed the IDE->Tools-> Arduino runs on and Events run on to core1 and core 0 respectively. Flash mode is changed to DIO.

Now it works as required, and without core panic error . There are a couple of minor glitches that could be solved and acceptable tradeoffs.

I think running the program in the same core (default in the IDE) could be the issue. I have not seen this mentioned in any of the documentation of libraries. Though Espressif had documented Errors, they had not offered any solutions (atleast to my knowledge).

Weird - thanks for coming back for sharing what you found out

You are welcome.

There is some strange behavior, that I am still trying to understand. After switching on matrix , if I try to open file (LittleFS), it produces core panic error and reboots. But if I again do the same, it works without any glitch. This is a consistent behavior. seems funny.

In any case, ESP32 makers should really look into this conflict issue with cache disabling. Some of these issues might be a reason why ESP32 , inspite of having very good features could not step into professional industry.

I am also looking into raspberry pi pico W to see if it could be used instead of ESP32.

I finally gave up on GpxMatrix library and choose adafruit_protomaster. This one doesn't interfere with the memory as much as GPxmatrix does. I didn't have time to go deep into that library to look into why it is disabling cache , which in turn prevents LittleFS from working.

Thx for sharing your solution

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.