Lets say I have 200 bytes of data that I want to store in flash. So, I request a 200-byte block.
In order to store, the area has to be cleared first. As far as I understand the implementation limitations, pstorage_clear() has to clear the entire page even though it takes in a size argument.
I want to guard against power loss during a clear/store cycle that would corrupt the data, say the power was lost right after the clear. My first thought was to request two 200-byte blocks and sequentially store the same data to both blocks. I.e. clear/store to block one and once it finishes successfully, clear/store to block two. This would guarantee that one of the blocks always has valid data. Another way would be to alternate which block to use. But since the entire page is erased every time, this wont work.
So, my next thought was to request two separate pages by making the block size 1024 bytes, then in theory this should work, right? Though that would be huge waste of space.
Am I overthinking this?
Don't mind the required header data/crc checks (I've already implemented that).