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

FDS Memory

SDK 15.1 API 6.1 and i use SES

I removed previous as i was trying ot use fstorage. I switched to fds calls and it seems to work better.

However, does the fds calls take time or work in unison.

Using the flash_fds example, i made a function to return the boot_count. I changed its variable name to stored_keys. I also made a function to update the stored_keys value. I also could not figure out how the delete all function worked so i just manually did delete_record for all the keys i will use. 

If i call the delete_all function, it deletes all the records, and the last thing done in the function call is to set the stored_keys value to 0.

After the first call to delete_all after calling the function to store the new value, i try and print using NRF_LOG_INFO the value of stored keys using the get stored_keys value function, it returns the old stored value. If i had 2 stored keys it would return 2. However, if i run the delete_all function a second time, it returns 0.

is there some timing issues i am running into?

I tried to setup variables like pending, and it seems to not work. This while loop becomes an infinite loop and never releases. 

    m_fds_oper_status.update_pending = true;
    tb_fds_update_mlock_user_count(0);
    
    while(m_fds_oper_status.update_pending){
        sd_app_evt_wait();
    }
     NRF_LOG_INFO("delete_all_process_COUNT: %d", tb_fds_get_mlock_user_count());
    ...
    case FDS_EVT_UPDATE:
        {
            m_fds_oper_status.update_pending = false;
            if (p_evt->result == FDS_SUCCESS)
            {
                if(p_evt->write.record_key == TB_REC_KEY_CONFIG){ 
                    NRF_LOG_INFO("FDS_EVT_UPDATE COUNT: %d", tb_fds_get_mlock_user_count());
                }
            }

If i comment out  while(m_fds_oper_status.update_pending){} it will print out delete_all_process INFO and the FDS_EVT_UPDATE INFO lines. but i need it to process the update before going on.

Parents
  • Hi,

    The fds_file_delete() API is asynchronous (it schedules the flash operation), which means that the record won't be erased until you receive the FDS_EVT_DEL_RECORD event in your registered fds callback. Did you try to wait for this event before you searched for the record? 

    EDIT: sorry, I overlooked the last part of your question showing your FDS callback. It's called in an interrupt context so the while loop will become blocking and prevent the app from receiving new FDS events.  

Reply
  • Hi,

    The fds_file_delete() API is asynchronous (it schedules the flash operation), which means that the record won't be erased until you receive the FDS_EVT_DEL_RECORD event in your registered fds callback. Did you try to wait for this event before you searched for the record? 

    EDIT: sorry, I overlooked the last part of your question showing your FDS callback. It's called in an interrupt context so the while loop will become blocking and prevent the app from receiving new FDS events.  

Children
Related