pellepl / spiffs

Wear-leveled SPI flash file system for embedded devices
MIT License
1.48k stars 403 forks source link

spiffs_Overflowed_Problem #219

Open baskarrajan opened 5 years ago

baskarrajan commented 5 years ago

Hi, I created 8MB flash files system for mounting spiffs. I used full 7MB memory for one file for write,read and then deleted the file. After deleted the file , I trying to write with 6MB with new file and it's giving error "errno -10004" after some amount of data written. Is it not possible to reuse the deleted file system area for another file. why? Why erase block function not working in spiffs to create a new file?

cfr-mir commented 5 years ago

Hi baskarrajan, I have experienced the same problem. I have tracked down the problem. SPIFFS_GC can not be used while you have a file open for write. Unfortunatly spiffs_write actually calls spiffs_check_gc, which calls spiffs_gc.

The problem is that spiffs_write assumes that fs->work contains an index page, but spiffs_gc actually overwrites fs->work with a list of candidates for garbage collection.

I wonder if this works if you write more that one file simultaneously.

WORK AROUND:

Call SPIFFS_gc manually after deleting the old file and before opening a new file for write.

Best Regards Carsten