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

AlexESP32
Posts: 65
Joined: Thu Oct 03, 2019 9:41 am

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

Postby AlexESP32 » Thu Jul 22, 2021 6:38 am

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

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Thu Jul 22, 2021 9:09 am

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.

Who is online

Users browsing this forum: No registered users and 172 guests