<?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 make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20752/how-to-make-sure-that-the-bootloader-starts-in-dfu-mode-if-a-valid-app-is-not-present</link><description>Hi, 
 I am trying to implement a Single Bank DFU over Bluetooth for my nRF51822 (256KB / 16KB RAM) using SDK v7.1 and Softdevice 110. I am using GCC to compile the bootloader and in order to switch from dual bank (which I was doing previously before</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Apr 2017 08:59:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20752/how-to-make-sure-that-the-bootloader-starts-in-dfu-mode-if-a-valid-app-is-not-present" /><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81006?ContentTypeID=1</link><pubDate>Wed, 05 Apr 2017 08:59:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66209be8-8f4b-431b-9437-fdc54d88997e</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Thanks for the heads up. I made the changes and so far the bootloader is working great.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81005?ContentTypeID=1</link><pubDate>Wed, 05 Apr 2017 08:47:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18c89b28-f391-41e6-b660-eb2f18b8230d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Line 341 and 342 only assign the address of the functions into .prepare and .cleared so it can be called later on.&lt;/p&gt;
&lt;p&gt;If you look at my code and look for &lt;code&gt;SINGLEBANK PATCH&lt;/code&gt;you can find that one more thing I added was to delay the notification of BLE_DFU_START_PROCEDURE until we finish clearing the flash. This way we can let the master to wait until we finish clearing bank0. Please have a look at dfu_clear_cb_handler() &lt;a href="https://github.com/NordicSemiconductor/nrf51-dfu-single-bank-ble/blob/master/bootloader%20-%20SingleBankBLE/dfu_transport_ble.c"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81004?ContentTypeID=1</link><pubDate>Wed, 05 Apr 2017 08:26:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31248053-3fcd-4c9d-9470-3422e13bbbd9</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Hi Hung, thanks alot for your continued and patient support. I was able to find the part of the code (at least its equivalent in SDK 7) that you mentioned in the last comment. In &lt;code&gt;dfu_single_bank.c&lt;/code&gt; I always assumed that lines 341 and 342 were actually calling the functions that were being assigned to the function pointers(?) leading me to believe that &lt;code&gt;dfu_cleared_func_app&lt;/code&gt; which sets the bootloader settings bank0 =BANK_INVALID_APP was being called.&lt;/p&gt;
&lt;p&gt;Therefore, now I added &lt;code&gt;m_function.cleared()&lt;/code&gt; in line 367 after &lt;code&gt;m_functions.prepare()&lt;/code&gt; which erases bank 0. This gives me the functionality I desire as a failed DFU will always set the chip to DFU mode. I don&amp;#39;t know how it affects the rest of the bootloader functionality, but for my purposes where I only need to update the app, it is working perfectly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81007?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2017 15:17:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a04eeaf9-7c71-4425-a436-331389bbb09c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Ashkya,&lt;/p&gt;
&lt;p&gt;I guess the issue happens created because of the  port from dual bank to single bank. When we do dual bank, we will not set the application as INVALID when we are receiving the image. This way when there is any issue when transferring the image, we can always revert to the original application. We set it right before we erase the application bank to swap with the new image.&lt;/p&gt;
&lt;p&gt;Where in your code you erase bank 0 to receive the new image ?&lt;/p&gt;
&lt;p&gt;If you have a look &lt;a href="https://github.com/NordicSemiconductor/nrf51-dfu-single-bank-ble/blob/master/bootloader%20-%20SingleBankBLE/dfu_single_bank.c"&gt;here&lt;/a&gt; at line 142 you can see when I erase bank 0 (pstorage_raw_clear) and then write to bootloader setting to mark that the application is invalid (bank0 =BANK_INVALID_APP) with the call             &lt;code&gt;bootloader_dfu_update_process(update_status);&lt;/code&gt;       at line 157&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81003?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2017 09:42:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aff6507b-12e8-4017-8197-705c452597ea</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Hi Hung, I have determined the problem and it is as I suspected. After a failed DFU OTA (I quit the app when the firmware is transferring), I read the bootloader settings from the chip. They were:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;0x0003FC00: 00000001 00000000 00000000 00000000   |................|
0x0003FC10: 00000000 00000000 00000000 00000000   |................|
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From what I understand, the DFU before it starts should set the bank_0 to BANK_INVALID_APP or BANK_ERASED such that if the DFU fails we know that a new application has not been uploaded. But from what we see here, that is not the case. Also, the CRC for the app is not set. If I then erase the page at 0x3fc00 and then write 0xFF(BANK_INVALID_APP) then DFU starts as expected.&lt;/p&gt;
&lt;p&gt;So what I need help with is to isolate the code which sets the bootloader settings at the start of the DFU and make sure it does its job.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/80996?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 07:59:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6332a6be-69ed-41cb-b08a-215ec0c40882</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@ashkya: You may want to have a look at my FAQs &lt;a href="https://devzone.nordicsemi.com/blogs/685/common-faq-on-dfu/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Section A and E is recommended.&lt;/p&gt;
&lt;p&gt;I would suggest you to use GDB to step in to the code and check why the application doesn&amp;#39;t start. Also you can do hex dump and compare before and after a failed DFU to see what changed. Check if the original application image has been wiped out or modified or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81001?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 14:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b39edc4-0a85-4d71-9ce7-de77c7a668e6</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Right now, I am on my last attempt to compile a (working as expected) bootloader from SDK v7. I still have the problem that if the DFU is somehow stopped, the firmware bricks, even when the DFU is in dual bank mode. I am really trying, and failing, to find the relevant code that sets the behavior of the bootloader to avoid this problem. I suspect it has something to do with the assembly code in bootloader_util_reset but cannot be sure. If you could shed some light in this matter, it would be great. Anyway, I will continue with it and see if I can find what is not correct. If I cannot find the problem, I will attempt to use SDK v8 as you suggest.&lt;/p&gt;
&lt;p&gt;Thanks for your answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81000?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 14:23:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1264c2c0-46b2-4c79-958e-2d1af49d818c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;The bootloader in SDK v8.0 might not be compatible to be compiled out of the box with SDK v7. But I don&amp;#39;t think there is any reason it shouldn&amp;#39;t work after some modification to make it works with older Softdevice (softdevice APIs may slightly change).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/80999?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 13:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3adb485-b46c-461e-bd29-7a9cc1cacfcf</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Hi Hung, my application is based on a fork of the nordic SDK v7.1.0 and is based on S110. This is the reason why I have been trying go compile a bootloader using SDKv7. Is it possible to compile a bootloader from a newer SDK that is backwards compatible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/81002?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2017 14:31:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a12f0f53-4899-47fd-8fd9-c1ca999ef1b0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Using the makefile from Blinky example might not be the best idea, as it will have wrong memory configuration (location of the bootloader in flash) and result in that both the bootloader and the softdevice is trying to write to address 0x0000000.&lt;/p&gt;
&lt;p&gt;I would suggest to use original bootloader and only update them with the .c files provided in the example. (and replace dfu_dual_bank.c )&lt;/p&gt;
&lt;p&gt;Why not moving to SDK v8 or later ? Then you don&amp;#39;t need to do much modification.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/80998?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2017 10:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7c196eb-65d2-4f62-a6fe-93d7fc0b5b92</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Also, I guess it is worth mentioning that I am developing in a Mac environment so I have no Keil development environment to debug my builds unfortunately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/80997?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2017 09:51:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba6c06d5-dd36-43a8-b38f-ccfd20a4828c</guid><dc:creator>ashakya</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Firstly, thank you for your answer. I realised what you said is true and simply replacing dfu_dual_bank.c with dfu_single_bank.c was not enough to get the results that I desired. Therefore, I looked at the link you posted and tried to compile the bootloader from your modified repository available &lt;a href="https://github.com/NordicSemiconductor/nrf51-dfu-single-bank-ble"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So what I did was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;copied the GCC Makefile from the Blinky example and added all the files from the above repository to its list of sources and headers&lt;/li&gt;
&lt;li&gt;added a gcc compatible bootloader_util.c&lt;/li&gt;
&lt;li&gt;made small change in main.c to use internal oscillator&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But however when I use srec_cat to merge the final app+sd+bootloader hex, I get the following error&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;srec_cat:
bootloader.hex: 1:
multiple 0x00000000 values (previous = 0xC0, this one = 0x00)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Do you have an idea what is causing this?&lt;/p&gt;
&lt;p&gt;Best
ashakya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure that the Bootloader starts in DFU mode if a valid app is not present?</title><link>https://devzone.nordicsemi.com/thread/80995?ContentTypeID=1</link><pubDate>Fri, 24 Mar 2017 13:12:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57c47116-a783-40af-a2c2-e6e7d483d159</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@ahakya: Porting DFU from dual bank to single bank in SDK v7.1 may requires some more step than just replacing dfu_dual_bank.c with dfu_single_bank.c . I&amp;#39;m not sure if you already did what needed. Please have a look at section J in &lt;a href="https://devzone.nordicsemi.com/blogs/685/common-faq-on-dfu/"&gt;this guide&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I assume that when the process is interrupted, your device didn&amp;#39;t even advertise as &amp;quot;DFUTarg&amp;quot;. And it&amp;#39;s bricked ?
You may want to set your bootloader into debug mode and try to step into the code (or put some UART logging) to check why it doesn&amp;#39;t stay in DFU mode and start advertising as &amp;quot;DFUTarg&amp;quot;. To be able to debug the bootloader, please have a look at section F in the same blog I quoted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>