Search found 8 matches

by Charger
Fri Dec 11, 2020 2:21 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition

Yes, the nvs_close() returned before all the data were even read from RAM (read for writing to flash ... they had already been read before for calculating the checksum). I didn't try setting CONFIG_SPI_FLASH_VERIFY_WRITE. What I did instead was break up the blob (which was a hangover from a previous...
by Charger
Mon Sep 07, 2020 12:12 am
Forum: ESP-IDF
Topic: [SOLVED] DHCP server clears IP address of a random station when a 10th station joins
Replies: 0
Views: 1610

[SOLVED] DHCP server clears IP address of a random station when a 10th station joins

tcpip_adapter_get_sta_list() returns correct IP address data for the first nine stations. But when a 10th station joins, it turns one of the previous stations into 0.0.0.0. Here is an example: {"5433cb394950":"192.168.5.2"},{"1004e6b4182c":"192.168.5.8"},{"1019fe306938":"192.168.5.3"},{"101370f86fd0...
by Charger
Fri Jun 05, 2020 12:16 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition

Yes, we're using FreeRTOS. But the commit and then changing the variable happen in the same thread, so I thought the nvs_commit() at least would be synchronous and act as a write barrier. However, there is the following comment for spi_flash_write_inner(), which nvs_set_blob() eventually calls: /* W...
by Charger
Thu Jun 04, 2020 8:30 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: Random ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() sometimes?

Thanks, Jakob (and apologies about the spelling before)! You've pinpointed what appears to be a race condition. That bit in the blob corresponds to a struct member which is set immediately after the write helper function returns, i.e. the flow is: ESP_ERROR_CHECK(nvs_set_blob(handle, "info", &dev_co...
by Charger
Thu Jun 04, 2020 12:35 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: Random ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() sometimes?

Hi Jacob! Unfortunately this happens on all three prototypes. I've now rewritten our code so instead of serialising a struct it gets/sets each of the struct's members (as ints and blobs) individually. This will decrease the speed at which we use NVS, but I'm not sure if it will resolve the problem o...
by Charger
Mon Jun 01, 2020 7:31 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: Random ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() sometimes?

Sure! Thank you for offering to take a look. I've attached the bin file as copied from the 64 KiB NVS partition using esptool.
by Charger
Mon Jun 01, 2020 5:23 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

Re: Random ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() sometimes?

The blob is 250 bytes in size ... not huge, but probably bigger than the original key:value intention for NVS. I use it to serialise a struct with all the persistent settings. That's a great idea with the handles. I actually call open/get/close and open/set/commit/close every time. Might try also mo...
by Charger
Mon Jun 01, 2020 12:55 am
Forum: ESP-IDF
Topic: [SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition
Replies: 18
Views: 18868

[SOLVED] ESP_ERR_NVS_NOT_FOUND from nvs_get_blob() due to nvs_commit() race condition

Are there any known instances in which an NVS read will fail even though the NVS seems to contain valid data? Using a 64 KiB NVS partition to store 250 B blobs, the NVS works for a while, but after some seemingly random number of reads/writes/reboots the nvs_get_blob() will return 4354 (ESP_ERR_NVS_...