This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

Potential FDS bug?

Hi,

I just found, fds initialization sequence is important for fds_event_handler to be called.

My scenario: nrf52832

SDK 12.2.0

MDK

My sequence to call fds initialisation is as follows:

  1. User fds_register

  2. user fds_init

  3. ble_stack_init

  4. pm_init

  5. pm fds_register

  6. pm_fds_init

BTW, there is fs_sys_event_handler in sys_evt_dispatch().

Then, in my ble_enable() user function, I have to wait the flash ready event, and in user fds_event_handler, I check whether flash writing count is 0 or not. If flash writing count is 0, I will start advertising.

Unfortunately, user fds_event_handler is never called(and event pm fds_event_handler). My flash writing operations before BLE started are quite a lot.

I believe this is a sequence issue. So I updated the sequence a bit:

  1. User fds_register

  2. pm fds_register

  3. user fds_init

  4. ble_stack_init

  5. pm_init

  6. pm_fds_init

I changed peer_data_storage.c code a bit. like this:

ret_code_t pds_init()
{
    ret_code_t ret;

    // Check for re-initialization if debugging.
    NRF_PM_DEBUG_CHECK(!m_module_initialized);

//    ret = fds_register(fds_evt_handler);
//    if (ret != NRF_SUCCESS)
//    {
//        return NRF_ERROR_INTERNAL;
//    }

    ret = fds_init();
    if (ret != NRF_SUCCESS)
    {
        return NRF_ERROR_STORAGE_FULL;
    }

...

And also declare pm fds_event_handler as external so I can set it into fds_register() in step 2.

After that, each event is recieved successfully. However, I do not think it is a good solution, it is ugly since I need to change nordic internal pm code.

May I ask, is there a better solution for this?

By the way, I need to initialise user fds before BLE stack init - I need to determine which mode I am using from flash, eg, central mode or peripheral mode.

Thanks, Vincent

  • Hi,

    fds in SDK 12.2 can't write to flash if the SoftDevice is disabled.

    If fds is not 'installed' it needs the SoftDevice to be enabled to install upon booting the first time. After that first boot, it is possible to initialize fds and read even if the SoftDevice is disabled, but still you won't be able to write.

    It might be possible that you don't need to start advertising right after you enable the stack: you could enable the stack, do all the flash operations you need to (read/write) and determine whether to start advertising or scanning or whatnot at a later point. Enabling the stack and advertising/scanning are different things.

    Regards, emdi

  • Hi emdi,

    Thanks a lot for your confirmation. You are right, after I install fds after softdevice enabled, everything works fine.

    Base on that, I am happy to close it.

    Vincent

Related