zephyr/samples/subsys/nvs
Kumar Gala ff579a3af3 flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups:

git grep -l DT_FLASH_AREA_.*_ID | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'

git grep -l DT_FLASH_AREA_.*_OFFSET | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'

git grep -l DT_FLASH_AREA_.*_SIZE | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
..
src flash: Convert DT_FLASH_AREA to FLASH_AREA macros 2020-05-13 21:22:53 +02:00
CMakeLists.txt
README.rst
prj.conf
sample.yaml samples: clean test identifiers 2020-05-11 17:00:26 +02:00

README.rst

.. _nvs-sample:

NVS: Non-Volatile Storage
#########################

Overview
********

This is a simple application demonstrating use of the NVS
module for non-volatile (flash) storage.  In this application,
a counter is incremented on every reboot and stored in flash,
the application reboots, and the reboot counter data is retrieved.

Requirements
************

* A board with flash support

Building and Running
********************

This sample can be found under :zephyr_file:`samples/subsys/nvs` in the Zephyr tree.

The sample can be build for several platforms, the following commands build the
application for the nrf51dk_nrf51422 board.

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/nvs
   :board: nrf51dk_nrf51422
   :goals: build flash
   :compact:

After flashing the image to the board the output on the console shows the
reboot counter and the boards reboots several times to show the reboot counter
is incremented.

Sample Output
=============

.. code-block:: console

   ***** Booting Zephyr OS v1.12.0-rc1-176-gf091be783 *****
   [fs/nvs] [DBG] nvs_reinit: (Re)Initializing sectors
   [fs/nvs] [DBG] _nvs_sector_init: f->write_location set to c
   [fs/nvs] [INF] nvs_init: maximum storage length 256 byte
   [fs/nvs] [INF] nvs_init: write-align: 1, write-addr: c
   [fs/nvs] [INF] nvs_init: entry sector: 0, entry sector ID: 1
   No address found, adding 192.168.1.1 at id 1
   No key found, adding it at id 2
   No Reboot counter found, adding it at id 3
   Id: 4 not found, adding it
   Longarray not found, adding it as id 4
   Reboot counter history: ...0
   Oldest reboot counter: 0
   Rebooting in ...5...4...3...2...1
   ***** Booting Zephyr OS v1.12.0-rc1-176-gf091be783 *****
   [fs/nvs] [INF] nvs_init: maximum storage length 256 byte
   [fs/nvs] [INF] nvs_init: write-align: 1, write-addr: c7
   [fs/nvs] [INF] nvs_init: entry sector: 0, entry sector ID: 1
   Entry: 1, Address: 192.168.1.1
   Id: 2, Key: ff fe fd fc fb fa f9 f8
   Id: 3, Reboot_counter: 1
   Id: 4, Data: DATA
   Id: 5, Longarray: 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18
   Reboot counter history: ...1...0
   Oldest reboot counter: 0
   Rebooting in ...5...4...3...2...1
   ...