1
1
# NVStore
2
2
3
- A lightweight module providing the functionality of storing data by keys in the internal flash, for security purpose.
3
+ NVStore is a lightweight module that stores data by keys in the internal flash for security purposes.
4
4
5
5
## Description
6
6
7
7
NVStore provides the ability to store a minimal set of system critical items in the internal flash.
8
- For each item key, NVStore module provides the ability to set the item data or get it.
9
- Newly set values are added to the flash (as in journal), with the effect of overriding the previous value for this key.
8
+ For each item key, the NVStore module provides the ability to set the item data or get it.
9
+ Newly added values are added to the end of the existing data, superseding the previous value that was there for the same key.
10
10
The NVStore module ensures that power failures don't harm existing data during any operation.
11
- The full interface can be found under nvstore.h.
11
+ The full interface can be found under ` nvstore.h ` .
12
12
13
13
### Flash structure
14
14
NVStore uses two Flash areas, active and nonactive. Each area must consist of at least one erasable unit (sector).
@@ -31,28 +31,28 @@ Each item is kept in an entry containing a header and data, where the header hol
31
31
## Usage
32
32
33
33
### Enabling NVStore and configuring it for your board
34
- NVStore is enabled by default for all devices having the internal flash driver (have "FLASH" in the device_has attribute).
34
+ NVStore is enabled by default for all devices with the internal flash driver (have "FLASH" in the device_has attribute).
35
35
One can disable it by setting its "enabled" attribute to false.
36
36
Unless specifically configured by the user, NVStore selects the last two flash sectors as its areas, with the mininum size of 4KBs,
37
37
meaning that if the sectors are smaller, few continuous ones will be used for each area.
38
- The user can override this by setting the addresses and sizes of both areas in mbed_lib.json on a per board basis.
38
+ The user can override this by setting the addresses and sizes of both areas in` mbed_lib.json ` on a per board basis.
39
39
In this case, all following four attributes need to be set:
40
40
- area_1_address
41
41
- area_1_size
42
42
- area_2_address
43
43
- area_2_size
44
44
45
- In addition, the num_keys value should be modified, in order to change the default number of different keys.
45
+ In addition, the ` num_keys ` value should be modified to change the default number of different keys.
46
46
47
47
### Using NVStore
48
48
NVStore is a singleton class, meaning that the system can have only a single instance of it.
49
- To instanciate NVStore, one needs to call its get_instance member function as following:
49
+ To instantiate NVStore, one needs to call its get_instance member function as following:
50
50
``` c++
51
51
NVStore &nvstore = NVStore::get_instance();
52
52
```
53
- After the NVStore instantiation, one can call the init API, but it is not necessary, as all
54
- NVStore APIs (get, set et al. ) perform a "lazy initialization".
53
+ After the NVStore instantiation, one can call the init API, but it is not necessary because all
54
+ NVStore APIs (get, set and so on ) perform a "lazy initialization".
55
55
56
56
### Testing NVStore
57
- Run the NVStore functionality test with the mbed command as following:
58
- mbed test -n features-nvstore-tests-nvstore-functionality
57
+ Run the NVStore functionality test with the ` mbed ` command as following:
58
+ ``` mbed test -n features-nvstore-tests-nvstore-functionality ```
0 commit comments