Petit FatFs Module Application Note


Basic Considerations

The FatFs module is assuming following conditions on portability.

Memory Usage (R0.03)

AVRx86
Compilergcc(WinAVR)VC6
_WORD_ACCESS11
Code (default)20201589
Code (!_USE_READ)-428-236
Code (_USE_DIR)+564+415
Code (_USE_LSEEK)+490+228
Code (_USE_WRITE)+516+323
RAM (bss)24
RAM (work)4244

_FS_FAT16 is 1. _FS_FAT12, _FS_FAT32 and _USE_LCC are 0. This is the size of the Petit FatFs module itself. In addition to this, a low level disk I/O module will be required for a complete function. The size of MMC/SDC module on AVR becomes approximate 620 bytes without write function and 840 bytes with write function.

Module Size Reduction

Follwing table shows which function is removed by configuration options for the module size reduction.

Function_USE_READ_USE_DIR_USE_LSEEK_USE_WRITE
0000
pf_mount
pf_open
pf_readx
pf_lseekx
pf_opendirx
pf_readdirx
pf_writex

Performance effective file access

For good performance on reading a file on the small embedded system, application programmer should consider what process is done in the file system module.

The Petit FatFs reads the disk sectors without a sector buffer. This means the file system reads a part of the sector contains the required data every reference point even if they are in the same sector. However the generic storage device are not byte addressable so that the disk I/O layer will read the entire sector and pick up the data bytes from the read data steram.

When read 512 byte data from a file at a time, the data sector will be read only a time. When read that data in byte-by-byte, the data sector will be read 512 times. Therefore the byte-by-byte read request will drastically decrease the read performance. To avoid this stupid read controls, the file data should be read in long block as possible. Sector alignment access is not impotant on the Petit FatFs.

The tiny microcontrollers targeted by Petit FatFs has a limited size of RAM. It may not able to allocate a certain size of read buffer and most type of text processing will require byte-by-byte read operation. The Petit FatFs supports data forwarding feature for such purpose.

About FatFs License

Petit FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the license document that included in the source files.

/*----------------------------------------------------------------------------/
/  Petit FatFs - FAT file system module  R0.03                  (C)ChaN, 2014
/-----------------------------------------------------------------------------/
/ Petit FatFs module is a generic FAT file system module for small embedded
/ systems. This is a free software that opened for education, research and
/ commercial developments under license policy of following trems.
/
/  Copyright (C) 2014, ChaN, all right reserved.
/
/ * The Petit FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
/ * Redistributions of source code must retain the above copyright notice.
/
/-----------------------------------------------------------------------------/

Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about Petit FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course Petit FatFs is compatible with the projects under GNU GPL. When redistribute the Petit FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.

Return