Key-value store on flash with FreeRTOS

tothphu wrote on Monday, April 09, 2018:

Hey,

I’d like to store settings for an embedded product running FreeRTOS. I’ve spent the last 2 hours searching, but all solutions seemed to be a bit too large.

LevelDB seemed to be the most compact so far: https://github.com/google/leveldb however there was no FreeRTOS port available I could find.

Also seen https://github.com/iondbproject/iondb which looked ok (failing on the string key requirement), but still no FreeRTOS port

Is there anything else I missed? All I need is:

  • key-value storage
  • a few tens of entries
  • memory and code size is critical
  • persistence on either FreeRTOS FAT32, or raw flash, or some other filesystem (feel free to suggest others)
  • easy cross compilation
  • the key is preferably a string (as one solution for a generic storage, which can survive updates with code changes, some values might become obsolete and new created)

It will basically be used to store a few settings.

Any help is greatly appreciated.

Thanks,
Peter

waveringradiant wrote on Monday, April 09, 2018:

My first thought was, “That sounds like you want a C++ map”

My second thought was, “Can you just wrap a C++ map with a C api and use that?” but you probably have reason that you’re not already doing that (maybe no C++ compiler, dynamic memory allocation issues, etc.)

Found this link that might be useful: https://stackoverflow.com/questions/647054/porting-stdmap-to-c

Not that if you need re-entrancy / mutual exclusion (use from multiple threads), etc. you’re probably going to have to add that in yourself.

Good luck!