Page 1 of 1

Voltage Drop in same time of NVS write process. Corrupted Data?

Posted: Thu Jul 22, 2021 6:38 am
by AlexESP32
Hello All,

How is the behavior when there is a voltage drop in same time of NVS write process? Is there any protection mechanism which recognize that voltage drop and will stop this write process or would it be possible to get here some corrupted data?

Thank you.

Greetings

Re: Voltage Drop in same time of NVS write process. Corrupted Data?

Posted: Thu Jul 22, 2021 9:09 am
by ESP_Sprite
NVS is written in a way where it doesn't 'overwrite' data. The long and short of it is that if you update data, it will write it to a new entry, and only when it's done, it'll add a checksum to indicate it's valid. Any power loss that leads to corruption will make the checksum not match and the NVS read functions return the old value. In that sense it's atomic: on the user side a write either succeeds 100% or never happened at all; there's nothing in between.