The first 1MB are divided into 8 data groups of 128kB each.
Data group #0 is not available (reserved for partition tables, certificates and secret keys, factory configuration etc).
Data group #1 stores the constants and technical flags.
Data group #2 stores the configuration.
Data group #3 stores the templates.
Data group #4 stores the statistics.
Data groups #4, #5, #6 and #7 are RFU.
Low-level implementation and wear-leveling
All the data groups are formatted and used the same way.
Every data group is made of 32 pages (each page is 4kB).
The pages are used by 2 : page 0 comes with page 16, page 1 with page 17, etc.
Data entries are distributed among the pages based on their low-order nibble:
- entries #00, #10, #20 … go to pages 0 and 16,
- entries #01, #11, #21 … go to pages 1 and 17, etc.
The flash is always accessed in 4-B blocks and aligned on 4-B boundaries.
The 1st block of every page stores the page’s state:
0xFFFFFFFF: the page is empty
0xAA55FFFF: the page has room to receive new data
0xAA55DEAD: the page contains valid data, and has no room left; in is being transferred to its sister page
- any other value : error, the page shall be made empty again