Commit graph

17 commits

Author SHA1 Message Date
Dominik Ermel 2addfb4696 settings: Deprecate base64 in fs backed settings
Encoding of values with use of base64 has been marked as deprecated and
will be removed in future releases.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-01-16 10:21:29 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Kamil Piszczek ff75620b45 settings: fix Kconfig SETTINGS_NVS dependency
The SETTINGS_NVS now depend on the NVS and FLASH_MAP as it was intended.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-10-11 14:55:24 +02:00
Kamil Piszczek 7866ea615a settings: addding NVS & FS to default settings backend config
Added default backends in the Settings Kconfig for NVS and FS.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-10-11 14:55:24 +02:00
Laczen JMS b9dc69b38e subsys/settings: Remove optional from Kconfig
Kconfig does not set SETTINGS_NONE as default backend (meaning no
backend) because SETTINGS_NONE is optional. There is no difference
between SETTINGS_NONE and SETTINGS_CUSTOM. By removing the optional line
SETTINGS_NONE is selected as default, to use a custom backend
SETTINGS_CUSTOM=y must be set.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2019-10-01 06:20:36 -05:00
Kamil Piszczek 88bb7597b1 settings: adding new nvs backend
Added NVS backend to the Settings subsystem.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-07-10 10:57:22 +02:00
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
François Delawarde 94451b22fc subsys/settings: Allow to register custom backends in settings subsystem
Major changes are:
- Expose settings backend API to enable custom backend support.
- Add a new CONFIG_SETTINGS_CUSTOM backend to allow registering a custom
backend.
- Change api of the handlers h_set() routines to allow for
backend-specific read callbacks.
- Provide a customizable settings_backend_init() routine for custom
backends.
- Move runtime settings support to be its own backend.

Signed-off-by: François Delawarde <fnde@oticon.com>
2019-04-26 11:24:31 +03:00
Andrzej Puzdrowski 4e4048fadf settings: enable logging
This patch introduce logging to settings.

Error in stored data record might occurred in runtime, so
better to switch assertion to error logging.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-03-09 11:07:15 -05:00
Andrzej Puzdrowski 15159dddf1 settings: always uses the storage partition for FCB
It was possible via Kconfig to assign any partition for FCB using
its number. Partitions flash_area_id becomes non predefined
(are auto-generated). So it is possible only to guess which
number will be signed to certain area.

Unfortunately it is not possible to transfer FLASH_AREA_XXX_ID
label via Kconfig.

Patch assigns settings to the storage partition and remove
SETTINGS_FCB_FLASH_AREA property from settings Kconfig.

fixes #13388

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-03-04 16:51:19 +01:00
Andrzej Głąbek 7e3d5142a6 settings: Fix default value of flash area ID in Kconfig
Use the value extracted from DT instead of a hardcoded 4, as it is done
in commit 977b292d8072e4024664cf7293d42e532de64cd4 for tests.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-02-13 11:03:51 -06:00
Andrzej Puzdrowski 63961e36a1 settings: make base64 encoding optional
Thanks to previous commit base64 encoding of the settings
value is not required anymore for NFFS and FCB back-end.

This patch makes encoding an option in case it will be required
in the future.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-12-11 11:22:16 +01:00
Andrzej Puzdrowski 76f8b97871 subsys/settings: stream-style encoding and decoding to/from storage
This patch reworks routines used to store and read the settings data.
Provide stream-style encoding and decoding to/from flash, so the the
API only requires a pointer to binary data, and the settings
implementation takes care of encoding/decoding to/from base64 and
writing/reading to/from flash on the fly. This would eliminate the
need of a separate base64 value buffer on the application-side, thereby
further contributing to the stack footprint reduction.

Above changes allows to remove:
  256-byte value length limitation.
  removing enum settings_type usage so all settings data are treated
  now as a byte array (i.e. what's previously SETTINGS_BYTES)

Introduced routine settings_val_read_cb for read and decode the
settings data from storage inside h_set handler implementations.
h_set settings handler now provide persistent value's context
used along with read routine instead of immediately value.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-12-11 11:22:16 +01:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Ulf Magnusson aa26289458 kconfig: Get rid of leading/trailing whitespace in prompts
Leading/trailing whitespace in prompts requires ugly workarounds in
genrest.py, as e.g. *prompt * is invalid RST. strip() all prompts in
Kconfiglib and get rid of the genrest.py workarounds. Add a warning too.

The Kconfiglib update has some unrelated cleanups and fixes (that won't
affect Zephyr).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-19 09:26:39 +03:00
Johan Hedberg d67009da08 subsys: settings: Fix Kconfig dependencies
If CONFIG_FLASH_PAGE_LAYOUT is not enabled, building the settings code
fails at the linking stage with the following error when FCB is the
backend.

libzephyr.a(settings_init.c.obj): In function `settings_init_fcb':
subsys/settings/src/settings_init.c:62: undefined reference to `flash_area_get_sectors'
collect2: error: ld returned 1 exit status

Also, the File System backend will currently only work with NFFS due
to fs_rename() missing from other File Systems (FAT in particular).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-04-26 16:24:31 +02:00
Andrzej Puzdrowski 94ff339cbf subsys: Add a new settings subsystem
Adapt the MyNewt non-volatile configuration system to become a settings
system in Zephyr.
The original code was modifed in the following ways:

* Renamed from config to settings
* Use the zephyr FCB, FS API, and base64 subsystems
* lltoa like function was added to sources as it was required but not
  included in Zephyr itself.
* The original code was modified to use Zephyr's slist.h as single
  linked list implementation.
* Reworked code which was using strtok_r, added function
  for decoding a string to a s64_t value.
* Thank to the above the settings subsys doesn't require newlibc anymore.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-28 10:44:20 -04:00