ELM - FAT File System Module

# 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 low cost microcontrollers, such as AVR, 8051, PIC, ARM, Z80 and etc..., without any change. Petit FatFs module is also available here.

#### Features

- Windows compatible FAT12/16/32 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 OEM code pages including DBCS.
  - Long file name (LFN) support in OEM code 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 access the FAT volumes.

- 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, Expand File Size
- f_truncate - Truncate File Size
- 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_utime - Change Timestamp
- f_rename - Rename/Move a File or Directory
- f_mkfs - Create a File System on the Drive
- f_forward - Forward file data to the stream directly
- f_chdir - Change current directory
- f_chdrive - Change current drive
- f_gets - Read a string
- f_putc - Write a character
- f_puts - Write a string
- f_printf - Write a formatted string

### Disk I/O Interface

Since the FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write the physical disk and to get current time. The low level disk I/O module is not a part of FatFs module so that it must be provided by user. The sample drivers are also available in the resources.

- 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 module is a free software opened for education, research and development. You can use, modify and/or republish it for personal, non-profit use or commercial products without any restriction under your responsibility.

- FatFs User Forum
- FatFs module application note
- ARM-Projects by Martin THOMAS (examples for LPC2000, AT91SAM and STM32)
- FAT32 Specification by Microsoft (The reference document on FAT file system)
- 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)