ESP32 crashes when using nvs_get_*() in the Preferences library

Hi all,
I am completely stuck. I have a project in which I use preferences along with SPIFFS indirectly because of wifimanager. I haven't been able to confirm it from online documentation but I believe both libraries can be used simultaneously?

The problem I face occurs when I read existing data from a preferences namespace.
for example,

preferences.getUChar("myvar", 0);

would crash if I ever used

preferences.putUChar("myvar", 123);

before.

More specifically, it crashes in getUchar() at this specific line:

esp_err_t err = nvs_set_u8(_handle, key, value);

and any preference type causes that issue, its not just with unsigned chars. I wonder what could be causing this issue. I have tried resetting the NVS to see if it was just corrupted but no. I suspect it may be due to SPIFFS used by wifimanager?

I also tried disabling global interrupts while operating with preferences but no, I get the watchdog to kick when I do this somehow?

I don't use EEPROM, so that's that. But I litterally have no clue why this crash occurs... I dont want to change everything for SPIFFS, especially if it means storing uint8_t flags in a text file...

Any idea what could cause this issue? Thanks!

JSCB, it would be helpful to see how you used those statements in context. Could you post a minimal sketch please?

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