2014-05-21 10:53 AM
Hey,
I am using STM32F405 as the controller in my project. We have hundreds parameters needed to be saved in the Flash memory and this parameters will be modified one by one during the running. The problem is the flash memory must be erased by section and rewrite the whole section even if we just want to change one byte in the memory. It takes long time and has to stop the access the all parameters during the updating. Is there fast method that we can overwrite the one byte/ byte?2014-05-21 11:03 AM
Is there fast method that we can overwrite the one byte/ byte?
Not really, what you'd really want is two regions, and then use a journaling method to write new copies of your structure, erase the old region after you've transitioned to the new one, and a method to recover the most recent entry.2014-05-24 01:49 PM
I would personally go for an assymmetric construct:
Initialize one page (or more) as the parameter page. Save the ''current'' version there. Then use one page (or more) as the ''changes'' log. Save any changes to the parameters there. Use 0xffff as a marker to indicate: no more changes. Clear the changes page, so you get the marker in the first position, Then log records: ''parameter x changed to y'' until the changes page is full. You only need to write a few bytes to achieve this. The bad news is that you'll need to rewrite the ''current parameters'' page every now and then. Oh, and you'll need to escape ''0xff''. or ''0xffff'' whatever datasize you chose to use. If you can't trust the power to stay applied during this, some extra care is required. e.g. write a NEW page with the current version of the parameters, then invalidate the old one, and then erase the old one.