SPI Flash Object Storage C++

Thread Starter


Joined Oct 10, 2019
I'm new to embedded systems and working on a project with an STM32L4 microcontroller along with a GPS receiver, temperature sensor and Bluetooth radio. You connect to the device periodically via Bluetooth to view the data from an app. I want the location and temperature history to be persisted across power cycles. The oldest data will be purged eventually, maybe after a few weeks or so. User settings will also need to be stored. I'm interested in what the 'standard' way to do this would be?

Due to possibly a few weeks or more of data being stored it seems like NOR flash (via SPI, in indirect mode) might be the best option for the STM32L4?

Interaction with NOR flash over SPI seems complex to manage (writing blocks to memory addresses). That, along with the possibility of dealing with worn or bad blocks, got me interested in using littlefs instead (without mbed). Does this seem like a good idea for my use case?

I'm using C++ and have custom objects that store this data, one option seems to be serialising objects to store them in the NOR flash? Do I need to bother with that or is there some better option?