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

Persistent Storage Manager - clearing problem

I am using pstorage library to keep some data in NVM. Should I use some nrf_delay calls while using pstorage_clear()? I am calling pstorage_store from callback function called by pstorage_clear, but when i check (just before pstorage_store) if there are any operations still pending on NVMC, in some situations (I didn't managed to reconstruct these situations) it show that clear is still not finished (pstorage_access_status_get returns 1, only sometimes 0).

I am using SD v6, and SDK 5.2.2

Parents
  • I think the pstorage_store doesn't work when you call it from the pstorage callback function. If you look at pstorage.c you will see that it calls your callback before it decrements the count of pending operations, which means immediately after you call pstorage_store it will forget your storage operation.

    Specifically, the app_notify call on line 501 happens before the subsequent book keeping: m_cmd_queue.count--; m_cmd_queue.rp++;

    It would be nice to get a new version of pstorage.c that does support this.

    So I'm currently doing follow up writes using timers and for the most part that seems to work.

Reply
  • I think the pstorage_store doesn't work when you call it from the pstorage callback function. If you look at pstorage.c you will see that it calls your callback before it decrements the count of pending operations, which means immediately after you call pstorage_store it will forget your storage operation.

    Specifically, the app_notify call on line 501 happens before the subsequent book keeping: m_cmd_queue.count--; m_cmd_queue.rp++;

    It would be nice to get a new version of pstorage.c that does support this.

    So I'm currently doing follow up writes using timers and for the most part that seems to work.

Children
No Data
Related