The ffree function calculates the free space in the Flash File System on the specified drive. If the drive string is empty ("") the default drive specified in the FILE_CONFIG.C configuration file is used. The following values are supported for the drive: | Drive | Description |
|---|
| "F:" | Embedded Flash drive. | | "S:" | SPI Flash drive. | | "M:" | Memory Card drive. | | "R:" | Ram drive. |
Flash devices are organized as a number of fixed-size memory blocks. When erasing a block, Flash devices require that the entire block (not just a portion) is erased. So, to change data in a Flash block, you must first erase the entire block. Multiple files may be stored in a single Flash block. In fact, a Flash block can simultaneously hold valid file data, invalid file data (which has been programmed but not yet erased), and free space. When some, but not all, of the files stored in a single block are erased by the Flash File System, the whole Flash block is not erased because it still contains valid data — only the allocation information of deleted files is destroyed. Programmed data is invalidated but remains present in flash block. When all data programmed into a Flash block is invalidated, the system finally erases it. Memory is managed similarly in a RAM-base File System. The ffree function returns the size of free memory. Invalidated data is considered to be used memory. It is normal, when you have stored two small files and subsequently deleted one of them, to obtain the same return value from ffree as when both of the files were present. The ffree function is in the RL-FlashFS library. The prototype is defined in rtl.h. Note - The amount of free space reported by ffree may be misleading due to the memory management algorithm.
|