SerialFlash, eraseAll eraseBlock and remove

Status
Not open for further replies.

dimitre

Well-known member
It would be great to have a way of actually erasing files on SerialFlash without calling eraseAll. Would it be possible?
Wondering if one can find all blocks allocated for a specific file and erase them using eraseBlock function.
Any ideas? Thanks
 
From my understanding this is a limitation on FlashRam itself. Flash Ram requires data to be erased in chunks which could span across multiple files or include only a portion of a file. My personal work around for this was to divide data up into multiple files, and make sure those files are created as "erasable" and use a wrapper class to handle the data in the files. If I need to wipe or replace data in a file, the wrapper class just copies all current data to ram, makes changes needed to the data, erases the file using SerialFlashFile.erase(), and then writes the new data back to the file.
 
SerialFlash has a file.erase() function. It's documented in the readme. Looks like the readme didn't get a heading for this function, so it's not as easy to see as the others when reading. I've updated it just now.

https://github.com/PaulStoffregen/SerialFlash/commit/63aa3a33d61076c08d40668e43e7c8cf2e97fbdd

The file needs to be made with SerialFlash.createErasable(filename, size). Normally the files are packed to the chip's 256 byte page boundaries. This alternate create function aligns the file to erasable sector boundaries (64K or 256K depending on the chip).
 
Status
Not open for further replies.
Back
Top