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.
Does ESP32 erases whole sector while writing a byte to flash
-
- Posts: 16
- Joined: Wed Jun 13, 2018 11:48 am
-
- Posts: 9759
- Joined: Thu Nov 26, 2015 4:08 am
Re: Does ESP32 erases whole sector while writing a byte to flash
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.
All in all, writing the page byte by byte should happily work.
Re: Does ESP32 erases whole sector while writing a byte to flash
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.
-
- Posts: 16
- Joined: Wed Jun 13, 2018 11:48 am
Re: Does ESP32 erases whole sector while writing a byte to flash
ok got it....Thanks
So I can use the esp32 wroom 32 flash for continuous data storage without having concern about read/write cycles
So I can use the esp32 wroom 32 flash for continuous data storage without having concern about read/write cycles
Who is online
Users browsing this forum: Google [Bot], kaxx1975 and 182 guests