<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>FDS NO_SWAP error - no swap pages</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56639/fds-no_swap-error---no-swap-pages</link><description>Using SDK 16.0.0 on an nRF 52840 board. 
 Managed to get a board into a state where it had only data pages and no swap pages, and therefore fds_init fails with the NO_SWAP code from pages_init. Saw some other similar tickets, but none of them exactly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Jul 2020 10:55:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56639/fds-no_swap-error---no-swap-pages" /><item><title>RE: FDS NO_SWAP error - no swap pages</title><link>https://devzone.nordicsemi.com/thread/260112?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 10:55:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a02675e5-2c59-4197-9e3d-ed982c17858f</guid><dc:creator>sihan chen</dc:creator><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;Can someone provide me a sample code for rebuild the SWAP page ID,&amp;nbsp; Many thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS NO_SWAP error - no swap pages</title><link>https://devzone.nordicsemi.com/thread/231955?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 15:30:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f0a5e1e-2d86-44b4-a3e0-0e0265a0e48d</guid><dc:creator>sarah_sdw</dc:creator><description>&lt;p&gt;Same error with sdk15.3. resolved with this, thank !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS NO_SWAP error - no swap pages</title><link>https://devzone.nordicsemi.com/thread/229954?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2020 19:56:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d28ff306-a4b3-434d-82c1-32b17537e1e6</guid><dc:creator>aodonnell</dc:creator><description>&lt;p&gt;This worked great, thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS NO_SWAP error - no swap pages</title><link>https://devzone.nordicsemi.com/thread/229861?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2020 13:33:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fcde4df-a5e3-4687-912a-460794c9fd1e</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user=""]Even without knowing the exact cause, it would be great to be able to implement recovery when this error code is returned. I know that means erasing a page and then reinitializing, but I can&amp;#39;t seem to figure out how to erase the correct &amp;quot;page number&amp;quot; using&amp;nbsp;sd_flash_page_erase.[/quote]
&lt;p&gt;&amp;nbsp;You would have to iterate page for page through the flash looking for an empty data page that hasn&amp;#39;t been written to yet. You can do this by making a new function that is similar to the page_can_tag function but starts to check the page data &lt;strong&gt;after&lt;/strong&gt; the page tag:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static bool page_can_tag2(uint32_t const * const p_page_addr)
{
    // This function should consider pages that have only the first half
    // of the fds page tag written as erased (taggable).
    // That is because the tag is two words long, and if the device
    // has rebooted after writing the first word, that would cause
    // the page to be unusable (since undefined and not fully erased).
    // By considering the first word as erased if it contains fds page tag,
    // the page can be re-tagged as necessary.

    if ((p_page_addr[FDS_PAGE_TAG_WORD_0] != FDS_ERASED_WORD) &amp;amp;&amp;amp;
        (p_page_addr[FDS_PAGE_TAG_WORD_0] != FDS_PAGE_TAG_MAGIC))
    {
        return false;
    }

    // Ignore the tag and check if the rest of the page is written or not
    for (uint32_t i = FDS_PAGE_TAG_SIZE; i &amp;lt; FDS_PAGE_SIZE; i++)
    {
        if (*(p_page_addr + i) != FDS_ERASED_WORD)
        {
            return false;
        }
    }

    return true;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can call this function for each data page and see if it has been written to or not. If it hasn&amp;#39;t then you can delete it and reset the chip which will cause the system to promote the page to a swap page.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>