<?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>NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34732/no_swap-error-from-pages_init-when-initializing-fds</link><description>I&amp;#39;m using SDK 14.2, S132, and the NRF52832 
 This problem occurs during the pm_init() function when initializing the soft device. Investigating further has led to the pages_init() function which returns NO_SWAP. 
 If I erase the flash of the device first</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Jan 2019 16:39:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34732/no_swap-error-from-pages_init-when-initializing-fds" /><item><title>RE: NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/thread/163825?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 16:39:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:856104a2-8c98-4a9a-9eda-db1d8df0272c</guid><dc:creator>arthare</dc:creator><description>&lt;p&gt;I fixed this with a similar approach as senorwigglez by wiping out the old data.&amp;nbsp; I did it by modifying fds_init() to wipe out the data and let FDS re-init.&lt;br /&gt;&lt;br /&gt;I added a parameter force_wipe so the caller can demand a clean start.&amp;nbsp; If it encountered NO_PAGES or NO_SWAP, then I changed init_opts to FRESH_INSTALL, and let it continue and wipe out the storage rather than failing by returning FDS_ERR_NO_PAGES.&amp;nbsp; Seems to work so far.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;switch (init_opts)
    {
        case NO_PAGES:
        case NO_SWAP:
            if(eInitMode == FDS_INIT_FORCE_REDO)
            {
                // they want to force a fresh filesystem on us
                init_opts = FRESH_INSTALL;
            }
            else
            {
                return FDS_ERR_NO_PAGES;
            }

        case ALREADY_INSTALLED:
        {
            // No initialization is necessary. Notify the application immediately.
            m_flags.initialized  = true;
            m_flags.initializing = false;
            event_send(&amp;amp;evt_success);
            return FDS_SUCCESS;
        }

        default:
            break;
    }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/thread/134043?ContentTypeID=1</link><pubDate>Wed, 30 May 2018 13:14:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2da03e30-267a-4443-bc0c-addc4d09e0f5</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;Alright so I managed to get something working. It&amp;#39;s not a clean solution by any means but it seems to get the job done. For anyone else that happens to have this problem this is what I did:&lt;/p&gt;
&lt;p&gt;1. Set a flag in the main loop when you want to do a DFU (in my case I had a custom BLE service that I could just write to and set the flag)&lt;/p&gt;
&lt;p&gt;2. Call a function to erase the flash pages used by using sd_flash_page_erase&lt;/p&gt;
&lt;p&gt;2a. I wasn&amp;#39;t able to get NRF_EVT_FLASH_OPERATION_SUCCESS events reliably at all so instead of checking for it, I just implemeneted the following loop:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  ret_code_t err_code;
  uint32_t event_type;

  for (int i = 0; i &amp;lt; FDS_VIRTUAL_PAGES; i++)
  {
    // address will look like 0x6A000 and we just want 0x6A so shift the
    // lower bits out
    err_code = sd_flash_page_erase((m_fs.start_addr &amp;gt;&amp;gt; 12) + i);

    // if sd is busy then wait for another sd event before trying again
    while(err_code == NRF_ERROR_BUSY)
    {
      sd_app_evt_wait();
      err_code = sd_flash_page_erase((m_fs.start_addr &amp;gt;&amp;gt; 12) + i);
    }

    // fetch events in queue until there are none left which should include
    // the flash event
    while(sd_evt_get(&amp;amp;event_type) == NRF_SUCCESS);
  }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now the pages used for FDS should be erased and you can run DFU and the device will initialize normally. I have no idea whether this is a safe way to implement this but again I don&amp;#39;t see any erase way to do it through the FDS API.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/thread/133773?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 09:16:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ff476bb-eeb8-4a18-b84c-5fd9a4793da4</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;pages_init returns 0x02. If I set a breakpoint in the loop when all of the pages are initialized, all them are &amp;quot;FDS_PAGE_DATA&amp;quot; and I believe aren&amp;#39;t able to be garbage collected which is why the initialization fails.&lt;/p&gt;
&lt;p&gt;All four pages (from 0x74000 - 0x77000) show: 0xDEADC0DE 0xF11E01FE&lt;/p&gt;
&lt;p&gt;This makes sense if we&amp;#39;re getting FDS_PAGE_DATA during the page intialization.&lt;/p&gt;
&lt;p&gt;What I want to implement is some way to just deallocate or completely erase the area used by FDS in between DFU updates. I can&amp;#39;t seem to find a straightforward way to do this using only FDS however.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/thread/133745?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 07:36:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:688e6983-f0a7-4ba1-8482-a63184bf10f4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you also check the first and second word on the pages that you try to initialize, before you run pages_init()?&lt;/p&gt;
&lt;p&gt;See&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Flib_fds_format.html&amp;amp;anchor=lib_fds_format_page" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;&amp;nbsp;to see the descriptions. is word0 0xDEADC0DE and word1 either 0xF11E0FF or 0xF11E0FE?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP error from pages_init() when initializing FDS</title><link>https://devzone.nordicsemi.com/thread/133742?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 07:32:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d120f6b-8e1d-4578-a036-7e042bad27dd</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply.&lt;/p&gt;
&lt;p&gt;Can you confirm whether your pages_init() function actually returns NO_SWAP, or if it returns&amp;nbsp;NO_PAGES (since there is no break; between these cases in the switch after pages_init();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you check which one(s) of the returns that are added in&amp;nbsp;static fds_init_opts_t pages_init(void) in fds.c, starting from line 632 (if not modified)?&lt;/p&gt;
&lt;p&gt;The reason I ask is that the return&amp;nbsp;FDS_ERR_NO_PAGES means that pages_init() returns 0x00 or 0x02.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This means that either, the return stays the same as it is initialized in pages_init: ret = NO_PAGES, or it is ret |= PAGE_DATA.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you check what lines that ret is changed inside pages_init()?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>