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

Question about bond infomation ?

Hi all, I have some question.

When I using mobile to bond with my DK nrf52832. Infomation will save to flash via FDS library.

So, when I delete bond from mobile and rebond with DK. I see old bond infomation not deleted, one byte was changed to 0x00. The new infomation recorded in the next address field. 

when I using function pm_peers_delete() for delete all bond. I see bond info not deleted, only one byte was changed to 0x00. 

So my question, When the data area for bond will be full. And when it full, what is going to happen. I see PM_EVT_STORAGE_FULL, It will delete bond have rank lowest by  pm_peer_delete. So it will not delete follow my explain above. So It can't next bond ? Or I misunderstanding . Pls, explain to me. 

When I connect and disconnect with DK (bonded before). I see it will write some more data to adjacent data area. What is data? 

Thank you !!!

Parents
  • Hello,

    It is correct, as you observe, that when you delete bonding information, which are FDS records, it will not actually be deleted, but marked as "dirty", by setting the record key to 0. The records are still there, physically, since you need to erase whole flash pages in order to clear it. It may not be that the records that are stored on the same flash page is dirty (yet), so that is why the FDS doesn't actually delete them.

    If the peer manager tries to store bonding data, and it fails because pm_peer_rank_highest() returns NRF_ERROR_STORAGE_FULL, it will call pm_handler_flash_clean_on_return(), which will run fds_gc() (garbage collection), which will go through all your records, keep the ones that are still valid, and erase the rest. 

     

    When I connect and disconnect with DK (bonded before). I see it will write some more data to adjacent data area. What is data? 

     This depends. It could be that the peer manager has updated the rank of the peer, or that it stores some connection settings. It is typically not something you have to worry about.

    If you want to read more about the FDS records and garbage collection, you can do so here.

    Best regards,

    Edvin

Reply
  • Hello,

    It is correct, as you observe, that when you delete bonding information, which are FDS records, it will not actually be deleted, but marked as "dirty", by setting the record key to 0. The records are still there, physically, since you need to erase whole flash pages in order to clear it. It may not be that the records that are stored on the same flash page is dirty (yet), so that is why the FDS doesn't actually delete them.

    If the peer manager tries to store bonding data, and it fails because pm_peer_rank_highest() returns NRF_ERROR_STORAGE_FULL, it will call pm_handler_flash_clean_on_return(), which will run fds_gc() (garbage collection), which will go through all your records, keep the ones that are still valid, and erase the rest. 

     

    When I connect and disconnect with DK (bonded before). I see it will write some more data to adjacent data area. What is data? 

     This depends. It could be that the peer manager has updated the rank of the peer, or that it stores some connection settings. It is typically not something you have to worry about.

    If you want to read more about the FDS records and garbage collection, you can do so here.

    Best regards,

    Edvin

Children
  • Hi Edvin,

    As  I observed, if I define FDS_VIRTUAL_PAGES = 3, I will have 2 pages (8K) for stored data, 1 page (4K) for FDS_PAGE_SWAP, when stored full at 2 pages for data, program will run fds_gc and erase all dirty records, and copy valid record to page swap, then continue store record at swap page. When swap page full, fds_gc erase again dirty record and copy valid record to page data. the process continues, I understand that right ? 

    Thank

  • Quite close. As you say, the swap page is used to copy the valid records from a data page to the swap page. When all the valid records from one flash page are copied, the data page will be deleted, and the swap page becomes a data page. The empty page will become the new swap page. Since a data page can't have more records than what would fit into a swap page, the swap page will never be full. Once the swap page contains all the records from a data page, and the old data page is erased and has become the swap page, the rest of the space on the new data page(the old swap page) will be used for storing new records, and the new swap page will be used to swap records for the next data page.

    fds_gc() will iterate through all the data pages, so after fds_gc() you shouldn't have any dirty records.

    Best regards,

    Edvin

Related