<?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>How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44256/how-to-fully-erase-app-when-using-bootloader-and-dfu</link><description>We are currently working on a production board where debugging is not easy. The board seems to have gotten into a state where FDS is reporting no available pages. I think it may simply be a matter of garbage collecting that was not being done but unfortunately</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Sep 2021 06:21:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44256/how-to-fully-erase-app-when-using-bootloader-and-dfu" /><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/330148?ContentTypeID=1</link><pubDate>Mon, 20 Sep 2021 06:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa9a77c0-8e13-459e-98f7-eac63fe00df3</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/antedote"&gt;AntEdote&lt;/a&gt;, it&amp;#39;s possible, but we have not implementeded a mechanism to do it, unfortunately. Mainly because it should not be needed in the first place.&lt;/p&gt;
&lt;p&gt;Please create a new ticket and include relevant info such as SDK version and chip variant so we can help come up with a solution that best fits your requirements. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/330101?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 16:28:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f978d37d-900d-4f32-9e23-77fe31fc0f0a</guid><dc:creator>AntEdote</dc:creator><description>&lt;p&gt;I have the same issue now. Is it possible to erase app data from the bootloader now?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/174453?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 07:59:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8008d84-bdb6-4ffd-9eca-59a4258aa850</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Setting&amp;nbsp;&lt;span&gt;NRF_DFU_APP_DATA_AREA_SIZE&amp;nbsp; &amp;gt;=&amp;nbsp;FDS_VIRTUAL_PAGES should prevent this from happening, but&amp;nbsp; I agree that there should be a bootloader option&amp;nbsp;to erase the app data.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/174220?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 10:50:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35f614d4-214f-4952-94ef-3b83f82da9a9</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;I definitely agree. My concern is more about preventing this in the future and recovering if it does happen. I&amp;rsquo;m going to play around with reserving app data area as I wasn&amp;rsquo;t aware that was an option. That being said, I still think the ability to do a &amp;ldquo;full&amp;rdquo; erase from the bootloader (but while preserving the bootloader) would be helpful.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/174168?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 08:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88c297d1-8f15-4159-8ac0-9c200abbd7d6</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I think the problem is that the bootloader has written data into the app data region. If you are able to replicate this again I suggest you readout the entire application region with nrfjprog&amp;nbsp;--memrd&amp;nbsp;&amp;lt;address&amp;gt; --n &amp;lt;bootloader start - app start&amp;gt; &amp;gt; application_region.txt, then compare the memory content with a working device.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173749?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 15:17:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abfb8d35-7cee-457a-8c69-72794e07698b</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;I think the issue in the case where the application has &amp;ldquo;receded&amp;rdquo; between updates is that those pages aren&amp;rsquo;t erased and therefore will still appear to FDS to be application pages (FDS_PAGE_UNDEFINED) and FDS will skip over them. &amp;nbsp;But it&amp;rsquo;s entirely possible I&amp;rsquo;m missing something.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173745?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 14:54:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deeff2bb-1cd4-4269-9e6b-a845ea2ce797</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I will report this as a feature request internally. I was a bit surprised to see that FDS wouldn&amp;#39;t reclaim pages used during DFU. It means that&amp;nbsp;&amp;nbsp;&lt;span&gt;NRF_DFU_APP_DATA_AREA_SIZE&amp;nbsp; must be equal to&amp;nbsp;FDS_VIRTUAL_PAGES in the current implementation.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You may have seen it already, but the fds.c-&amp;gt;flash_bounds_set() can be used to find the flash boundaries for FDS. The function is defined as static, so the module needs to be modified to expose this function to the app. &lt;/span&gt;&lt;span&gt;It will become a bit more complicated if you have a requirement to retain valid data records instead of just deleting everything to recover the device though.&amp;nbsp; Parsing the FDS pages to find which can be freed (either erased or only containing deleted records) could be an option.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173736?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 14:22:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f59abea-a406-4029-8fca-ea1854b95464</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;Yeah, that was my thinking too. Unfortunately after spending quite a bit of time on it I don&amp;rsquo;t think there&amp;rsquo;s a way for the application to erase those pages. The issue is that the pages aren&amp;rsquo;t tagged so the application has no more idea of which ones are valid than does the FDS subsystem. I tried various schemes to work around that but to no avail.&lt;/p&gt;
&lt;p&gt;I may look at adding something to the bootloader but maybe you guys could consider it as a possible future enhancement.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173735?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 14:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a45775fb-4524-487f-a842-9a6b14ab2659</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes, you are right, sorry. I was under the impression that FDS could reclaim flash pages if they didn&amp;#39;t have a valid page tag, but it&amp;#39;s only pages that have been fully erased that can be reclaimed. So I guess the problem was that the staged image (debug version) grew into the app&amp;nbsp;data section, causing FDS initialization to fail on the following startup. The bootloader does not delete data in the swap area after DFU.&amp;nbsp;&lt;/p&gt;
[quote user="jefffhaynes"]It sounds like the answer is to only ever flash our board with a release build. However, because we can’t reclaim that space, if someone were to flash the device in debug mode, it will effectively unrecoverably corrupt the device (assuming we haven’t reserved enough FDS).&amp;nbsp;[/quote]
&lt;p&gt;&lt;span&gt;I think you would have avoided this issue if NRF_DFU_APP_DATA_AREA_SIZE&amp;nbsp; was equal to FDS_VIRTUAL_PAGES, but then you would not have been able to perform a dual banked update for the debug build.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is no existing mechanism in the bootloader to clean up the bank 1 area after an update. I think this mechanism would be more straightforward to add to the application code. E.g., manually erase FDS pages in case initialization fails, then do a reboot. With nrfjprog,&amp;nbsp;you can use --erasepage command to manually erase the flash pages used for FDS.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173700?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 12:36:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f3f66a5-b9a2-4d70-b29d-b58856daa10e</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;I&amp;rsquo;m not following. You say FDS can reclaim pages that don&amp;rsquo;t have a valid tag but that&amp;rsquo;s only true if they&amp;rsquo;re deleted, correct? &amp;nbsp;And it sounds like you&amp;rsquo;re saying that DFU won&amp;rsquo;t delete excess app space if the app shrinks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It sounds like the answer is to only ever flash our board with a release build. However, because we can&amp;rsquo;t reclaim that space, if someone were to flash the device in debug mode, it will effectively unrecoverably corrupt the device (assuming we haven&amp;rsquo;t reserved enough FDS).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So - back to my original question. It would be nice if there was a mechanism via DFU/nrfprog to erase the app + FDS (non-bootloader) space. But it sounds like that is not currently possible, correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173695?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 12:19:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50b94929-5a22-4925-ae23-3cca8d3d71cd</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="jefffhaynes"]I actually ended up cracking open the case and resetting everything but one question I did have that might help me debug in the future was whether the DFU erases the existing app before writing the new one.[/quote]
&lt;p&gt;Only if the bootloader needs this area to fit the new FW image and&amp;nbsp;DFU_APP_DATA_RESERVED/NRF_DFU_APP_DATA_AREA_SIZE symbol in bootloader is set to &amp;#39;0&amp;#39;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;FDS can reclaim pages that don&amp;#39;t have a valid page tag. For this reason it is important to make sure that the app does not grow into the app data region.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173688?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 11:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2d84638-2fca-4f8a-a5f5-6e286027f998</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;I believe what triggered it was switching to release mode but I was confused as to why that would cause it to lose track of the swap. It&amp;rsquo;s possible I did something else but I don&amp;rsquo;t remember what it was.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Allocating more pages to FDS didn&amp;rsquo;t solve the problem (I should point out that we are pushing the limits of the nrf82540 and using a lot of that flash).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I actually ended up cracking open the case and resetting everything but one question I did have that might help me debug in the future was whether the DFU erases the existing app before writing the new one. Meaning, in the case of going from debug to release where the program size was cut in half, will FDS get to reclaim that space or will it detect those pages as unknown and assume they can&amp;rsquo;t be used?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to fully erase app when using bootloader and DFU?</title><link>https://devzone.nordicsemi.com/thread/173647?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 09:52:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb6fd02f-a0aa-4e7c-b30d-7bca2b3745dc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you changed the number of allocated pages to FDS at some point? The only way for this to happen (that I know of) is if you update the app on the device with a new version with fewer pages allocated to FDS (=FDS_VIRTUAL_PAGES in sdk_config.h), and that the SWAP page happens to be outside of the new region at the time of update. SWAP is moved to a different page every time GC is run, which might explain why it&amp;#39;s difficult to replicate.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-7d3e06cdd84a40c0bd58612e1f068b44/Untitled-Diagram.png" /&gt;&lt;/p&gt;
&lt;p&gt;You can dump the memory to confirm if this is why you get the &amp;quot;NO PAGES&amp;quot; error. I provided instructions on how to do that in this thread:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/42676/fds_err_no_pages-returned-when-fds_init-is-called/166492#166492"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/42676/fds_err_no_pages-returned-when-fds_init-is-called/166492#166492&lt;/a&gt;.&amp;nbsp; EDIT: Nevermind, sounds like you can&amp;#39;t attach a debugger to the device. Also,&amp;nbsp;I forgot to answer your question. It is possible to erase the app data region to avoid the &amp;quot;no page&amp;quot; error. You can modify the application code to erase the app data region in case&amp;nbsp;FDS initialization fails, or make a new app with more pages allocated to FDS.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>