<?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 returned from pages_init() causes fatal error</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70443/no_swap-returned-from-pages_init-causes-fatal-error</link><description>Hello, 
 My device is failing to initialize because of an error with fds_init(). I am using SDK 14.2 with NRF52840. 
 It seems like the same problem as here , except no answer was ultimately provided. Basically, I have a device that returns FDS_PAGE_DATA</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Apr 2024 14:15:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70443/no_swap-returned-from-pages_init-causes-fatal-error" /><item><title>RE: NO_SWAP returned from pages_init() causes fatal error</title><link>https://devzone.nordicsemi.com/thread/480734?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 14:15:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06f087f5-0f91-41c7-bab6-b5952eb7359f</guid><dc:creator>Karl</dc:creator><description>&lt;p&gt;This issue caused a lot of pain for us using SDK 15.3, because our users devices would practically just become unusable as they would enter a crashloop on startup when the fds section is corrupt. I was finally able to implement a workaround:&lt;/p&gt;
&lt;p&gt;1. on startup, execute fds_init() and see if it returns&amp;nbsp;FDS_ERR_NO_PAGES&lt;br /&gt;2. if it does,&amp;nbsp;&lt;span&gt;initialize a new fstorage instance (to calculate start/end addr, see fds.c -&amp;gt;&amp;nbsp;&lt;/span&gt;flash_bounds_set())&lt;br /&gt;3. also register a new fstorage_evt_handler&lt;br /&gt;4. execute&amp;nbsp;nrf_fstorage_erase to clear the entire FDS flash area that is utilized by the peer manager&lt;br /&gt;5. on successful NRF_FSTORAGE_EVT_ERASE_RESULT event, execute a reboot&lt;/p&gt;
&lt;p&gt;This successfully revived devices with this issue, from unusable state.&amp;nbsp;This&amp;nbsp;comes at the small cost of losing bonding keys and having to pair again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP returned from pages_init() causes fatal error</title><link>https://devzone.nordicsemi.com/thread/289370?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2021 09:58:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7815196-cb27-44b7-bf5e-19f6915d41f4</guid><dc:creator>Edvin</dc:creator><description>[quote user="nordev"]&lt;strong&gt;do you think that one bug fix is enough?&lt;/strong&gt; Or does 17.0 have other bugfixes that are not included in Peter Myrre&amp;#39;s files?&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;There are later bugfixes than the one that Petter mentions in that post, yes.&lt;/p&gt;
&lt;p&gt;The one that I am thinking of is applied to SDK16.0.0 (but if you port to the SDK16 version, you may as well port to the SDK17.0.2 version. They are practically the same).&lt;/p&gt;
&lt;p&gt;Mentioned in the release notes for SDK 16.0.0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;- 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;&amp;nbsp;&lt;/p&gt;
[quote user="nordev"]I did not find fds_record_write() anywhere in my application except the SDK:[/quote]
&lt;p&gt;&amp;nbsp;So then it looks like it is your peer manager that uses the FDS to store bonding data for BLE.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nordev"]And if I clear FDS, does that mean the next time I try connect to my device with the phone, it will ask me to pair again, because the encryption keys will have been deleted? If this is the case, then it does not seem like a big problem to clear FDS.&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;That is correct. You may need to delete the bond information on the phone as well. Go into your bluetooth settings, find the nRF device and click something like &amp;quot;forget device&amp;quot; (depending on the OS).&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: NO_SWAP returned from pages_init() causes fatal error</title><link>https://devzone.nordicsemi.com/thread/289308?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2021 22:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68dc75e0-de67-476b-9c69-301966daa49d</guid><dc:creator>nordev</dc:creator><description>&lt;p&gt;Thank you Edvin.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. I only call fds_gc in the case of&amp;nbsp;PM_EVT_STORAGE_FULL and never otherwise.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Do you think the bug fixes included in the files linked here (by Peter Myrre) will stop the NO_SWAP bug, without needing to upgrade to 17.0 now?&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/29926/bug-in-peer-manager-in-sdk-14-2"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/29926/bug-in-peer-manager-in-sdk-14-2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Before I integrated this bugfix, I would sometimes get a cascade of back to back &amp;quot;garbage collected&amp;quot; events, such that it practically bricked the device. It seemed random, and I could never figure out a specific cause, but I haven&amp;#39;t gotten such a cascade since I added the bug fix.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The device for which the FDS_VIRTUAL_PAGES needed to be incremented to 6 had its issues before I added this bugfix.&amp;nbsp;It is still left with extra data pages, but I am wondering if maybe I don&amp;#39;t have to worry about having to increment FDS_VIRTUAL_PAGES anymore, i.e.,&lt;strong&gt; do you think that one bug fix is enough?&lt;/strong&gt; Or does 17.0 have other bugfixes that are not included in Peter Myrre&amp;#39;s files?&amp;nbsp;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/70443/no_swap-returned-from-pages_init-causes-fatal-error/289219#289219"]&lt;p&gt;If you support BLE bonding, the peer manager will use the FDS pages to store the bonding keys. Your application may also store some custom data, such as configuration settings. If you are unsure whether or not you have implemented this, you probably have not. Search for fds_record_write() in your application to find out what is using it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So as long as your application is not requiring any data in the FDS it should be safe to erase. &lt;/p&gt;[/quote]
&lt;p&gt;I did not find fds_record_write() anywhere in my application except the SDK:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1610661736684v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;...so &lt;strong&gt;the only effect of clearing FDS is that my bond information will be deleted?&lt;/strong&gt; If my central (phone) only requests to pair once (upon first connection), but not upon each subsequent connection, &lt;strong&gt;does that mean I am bonding and not just pairing?&amp;nbsp;&lt;/strong&gt;(Based on the definition I read&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/11939/connecting-bonding-pairing-and-whitelists"&gt;here&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;And if I clear FDS, does that mean the next time I try connect to my device with the phone, it will ask me to pair again, because the encryption keys will have been deleted? If this is the case, then it does not seem like a big problem to clear FDS.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NO_SWAP returned from pages_init() causes fatal error</title><link>https://devzone.nordicsemi.com/thread/289219?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2021 13:30:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aad7dcff-0f42-47f2-b537-3e35b4c4d1cd</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The issue is not that your data pages are filling up. The issue is that there is a bug in FDS that some times, when you loose the power at the wrong point in time can corrupt the FDS pages, causing you to be left with only data pages, and no swap pages.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The solution consists of two things:&lt;/p&gt;
&lt;p&gt;1: Do not (!) run fds_gc() on startup. This should only be called when you get the event NRF_STORAGE_FULL. What we see is that some customers put fds_gc() as part of their init procedure. This will beat up the flash (use up the flash erase/write cycles), and increase the risk of this bug being present.&lt;/p&gt;
&lt;p&gt;2: Port either your whole application, or at least the FDS module to the latest SDK (currently SDK17.0.2). There is at least a few known issues that can lead to this bug surfacing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]My understanding is that the FDS holds the application and its data... &lt;strong&gt;so if I erase it, won&amp;#39;t I be erasing my application and render my device useless? Please correct me if I misunderstand.&amp;nbsp;&lt;/strong&gt;[/quote]
&lt;p&gt;&amp;nbsp;This is not correct. FDS is the flash area used for the application to store it&amp;#39;s custom data. The flash in the nRF Starts at 0x00000000 with the softdevice (if used). After the softdevice is your application. The FDS pages are near the top of the flash. If you have a bootloader, this is located at the very top of the flash (0x00100 0000 and down). The FDS is placed directly below this.&lt;/p&gt;
&lt;p&gt;FDS can be used by different parts of your application. If you support BLE bonding, the peer manager will use the FDS pages to store the bonding keys. Your application may also store some custom data, such as configuration settings. If you are unsure whether or not you have implemented this, you probably have not. Search for fds_record_write() in your application to find out what is using it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So as long as your application is not requiring any data in the FDS it should be safe to erase. When the nRF was programmed the first time, it was probably with an empty FDS flash area, unless something was manually programmed into this address.&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>