Actually there shouldn't be a race condition like this.
Code: Select all
nvs_set_blob()
Code: Select all
nvs_set_blob()
Code: Select all
/* Wrapper around esp_rom_spiflash_write() that verifies data as written if CONFIG_SPI_FLASH_VERIFY_WRITE is set.
If CONFIG_SPI_FLASH_VERIFY_WRITE is not set, this is esp_rom_spiflash_write().
*/
Code: Select all
int storage_write(uint8_t * tosave, size_t save_size){
nvs_handle_t NvsHandle;
const char * save_key = "AGT";
console_printf("[I] storage.c storage_write: Saving \"%s\"\n", save_key);
esp_err_t err = nvs_open(STORAGE_NAMESPACE, NVS_READWRITE, &NvsHandle);
if (err != ESP_OK) {
console_printf("[E] storage.c storage_write: Error opening: (%s)\n", esp_err_to_name(err));
nvs_close(NvsHandle);
return err;
}
err = nvs_set_blob(NvsHandle, save_key, tosave, save_size);
if (err != ESP_OK) {
console_printf("[E] storage.c storage_write: Error writing: %s\n", esp_err_to_name(err));
nvs_close(NvsHandle);
return err;
}
err = nvs_commit(NvsHandle);
if (err != ESP_OK) {
console_printf("[E] storage.c storage_write: Error commit: %s\n", esp_err_to_name(err));
nvs_close(NvsHandle);
return err;
}
//vTaskDelay(10000/ portTICK_PERIOD_MS); // for big blobs, this is necesary..
nvs_close(NvsHandle);
return 0;
}
Users browsing this forum: No registered users and 410 guests