<?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 page</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67746/fds-no-swap-page</link><description>Hi, 
 I am seeing a bricked device due to the fds_init() returning FDS_ERR_NO_PAGES. After some debugging, I found that all pages are marked as FDS_PAGE_DATA (no FDS_PAGE_SWAP). One of these pages is empty with just FDS_PAGE_TAG_MAGIC and FDS_PAGE_DATA</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Nov 2020 18:49:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67746/fds-no-swap-page" /><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/279582?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 18:49:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a39991b-e4c2-4ba4-9431-050eb58f38f4</guid><dc:creator>Ray Ma</dc:creator><description>&lt;p&gt;I don&amp;#39;t have a way to repro this so I end up implementing the patch, so far it seems working fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/277956?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 07:42:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef1c559c-520c-4b62-aad0-aa1663405114</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Sorry. Yes, you are correct. I was reading from the release notes from SDK17.0.0, but the snippet I pasted in my previous reply was from the section &amp;quot;nRF5 SDK v16.0.0&amp;quot; from the 17.0.0 release notes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you have a reliable way to reproduce this issue? Do you call fds_gc() in your initialize procedure? (during the startup of your application?)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/277893?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 18:50:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d644a4-beea-4682-943e-57aa06968a8b</guid><dc:creator>Ray Ma</dc:creator><description>&lt;p&gt;Hey Edvin,&lt;/p&gt;
&lt;p&gt;I downloaded the SDK17 and turns out the FDS code is exactly the same as in SDK16, looks like the fixes you mentioned are already in SDK16.&lt;/p&gt;
&lt;p&gt;-Ray&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/277732?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 08:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4772a454-eab3-47f4-94e2-5b145b7f2c83</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;In theory it could, but it is hard to say without knowing what causes it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From the release notes in SDK17.0.0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Bug fixes
****************

** Drivers and libraries **

- FDS: fixed two bugs where a power loss at very specific times during garbage
  collection could corrupt the file system, making FDS unable to initialize and return
  FDS_ERR_NO_PAGES on initialization.
- FDS: fixed a bug that prevented using the last word of a flash page to save a record.
...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The first one, which could cause FDS_ERROR_NO_PAGES is the one that can also cause FDS_VIRTUAL_PAGES, depening on which and how many pages that are corrupted so I would recommend porting to at least SDK17 if you experience FDS issues. While you are at it, SDK17.0.0 and SDK17.0.2 are basically the same from an API perspective. And it is almost the same as SDK16 as well, so it will not be much work porting from SDK16 to 17.0.2. It would also be possible to only port the FDS to the latest SDK, if porting is too much work.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The patch I mentioned is not something we have implemented officially, but it would consist of identifying what page that is corrupted, erasing it and run fds_init() again. Alternatively, a soft reset instead of fds_init(). fds_init() will take care of the rest if the page is completely blank, and it doesn&amp;#39;t have a swap page.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/277698?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 02:19:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd506374-12c9-4b16-9605-84bf2a09caac</guid><dc:creator>Ray Ma</dc:creator><description>&lt;p&gt;Hey Edvin,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the response. I am not sure if I can replicate this since I only saw the issue one. Do you think a soft reset or watchdog reset during GC would also trigger this issue?&lt;/p&gt;
&lt;p&gt;Regarding&amp;nbsp;&lt;em&gt;&lt;span&gt;Therefore you should only call fds_gc() when you receive an event saying that it is needed.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/em&gt;&lt;span&gt;which event should I be looking for to start GC?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Another interesting behavior I found out is that If I set&amp;nbsp;FDS_VIRTUAL_PAGES to 4 instead of 3, one of&amp;nbsp;my fds_write will never trigger the fds_event_handler that I&amp;#39;ve registered. I have confirmed there is enough FLASH space for the allocation, and I did see 4 pages been&amp;nbsp;initialized in the fds_stat. I am wondering if this is caused by the internal m_fs_event_handler not getting called(I am not sure how does it get called), any idea or suggestion for me to debug this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Ray&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS no swap page</title><link>https://devzone.nordicsemi.com/thread/277657?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 15:23:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc76e041-bfd1-4dad-9b99-a12dccb9d1d6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Do you have a solid way of replicating this? Have you tried to use SDK17.0.2? There have been some FDS patches in the later SDKs. Try that, and see if it works.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If not, do I would be very interrested in trying to replicate this, if you have a method that can replicate the issue persistently.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One thing that you can check:&lt;/p&gt;
&lt;p&gt;Do not call fds_gc() on startup. This should only be called when the FDS is full. The reason for this is that most cases we have seen when this occurs, it is due to bugs in the fds_gc(), when power is being cut during this process.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you run the device on battery, and it is starting to run out of power, it will switch on and off frequently, and possibly for a long time. If this happens, the risk of bugs are higher. Therefore you should only call fds_gc() when you receive an event saying that it is needed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We have found some causes for this bug, but there may be more, so please let me know if you can recreate it persistently.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This can, however be patched in the case where the missing swap page is empty (almost empty). As long as it doesn&amp;#39;t contain any records, it should be safe to erase the page and manually write the magic page tag and the swap page tag.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>