NVStore example for Mbed OS. This is an example of an application that uses the NVStore APIs. The application invokes the NVStore APIs and prints the results after each such invocation.

Required hardware

# Other hardware

Although the board shown in this examples is K64F, the example should work on any Mbed enabled hardware supporting the internal flash driver (has "FLASH" in the "device_has" in targets/target.json file).

Getting started

1. Import the example.

``` mbed import mbed-os-example-nvstore cd mbed-os-example-nvstore ```

2. Keep the default NVStore configuration, which uses the last two sectors (4KB each) as NVStore areas.

3. Compile and generate binary.

For example, for `GCC`:

``` mbed compile -t GCC_ARM -m K64F ```

4. Open a serial console session with the target platform using the following parameters:

  • Baud rate: 115200
  • Data bits: 8
  • Stop bits: 1
  • Parity: None

5. Copy the application `mbed-os-example-nvstore.bin` in the folder `mbed-os-example-nvstore/BUILD/<TARGET NAME>/<PLATFORM NAME>` onto the target board.

6. Press the RESET button on the board to run the program

7. The serial console should now display a series of results following the NVStore API invocations.

8. Now copy `mbed_app-8KB-areas.json` to `mbed_app.json`. This should use 8KB areas (two pairs of last sectors) as NVStore areas.

9. Repeat steps 3-7. Notice the changes in prints of area addresses and sizes and with the amount of possible keys this configuration can hold.

10. To restore the default configuration, copy `mbed_app-default-areas.json` to `mbed_app.json`.

Troubleshooting

If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.

Committer:
mbed_official
Date:
Mon Jun 03 15:02:15 2019 +0100
Revision:
29:226b38fd84c6
Parent:
9:41427d643b56
Merge pull request #40 from 0xc0170/fix_license

add contributing + license files
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-nvstore

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:6e33ad0eda0c 1 # mbed-os-example-nvstore
mbed_official 0:6e33ad0eda0c 2
mbed_official 0:6e33ad0eda0c 3 NVStore example for Mbed OS
mbed_official 0:6e33ad0eda0c 4
mbed_official 0:6e33ad0eda0c 5 ## Getting started with NVStore ##
mbed_official 0:6e33ad0eda0c 6
mbed_official 0:6e33ad0eda0c 7 This is an example of an application that uses the NVStore APIs.
mbed_official 0:6e33ad0eda0c 8
mbed_official 0:6e33ad0eda0c 9 The application invokes the NVStore APIs and prints the results after each such invocation.
mbed_official 0:6e33ad0eda0c 10
mbed_official 0:6e33ad0eda0c 11 ## Required hardware
mbed_official 0:6e33ad0eda0c 12 * An [FRDM-K64F](http://os.mbed.com/platforms/FRDM-K64F/) development board.
mbed_official 0:6e33ad0eda0c 13 * A micro-USB cable.
mbed_official 0:6e33ad0eda0c 14
mbed_official 0:6e33ad0eda0c 15 ### Other hardware
mbed_official 0:6e33ad0eda0c 16
mbed_official 0:6e33ad0eda0c 17 Although the board shown in this examples is K64F, the example should work on any Mbed enabled hardware supporting the internal flash driver (has "FLASH" in the "device_has" in targets/target.json file).
mbed_official 0:6e33ad0eda0c 18
mbed_official 0:6e33ad0eda0c 19 ## Getting started ##
mbed_official 0:6e33ad0eda0c 20
mbed_official 0:6e33ad0eda0c 21 1. Import the example.
mbed_official 0:6e33ad0eda0c 22
mbed_official 0:6e33ad0eda0c 23 ```
mbed_official 0:6e33ad0eda0c 24 mbed import mbed-os-example-nvstore
mbed_official 0:6e33ad0eda0c 25 cd mbed-os-example-nvstore
mbed_official 0:6e33ad0eda0c 26 ```
mbed_official 0:6e33ad0eda0c 27
mbed_official 0:6e33ad0eda0c 28 2. Keep the default NVStore configuration, which uses the last two sectors (4KB each) as NVStore areas.
mbed_official 0:6e33ad0eda0c 29
mbed_official 0:6e33ad0eda0c 30 3. Compile and generate binary.
mbed_official 0:6e33ad0eda0c 31
mbed_official 0:6e33ad0eda0c 32 For example, for `GCC`:
mbed_official 0:6e33ad0eda0c 33
mbed_official 0:6e33ad0eda0c 34 ```
mbed_official 0:6e33ad0eda0c 35 mbed compile -t GCC_ARM -m K64F
mbed_official 0:6e33ad0eda0c 36 ```
mbed_official 0:6e33ad0eda0c 37
mbed_official 0:6e33ad0eda0c 38 4. Open a serial console session with the target platform using the following parameters:
mbed_official 0:6e33ad0eda0c 39
mbed_official 29:226b38fd84c6 40 * **Baud rate:** 9600
mbed_official 0:6e33ad0eda0c 41 * **Data bits:** 8
mbed_official 0:6e33ad0eda0c 42 * **Stop bits:** 1
mbed_official 0:6e33ad0eda0c 43 * **Parity:** None
mbed_official 0:6e33ad0eda0c 44
mbed_official 0:6e33ad0eda0c 45 5. Copy the application `mbed-os-example-nvstore.bin` in the folder `mbed-os-example-nvstore/BUILD/<TARGET NAME>/<PLATFORM NAME>` onto the target board.
mbed_official 0:6e33ad0eda0c 46
mbed_official 0:6e33ad0eda0c 47 6. Press the **RESET** button on the board to run the program
mbed_official 0:6e33ad0eda0c 48
mbed_official 0:6e33ad0eda0c 49 7. The serial console should now display a series of results following the NVStore API invocations.
mbed_official 29:226b38fd84c6 50
mbed_official 9:41427d643b56 51 8. Unless specifically configured by the user, NVStore selects the last two flash sectors as its areas, with the minimum size of 4KBs. This means that if the sectors are smaller, a few continuous ones will be used for each area.
mbed_official 29:226b38fd84c6 52
mbed_official 9:41427d643b56 53 If the automatically selected sectors do not fit your flash configuration, you can override this by setting the addresses and sizes of both areas in `mbed_lib.json` for each board.
mbed_official 9:41427d643b56 54
mbed_official 9:41427d643b56 55 Copy `mbed_app-K64F-8KB-areas.json` to `mbed_app.json` and edit `mbed_app.json` to match your board.
mbed_official 9:41427d643b56 56
mbed_official 9:41427d643b56 57 This example defines two areas of 8KB each (the last four sectors) as NVStore areas.
mbed_official 9:41427d643b56 58
mbed_official 9:41427d643b56 59 Set the following four attributes:
mbed_official 9:41427d643b56 60
mbed_official 9:41427d643b56 61 - `area_1_address`
mbed_official 9:41427d643b56 62 - `area_1_size`
mbed_official 9:41427d643b56 63 - `area_2_address`
mbed_official 9:41427d643b56 64 - `area_2_size`
mbed_official 9:41427d643b56 65
mbed_official 0:6e33ad0eda0c 66 9. Repeat steps 3-7. Notice the changes in prints of area addresses and sizes and with the amount of possible keys this configuration can hold.
mbed_official 0:6e33ad0eda0c 67
mbed_official 0:6e33ad0eda0c 68 10. To restore the default configuration, copy `mbed_app-default-areas.json` to `mbed_app.json`.
mbed_official 0:6e33ad0eda0c 69
mbed_official 0:6e33ad0eda0c 70 ## Troubleshooting
mbed_official 0:6e33ad0eda0c 71
mbed_official 0:6e33ad0eda0c 72 If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
mbed_official 29:226b38fd84c6 73
mbed_official 29:226b38fd84c6 74 ## License and contributions
mbed_official 29:226b38fd84c6 75
mbed_official 29:226b38fd84c6 76 The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more info.
mbed_official 29:226b38fd84c6 77
mbed_official 29:226b38fd84c6 78 This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.
mbed_official 29:226b38fd84c6 79