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

Flash FDS initialization failure

When the nRF52 micro-controller is programmed through batch file i.e. nrfjprog utility, the flash fds fails to initialize. Every time, flash fds initialization fails, I have code for soft_Reset.

Initialization fails 3 times and then Flash FDS initializes with success.

After a bit of debugging, I found out fds_register(flash_fds_evt_handler) returns with Success. fds_init() returns with Success.

But the flash_fds_evt_handler() never gets called in the first 3 attempts.

Any insight will be helpful.

I have attached the code snippet below. I am using nRF52932 microcontroller, SDK12.2.0, softdevice s132 v3.0.0

ble_stack_init();

// fds must be initialized after the Softdevice, as it uses the system event to run
flash_fds_init();           
// must wait for fds to initializ
while(!fds_init_complete)   
{
    power_led_red_on();
    nrf_delay_ms(1000);
    NVIC_SystemReset();
}
// use fds to get the auth params (first time though, this Writes the default auth params) 
load_auth_params();
  • I knew about this issue. So, I have already added this. Still, it did not fix the problem.

    I have added code snippet for your reference.

    Following is part of sys_evt_dispatch(uint32_t sys_evt) function call:

    fs_sys_event_handler(sys_evt);
    ble_advertising_on_sys_evt(sys_evt);
    

    Following is part of ble_stack_init() function call: // Register with the SoftDevice handler module for BLE events. err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch); APP_ERROR_CHECK(err_code);

    // Register with the SoftDevice handler module for System events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
  • Could you show how you initialize fds?

    Are you calling fds_init() after fds_register()?

    You won't receive the initialization event otherwise.

  • Following is the sequence of initialization

    ret_code_t flash_fds_init(void)
    {
        ret_code_t ret = fds_register(flash_fds_evt_handler);
    	if (ret != FDS_SUCCESS)
    {
        return ret;
    }
    ret = fds_init();
    if (ret != FDS_SUCCESS)
    {
            return ret;
    }
    return NRF_SUCCESS;
    }
    

    Both return with NRF_SUCCESS.

    Edit: Added code snippet for entire function

  • I found my mistake.

    I was initialing peer manager before soft-device and then custom fds user. This why fds was initialization state when custom fds user was register. I didn't get callback for peer manager or custom fds user.

    Best way to do this is to initialize soft-device first followed by all the fds users.

  • Hello,

    I am having the exact same issue with the aggravating factor of the event handler not reacting to the write operation after FDS becomes available (after the three reboots). The fds_write function returns FDS_SUCCESS but the handler is not triggered. 

    Best way to do this is to initialize soft-device first followed by all the fds users

    Could you please explain how to do this? I'm running the FDS initialization at the top of the main function of my program, and I am a bit lost in the BLE and NRF code.

    I'm running this at a TY51822r3 Switch Science board.

    Thank you in advance for your help!

Related