Hi folks, I am using ESP8266 to do some data logging in the External flash provided on the ESP8266 my issue is, The user program is stored in the external flash and if i use all the flash memory to log the data what would happen? will it cause serious trouble?
That should work OK. Normally it will not allow a user to overwrite that area of flash. Check into spiffs, that is the current file system that I believe is about to change.
Go to Tools->Flash size and it will give you the option of how to split the flash memory between code and file system.
I don't know what it does if you try to write more file data than allocated. (I've never used up all the file system flash.) Hopefully it gives some sort of "out of space" error.
ESP8266 flash is partitioned. That is how user flash, OTA updates, SPIFFs, are kept separate.
When using the SPIFFs, the code is informed of the size:
#define maxBlks 7680
#include "FS.h"
After that, reading a file in the filesystem is like this
FileRead = SPIFFS.open("/oui.txt", "r") ;
FileRead.seek(fileByteOffset, SeekSet) ; // Seek to record
while (ok && FileRead.available() > 0) // While not EOF
{
currentCharacter = FileRead.read() ;
SPIFFS Deprecation Warning
https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html#spiffs-deprecation-warning
For any ESP8266 file system, this would be applicable, although it was written for SPIFFS:
https://github.com/pellepl/spiffs/wiki/FAQ
How long will my SPI flash live?
That depends on everything. But, let's construct a simple case where we do not dive into details too much.
Let's say we have a 1MB flash. There is only one file. Each second we open the file, read a number, increment it, and store the file again.
Suppose we divide the flash into 128 bytes pages and 64k blocks. The flash copes with 10000 erases before it fails.
Thus, we will have 1MB / 64k = 16 blocks. Each block has 512 pages, and one file update will consume two pages (metadata + data), meaning we can do 512/2 = 256 file updates before we've used a full block which needs erasing before reuse. Also, spiffs always need two free blocks.
Considering above, after (16-2) * 256 = 3584 file updates the system is full of deleted pages and blocks will need to be erased. Henceforth, after each 256th file update a block must be erased. As we have 16 blocks and have wear leveling, it will take 256 * 16 file updates before same block is erased again. This we can do 10000 times before things fail, so to sum it up we can do 3584 + (256 * 16) * 10000 file updates before the spi flash is worn out, roughly 40960000 times. To play it safe as we haven't considered some extra meta data, we multiply by 0.75 (pretty aggressive) we sum it up to 30,7 million.
Which at one write per second is 355 days.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.