Flash是按页操作的,这种方式比较适合扇区比较大的Flash来用,假设我们的MCU的Data Flash有两个扇区,将两个扇区分别标记为逻辑扇区1(logical sector 1)和逻辑扇区2(logical sector 2)。假设我们要用Flash模拟EEPROM来存储DTC,我们都知道DTC是个很小的数据,但是更新可能会比较频繁,如下图:首先,逻辑扇区1(logical sector 1)是空白的等待我们写入数据,属于工作片区(Actived)。
假设Flash一次性可以写8个字节,我们可以这样划分:前4个字节来存储DTC标识,后4个字节来存储具体DTC(这是一种假设,程序员可以自行设计存储长度等),每次DTC有更新我们就接着往没有被写到的空间更新数据,直到逻辑扇区1(logical sector 1)被写满,我们将最新的DTC数据复制进逻辑扇区2(logical sector 2)里面,然后擦除整片逻辑扇区1(logical sector 1),这时,逻辑扇区1(logical sector 1)状态变成(Not Actived)待工作片区,逻辑扇区2(logical sector 2)变成(Actived)工作片区,等逻辑扇区2(logical sector 2)写满再将最新数据复制到逻辑扇区1(logical sector 1),然后擦除逻辑扇区2(logical sector 2),这样来回反复。
1.Memory Split for NVM and Quasi-Static Data
2.Garbage Collection
2.1 Initial Status with valid State Pages
2.2 Sector 0 filled with Data Blocks
2.3 Copy Process
3.Quasi-Static Format
4.FEE State Page
- › A FEE State Page is stored in the first 128 bytes of a WL.
- › A FEE State Page is using the first 16 pages of DFLASH (16 * 8-byte = 128 bytes).
- › The remaining 48 pages of DFLASH (48 * 8 bytes = 384 bytes) are not programmed.
- › FEE State pages are not written to fixed addresses -> floating State Page.
- › Each FEE sector typically contains up to 2 FEE State Pages.
- › If an FEE State Page is not be written correctly, FEE will automatically store the FEE State Page to the next WL.
5.Data Page Format
- › FEE user data are stored in FEE data blocks.
- › FEE data blocks start with a so called header page (8-byte).
- › The following pages contain FEE user data.
- › Each page with FEE user data has a 1 byte page identifier.
- › After header and data pages are written, a check of the written FEE data block is executed.
- › Pages from previously written FEE data blocks, which are stored in the same WL as the actual written FEE data block, are also checked.
- › Afterwards a marker page is written which indicates that the FEE data block is correctly stored.
- › In case of problems found during check of FEE data, FEE will write the data to the next WL.