SLFS - Small Logger File System


  The SLFS (Small Logger File System) is a logger file system, implemented on the serial flash with unified
sector size (4 KB).

  The logger file system uses the FIFO approach - for the writing the file is added to the tail of the internal list
while for the reading the file is taken from the head of the list.
  In most cases, after the reading the file is erased from SLFS and disk space is released.
  If SLFS disk is full and new file is added, the oldest file(s) will be automatically erased.

  Files in SLFS may have an arbitrary length.

  SLFS uses the write-ahead journaling for file creating/deleting and wear leveling for the system metadata.

SLFS RAM usage

  The SLFS uses global structure DF_FLI (52 bytes), structure DF_DISKINFO (328 bytes) per each disk and the one
global buffer with the size of the flash sector (4096 bytes).

SLFS multi-access

  The SLFS was designed for the small embedded systems with limited RAM capacity.
   In SLFS, the only one file at time may be open - if the file is open for reading or was created for writing, no more
files can be open/created until file will be closed.

SLFS Wear leveling

  The SLFS has a reserved area N * log (metadata) data size, where N is defined by user.
  The SLFS write capacity counter is set to the maximal erasing number value. After each file closing, the counter is decremented.  When the capacity counter reaches the zero value, the log (metadata) is relocated to the next position  in the reserved area and the capacity counter is set to the maximal erasing number value again.
  When there is no more free space available in the reserved area for the metadata relocation, the SLFS is set as read-only.

SLFS API usage

    The flash formatting

  For the flash formatting, the function df_create_mbr() is used. Then, one or more SLFS disks may be created
by the function slfs_create_disk().

    The SLFS initialization

  After the system restart, the file system(s) should be initiated by the function df_init_disks().

    File writing

  File is created for the writing by function slfs_file_create().
  The writing is performed by function slfs_file_write().
  After finishing writing to the file, the file must be close by the functionslfs_file_close().

    File reading

  File is open for the reading by function slfs_file_open().
  The reading is performed by function slfs_file_read().
  After finishing reading from the file, the file must be close by the function slfs_file_close() or slfs_file_close_not_erase().

    Files enumeration

  To get actual number of the files in the SLFS, the function slfs_get_files_number() should be used.
  To enumerate all files, the functions slfs_enum_files_first()/slfs_enum_files_next() are used.

SLFS example

  In SLFS example, a serial flash M25PX64 (8MBytes) and NXP Cortex M3 LPC1766 CPU are used.
  The test program contains a small RS232 CLI (console). The UART is set for 115200 baud, 8 bit, 1 stop bit, no parity, no handshake.

  The CLI supports the following commands (more details in the file main.c):

ver shows the flash on-chip information: manufacturer id, memory type, memory capacity
fs_create the flash formatting and test file systems creating
fs_dump dump the MBR and disks info
fs_files enumerate and dump actual files at SLFS disk (in example - disk 'B')
fs_dinfo dump SLFS disk metadata (in example - disk 'B')
fs_create_files Creates files at SLFS disk (in example - disk 'B')
Usage:  "fs_create_files N", where N - number files to create.
     (for example "fs_create_files 10")
fs_chk_files Checks files at SLFS disk (in example - disk 'B')
Should be used after "fs_create_files" command.
Usage:  "fs_chk_files N", where N - number files to check.
     (for example "fs_chk_files 10")
The checking assumes file reading and, accordingly, the file erasing.

    Test configuration

  In the file flash_fs_cfg.h

  - the flash/disks configuration is defined - flash IC data for the file system(s) creations, the disk(s) number and size etc.

  In the file main.c

  - function init_fli() provides the initialization before creating and/or initialization for the flash / disks.
  - function create_flash_fs() provides the flash formatting and creates desired disks on the flash
  - functions init_fli() and df_init_disks() are doing the flash information initialization and disk(s) initialization after a restart.

  In the file df_create_init.c

  - function df_chk_flash_ic() provides the checking the flash IC on-chip parameters. If your project flash is
    not M25PX64, you should update the function code.


slfs.pdf   The SLFS (Small Logger File System) User Guide   SLFS source code with examples for the LPC1766 MCU.
  The example includes project for the compilers:

   - Rowley CrossWorks Studio 2.x
   - IAR ARM 6.xx
   - GCC "GNU Tools ARM Embedded" 4.7
   - Keil 4.xx