-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32 Preferences.putString() occasionally hangs after begin()" #11215
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
Comments
Code doesn't run in a void. If there is something else actively using the flash, Preferences must wait to access the device. Provide code that can be compiled that demonstrates the error. Also, preferences writes in ~4k byte blocks. It isn't really saving you much to break the json apart and make multiple writes (as long as the json is under 4k). |
hello @lbernstone this is the json that i get from server httpget !
declaration functions :
setup Function :
TaskSetupOTA task :
|
We do not need the full code. If you create a sketch small enough to reproduce (no JSON or other external things) we can work on it. With everything else you have going on, it is not clear whether the issue is on our end or yours. We need actually a minimal example, like writing same strings or randomly generated ones and that to be the only thing going on. |
OK understood , let me write the sketch for you guys |
Board
esp32 dev module
Device Description
NA
Hardware Configuration
NA
Version
v2.0.16
IDE Name
VSCode
Operating System
Windows 10
Flash frequency
80 Mhz setCpuFrequencyMhz(80);
PSRAM enabled
yes
Upload speed
115200
Description
Issue: preferences.putString() occasionally hangs
Hi, I'm experiencing an intermittent issue with Preferences.putString() on ESP32.
In my code, I'm updating several configuration values using Preferences. The preferences.begin() call always works fine — no issues there. But sometimes, the execution gets stuck at the beginning of the saving process, right after printing "Let Save new Configuration ...". It seems like the first putString() call is hanging or blocking, and the device doesn't proceed to the next lines (e.g., I don't see "T1", "T2", etc.).
Here's the relevant code:
Sometimes everything works perfectly and I see all the T1, T2, ... T9 messages in the Serial Monitor. Other times, it hangs after "Let Save new Configuration ...", and nothing further happens.
Any ideas on what could be causing putString() to get stuck like this? Could this be a flash memory or corruption issue?
Thanks in advance for any help or suggestions!
Sketch
Debug Message
Other Steps to Reproduce
sometimes passes sometimes hangs ...
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: