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

wait_for_flash_ready(&fstorage)

SDK 15.2

SES

nrf52832

Hello!

I´m trying to store an array in the memory. When the devices starts advertising or it is connected the code loops in wait_for_flash_ready(&fstorage);

for(uint32_t i=0; i<10; i++)
{
    ret_code_t rc= nrf_fstorage_write(&fstorage, my_addr+(i*4), &my_array[i], 4, NULL);
    APP_ERROR_CHECK(rc);

    wait_for_flash_ready(&fstorage);
    NRF_LOG_INFO("Done.");
}

Any idea why this could be happening??

Thanks for the help

Parents
  • Hello,

    I assume you have a nrf_fstorage_sys_evt_handler(), and when there is much BLE activity you may experience NRF_EVT_FLASH_OPERATION_ERROR (operation timeout due to other higher level priorities in the softdevice) instead of NRF_EVT_FLASH_OPERATION_SUCCESS.

    When receiving NRF_EVT_FLASH_OPERATION_ERROR you should retry the nrf_fstorage_write().

    Best regards,
    Kenneth

  • Hey! I tried to check nrf_fstorage_sys_evt_handler() and it actually never enters that function.

    I tested the previous code without the for loop and commenting wait_for_flash_ready. It actually works when i want to write just a part of the array, but when i add the for loop i get a fatal error.

    EDIT: in nrf_fstorage_sd.c i modified the is_busy function 

    static bool is_busy(nrf_fstorage_t const * p_fs)
    {
        UNUSED_PARAMETER(p_fs);
    
        if(m_flags.state == NRF_FSTORAGE_STATE_OP_EXECUTING)
        {
            test_value ++;
        }
    
        return (m_flags.state != NRF_FSTORAGE_STATE_IDLE);
    }

    the code never stops and the test value is always increasing.

Reply
  • Hey! I tried to check nrf_fstorage_sys_evt_handler() and it actually never enters that function.

    I tested the previous code without the for loop and commenting wait_for_flash_ready. It actually works when i want to write just a part of the array, but when i add the for loop i get a fatal error.

    EDIT: in nrf_fstorage_sd.c i modified the is_busy function 

    static bool is_busy(nrf_fstorage_t const * p_fs)
    {
        UNUSED_PARAMETER(p_fs);
    
        if(m_flags.state == NRF_FSTORAGE_STATE_OP_EXECUTING)
        {
            test_value ++;
        }
    
        return (m_flags.state != NRF_FSTORAGE_STATE_IDLE);
    }

    the code never stops and the test value is always increasing.

Children
Related