1# Copyright (c) 2018 Nordic Semiconductor ASA 2# Copyright (c) 2025 Analog Devices, Inc. 3# SPDX-License-Identifier: Apache-2.0 4 5menuconfig SETTINGS 6 bool "Settings" 7 help 8 The settings subsystem allows its users to serialize and 9 deserialize state in memory into and from non-volatile memory. 10 It supports several back-ends to store and load serialized data from 11 and it can do so atomically for all involved modules. 12 13if SETTINGS 14 15module = SETTINGS 16module-str = settings 17source "subsys/logging/Kconfig.template.log_config" 18 19config SETTINGS_RUNTIME 20 bool "runtime storage back-end" 21 help 22 Enables runtime storage back-end. 23 24config SETTINGS_DYNAMIC_HANDLERS 25 bool "dynamic settings handlers" 26 default y 27 help 28 Enables the use of dynamic settings handlers 29 30config SETTINGS_SAVE_SINGLE_SUBTREE_WITHOUT_MODIFICATION 31 bool "Save single or subtree (without modification) function" 32 help 33 Includes the `settings_save_subtree_or_single_without_modification()` function which 34 allows saving an item that might be a subtree or a single setting, without changing the 35 value. To save a single setting, the setting must support reading and writing of it 36 using the `h_get()` function pointer and must support reading it into a large buffer 37 size. 38 39config SETTINGS_SAVE_SINGLE_SUBTREE_WITHOUT_MODIFICATION_VALUE_SIZE 40 int "Save single or subtree (without modification) maximum value size" 41 default 65 42 depends on SETTINGS_SAVE_SINGLE_SUBTREE_WITHOUT_MODIFICATION 43 help 44 The maximum size of a single setting that can be saved using the 45 `settings_save_subtree_or_single_without_modification()` function - note that this will 46 use stack memory. 47 48# Hidden option to enable encoding length into settings entry 49config SETTINGS_ENCODE_LEN 50 bool 51 52DT_CHOSEN_ZEPHYR_SETTINGS_PARTITION := zephyr,settings-partition 53DT_ZEPHYR_RETENTION := zephyr,retention 54 55config SETTINGS_SUPPORTED_RETENTION 56 bool 57 default y if RETENTION && $(dt_chosen_has_compat,$(DT_CHOSEN_ZEPHYR_SETTINGS_PARTITION),$(DT_ZEPHYR_RETENTION)) 58 59choice SETTINGS_BACKEND 60 prompt "Storage back-end" 61 default SETTINGS_ZMS if ZMS 62 default SETTINGS_NVS if NVS 63 default SETTINGS_FCB if FCB 64 default SETTINGS_FILE if FILE_SYSTEM 65 default SETTINGS_RETENTION if SETTINGS_SUPPORTED_RETENTION 66 default SETTINGS_NONE 67 help 68 Storage back-end to be used by the settings subsystem. 69 70config SETTINGS_ZMS 71 bool "ZMS (Zephyr Memory Storage)" 72 depends on ZMS 73 depends on FLASH_MAP 74 select SYS_HASH_FUNC32 75 help 76 Use ZMS as settings storage backend. 77 78if SETTINGS_ZMS 79 80config SETTINGS_ZMS_LL_CACHE 81 bool "ZMS linked list lookup cache" 82 help 83 Enable ZMS lookup cache for linked list, used to reduce the 84 Settings load time by having most linked list elements already 85 in cache. 86 87config SETTINGS_ZMS_LL_CACHE_SIZE 88 int "ZMS linked list lookup cache size" 89 default 128 90 range 1 $(UINT32_MAX) 91 depends on SETTINGS_ZMS_LL_CACHE 92 help 93 Number of entries in Settings ZMS linked list cache. 94 95endif # SETTINGS_ZMS 96 97config SETTINGS_FCB 98 bool "FCB" 99 depends on FCB 100 help 101 Use FCB as a settings storage back-end. 102 103config SETTINGS_FILE 104 bool "File" 105 depends on FILE_SYSTEM 106 select SETTINGS_ENCODE_LEN 107 help 108 Use a file (on mounted file system) as a settings storage back-end. 109 110config SETTINGS_NVS 111 bool "NVS non-volatile storage support" 112 depends on NVS 113 depends on FLASH_MAP 114 help 115 Enables NVS storage support 116 117if SETTINGS_NVS 118 119config SETTINGS_NVS_NAME_CACHE 120 bool "NVS name lookup cache" 121 help 122 Enable NVS name lookup cache, used to reduce the Settings name 123 lookup time. 124 125config SETTINGS_NVS_NAME_CACHE_SIZE 126 int "NVS name lookup cache size" 127 default 128 128 range 1 $(UINT16_MAX) 129 depends on SETTINGS_NVS_NAME_CACHE 130 help 131 Number of entries in Settings NVS name cache. 132 133endif # SETTINGS_NVS 134 135config SETTINGS_RETENTION 136 bool "Retention storage support" 137 depends on SETTINGS_SUPPORTED_RETENTION 138 help 139 Enables retention storage support (bulk load/save supported only). 140 141config SETTINGS_CUSTOM 142 bool "CUSTOM" 143 help 144 Use a custom settings storage back-end. 145 146config SETTINGS_TFM_PSA 147 bool "TF-M PSA" 148 depends on BUILD_WITH_TFM 149 select EXPERIMENTAL 150 help 151 Enables PSA Settings backend. Intended for use with boards 152 using TF-M which cannot make use of persistent storage otherwise. 153 This backend uses the PSA ITS or PS service to store settings data. 154 Note: This settings backend compacts settings data into as few secure storage nodes as possible. 155 After each save, the entire settings array is written to the secure storage. To avoid excessive 156 latency on saving, settings are saved after a delay using a kernel work item. 157 Note: With this backend, all settings are kept in RAM at all times. The RAM consumption 158 is controlled by the SETTINGS_TFM_PSA_NUM_ENTRIES Kconfig option. 159 160config SETTINGS_NONE 161 bool "NONE" 162 help 163 No storage back-end. 164endchoice 165 166config SETTINGS_FCB_NUM_AREAS 167 int "Number of flash areas used by the settings subsystem" 168 default 8 169 depends on SETTINGS_FCB 170 help 171 Number of areas to allocate in the settings FCB. A smaller number is 172 used if the flash hardware cannot support this value. 173 174config SETTINGS_FCB_MAGIC 175 hex "FCB magic for the settings subsystem" 176 default 0xc0ffeeee 177 depends on SETTINGS_FCB 178 help 179 Magic 32-bit word for to identify valid settings area 180 181config SETTINGS_FILE_PATH 182 string "Default settings file" 183 default "/settings/run" 184 depends on SETTINGS_FILE 185 help 186 Full path to the default settings file. 187 188config SETTINGS_FILE_MAX_LINES 189 int "Compression threshold" 190 default 32 191 depends on SETTINGS_FILE 192 help 193 Limit how many items stored in a file before compressing 194 195config SETTINGS_NVS_SECTOR_SIZE_MULT 196 int "Sector size of the NVS settings area" 197 default 1 198 depends on SETTINGS_NVS 199 help 200 The sector size to use for the NVS settings area as a multiple of 201 FLASH_ERASE_BLOCK_SIZE. 202 203config SETTINGS_NVS_SECTOR_COUNT 204 int "Sector count of the NVS settings area" 205 default 8 206 depends on SETTINGS_NVS 207 help 208 Number of sectors used for the NVS settings area 209 210config SETTINGS_ZMS_SECTOR_SIZE_MULT 211 int "Sector size of the ZMS settings area" 212 default 1 213 depends on SETTINGS_ZMS 214 help 215 The sector size to use for the ZMS settings area as a multiple of 216 FLASH_ERASE_BLOCK_SIZE. 217 218config SETTINGS_ZMS_CUSTOM_SECTOR_COUNT 219 bool "Customize the sector count of the ZMS settings partition" 220 depends on SETTINGS_ZMS 221 help 222 The number of sectors used by default is the maximum value that can 223 fit in the settings storage partition. 224 Enabling this config allows to customize the number of used sectors. 225 226config SETTINGS_ZMS_SECTOR_COUNT 227 int "Sector count of the ZMS settings area" 228 default 8 229 depends on SETTINGS_ZMS && SETTINGS_ZMS_CUSTOM_SECTOR_COUNT 230 help 231 Number of sectors used for the ZMS settings area 232 233config SETTINGS_ZMS_MAX_COLLISIONS_BITS 234 int "number of bits reserved to handle collisions between hash numbers" 235 default 4 236 depends on SETTINGS_ZMS 237 help 238 The maximum number of hash collisions needs to be well sized depending 239 on the data that is going to be stored in ZMS and its hash values 240 241config SETTINGS_ZMS_NO_LL_DELETE 242 bool "Disable deletion of Linked list hashes" 243 help 244 For some applications, the Settings delete operation is too long for 245 ZMS because of the linked list update. 246 As a tradeoff for performance the linked list is not updated. As a 247 result, some nodes will be unused and will occupy some space in the 248 storage. 249 These nodes will be used again when the same Settings element that has 250 been deleted is created again. 251 252config SETTINGS_ZMS_LOAD_SUBTREE_PATH 253 bool "Load only subtree path if provided" 254 help 255 Loads first the key defined by the subtree path. 256 If the callback handler returns a zero value it will 257 continue to look for all the keys under that subtree path. 258 If the callback handler returns a non negative value, it 259 returns immeditaley. 260 261config SETTINGS_SHELL 262 bool "Settings shell" 263 depends on SHELL 264 help 265 Enable shell commands for listing and reading the settings. Note that 266 reading the settings requires quite a big stack buffer, so the stack 267 size of the shell thread may need to be increased to accommodate this 268 feature. 269 270if SETTINGS_TFM_PSA 271 272choice SETTINGS_TFM_PSA_BACKEND 273 prompt "TF-M PSA Settings backend" 274 default SETTINGS_TFM_PSA_BACKEND_ITS 275 help 276 PSA storage option to be used by the PSA settings backend. 277 278config SETTINGS_TFM_PSA_BACKEND_PS 279 bool "PSA Protected Storage (PS)" 280 depends on TFM_PARTITION_PROTECTED_STORAGE 281 help 282 Use PSA Protected Storage as settings storage backend. 283 284config SETTINGS_TFM_PSA_BACKEND_ITS 285 bool "PSA Internal Trusted Storage (ITS)" 286 depends on TFM_PARTITION_INTERNAL_TRUSTED_STORAGE 287 help 288 Use PSA Internal Trusted Storage as settings storage backend. 289 290endchoice # SETTINGS_TFM_PSA_BACKEND 291 292config SETTINGS_TFM_PSA_NUM_ENTRIES 293 int "Maximum number of settings entries" 294 default 10 295 help 296 Configures the maximum number of settings that can be stored simultaneously. 297 Note: This value determines the size of a statically-allocated buffer which holds 298 all the settings entries in RAM at all times. 299 300config SETTINGS_TFM_PSA_LAZY_PERSIST_DELAY_MS 301 int "Milliseconds delay before persisting settings" 302 default 500 303 help 304 PSA Secure Storage APIs may block for a long period of time when writing to flash, which may be 305 unacceptable for time-sensitive events. 306 Data is always persisted to the secure storage using k_work_delayable, instead of happening in 307 the same context as settings_save. This option sets the delay with which the 308 work item is scheduled. The delay is useful in cases where a write may 309 block a time-sensitive event, for example Bluetooth pairing, which requires a 310 sequence of settings writes. 311 312endif # SETTINGS_TFM_PSA 313 314endif # SETTINGS 315