This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FDS - initializing flag not unset when fds init returns with error (potential bug)

I'm using FDS module from nRF SDK 16.0.0.

Below I'll describe issue which I'm experiencing when trying to initialize FDS twice:

To be sure that my FDS filesystem will be always available I check if fds_init() returns SUCCESS -

if not I'm assuming that  flash area reserved for FDS is corrupted and I format all FDS area sectors (erase).

Than I'm trying to re-initialize fds  (fds_init called again) as result I'm receiving SUCCESS code, but no FDS_EVT_INIT event is send by FDS event handler.

To be clear I've registered callback function to FDS event handler (using fds_register()) before calling fds_init() first time.

Concluding -  I've found that when fds_init() exits with NO_PAGES error (e.g. all pages in FDS area are corrupted) it is not setting m_flags.initializing to false to signalize that initialization is no more in progress - see part of fdsinit() code below:

  //...
    fds_init_opts_t init_opts = pages_init();

    switch (init_opts)
    {
        case NO_PAGES:
        case NO_SWAP:
            ////m_flags.initializing = false; - this line probably should be added here
            return FDS_ERR_NO_PAGES;

        case ALREADY_INSTALLED:
        {
            // No initialization is necessary. Notify the application immediately.
            m_flags.initialized  = true;
            m_flags.initializing = false;
            event_send(&evt_success);
            return NRF_SUCCESS;
        }

        default:
            break;
    }

    //...

Is it a bug or intended behavior?

Br,

Krystian

Parents Reply Children
Related