Unable to make the FDA and FSTORAGE work together with SoftDevice (S140) and FreeRTOS

We are working on a project where we utilize the S140 SoftDevice (on an nRF52840) for a BLE application. We are using the FreeRTOS as real time scheduler for our system.

When we try to perform flash operations (erase and write) through fstorage we experience that the application is resetting and repeats the startup until it reaches the flash operation  again, and again.....

We are using the following code to utilize the flash functionality:

void wait_for_flash_ready( nrf_fstorage_t const * p_fstorage )
{
    /* While fstorage is busy, sleep and wait for an event. */
    while ( nrf_fstorage_is_busy( p_fstorage ) )
    {
        power_manage();
    }
}

static void power_manage( void )
{
#ifdef SOFTDEVICE_PRESENT
    (void) sd_app_evt_wait();
#else
    __WFE();
#endif
}

...
    rc = nrf_fstorage_erase( &fstorage, ( ( starting_page + i )*FW_NRF_FLASH_PAGE_SIZE ), 1, NULL );

    if ( rc )
    {
        return -ERR_IO;
    }
    wait_for_flash_ready( &fstorage );

    rc = nrf_fstorage_write( &fstorage, ( ( starting_page + i )*FW_NRF_FLASH_PAGE_SIZE ), (uint8_t *)page_bkup, FW_NRF_FLASH_PAGE_SIZE, NULL );

    if ( rc )
    {
        return -ERR_IO;
    }

    wait_for_flash_ready( &fstorage );
.....

The code goes into reset when sd_app_evt_wait() is accessed.

The flash operations worked fine before the SoftDevice was introduced utilizing nrf_fstorage_nvcm.

We do also see that the FDS initialization goes well and the 3 virtual pages located at 0xFD000, 0xFE000 and 0xFF000 are flashed with the DEADC0DE and 0xF11E01FE at the start.

Are there any special consideration one need to take into account when combining SoftDevice , FreeRTOS and flash-operations in the application.

Parents
No Data
Reply Children
No Data