<?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 is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44578/how-is-the-bootloader-safely-copied-during-a-ble-dfu</link><description>SDK: 15.2.0 
 Reference documentation: http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_bootloader_dfu_banks.html?cp=4_0_0_3_5_1_2 
 Hello, 
 I have extensively researched the SDK documentation and Nordic forums but cannot</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Mar 2019 14:46:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44578/how-is-the-bootloader-safely-copied-during-a-ble-dfu" /><item><title>RE: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/176242?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2019 14:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23ca5968-77b8-40d6-a5da-0624e0acf797</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;No worries! Thanks for your reply. I guess I will have to test out the DFU to know for sure since I am still a bit confused due to the documentation inconsistencies and the difference between single and dual-bank.&lt;/p&gt;
&lt;p&gt;Thanks for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175899?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 11:42:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ec03dfe-b86f-4f2b-adce-1d82336515fb</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Derek,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply (I am out of office).&lt;/p&gt;
[quote user="droberson"]Sorry to keep asking but something doesn&amp;#39;t make sense here. Either the documentation and diagram is completely wrong or you can in fact perform a SoftDevice and Bootloader update in single-bank mode.[/quote]
&lt;p&gt;If your definition of dual bank is on the system as a whole, then I see that you could call this something else. Looking at it from a pure SoftDevice and/or bootloader perspective (which is what is important for not bricking the device), we see it as dual bank for the reason I have descried. It seems from your last post that you have a correct understanding of how this works, so I guess this is mostly a&amp;nbsp;matter of semantics.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175724?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 14:54:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:887ffb8b-5f2c-49e3-ae9c-e88134fa1860</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Any update on this?&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 is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175112?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 16:14:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e972dd2-377f-4f59-b416-b44771f10a6b</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;&lt;strong&gt;&amp;quot;&amp;nbsp;It shows how&amp;nbsp;the SoftDevice and/or bootloader is temporarily placed in the application region.&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this not a single-bank update by definition since the application is deleted to make room for the SoftDevice and bootloader as depicted&amp;nbsp;in the diagram?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;quot;In any case looking at the figure shows clearly how this is done, and that it is dual banked.&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The diagram description actually says it is a single-bank update. Is the description wrong as well? Also, you confirmed that the definition of a single-bank update is that the application is deleted to make room for the update itself. Is this not what the diagram is demonstrating? It clearly shows that the application is deleted to make room for the SoftDevice and bootloader.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1552060733217v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In regards to single-bank: &amp;quot;The down side is that if something goes wrong with the transfer or validation of the image, there is no valid firmware to run. This is OK for the application, as then the bootloader would just enter DFU mode. But if it happens to the bootloader (or SoftDevice if you do DFU over BLE), the device will effectively be bricked. That is why dual banking is required for the bootloader and SoftDevice.&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Lets say we are updating the bootloader in single-bank mode and that this is possible. Based on the diagram above and according to the definition of single-bank updates, the following would occur.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. The application is erased to make room to download the bootloader.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. The bootloader is downloaded into the now free flash memory previously occupied by the application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. The MBR then validates the new bootloader and proceeds to copy and overwrite the old bootloader with the new one.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If the device were to lose power during this time, the new bootloader would still reside in flash and the MBR could restart the copy process until it succeeds. Effectively, operating the same as in the dual-bank scenario. The only difference being that the application was deleted to make room for the new bootloader download.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry to keep asking but something doesn&amp;#39;t make sense here. Either the documentation and diagram is completely wrong or you can in fact perform a SoftDevice and Bootloader update in single-bank mode.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for being patient with me and clarifying the documentation.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Derek&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: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175105?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 15:45:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bee76dfc-02ea-4348-bede-9e3f0d125ffb</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user="droberson"]You state that single bank upgrades are only allowed for the application. However, according to the documentation link below, the SoftDevice and Bootloader can be updated in single bank mode.[/quote]
&lt;p&gt;No, not exactly. It shows how&amp;nbsp;the SoftDevice and/or bootloader is temporarily placed in the application region.&amp;nbsp;But I understand why you read it like this, as there is a formatting issue in the documentation that makes it look like &amp;quot;SoftDevice and bootloader&amp;quot; is a subsection of &amp;quot;Single-bank updates&amp;quot;. In any case looking at the figure shows clearly how this is done, and that it is dual banked.&lt;/p&gt;
[quote user="droberson"]Dual-bank: Copy update into free flash memory without first erasing the application.[/quote]
&lt;p&gt;Yes, correct.&amp;nbsp;Dual bank means essentially: 1) first copy to a temporary location in flash and validate that everything is ok. 2) copy the already validated new firmware to the correct location. As everything is validated, this cannot fail. If a reset occurs at a &amp;quot;bad&amp;quot; time, it is just a matter of trying to copy again, and this is handled automatically.&lt;/p&gt;
[quote user="droberson"]Single-bank: Erase the application to make room for the update, perform the update, and then restore the application.[/quote]
&lt;p&gt;Yes, that is correct. The down side is that if something goes wrong with the transfer or validation of the image, there is no valid firmware to run. This is OK for the application, as then the bootloader would just enter DFU mode. But if it happens to the bootloader (or SoftDevice if you do DFU over BLE), the device will effectively be bricked. That is why dual banking is required for the bootloader and SoftDevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175099?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 15:27:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd77e9ff-8906-439d-83f3-3a4c48c95aea</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Hey Einar,&lt;/p&gt;
&lt;p&gt;Thanks for your response! I see now that the MBR is responsible for the copy process.&lt;/p&gt;
&lt;p&gt;You state that single bank upgrades are only allowed for the application. However, according to the documentation link below, the SoftDevice and Bootloader can be updated in single bank mode.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_bootloader_dfu_banks.html?cp=4_0_0_3_5_1_2_1_0#lib_bootloader_dfu_single_bank_sd"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_bootloader_dfu_banks.html?cp=4_0_0_3_5_1_2_1_0#lib_bootloader_dfu_single_bank_sd&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The above link should take you to the section I am referencing, but if not, refer to section &amp;quot;Single-bank updates&amp;quot; followed by subsection &amp;quot;SoftDevice and bootloader&amp;quot;. Am I missing something here?&lt;/p&gt;
&lt;p&gt;Also, please confirm my understanding of dual-bank vs single-bank updates.&lt;/p&gt;
&lt;p&gt;Dual-bank: Copy update into free flash memory without first erasing the application.&lt;/p&gt;
&lt;p&gt;Single-bank: Erase the application to make room for the update, perform the update, and then restore the application.&lt;/p&gt;
&lt;p&gt;Is my understanding of this correct?&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How is the Bootloader safely copied during a BLE DFU?</title><link>https://devzone.nordicsemi.com/thread/175032?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 13:45:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34ac50be-04b9-4c31-8823-c85c16121851</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Derek,&lt;/p&gt;
&lt;p&gt;1. Safe upgrades of the Bootloader (and SoftDevice) is the responsibility of the MBR, which resides in thr first flash page, starting at address 0.&amp;nbsp;The MBR is a&amp;nbsp;minimal bootloader responsible for copying in place and verifying the bootloader and/or SoftDevice when they are upgraded.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Bootloader (and SoftDevice) upgrades are &lt;em&gt;always&lt;/em&gt; dual bank. If there is not enough available space, the bootloader will erase the application to make room for temporarily storing the new bootloader. Then it will write a command to the MBR settings page (second highest flash page), which is checked by the MBR on every startup. If a command is present indicating that a new bootloader should be copied in place, this is handled by the MBR, which then validates that the copy is successful (identical with the temporary bootloader). If there is a reset at any point in this process before the copying has been successfully performed this will be detected on the next startup and the MBR will attempt to erase the flash and reprogram the bootloader again, until it is successful.&lt;/p&gt;
&lt;p&gt;2. Single bank upgrades are only allowed for the application. It cannot be used for bootloader (or SoftDevice), as it would not have been safe.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>