# FAT File System Module

FatFs module is an experimental project to implement a FAT file system to small embdded systems. The FatFs module is written in compliance with ANSI C, therefore it is independent of hardware architecture. It can be incorporated into most 8-bit microcontrollers, such as 8051, PIC, AVR, H8, Z80 and etc..., without any change. I created two modules in different configurations in consideration of various use.

#### Features of FatFs Module

1. Separated buffer for FAT structure and each file, suitable for fast multiple file accsess.
2. Supports multiple drives/partitions.
3. Supports FAT12, FAT16(+FAT64) and FAT32. (FAT64: FAT16 in 64KB/cluster)
4. Supports 8.3 format file name and NT lower case flag. (LFN is not supported)
5. Supports two partitioning rules: FDISK and Super-floppy.
6. Optimized for 8/16-bit microcontrollers.

#### Features of Tiny-FatFs Module (different to FatFs)

1. Very low memory consumption, suitable for small memory system. (RAM:1KB)
2. Supports only single drive.

### Application Interface

FatFs/Tiny-FatFs module provides following functions.

- f_mount - Register/Unregister a Work Area
- f_open - Open/Create a File
- f_close - Close a File
- f_read - Read File
- f_write - Write File
- f_lseek - Move R/W Pointer
- f_sync - Flush Cached Data
- f_opendir - Open a Directory
- f_readdir - Read a Directory Item
- f_getfree - Get Free Clusters
- f_stat - Get File Status
- f_mkdir - Create a Directory
- f_unlink - Remove a File or Directory
- f_chmod - Change Attribute
- f_rename - Rename/Move a File or Directory
- f_mkfs - Create a File System on the Drive

### Disk I/O Interface

Since the FatFs/Tiny-FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write physical disk and to get current time. These functions must be provided by user. The low level disk I/O module that have this interace must be provided by user. The sample projects are also available.

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

### Resources

The FatFs/Tiny-FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or profit use without any restriction under your responsibility.

- FatFs home page
- FatFs module application note
- Benchmark (Test Board: ATmega64/9.2MHz with MMC/HDD/CFC)
- FAT32 Specification (Microsoft)
- How to Use MMC/SDC