• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/29-Dec-2025-212177

nxp/29-Dec-2025-2117

socs/29-Dec-2025-42

src/29-Dec-2025-243162

CMakeLists.txtD29-Dec-2025439 1711

KconfigD29-Dec-2025741 2923

README.rstD29-Dec-20252.2 KiB6855

prj.confD29-Dec-2025172 108

sample.yamlD29-Dec-20251.9 KiB4846

README.rst

1.. zephyr:code-sample:: nvs
2   :name: Non-Volatile Storage (NVS)
3   :relevant-api: nvs_high_level_api
4
5   Store and retrieve data from flash using the NVS API.
6
7Overview
8********
9
10This is a simple application demonstrating use of the NVS
11module for non-volatile (flash) storage.  In this application,
12a counter is incremented on every reboot and stored in flash,
13the application reboots, and the reboot counter data is retrieved.
14
15Requirements
16************
17
18* A board with flash support
19
20Building and Running
21********************
22
23The sample can be built for several platforms, the following commands build the
24application for the nrf51dk/nrf51822 board.
25
26.. zephyr-app-commands::
27   :zephyr-app: samples/subsys/nvs
28   :board: nrf51dk/nrf51822
29   :goals: build flash
30   :compact:
31
32After flashing the image to the board the output on the console shows the
33reboot counter and the boards reboots several times to show the reboot counter
34is incremented.
35
36Sample Output
37=============
38
39.. code-block:: console
40
41   ***** Booting Zephyr OS v1.12.0-rc1-176-gf091be783 *****
42   [fs/nvs] [DBG] nvs_reinit: (Re)Initializing sectors
43   [fs/nvs] [DBG] _nvs_sector_init: f->write_location set to c
44   [fs/nvs] [INF] nvs_mount: maximum storage length 256 byte
45   [fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c
46   [fs/nvs] [INF] nvs_mount: entry sector: 0, entry sector ID: 1
47   No address found, adding 192.168.1.1 at id 1
48   No key found, adding it at id 2
49   No Reboot counter found, adding it at id 3
50   Id: 4 not found, adding it
51   Longarray not found, adding it as id 4
52   Reboot counter history: ...0
53   Oldest reboot counter: 0
54   Rebooting in ...5...4...3...2...1
55   ***** Booting Zephyr OS v1.12.0-rc1-176-gf091be783 *****
56   [fs/nvs] [INF] nvs_mount: maximum storage length 256 byte
57   [fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c7
58   [fs/nvs] [INF] nvs_mount: entry sector: 0, entry sector ID: 1
59   Entry: 1, Address: 192.168.1.1
60   Id: 2, Key: ff fe fd fc fb fa f9 f8
61   Id: 3, Reboot_counter: 1
62   Id: 4, Data: DATA
63   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
64   Reboot counter history: ...1...0
65   Oldest reboot counter: 0
66   Rebooting in ...5...4...3...2...1
67   ...
68