<?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>Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89526/data-saved-in-flash-fds-that-were-previously-retained-are-erased-during-dfu-on-some-devices</link><description>Hi All, 
 In our product we have noticed that, on a few occasions, some important information that is saved using FDS (in a file with ID: 0x02) are being erased when an OTA update is performed. On most occasions these data are retained after an OTA update</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Sep 2022 07:58:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89526/data-saved-in-flash-fds-that-were-previously-retained-are-erased-during-dfu-on-some-devices" /><item><title>RE: Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/thread/385177?ContentTypeID=1</link><pubDate>Thu, 08 Sep 2022 07:58:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bae272db-c25a-4eb5-a466-281d2cbd901e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Stavros,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think what need to be checked is that if you use exact 50 pages or it&amp;#39;s 51 pages. There is one extra page for the swap page.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please try to match the address where it&amp;#39;s reserved with the address&amp;nbsp;returned from&amp;nbsp;flash_end_addr() function in&amp;nbsp;flash_bounds_set() in fds.c&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Other than that I couldn&amp;#39;t think of any reason why fds didn&amp;#39;t work as it should. If you can reproduce the issue you can try to read a hex dump after the board updated and compare with before it&amp;#39;s updated to see if there is any corruption in the 50 reserved pages.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/thread/385082?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 15:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c51cb97-864e-4d26-95d4-3ef9b29505f3</guid><dc:creator>clockis</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Excuse me for getting back to you with such a big delay but&amp;nbsp;after deciding to apply the proposed fix by modifying the bootloader to reserve 50 pages (the application could not be changed to use only 3 pages as we need the 50 pages). This was indeed fixed using this method. The final solution was&amp;nbsp;applied by performing an OTA update of the Application + Bootloader + SoftDevice so the issue is resolved for the product&amp;#39;s new FW release.&lt;/p&gt;
&lt;p&gt;However on some devices (not every device and not every time) after performing the DFU the&lt;span&gt;&amp;nbsp;&lt;/span&gt;application FW at startup&lt;span&gt;&amp;nbsp;&lt;/span&gt;tries to&amp;nbsp;read important information&lt;span&gt;&amp;nbsp;(in a file with ID: 0x02)&lt;/span&gt;&amp;nbsp;from the FDS but fails because the FDS handler is never called and the FDS appears to be always busy. This causes unexpected behavior and the device ultimately becomes unresponsive (and needs to be erased and flashed again which is not possible for devices that are already sent to clients).&lt;/p&gt;
&lt;p&gt;The only modification in the bootloader was to increase the&amp;nbsp;&lt;span&gt;DFU_APP_DATA_RESERVED define to reserve all of the 50 pages of Flash(FDS) our application uses.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When erasing the device and re-flashing the FW this behavior is not reproducible so it has not been possible for us to debug and probe this behavior further.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What could be the possible reason for this behavior?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/thread/375679?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2022 08:01:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f74382c-2c23-47b1-8756-27d6f3356b14</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Stavros,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;On older SDK&amp;nbsp;&lt;span&gt;NRF_DFU_APP_DATA_AREA_SIZE&amp;nbsp; was called&amp;nbsp;DFU_APP_DATA_RESERVED.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So what I can see here is that the bootloader was configured to reserve only 3 pages for application data (fds).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When in your application you configured 50 pages for fds.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The way fds works is that the data can be stored in any of the 50 pages depends on the amount of records, and the number of updates. So in the case that the fds already use pages that&amp;#39;s outside of the 3 pages reserved by the bootloader, there is a chance that the data be erased by the bootloader when it&amp;#39;s receiving a new image.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My suspicion for the reason why there weren&amp;#39;t any issue for many years is that the fds hasn&amp;#39;t touch the pages at the bottom of the 50 pages you reserved. But when it does and then a DFU update happens , some pages at the bottom of the 50 pages was erased to make space for the new image and hence the issue only appeared now.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The solution for this is to either change the application to use only 3 pages (if you don&amp;#39;t have that much of data) or to update the bootloader to reserver 50 pages. Note that doing that will cause less space for receiving the new image. You would need to do some calculation here.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When you change the application fds setting to use less space, there is a chance that fds may crash due to new configuration, you may need to modify the fds/application code to handle that and reinitialize the flash area (delete all flash pages and lose data).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/thread/375608?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2022 15:07:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d65e3ed7-cc4b-4d16-8898-2917ecad3efe</guid><dc:creator>clockis</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Thank you very much for your immediate response.&lt;/p&gt;
&lt;p&gt;We are currently using SDK 13.0.0.&lt;/p&gt;
&lt;p&gt;I was unable to locate the&amp;nbsp;&lt;span&gt;NRF_DFU_APP_DATA_AREA_SIZE symbol in the bootloader&amp;nbsp;or the application FW.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have however looked into the issue you are describing as it was the first thing that came to mind, given that we are using the FDS.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I found the bootloader symbol shown below which other posts indicate as the parameter that affects which data are preserved after a DFU.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#define DFU_APP_DATA_RESERVED&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CODE_PAGE_SIZE * 3&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:monospace;"&gt;where,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:monospace;"&gt;#define CODE_PAGE_SIZE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t))&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the application FW:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#define FDS_VIRTUAL_PAGES 50&amp;nbsp;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;and,&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#define FDS_VIRTUAL_PAGE_SIZE 1024&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Does this provide the information you requested?&lt;/p&gt;
&lt;p&gt;Would this configuration between application FW and bootloader exhibit the behavior you mention in your previous response?&lt;/p&gt;
&lt;p&gt;Thank you very much for your time and I look forward to hearing from you.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Stavros&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data saved in flash (FDS) that were previously retained are erased during DFU on some devices</title><link>https://devzone.nordicsemi.com/thread/375062?ContentTypeID=1</link><pubDate>Fri, 01 Jul 2022 11:24:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:936f0e51-0458-4255-afa5-4377b58b958b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Stavros,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We would need to look into how you configured the bootloader to preserve data of the application when doing DFU (NRF_DFU_APP_DATA_AREA_SIZE).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By default this space should match with the number of pages used by FDS/fstorage (include the gabage collection page)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please be note that even though the file ID is not change, the location of the file is not fixed to one single page. There is a chance that the issue happens when the file is located at the last page and it might be erased if the configuration for reserved page is not correct.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>