Petit FatFs Module Application Note

Basic Considerations

The FatFs module assumes following conditions on portability.

Memory Usage (R0.03a)

AVRPIC24CM0
CompilergccC30gcc
text (default)194819621114
text (!PF_USE_READ)-356-288-196
text (PF_USE_DIR)+552+528+370
text (PF_USE_LSEEK)+474+432+172
text (PF_USE_WRITE)+440+453+276
bss224
Work424244

Other options are set as: PF_FS_FAT16 = 1, PF_FS_FAT12 = 0, PF_FS_FAT32 = 0 and PF_USE_LCC = 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. For instance, 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.

FunctionPF_USE_READPF_USE_DIRPF_USE_LSEEKPF_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.03a
/-----------------------------------------------------------------------------/
/
/ Copyright (C) 2019, ChaN, all right reserved.
/
/ Petit FatFs module is an open source software. Redistribution and use of
/ Petit FatFs in source and binary forms, with or without modification, are
/ permitted provided that the following condition is met:
/
/ 1. Redistributions of source code must retain the above copyright notice,
/    this condition and the following disclaimer.
/
/ This software is provided by the copyright holder and contributors "AS IS"
/ and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/-----------------------------------------------------------------------------/
...

Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, does not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses including GNU GPL. When you redistribute the FatFs source code with any changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license.

Return