tags:

views:

139

answers:

3

I'm looking for a storage library for storing data in flash memory in an embedded system. I'm on the verge of writing a custom one for want of a format with the right mix of features and simplicity.

Ideally it would be a format and C/C++ library with something better than storing raw structures, but less complex than a full blown file system. I need to store multiple data structures some of which are optional and may change format from time to time.

Nice to haves would be simple wear leveling / journaling schemes and data redundancy/reliability features. The simple journaling is because most low level flash chips I'm working with are happiest when you write from one end to another and start over at the top. Data redundancy/reliability could be use and checking of parity bits or complete extra copies.

Any suggestions?

+3  A: 

JFFS2 is an obvious candidate. I have used it extensibly with MIPS and SuperH guys, but only with NAND. It gives great results in wear leveling and performance. Not, it is a full-blown file-system which doesn't seem to be what you describe, but honestly, I don't think you'll find a single solution for what you want. But it might be the simeplest solution: JFFS2 + {SQLite|Protobuf|Berkeley DB}

I do hope that I'm wrong and you find one. :-)

Gianni
I had looked at JFFS2 and didn't know how much work was in store for use without an RTOS in the embedded system. My guess is that JFFS2 is more than I want - though I it occurs to me to look and see if it's viable to use SQLite et al. directly on the flash with no intervening file system layer by treating a section of the flash as a single file.
Digikata
@Digikata Maybe, just simply using a on-disk data structure, in the form of a linked list that you iterate through looking for the last version ID. You can skip all the FS and other stuff.
Gianni
Yup, that was the direction I was contemplating for rolling my own format.
Digikata
+2  A: 

Look my question.

I've found out that fat16(12) and ELM-Petit FAT File System Module are suites well to my needs. It required to code sector writing/reading procedures only.

Mtr
+2  A: 

Like Robert and Mtr I can recommend the FatFs Generic File System Module. I am using it on an Cortex-M3 with 3 logical devices (USB, SD-Card and external Flash). Especially the f_mkfs was very handy to get the FileSystem to the external Flash. The "only" thing I had to code my self were the low level disk I/O functions. If you do not need all functionality provided by the FatFs module, reducing the module size is pretty easy using the config.h (can't remember the name :D).

Edit: I chose FAT as it can be used by Win & Linux...

BaumS