Post History
There is no provision in FatFS or the fat32 filesystem in general regarding hot-unplug, so this behaviour depends wholly on the implementation layer for your hardware. As an example, in my use cas...
Answer
#2: Post edited
- There is no provision in FatFS or the fat32 filesystem in general regarding hot-unplug, so this behaviour depends wholly on the implementation layer for your hardware.
As an example, in my use case I have tested the behaviour of my system when I remove the memory card without calling f_close() on open files. I found that there is a 0-sized file that was created when I called f_open(), and when I used filesystem repair tool in Disks on Linux, it created "orphaned" files it found - the data in them was usable up to the removal of the card. You will need to implement card detect interrupt that would flush all filesystem IO and close all opened files if you want to handle it robustly.
- There is no provision in FatFS or the fat32 filesystem in general regarding hot-unplug, so this behaviour depends wholly on the implementation layer for your hardware.
- As an example, in my use case I have tested the behaviour of my system when I remove the memory card without calling f_close() on open files. I found that there is a 0-sized file that was created when I called f_open(), and when I used filesystem repair tool in Disks on Linux, it created "orphaned" files it found - the data in them was usable up to the removal of the card. If your card socket supports it (ie the card detect triggers before pin contact is lost), you will need to implement card detect interrupt that would flush all filesystem IO and close all opened files if you want to handle it robustly. Alternatively, you will need to buffer data in RAM and write it in f_open -> f_write -> f_sync -> f_close sequence every time. Depending on implementation, it can take a while to do those (a hundred ms is not uncommon).
#1: Initial revision
There is no provision in FatFS or the fat32 filesystem in general regarding hot-unplug, so this behaviour depends wholly on the implementation layer for your hardware. As an example, in my use case I have tested the behaviour of my system when I remove the memory card without calling f_close() on open files. I found that there is a 0-sized file that was created when I called f_open(), and when I used filesystem repair tool in Disks on Linux, it created "orphaned" files it found - the data in them was usable up to the removal of the card. You will need to implement card detect interrupt that would flush all filesystem IO and close all opened files if you want to handle it robustly.