I'm working on an embedded C++ project that involves logging certain types of statistical data (like successful accesses, failed attempts, and other events) to the flash memory (just incrementing these values). Due to the nature of the system, power can be lost at any moment, making it important that all data is written to the flash.
However, I'm also aware that flash memory has a limited lifespan in terms of write/erase cycles, especially when writing to the same address repeatedly. So, I'm looking for ways to optimize the number of writes to the flash memory without losing any statistics.
I'm currently considering solutions like write caching, wear leveling, and data compression. I'm not sure which method to implement due to their advantages and/or disadvantages, especially in an environment where power loss can occur unexpectedly.
Any insights or suggestions would be greatly appreciated.
Regards Dario