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

..--

boards/29-Dec-2025-73

src/29-Dec-2025-274206

CMakeLists.txtD29-Dec-2025256 116

KconfigD29-Dec-2025416 1712

README.rstD29-Dec-20253.6 KiB9579

prj.confD29-Dec-202590 75

sample.yamlD29-Dec-2025509 2725

README.rst

1.. zephyr:code-sample:: zms
2   :name: Zephyr Memory Storage (ZMS)
3   :relevant-api: zms_high_level_api
4
5   Store and retrieve data from storage using the ZMS API.
6
7Overview
8********
9 The sample shows how to use ZMS to store ID/VALUE pairs and reads them back.
10 Deleting an ID/VALUE pair is also shown in this sample.
11
12 The sample stores the following items:
13
14 #. A string representing an IP address: stored at id=1, data="192.168.1.1"
15 #. A binary blob representing a key/value pair: stored at id=0xbeefdead,
16    data={0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF}
17 #. A variable (32bit): stored at id=2, data=cnt
18 #. A long set of data (128 bytes)
19
20 A loop is executed where we mount the storage system, and then write all set
21 of data.
22
23 Each CONFIG_DELETE_ITERATION period, we delete all set of data and verify that it has been deleted.
24 We generate as well incremented ID/value pairs, we store them until storage is full, then we
25 delete them and verify that storage is empty.
26
27Requirements
28************
29
30* A board with flash support or native_sim target
31
32Building and Running
33********************
34
35The sample can be built for several platforms, but for the moment it has been tested only
36on native_sim target
37
38.. zephyr-app-commands::
39   :zephyr-app: samples/subsys/fs/zms
40   :goals: build
41   :compact:
42
43After running the generated image on a native_sim target, the output on the console shows the
44multiple Iterations of read/write/delete executed.
45
46Sample Output
47=============
48
49.. code-block:: console
50
51   *** Booting Zephyr OS build v3.7.0-2383-g624f75400242 ***
52   [00:00:00.000,000] <inf> fs_zms: 3 Sectors of 4096 bytes
53   [00:00:00.000,000] <inf> fs_zms: alloc wra: 0, fc0
54   [00:00:00.000,000] <inf> fs_zms: data wra: 0, 0
55   ITERATION: 0
56   Adding IP_ADDRESS 172.16.254.1 at id 1
57   Adding key/value at id beefdead
58   Adding counter at id 2
59   Adding Longarray at id 3
60   [00:00:00.000,000] <inf> fs_zms: 3 Sectors of 4096 bytes
61   [00:00:00.000,000] <inf> fs_zms: alloc wra: 0, f80
62   [00:00:00.000,000] <inf> fs_zms: data wra: 0, 8c
63   ITERATION: 1
64   ID: 1, IP Address: 172.16.254.1
65   Adding IP_ADDRESS 172.16.254.1 at id 1
66   Id: beefdead, Key: de ad be ef de ad be ef
67   Adding key/value at id beefdead
68   Id: 2, loop_cnt: 0
69   Adding counter at id 2
70   Id: 3, 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 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 5
71   4 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
72   Adding Longarray at id 3
73   .
74   .
75   .
76   .
77   .
78   .
79   [00:00:00.000,000] <inf> fs_zms: 3 Sectors of 4096 bytes
80   [00:00:00.000,000] <inf> fs_zms: alloc wra: 0, f40
81   [00:00:00.000,000] <inf> fs_zms: data wra: 0, 80
82   ITERATION: 299
83   ID: 1, IP Address: 172.16.254.1
84   Adding IP_ADDRESS 172.16.254.1 at id 1
85   Id: beefdead, Key: de ad be ef de ad be ef
86   Adding key/value at id beefdead
87   Id: 2, loop_cnt: 298
88   Adding counter at id 2
89   Id: 3, 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 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 5
90   4 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
91   Adding Longarray at id 3
92   Memory is full let's delete all items
93   Free space in storage is 8064 bytes
94   Sample code finished Successfully
95