# FatFs - Generic FAT File System Module

FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k and etc... Petit FatFs module is also available here↗ for tiny microcontrollers.

#### Features

- Windows compatible FAT file system.
- Platform independent. Easy to port.
- Very small footprint for code and work area.
- Various configuration options:
  - Multiple volumes (physical drives and partitions).
  - Multiple ANSI/OEM code pages including DBCS.
  - Long file name support in ANSI/OEM or Unicode.
  - RTOS support.
  - Multiple sector size support.
  - Read-only, minimized API, I/O buffer and etc...

### Application Interface

FatFs module provides following functions to the applications. In other words, this list describes what FatFs can do to access the FAT volumes.

- f_mount - Register/Unregister a work area
- f_open - Open/Create a file
- f_close - Close an open file
- f_read - Read file
- f_write - Write file
- f_lseek - Move read/write pointer, Expand file size
- f_truncate - Truncate file size
- f_sync - Flush cached data
- f_forward - Forward file data to the stream
- f_stat - Check existance of a file or sub-directory
- f_opendir - Open a directory
- f_closedir - Close an open directory
- f_readdir - Read a directory item
- f_mkdir - Create a sub-directory
- f_unlink - Remove a file or sub-directory
- f_chmod - Change attribute
- f_utime - Change timestamp
- f_rename - Rename/Move a file or sub-directory
- f_chdir - Change current directory
- f_chdrive - Change current drive
- f_getcwd - Retrieve the current directory
- f_getfree - Get free space on the volume
- f_getlabel - Get volume label
- f_setlabel - Set volume label
- f_mkfs - Create a file system on the drive
- f_fdisk - Divide a physical drive
- f_gets - Read a string
- f_putc - Write a character
- f_puts - Write a string
- f_printf - Write a formatted string
- f_tell - Get current read/write pointer
- f_eof - Test for end-of-file on a file
- f_size - Get size of a file
- f_error - Test for an error on a file

### Disk I/O Interface

Since the FatFs module is completely separated from disk I/O layer, it requires following functions to access the storage device. When O/S related feature is enabled, it will require process/memory functions in addition. However the low level disk I/O module is not a part of FatFs module, so that it must be provided by user. The sample implementations are also available in the downloads.

- disk_status - Get device status
- disk_initialize - Initialize device
- disk_read - Read sector(s)
- disk_write - Write sector(s)
- disk_ioctl - Control device dependent features
- get_fattime - Get current time

### Resources

The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.

- FatFs User Forum↗
- Read first: FatFs module application note
- Latest Information: http://elm-chan.org/fsw/ff/00index_e.html↗
- Nemuisan's Blog↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)
- ARM-Projects by Martin THOMAS↗ (Examples for LPC2000, AT91SAM and STM32)
- FAT32 Specification by Microsoft↗ (The reference document on FAT file system)
- The basics of FAT file system [ja]↗
- How to Use MMC/SDC↗
- Benchmark 1 (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)
- Benchmark 2 (LPC2368/72MHz with MMC via MCI)
- Demo movie of an application (this project is in ffsample.zip/lpc23xx)

Return