An SPI file system for embedded device

A brief introduction to my SPI flash file systems for embedded microcontrollers

I have always looked for a nice open source SPI Flash file system but could never find one  that did exactly what I wanted. I deciced to write my own.

Introduction

Microcontrollers are widely in use every day. The applications become more and more sophisticated every day. Often there is a need to store information on small embedded circuit boards with a micrcontroller on it. It might be to log data, store settings or some small file data. Whatever the need, it would always be very convenient to have high level file functions to write data to a SPI FLASH.

My requirements for a file system

I wanted a file system that would deliver the following:

  1. very small footprint for possible implementation on small 8-bit microcontrollers
  2. open source
  3. Easily customisable to work with any type of flash memory, be it SPI, NAND FLASH etc
  4. optimised for data logging
  5. generic enough for everyday use
  6. Fast
  7. Re-usable

It turned out that requirements 4 and 5 were not entirely compatible.

Existing systems

To a certain extent this requirement has already been answered with some very nice open source projects out there. Here follows a brief summary of systems I have looked at and reasons why I chose not to use them:

FatFs - Generic FAT File System Module

The generic FAT file system looks like a very interesting project indeed. From their website I can tell you that the file system provides:

  • A windows compatible implementation of FAT files
  • That it is platform independent
  • Has a small footprint code wise.
  • Is very configurable and actually supports features like I/O Buffers etc.

In general I was quite impressed with their efforts. The only thing that really bugged me was that on a SPI Flash based system the FAT architecture does not really lend itself very good towards circular logging of very large amounts of data (requirement 4). As a generic everyday use file system I could not fault it however.

Coffee file system from the contiki-os

The coffee file system looks a bit more modern than the FatFs project.

Coffee file system appears to be a log based file system. From the looks of it is very well thought out and appears to have all the bells and whistles that a micrcontroller file system shoud need.

My gripe with it was that I could not get it to work properly, and although it appears better suited towards everyday generic use and data logging, I just felt that it wasn't doing what I wanted in a correct manner.

My solution

Eventually i decided to come up with my own solution.

Because my requirements for (4) and (5) were not entirely compatible, I ended up making two file systems:

  • neofs: a generic file system for everyday use in microcontrollers
  • neocfs: a file system that is optimized for circular log buffers.

Currently the work is still a work in progress but the fundamental tests are passing at the moment. At the present I am implementing the neocfs file system on a commercial project, so I will be able to give some feedback soon on its practicakl application.

You can view the development releases at https://github.com/armandjordaan/neofs/tree/develop

The project is a code::blocks project with some test code. If you prefer a more polished product, rather check back in a few weeks when the tests will be more user friendly.

Summary

Two new SPI flash file systems have been presented. Although stillwork in progress, the file systems are already published to preview the implementations.

armand | Wednesday 12 August 2015 - 9:14 pm