Filesystem and write durability
Filesystem and write durability
I would like to write a few bits of data to the filesystem fairly frequently. Is there a recommended way to do this while maximizing the flash write durability?
Re: Filesystem and write durability
Every write writes at least 512 bytes to the flash, no matter how many of those are actually modified -- even if you only change a single bit. The best way to avoid wear is to buffer your writes, and only actually write to flash once in a while.
Re: Filesystem and write durability
The internal flash is even worst. The filesystem may write 512 byte blocks, but you actually need to erase an entire sector (16K - 64K on th F series, 2K on the L series).
If you wrote to flash directly, (i.e. not using a filesystem), then you can write individual bytes at a time. Well you erase a block to all 0xff's and then you can flip bits to zero, one byte at a time. Once a bit has been flipped to a zero you need to erase the entire sector to get it back to a a 1.
If you wrote to flash directly, (i.e. not using a filesystem), then you can write individual bytes at a time. Well you erase a block to all 0xff's and then you can flip bits to zero, one byte at a time. Once a bit has been flipped to a zero you need to erase the entire sector to get it back to a a 1.
Re: Filesystem and write durability
If you are writing regularly I would suggest using an SD card as they implement wear levelling which spreads the writing over the whole device instead of re-writing the same sectors. I have seen reports that some SD cards do wear levelling in the background and can be corrupted when you turn the power off without doing an orderly shutdown.
For that reason I suggest using Sandisk SD cards as they appear to just use a replacement sector from the erase pool whenever you do a write. The process is described here:
https://web.archive.org/web/20150326122 ... elv1.0.pdf
For that reason I suggest using Sandisk SD cards as they appear to just use a replacement sector from the erase pool whenever you do a write. The process is described here:
https://web.archive.org/web/20150326122 ... elv1.0.pdf
Re: Filesystem and write durability
[quote="dhylands"]If you wrote to flash directly, (i.e. not using a filesystem), then you can write individual bytes at a time. Well you erase a block to all 0xff's and then you can flip bits to zero, one byte at a time. Once a bit has been flipped to a zero you need to erase the entire sector to get it back to a a 1.[/quote]
It would work for me to flip bits to zero progressively. Is there a way to do that within Micropython? I am using the ESP8266 port but I would be interested in a general answer.
It would work for me to flip bits to zero progressively. Is there a way to do that within Micropython? I am using the ESP8266 port but I would be interested in a general answer.
Re: Filesystem and write durability
I'm not familiar with the esp8266. I know it has an external flash chip and I'm not sure what the underlying technology for it is.
I don't think that there are any modules for directly manipulating the flash.
I don't think that there are any modules for directly manipulating the flash.
Re: Filesystem and write durability
A quick look in the docs reveals the appropriate methods of the esp module:
http://docs.micropython.org/en/latest/e ... hlight=esp
http://docs.micropython.org/en/latest/e ... hlight=esp