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

FDS swap page not found

nRF5 SDK v15.2.0, nRF52840

This issue occurs on reset, most often after cycling power.

There are 4 pages reserved and 4 data pages are found.  Since a swap page isn't found, the initialization of FDS fails.

Changes made to debug this issue:

fds.c line 96 - static fds_page_t m_pages[FDS_DATA_PAGES+1]; // add one for the swap page in the event it isn't recognized as swap

fds_internal_defs - line 112 - Make default values bad state

typedef enum
{
FDS_PAGE_UNDEFINED = 0, // Undefined page type.
FDS_PAGE_DATA, // Page is ready for storage.
FDS_PAGE_SWAP, // Page is reserved for garbage collection.
FDS_PAGE_ERASED, // Page is erased.
} fds_page_type_t;


typedef enum
{
FDS_HEADER_CORRUPT = 0, // Header contains corrupt information, not related to CRC.
FDS_HEADER_VALID, // Valid header.
FDS_HEADER_DIRTY // Header is incomplete, or record has been deleted.
} fds_header_status_t;

What are possible paths for this state to occur? Is it most likely an interrupted garbage collection?

Is there a reason FDS_PAGE_TAG_SWAP and FDS_PAGE_TAG_DATA only differ by one bit?

If there is an empty page, can it be converted to a swap page?  There are 3 empty pages in my case.

/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-9cd8a7416485476db0b604e483852e1c/noSwap.png

  • Hello,

    ahedin25 said:
    static fds_page_t m_pages[3];  // FDS_DATA_PAGES == 3, FDS_VIRTUAL_PAGES == 4

     Of course. I see.

    I suggest that you look at the functions gc_swap_erase() and gc_page_erase() in fds.c. Since you have a data page (not swap), the gc_page_erase() is probably the closest. Alternatively, use nrf_fstorage_erase() directly, like it is done in gc_page_erase(). You may want to avoid the state machine in fds, so maybe avoid setting the state, like it does in nrf_fstorage_erase(), but you do want to wait for the page erase to finish. fs_event_handler should be called when this is done, with the p_evt->id == NRF_FSTORAGE_EVT_ERASE_RESULT, and hopefully p_evt->result == NRF_SUCCESS.

    When this has returned, the page is erased. From here, you can either try to initiate FDS once more (It should repair itself if it has N-1 Data pages and one empty page, where N = FDS_VIRTUAL_PAGES). Alternatively, in case the fds state machine is difficult to deal with, you can run NVIC_SystemReset(); to reset the application, which then will run fds_init() again. Now with the empty page it should repair itself.

    Best regards,

    Edvin

Related