<?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>Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99188/bank-1-dfu-settings-empty-in-bootloader-after-custom-dfu-in-app</link><description>Hi 
 
 I am currently developing a custom dfu in my app in background through LTE communication. I am working with nRF5 SDK 17.0.2, softdevice s132 7.2.0 and nRF52832. 
 I am using the secure bootloader given in the SDK in which I set NRF_BL_DFU_ALLOW_UPDATE_FROM_APP</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 May 2023 09:36:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99188/bank-1-dfu-settings-empty-in-bootloader-after-custom-dfu-in-app" /><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/426052?ContentTypeID=1</link><pubDate>Wed, 17 May 2023 09:36:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:532ece25-accd-4c66-8887-3a83ebaadde6</guid><dc:creator>TOCGRE</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve found the issue : the nrf52832 does not behave the same way with or without debugger attached when logs are enabled in release config.&lt;/p&gt;
&lt;p&gt;As my app size is&amp;nbsp; too big in debug config to do a dual bank DFU, I just added some logs to the release config to make the app smaller and enable dual bank DFU.&lt;/p&gt;
&lt;p&gt;When debugger is attached, the whole dfu process goes on without any error and new bootloader settings are written correctly. However if I attach debugger in the app project the program gets stuck when resetting to the bootloader (I still don&amp;#39;t know why). So the only way I found to debug the bootloader was to wait for the app to make DFU without attaching the debugger and attach the debugger as soons as the bootloader starts (supposedly at the end of the DFU process in app) thanks to a LED blink. But when running app without attaching debugger, I discovered that an error occurs and leads to a reset (which I thought was the one at the end of successful DFU process). Thus the bootloader I&amp;#39;m debugging does not find&amp;nbsp;new firmware info in bootloader settings. Hence the bootloader starts and launches the current app in bank0.&lt;/p&gt;
&lt;p&gt;I found that this error occuring during the in app DFU was due to logs. So I just disabled the logs in release config and copying the bank1 to bank0 and jumping to it works !&lt;/p&gt;
&lt;p&gt;So I don&amp;#39;t know exactly what the problem is but I guess that mayby logs in release&amp;nbsp;are in conflict with dfu modules or share a common area in flash...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Anyway thanks for helping me&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/425904?ContentTypeID=1</link><pubDate>Tue, 16 May 2023 14:07:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0da23038-7073-4719-bfc5-80eb13ab9b5e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="TOCGRE"]What can happen during the reset that can change flash in bootloader settings section ?[/quote]
&lt;p&gt;The reset itself does not cause any writing to flash, so it would have to be either the application before the reset, or the bootloader after. And the bootloader will normally only write to bootloader settings during a DFU update, and if some of the &amp;quot;forbidden&amp;quot; parts have been changed. If this change does not happen during&amp;nbsp;settings_forbidden_parts_copy_from_backup(), perhaps you can experiment with setting a breakpoint (or an eternal loop to prevent&amp;nbsp;further execution or something else) in the bootloader and moving it&amp;nbsp;around to try to narrow down where the data is changed (there are not that many part of the&amp;nbsp;bootloader that writes to the bootloder settings page)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/425377?ContentTypeID=1</link><pubDate>Fri, 12 May 2023 13:51:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a5f92a0-baf5-4060-8667-800e415b30f8</guid><dc:creator>TOCGRE</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After looking closer, the bank_1 part of struct s_dfu_settings is also empty in my app when dfu is completed so I guess it is normal to get it empty from the bootloader after the reset. My problem is just for bank_current.&lt;/p&gt;
&lt;p&gt;As you mention it I confirm that my app successfully copies the init packet to the bootloader settings at the beginning of DFU.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve investigated a little more and the issue does not seem to come from settings_forbidden_parts_copy_from_backup() function in the bootloader.&lt;/p&gt;
&lt;p&gt;I have looked to flash memory closer and at the bootloader settings address 0x0007F000 data are not the same when the app ask for reset and when the bootloader starts. It seems that data is lost in between.&lt;br /&gt;When I call nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_RESET); in the app to reset right after custom DFU, the bank_current value at address&amp;nbsp;0x0007F014 is 0x01. But at the beginning of the bootloader (first instruction of main()) the bank_current value at address 0x0007F014 is 0x00.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;So I was wondering if bootloader settings were considered to be at the same flash memory address in the app and in the bootloader but apparently in both projects m_dfu_settings_buffer[] is set at address 0x0007F000. Thus both projects are reading/writing the same flash area.&lt;/p&gt;
&lt;p&gt;What can happen during the reset that can change flash in bootloader settings section ?&lt;/p&gt;
&lt;p&gt;I also tried to migrate the SDK to 17.1.0 but it does not solve the issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/425231?ContentTypeID=1</link><pubDate>Fri, 12 May 2023 07:22:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d8ef628-0b5a-46b7-81ce-31655c3c46f5</guid><dc:creator>TOCGRE</dc:creator><description>&lt;p&gt;Hi erk1313,&lt;/p&gt;
&lt;p&gt;Thanks for helping ! It seems that ACL registers are only for nrf52840. On nrf52832 only BPROT peripheral is used to protect memory but I did not find any related issue in my case.&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/424075?ContentTypeID=1</link><pubDate>Fri, 05 May 2023 17:30:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ec56ad0-fb61-45e6-a424-218169f3b92b</guid><dc:creator>erk1313</dc:creator><description>&lt;p&gt;Check ACL register for what regions are protected:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1683307809476v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/424046?ContentTypeID=1</link><pubDate>Fri, 05 May 2023 14:22:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a62d320-fe2e-4784-b8a7-4741674879e0</guid><dc:creator>erk1313</dc:creator><description>&lt;p&gt;Could it be that dfu settings is write protected by ACL and though the write operation returns success, it actually failed to write?&lt;/p&gt;
&lt;p&gt;// &amp;lt;i&amp;gt; The settings page may be used to exchange information between the bootloader and the application.&lt;br /&gt;// &amp;lt;i&amp;gt; In that case it should not be protected.&lt;/p&gt;
&lt;p&gt;#ifndef NRF_BL_SETTINGS_PAGE_PROTECT&lt;br /&gt;#define NRF_BL_SETTINGS_PAGE_PROTECT 1&lt;br /&gt;#endif&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bank 1 DFU settings empty in bootloader after custom DFU in app</title><link>https://devzone.nordicsemi.com/thread/423196?ContentTypeID=1</link><pubDate>Tue, 02 May 2023 08:09:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ee62b18-da86-442a-9389-769207b7d66a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]1. Is my understanding of postvalidation ok ? The app dfu modules write the necessary settings to flash for the bootloader to postvalidate, activate and swap bank1 and 0. The postvalidation is made in the bootloader since I set&amp;nbsp;NRF_DFU_IN_APP to 1 in my app sdk_config.h.[/quote]
&lt;p&gt;Yes, this is correct. I do not see all you have done, but I wonder if the issue here&amp;nbsp;is&amp;nbsp;related to the backup and restoration of the bootloader settings page. The current bank is overwritten as you can see from the implementation of&amp;nbsp;settings_forbidden_parts_copy_from_backup() in&amp;nbsp;components/libraries/bootloader/dfu/nrf_dfu_settings.c. Based on what you write, it could be that it would be enough to remove the line that copies the&amp;nbsp;bank_current from the backup. Byt normally the bootloader would handle this for you, as long as you have copied the init packet to the bootloader settings (this is not overwritten by the backup when you have&amp;nbsp;NRF_BL_DFU_ALLOW_UPDATE_FROM_APP enabled).&amp;nbsp; See &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69006/custom-dfu-process/283301"&gt;this post&lt;/a&gt; for more on that.&lt;/p&gt;
[quote user=""]2. Why is s_dfu_settings empty for bank1 in the bootloader ?[/quote]
&lt;p&gt;If&amp;nbsp;s_dfu_settings.bank_1 was not empty before, then the only reason I can think of that would make it empty is if&amp;nbsp;nrf_dfu_bank_invalidate() was called with it&amp;#39;s address. And this happens close to the end of&amp;nbsp;postvalidate().&lt;/p&gt;
[quote user=""]3. More generally, do you have an idea why my bootloader does not copy the new firmware from bank1 to bank0 ?[/quote]
&lt;p&gt;I believe it is because of the backup restoration explained above, which means that the active bank will be reverted to bank0.&lt;/p&gt;
&lt;p&gt;PS: I recommend that you use nRF5 SDK 17.1.0 instead of 17.0.2, as that has support for the latest&amp;nbsp;revision of the nRF52832 (alternatively you must update the &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-MDK"&gt;MDK&lt;/a&gt; as explained in &lt;a href="https://infocenter.nordicsemi.com/pdf/in_142_v1.1.pdf?cp=19_22"&gt;IN142&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>