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:
Thu Mar 08 17:46:09 2018 +0000
Revision:
0:6e33ad0eda0c
Child:
2:0a3e19b12855
Update mbed-os reference to the one in main repo

.
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 0:6e33ad0eda0c 40 * **Baud rate:** 115200
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 0:6e33ad0eda0c 50
mbed_official 0:6e33ad0eda0c 51 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.
mbed_official 0:6e33ad0eda0c 52
mbed_official 0:6e33ad0eda0c 53 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 54
mbed_official 0:6e33ad0eda0c 55 10. To restore the default configuration, copy `mbed_app-default-areas.json` to `mbed_app.json`.
mbed_official 0:6e33ad0eda0c 56
mbed_official 0:6e33ad0eda0c 57 ## Troubleshooting
mbed_official 0:6e33ad0eda0c 58
mbed_official 0:6e33ad0eda0c 59 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.