This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS settings subsystem loading order

Hello everyone,

I'm using the NCS/Zephyr settings subsystem to store some application data in non-volatile memory.

The settings structure looks something like this:

app/peripherals
app/config/0

I use the SETTINGS_STATIC_HANDLER_DEFINE to register two set-functions one for <app/peripherals> and one for <app/config>. I would like to have the <app/peripherals> settings before the other stuff but the set-function for <app/config> is always called before the other one.

I was wondering if I could affect the order in which the set-functions are called?

Thanks in advance!

  • You mean to say the order at which you call the SETTINGS_STATIC_HANDLER_DEFINE macros decide which of the set functions is run first?

    No, I mean the order in which I store the settings decides which of the set functions is run first.

    It seems like it doesn't matter what I do with SETTINGS_STATIC_HANDLER_DEFINE macro. I tried the following things:

    • Change the order of the SETTINGS_STATIC_HANDLER_DEFINE macro calls.
    • Change the handler names to aa_handler and ab_handler.
    • Change the key strings.

    Nothing of those things changed the order in which the set functions are run.

    Best regards,
    David

  • Hi David

    Thanks for the input. 

    Unfortunately it seems there is no way to reliably affect the order of the callbacks then. This would be influenced by how the underlying file system reads out the records, which is something that could change if you change the file system, or if the file system is updated later on. 

    I would recommend that you modify your code to take this into account, and ensure that any 'order dependent' code is not run until all the set callbacks have been run (for instance by having all the set callbacks release (give) a semaphore that you can wait for somewhere else in the code). 

    Best regards
    Torbjørn 

Related