Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: NVS back-end #12160

Closed
nvlsianpu opened this issue Dec 18, 2018 · 4 comments · Fixed by #17124
Closed

settings: NVS back-end #12160

nvlsianpu opened this issue Dec 18, 2018 · 4 comments · Fixed by #17124

Comments

@nvlsianpu
Copy link
Collaborator

NVS was designed as ultra simple FS which is supposed to store configuration values very effectively.
It will be nice to have back-end for it - it can be used instead of fcb back-end. I expect similar complexity, but much better performance as NVS is traversable in both direction and It is able to take care about entry overriding by the implementation.

@Laczen
Copy link
Collaborator

Laczen commented Jan 3, 2019

@nvlsianpu, implementing a nvs backend for the settings module is not straight forward. It is mainly limited by the fact that settings supposes that data is stored in the backend as a line consisting of "name"=value. This is of course not good for flash usage as each name is stored in flash again when only the value is changing.
Removing this supposition requires quite some work. To allow for easy extension of the settings module I am proposing the following changes:
a. Change the api for set: value_ctx becomes a structure like:

value_ctx {
   size_t len;
   size_t (*read)(char *data, size_t len, void *arg);
   void *arg;
}

In the set routine value_ctx.len and value_ctx.read(&data, len, arg) can be used and arg contains information that is needed by the backend.
b. The save routine checks for duplicate data in the backend
c. The delete routine should also delete all items that have a name starting with the deleted entry name.

@nvlsianpu
Copy link
Collaborator Author

Generally the idea sound good.

b - this mean that you want to move comparation rutine to backends?
c - this sounds like a new feature (which I like).

Laczen added a commit to Laczen/zephyr that referenced this issue Jan 10, 2019
Preparation to fix zephyrproject-rtos#12160 - settings NVS backend

To allow easier integration of backends the settings module has been
reworked. Major changes are:

1. Change to the api: the set() routines are now of the form:
	''set(int argc, char **argv, size_t len, read_cb read, void *cb_arg)''
	the length that was found in the backend in len, and the data
	can be read using: ''read(data, len, cb_arg);
2. The reading of data in the set routines is directly reading in the
backend.
3. The records no longer need to be in the line format
4. The runtime interface has been removed (temporarily). A runtime
backend will be added.
5. Only the fcb backend is supported at the moment
6. A sample is added under samples/subsys/nsettings

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Laczen added a commit to Laczen/zephyr that referenced this issue Jan 14, 2019
Preparation to fix zephyrproject-rtos#12160 - settings NVS backend

To allow easier integration of backends the settings module has been
reworked. Major changes are:

1. Change to the api: the set() routines are now of the form:
	''set(int argc, char **argv, size_t len, read_cb read, void *cb_arg)''
	the length that was found in the backend in len, and the data
	can be read using: ''read(data, len, cb_arg);
2. The reading of data in the set routines is directly reading in the
backend.
3. The records no longer need to be in the line format
4. The runtime interface has been removed (temporarily). A runtime
backend will be added.
5. Only the fcb backend is supported at the moment
6. A sample is added under samples/subsys/nsettings

More rework, changes:
1. Runtime "backend" added
2. Reworked configuration of the module. It now allows the selection of
a default backend (only FCB at the moment). This sets up the settings
src and dst to use the default backend. Other sources could be added by
the application. These sources could also be of different type. The
module can also be configured without a backend, in this case the
application needs to set up the sources and destinations itself.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Laczen added a commit to Laczen/zephyr that referenced this issue Jan 22, 2019
Preparation to fix zephyrproject-rtos#12160 - settings NVS backend

To allow easier integration of backends the settings module has been
reworked. Major changes are:

1. Change to the api: the set() routines are now of the form:
	''set(int argc, char **argv, size_t len, read_cb read, void *cb_arg)''
	the length that was found in the backend in len, and the data
	can be read using: ''read(data, len, cb_arg);
2. The reading of data in the set routines is directly reading in the
backend.
3. The records no longer need to be in the line format
4. The runtime interface has been removed (temporarily). A runtime
backend will be added.
5. Only the fcb backend is supported at the moment
6. A sample is added under samples/subsys/nsettings

More rework, changes:
1. Runtime "backend" added
2. Reworked configuration of the module. It now allows the selection of
a default backend (only FCB at the moment). This sets up the settings
src and dst to use the default backend. Other sources could be added by
the application. These sources could also be of different type. The
module can also be configured without a backend, in this case the
application needs to set up the sources and destinations itself.

More rework, changes:
1. NVS backend added
2. Reworked fcb backend, when loading data from storage only the last
record is used to call set(), deleted records are not calling set().

More rework, changes:
1. File backend added
2. fcb backend: modification to continue set if no set routine was found
for a entry.

More rework, changes:
1. File backend modified to allow easier support for settings with
multiple configuration sources and destinations. Filenames for the file
backend are extended with 0 or 1, the settings system toggles between
these two files.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
@Laczen Laczen removed their assignment Mar 25, 2019
@Laczen
Copy link
Collaborator

Laczen commented Mar 25, 2019

I will no longer work on trying to add a nvs backend for the settings subsystem, so for me this can be closed.

@nvlsianpu nvlsianpu self-assigned this Jun 26, 2019
@nvlsianpu
Copy link
Collaborator Author

This is the early bird of NVS backed By @kapi-no : https://github.com/kapi-no/zephyr/commits/settings_nvs_backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants