Does ESP32 erases whole sector while writing a byte to flash
Posted: Fri Jun 29, 2018 5:52 am
by hemant.chaudhari
Hello,
I am using WROOM32 module which is having 4MB of flash connected to ESP32, I am using "spi_flash_write" API in order to write into the flash. I want to know when I write a byte into flash, does it holds the data into RAM and erases the page and after changing that particular byte the page get written to flash?.
Does it happens every time I change the byte in sector?
What will be the scenario when I am writing continuously to flash byte by byte.
Re: Does ESP32 erases whole sector while writing a byte to flash
Posted: Fri Jun 29, 2018 11:43 am
by ESP_Sprite
No, it does not, it maps directly to the flash function of the flash chip. This means that a write is only able to clear a bit, namely make it go from 1 to 0. As an example how it works: If you erase a sector, the bits all go to 1. If you then write, for example, the first byte to 0xF0, the first byte will become that. If you then write the 2nd byte to 0xAA, the 2nd byte will become that. However, if you write the first byte to 0xAA, the actual value that will be in flash for that byte is 0xA0, as the flash cannot reset the bytes that were already set to 0, back to 1. You'd need to erase the entire 4K sector for that.
All in all, writing the page byte by byte should happily work.
Re: Does ESP32 erases whole sector while writing a byte to flash
Posted: Fri Jun 29, 2018 1:34 pm
by ESP_igrr
Note that there are
some flash chips which contain "software erase" feature, and they
do erase one page even if only one byte is written (and therefore allow changing 0 -> 1 without an explicit erase operation). However, at the moment, such flash chips are not used in ESP32 modules produced by Espressif.
Re: Does ESP32 erases whole sector while writing a byte to flash
Posted: Mon Jul 09, 2018 10:24 am
by hemant.chaudhari
ok got it....Thanks
So I can use the esp32 wroom 32 flash for continuous data storage without having concern about read/write cycles