User`s manual

Dynamic C Users Manual digi.com 131
10.1.1.4 Wear Leveling
The current code has a rudimentary form of wear leveling. When you write into an existing block it selects
a free block with the least number of writes. The file system routines copy the old block into the new block
adding in the user’s new data. This has the effect of evening the wear if there is a reasonable turnover in
the flash files. This goes for the data as well as the metadata.
10.1.1.5 Low-Level Implementation
For information on the low-level implementation of the flash file system, refer to the beginning of the
library file FS2.LIB.
10.1.1.6 Multitasking and FS2
The file system is not re-entrant. If using preemptive multitasking, ensure that only one thread performs
calls to the file system, or implement locking around each call.
When using µC/OS-II, FS2 must be initialized first; that is, fs_init() must be called before
OSInit() in the application code.
10.1.2 Application Requirements
Application requirements for using FS2 are covered in this section, including:
which library to use
which drivers to use
defaults and descriptions for configuration macros
detailed instructions for using the first flash
10.1.2.1 Library Requirements
The file system library must be compiled with the application:
#use “FS2.LIB”
For the simplest applications, this is all that is necessary for configuration. For more complex applications,
there are several other macro definitions that may be used before the inclusion of FS2.LIB. These are:
#define FS_MAX_DEVICES 3
#define FS_MAX_LX 4
#define FS_MAX_FILES 10
These specify certain static array sizes that allow control over the amount of root data space taken by FS2.
If you are using only one flash device (and possibly battery-backed RAM), and are not using partitions,
then there is no need to set FS_MAX_DEVICES or FS_MAX_LX.
For more information on partitioning, please see Section 10.1.4 “Setting up and Partitioning the File Sys-
tem”.