Skip to content

Support object default reload #35

@mcbridejc

Description

@mcbridejc

Objects have built-in default values set at build-time. They also have persisted values, stored into flash.

The "reset app" NMT command should restore the persisted value (if it exists) or the built-in value (if none is persisted).

The "restore defaults" command object, when written, should cause the persisted values to be dropped.

Currently, objects defaults are just stored in their struct initializers, so they are initialized from .data at power on. Going forward, that will have to change, and default values will have to be stored separately.

There are implications for code size here. Many objects do not have defaults, or their defaults are smaller than their size in memory: e.g. a PDO might have a default configuration with 1 mapping ([u32;1]), but has to have storage for the maximum possible number of mappings ([u32; 8]). It's better if only the [u32; 1] goes into flash.

If the object struct is initialized with all zeros, it will go into BSS and no flash will be used to store it's initialization. If any field on the struct is non-zero, then the data for whole struct moves into the DATA section in flash. This means it is advantageous for code size to ensure that objects are zero initialized, and get initialized at run-time. This may mean wrapping objects in MaybeUninit and only allowing access to them via a function which performs the initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions