NVM area data backup mechanism (b)

Previous article describes the first area NVM backup mechanism, but write data length is limited by the size of the sector, this article describes the data backup mechanism second NVM area. This method first NVM area is divided into A, B and so the size of two regions, the region A as a formal data area, B area as backup area, the last byte of data for each region is valid flag FLAG, 1 indicates the region data valid, 0 indicates an invalid data region. If there is update data during power failure, after power is determined to which region of the data is valid according to A, B two areas FLAG, and thus continue to complete the update operation. In the present embodiment NVM region size is 32KB, A size of the area is divided into 16KB, B block size is divided into 16KB. Example: This example assumes that zone A has been successfully written data, new data needs to be written to NVM area. Otherwise the processing flow described below Step 4 The same.
(1) A region is determined after FLAG = 1, the data read out in a zone A to zone B, after the writing is successful, the B region FLAG value of 1.
After (2) B FLAG successfully modified region, the region A 0 to flag FLAG.
(. 3) A modified region flag FLAG is successful, to update the data area A, i.e., new data is written. After the update is successful, the district FLAG A sign written as 1.
After (4) A region FLAG successfully modified, the modified zone B flag FLAG is 0, thereby completing the data refresh operation.
So far two NVM area data backup programs all finished presentation.

Guess you like

Origin blog.51cto.com/13520299/2432604