NetBurner 3.1
EFFS-FAT File System Operation

EFFS-FAT File System Operation

Typical file system operation will involve mounting a drive, opening and closing files, and reading and writing files. The following is a list of the most common function calls used to perform these operations. For a complete list of functions refer to the "HCC Embedded Flash File System Implementation Guide" included with your development kit documentation as a pdf file.

Common EFFS FAT Function Calls

Create/delete working directory for current task priority:
int f_enterFS(void)
void f_releaseFS(void)

Mount/dismount a flash card:
int f_mountfat(MMC_DRV_NUM, mmc_initfunc, F_MMC_DRIVE0)
int f_delvolume(int drivenum)

Open/Close a file
‘F_FILE *f_open(const char *filename, const char *mode)’
‘int f_close(F_FILE *filehandle)

Read, write, and related functions:
int f_getfreespace(int drivenum, F_SPACE *pspace)
long f_write(const void *buf, long size,long size_st, F_FILE *filehandle)
long f_read( void *buf, long size,long size_st, F_FILE *filehandle)
long f_seek(F_FILE *filehandle,long offset, long whence)
int f_eof(F_FILE *filehandle)
int f_rewind(F_FILE *filehandle)
int f_delete(const char *filename)

Directory functions:
int f_findfirst(const char *filename, F_FIND *find)
int f_findnext(F_FIND *find)
int f_chdir(const char *dirname)
int f_mkdir(const char *dirname)

File time functions
int f_settimedate(const char *filename, unsigned short ctime, unsigned short cdate)
int f_gettimedate(const char *filename, unsigned short *pctime, unsigned short *pcdate)

File Time and Date Stamps

The EFFS supports file time and date stamps. There are a number of ways to obtain the current world time for an embedded system, including a Network Time Server (NTP), Real-time clock (RTC), and setting it manually. For simplicity the first two examples concentrate on file system calls. The third example includes methods to set the time and date through all the aforementioned methods. If no time or date is set, the file time stamp will be January 1, 1980.

File System Utils

All of the NetBurner EFFS examples include a helpful utility file called FileSystemUtils.cpp. This file provides an easy use interface for initializing, getting status, testing, reading and writing to a CF or SD/MMC card. To select between the types of cards, edit the header file cardtype.h. This file also demonstrates many of the commonly used EFFS function calls. These utility files are located in <nburn_install>\examples\_common\EFFS\FAT or <nburn_install>\examples\_common\EFFS\STD, depending on if you want to use an SD card (FAT), or the on chip file system (STD). The examples for EFFS that take advantage of these utility files can be found in <nburn_install>\examples\EFFS\FAT or <nburn_install>\examples\EFFS\STD, again, depending on which file system you wish to use.

EFFS FAT Example Programs

The following is a short reference for the different example applications that utlize EFFS-FAT, and what their primary function is.

Standard FAT EFFS Usage

FAT Basic - This program shows the basic file system operation for SD/MMC cards.
FAT AppUpdate - This program shows how to update a NetBurner application in onboard flash memory from an external SD flash card.
FAT FTP - This program demonstrates the file system and the use of FTP operations for SD/MMC flash cards.
FAT HTTP - This program sets up HTTP access to the FAT file system for SD/MMC flash cards, and shows how web pages can be served from the flash card, and override compiled in versions.
FAT HTML Variables - This program sets up HTTP access to the FAT file system for SD/MMC flash cards, and provides some functionality for dynamic web content. It also shows how web pages can be served from the flash card, and override compiled in versions.
FAT Multi Task - This program demonstrates basic file system operations for SD/MMC flash cards for multiple tasks.
FAT File Sys Speed Test - This example is used to test the speed of the EFFS FAT file system for operations such as file creation and data storage speed.
FAT RAM - This program illustrates basic file system operations for RAM drives.

EFFS FAT With NetBurner's Security Library

SSL HTTPS Dual Cert - This example illustrates how to have both a permanent compiled-in certificate and key, as well as one that can be loaded from an SD/MMD flash card using the EFFS FAT file system for a web server.
SSL POP3 Mail - This example demonstrates how to implement retrieving email from a server that requires SSL, and then saves it to an SD/MMD flash card using the EFFS FAT file system.
Send Mail w/ Attachment - This example demonstrates how to attach files from the EFFS FAT file system to an email and send it securely using SSL/TLS encryption.

Project Settings

To create a project that uses the EFFS-FAT file system, you will need to complete a few extra steps in addition to your normal project setup.
For NBEclipse users:

  • Add the EFFS-FAT library to the linker path:
    <nburn_install>/platform/<platform>/original/lib/libFatFFile.a
  • Import the source files found here into your project:
    <nburn_install>examples\_common\EFFS\FAT

For projects that use the command line tools:

  • Add the following lines to your makefile:
    XTRALIB = c:/platform/SB72EX/original/lib/libFatFFile.a
    include c:/examples/_common/EFFS/FAT/common.mak

Long File Names

The EFFS supports the 8.3 format by default, and optionally supports long file names. The long filename is optional because of the increase in system resources required to do long filenames. In particular the stack sizes of applications which call the file system must be increased and the amount of checking required is increased. The maximum long filename space required by the standard is 260 bytes. As a consequence each time a long filename is processed large areas of memory must be available.

To switch from the 8.3 format to long file names:

  • Edit \nburn\include\constants.h and increase the user task stack size to a minimum of 8096.
    #define USER_TASK_STK_SIZE (8096)
  • Run the batch file: \nburn\pcbin\longfilenames.bat. This will switch the EFFS library to the long file name version.
  • Rebuild the system library. From NBEclipse, select 'NBEclipse -> Rebuild System Files. For command line users, this will happen automatically when you runmake`.
  • Rebuild your application.

Note:On December 3rd 2003 Microsoft announced that it would exercise its patent rights relating to certain elements of how long filenames are implemented in FAT file systems. As a consequence it is up to the user to contact Microsoft to get the required licenses should they use the long filename option. It is also possible that some flash card manufacturers may obtain rights to use long file names on their media. You will need to check with your flash card vendor to determine if this is the case.