power down during erase

maxzen
Posts: 15
Joined: Fri Jun 08, 2018 11:56 am

power down during erase

Postby maxzen » Wed Jun 20, 2018 12:49 pm

we are using a esp32-wrover, our device can be disconnected at any time, what happens if the power is lost during erase?

As an example, some code is writing to nvs and, while the system is erasing a block to make room, the user disconnect the device from the power.

For sure some data will be lost, but is this the only effect or the flash (and the device) will be damaged?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: power down during erase

Postby ESP_Angus » Thu Jun 21, 2018 5:31 am

The flash won't be damaged, but the contents of the sector being erased will be undefined (probably partially erased). The same goes for power failure during a write operation (although usually in this case some of the first bytes in the sequence will be written correctly, and the bytes after that will still be unwritten - usually 0xFF).

The NVS library is specifically designed to be failsafe under these circumstances, ie either the old or the new version of the NVS contents will be returned.

Who is online

Users browsing this forum: No registered users and 77 guests