NVS crashing ESP32 after used a few times
Posted: Thu Feb 02, 2017 8:45 pm
Hi all,
I managed to save complex structs into NVS using key values. My code is working ok so far, the problem is using the NVS in write mode several times seems to crash entirely the ESP32 and I need to reboot it. I save all kind of structs with a well defined size of no more of 512bytes each. This is a typical code:
First code was using a delay of 10ms between setting the blob and committing. That has been increased up to 500ms in different attempts of finding stability. No luck so far. Above 30ms seemed to be stable but after trying several times it crashes
I am currently using IDF1.0, so not sure if the NVS has been reviewed since then.
Many thanks
I managed to save complex structs into NVS using key values. My code is working ok so far, the problem is using the NVS in write mode several times seems to crash entirely the ESP32 and I need to reboot it. I save all kind of structs with a well defined size of no more of 512bytes each. This is a typical code:
Code: Select all
/*
* Save any kind of structure into NVS by a Module/Key
* Module Handler must have a valid value.
*/
esp_err_t ConfigurationHandler::saveDataToModule(nvs_handle *moduleHandler, String key, void* data, size_t size)
{
Serial.printf("\r\nSaving data with key: '%s'", key.c_str());
esp_err_t opResult = nvs_set_blob(*moduleHandler, key.c_str(), data, size);
delay(500);
opResult = nvs_commit(*moduleHandler);
delay(500);
if (opResult == ESP_OK)
Serial.println("\r\nData saved");
else
Serial.println("\r\nData could not be saved");
return opResult;
}
I am currently using IDF1.0, so not sure if the NVS has been reviewed since then.
Many thanks