LittleFS writes cause crash sometimes ... #1600
Replies: 2 comments
-
W/o full code there's not much I can do, but off the bat I think there's data corruption somewhere. Nothing in this chip can have a
General Little FS rules are not to call from an IRQ and not to multi-thread any access whatsoever (only 1 core may call any |
Beta Was this translation helpful? Give feedback.
-
Hmm okay ... I just reduced the size of the character buffer from 1024 to 256 bytes, and now it's all working. I guess the failing call was from deeper in the call stack, with less memory remaining, so it was wrapping around the bottom of the stack. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm having a really odd problem today. I wonder if you can tell me some way I'm using LittleFS wrong, or if there's requirements for it that i'm not following.
I have code that writes configuration data to LittleFS, and it works fine when called from one part of my main loop, but causes the MCU to crash/reboot when it's called from another location.
Here's the Settings::put() command & its components ... it's converting a struct to ArduinoJSON and then writing a JSON string to a file. It's all really basic I think. (The string is 78 bytes long.)
I can call Settings::put() from my command line interpreter and it succeeds every time:
But this call from elsewhere in the main loop, responding to a change in the state of a pin, always leads to a crash:
GDB doesn't seem to be able to give me a complete backtrace when this happens, I only get this much:
The thing I can't figure out is that this always crashes when it's called from handlePlayEnd(), but never crashes when it's called from cmd_settings(). I don't see how the two ways of calling it are any different. Are there external side-effects I should be aware of? I tried bracketing the LittleFS calles in noInterrupts()/interrupts(), it made no difference.
Beta Was this translation helpful? Give feedback.
All reactions