zephyr/subsys/settings/Kconfig
Laczen JMS c20ff1150f subsys/settings: Enable handler ROM registration
Add the possibility to register handles to ROM using a new macro
SETTINGS_REGISTER_STATIC(handler), the handler is of type
settings_handler_stat and has to be declared as const:

```
const struct settings_handler_stat test_handler = {
	.name = "test", /* this can also be "ps/data"
	.h_get = get,
	.h_set = set,
	.h_commit = NULL, /* NULL defines can be ommited */
	.h_export = NULL  /* NULL defines can be ommited */
};
SETTINGS_REGISTER_STATIC(test_handler);
```

To maintain support for handlers stored in RAM (dynamic handlers)
`CONFIG_SETTINGS_DYNAMIC_HANDLERS`must be enabled, which is by default.

When registering static handlers there is no check if this handler has
been registered earlier, the latest registered static handler will be
considered valid for any set/get routine, while the commit and export
routines will be executed for both registered handlers.

When a dynamic handler is registered a check is done to see if there was
an earlier registration of the name as a static or dynamic handler
registration will fail.

To get to the lowest possible RAM usage it is advised to set
`CONFIG_SETTINGS_DYNAMIC_HANDLERS=n`.

Updates:

a. Changed usage of RAM to DYNAMIC/dynamic, ROM to STATIC/static
b. Updated settings.h to remove added #if defined()
c. Make static handlers always enabled
d. Corrected error introduced in common-rom.ld.
e. Changed return value of settings_parse_and_lookup to
   settings_handler_stat type to reduce stack usage.
f. Updated the name generated to store a handler item in ROM. It now
   uses the name used to register in combination with the line where
   SETTINGS_REGISTER_STATIC() is called.
g. renamed settings_handler_stat type to settings_handler_static
h. renamed SETTINGS_REGISTER_STATIC to SETTINGS_STATIC_HANDLER_DEFINE()

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2019-06-26 16:31:01 +02:00

114 lines
2.6 KiB
Plaintext

#
# Copyright (c) 2018 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#
menuconfig SETTINGS
bool "Enable settings subsystem with non-volatile storage"
help
The settings subsystem allows its users to serialize and
deserialize state in memory into and from non-volatile memory.
It supports several back-ends to store and load serialized data from
and it can do so atomically for all involved modules.
if SETTINGS
module = SETTINGS
module-str = settings
source "subsys/logging/Kconfig.template.log_config"
endif
config SETTINGS_RUNTIME
bool "runtime storage back-end"
depends on SETTINGS
help
Enables runtime storage back-end.
config SETTINGS_DYNAMIC_HANDLERS
bool "dynamic settings handlers"
depends on SETTINGS
default y
help
Enables the use of dynamic settings handlers
# Hidden option to enable encoding length into settings entry
config SETTINGS_ENCODE_LEN
depends on SETTINGS
bool
config SETTINGS_USE_BASE64
bool "encoding value using base64"
depends on SETTINGS
select BASE64
help
Enables values encoding using Base64.
choice
prompt "Storage back-end"
optional
default SETTINGS_FCB if FCB
default SETTINGS_NONE
depends on SETTINGS
help
Storage back-end to be used by the settings subsystem.
config SETTINGS_FCB
bool "FCB"
depends on FCB
help
Use FCB as a settings storage back-end.
config SETTINGS_FS
bool "File System"
depends on FILE_SYSTEM
select SETTINGS_ENCODE_LEN
help
Use a file system as a settings storage back-end.
config SETTINGS_CUSTOM
bool "CUSTOM"
help
Use a custom settings storage back-end.
config SETTINGS_NONE
bool "NONE"
help
No storage back-end.
endchoice
config SETTINGS_FCB_NUM_AREAS
int "Number of flash areas used by the settings subsystem"
default 8
depends on SETTINGS && SETTINGS_FCB
help
Number of areas to allocate in the settings FCB. A smaller number is
used if the flash hardware cannot support this value.
config SETTINGS_FCB_MAGIC
hex "FCB magic for the settings subsystem"
default 0xc0ffeeee
depends on SETTINGS && SETTINGS_FCB
help
Magic 32-bit word for to identify valid settings area
config SETTINGS_FS_DIR
string "Serialization directory"
default "/settings"
depends on SETTINGS && SETTINGS_FS
help
Directory where the settings data is stored
config SETTINGS_FS_FILE
string "Default settings file"
default "/settings/run"
depends on SETTINGS && SETTINGS_FS
help
Full path to the default settings file.
config SETTINGS_FS_MAX_LINES
int "Compression threshold"
default 32
depends on SETTINGS && SETTINGS_FS
help
Limit how many items stored in a file before compressing