Part 1
요약·해설
NVS mount와 최초 entry 생성, 다음 boot의 data 복원 및 counter 증가를 전체 console output으로 설명합니다.
Non-volatile flash
ID 1 · 2 · 3 · 4 · 5
Reboot counter history
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
DA6301C4BE740FABDAC40AAC12D2E5C8CBB4154B239ED3FF31948456E9F2CB98
.. zephyr:code-sample:: nvs
:name: Non-Volatile Storage (NVS)
:relevant-api: nvs_high_level_api
Store and retrieve data from flash using the NVS API.
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/nrf51822 board.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/nvs
:board: nrf51dk/nrf51822
: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_mount: maximum storage length 256 byte
[fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c
[fs/nvs] [INF] nvs_mount: 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_mount: maximum storage length 256 byte
[fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c7
[fs/nvs] [INF] nvs_mount: 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
...
Part 3
한국어 전문 번역
개요
Non-Volatile Storage(NVS) module을 사용해 flash에 data를 저장하고 다시 읽는 간단한 application입니다. Application은 boot할 때마다 reboot counter를 증가시켜 flash에 기록한 뒤 스스로 reboot하고, 다음 boot에서 이전 counter data를 가져옵니다.
요구 사항
- Flash storage를 지원하는 board
빌드 및 실행
Sample은 Zephyr tree의 samples/subsys/nvs에 있습니다. 여러 platform에서 build할 수 있으며 다음 command는 nrf51dk/nrf51822용 application을 build하고 flash합니다.
west build -b nrf51dk/nrf51822 samples/subsys/nvs
west flash
Image를 board에 flash하면 console에 reboot counter가 표시됩니다. Board가 여러 번 자동 reboot하면서 counter가 증가하고 flash에 저장된 값이 다음 실행에서도 유지되는 것을 보여 줍니다.
샘플 출력
첫 boot에서는 NVS sector를 초기화하고 address, key, reboot counter와 long array를 각 ID에 새로 저장합니다. 다음 boot에서는 같은 entry를 읽어 192.168.1.1, key byte, counter 1, DATA와 long array를 복원합니다. Counter history가 ...0에서 ...1...0으로 늘어나는 점이 non-volatile persistence를 확인해 줍니다.
***** 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_mount: maximum storage length 256 byte
[fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c
[fs/nvs] [INF] nvs_mount: 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_mount: maximum storage length 256 byte
[fs/nvs] [INF] nvs_mount: write-align: 1, write-addr: c7
[fs/nvs] [INF] nvs_mount: 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
...
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.