You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cores/nRF5/FC_Store/README.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,32 @@
1
-
# Flash Config Store
2
-
1
+
# Flash Config Storage
3
2
This library was originally designed to support storing bond info from NimBLE and has been redesigned to allow use as an EEPROM emulation for storing config data.
4
3
5
4
## Design
5
+
A **minimum** of 2 flash pages are required. Pages used for FC storage are identified with the value 0xf1a5c0f5UL as the first word in the page.
6
+
7
+
Wear leveling is accomplished by sequentially writing data across a number of flash pages. When data is updated the old data is marked with the location of the new data. When the end of the page is reached the original page is defragmented and valid data copied to the swap page which becomes the new data page and the old page is erased to be used for as the swap for the next defragmentation.
8
+
9
+
### Data format
10
+
The data is stored with a header in the following format:
11
+
12
+
| Data ID | New Address | Length | Reserved | Data |
- The data ID can be any value from 0x00 to 0xFFFFFFFE (0xFFFFFFFFF is reserved as empty).
17
+
- The New Address specifies the location of any updated data (0xFFFFFFFF if unchanged).
18
+
- The length is the length of the data in Bytes.
19
+
- Data is the stored data.
20
+
21
+
When a data value is written FC storage will write the header and data in the next available space. If there is not enough space for the new data a defragmentation will be triggered in an attempt to provide space.
22
+
23
+
When a data value is updated the New Address field of the previous data is updated to reflect the address of the new data location to read the updated data from. This continues for each time the value is updated.
24
+
25
+
When reading a value FC Storage will find the first instance of the ID and check the New Address field, if a new address has been set it will check the New Address field of that location, move to the next if set, and so on until the latest data is found.
26
+
27
+
### Defragmentation
28
+
The defragmentation process consolidates all the current valid data to the swap page(s) and updates the page pointer to the beginning of the data. This sets all New Address header fields to empty and frees up space needed for new data. The old data page(s) will then be erased and become the swap page for the next defragmentation.
29
+
30
+
6
31
7
-
A **minimum** of 2 flash pages are required.
8
32
9
-
Wear leveling is accomplished by sequentially writing data accross a page of flash. When data is updated the old data is marked with the location of the new data. When the end of the page is reached the original page is defragmented and valid data copied to the swap page which becomes the new main page and the old page is erased.
0 commit comments