Skip to content

Commit ff1c5e1

Browse files
RICCIARDI-Adrienanangl
authored andcommitted
[nrf fromtree] doc: storage: nvs: Tell about optional data CRC
The CONFIG_NVS_DATA_CRC configuration item allows to enable a CRC-32 on the data part of the NVS items. Signed-off-by: Adrien Ricciardi <[email protected]> (cherry picked from commit 61474ac) Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 2ec7254 commit ff1c5e1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

doc/services/storage/nvs/nvs.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ combination of these.
1919
Each element is stored in flash as metadata (8 byte) and data. The metadata is
2020
written in a table starting from the end of a nvs sector, the data is
2121
written one after the other from the start of the sector. The metadata consists
22-
of: id, data offset in sector, data length, part (unused), and a CRC. The CRC is
22+
of: id, data offset in sector, data length, part (unused), and a CRC. This CRC is
2323
only calculated over the metadata and only ensures that a write has been
24-
completed. The actual data of the element is not protected by a CRC. It is
25-
encouraged to include a CRC as part of the data and to take appropriate
26-
corrective actions when the data CRC does not match its expected value.
24+
completed. The actual data of the element can be protected by a different (and optional)
25+
CRC-32. Use the :kconfig:option:`CONFIG_NVS_DATA_CRC` configuration item to enable
26+
the data part CRC.
27+
**Note:** the data CRC is checked only when the whole data of the element is read.
28+
The data CRC is not checked for a partial read, as it is stored at the end of the
29+
element data area.
30+
**Note 2:** enabling the data CRC feature on a previously existing NVS content without
31+
data CRC will make all existing data invalid.
2732

2833
A write of data to nvs always starts with writing the data, followed by a write
2934
of the metadata. Data that is written in flash without metadata is ignored

0 commit comments

Comments
 (0)