<?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>Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20810/buttonless-secure-dfu-with-wdt-needs-dfu-twice</link><description>I use nrf51822xxAC，SDK 12.2，Buttonless Secure DFU and WDT in application. 
 I added NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload; to the wait_for_event loop in the DFU to pet the dog. 
 But it needs to DFU twice to let the chip run into application. 
 The same</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Nov 2017 08:34:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20810/buttonless-secure-dfu-with-wdt-needs-dfu-twice" /><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81294?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2017 08:34:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8edc9c7c-6eac-4e03-a79b-6c4e58c53f1d</guid><dc:creator>Guillaume LS</dc:creator><description>&lt;p&gt;You will face the same watchdog issue if you try to update the SoftDevice. I think the same fix has to be applied also in the nrf_dfu_sd_continue_impl() function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81293?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 10:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea5a5bdf-9e3e-46ef-ad44-489c2da4ac71</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Good to know it worked. Thanks for the tip, I will update my blog.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81292?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 07:43:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41733b1a-5609-4650-9424-ea145953590a</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;Thanks a lot. I think you can update your Secure DFU blog with the WTD handle. ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81280?ContentTypeID=1</link><pubDate>Mon, 10 Apr 2017 13:43:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13602951-3749-4b20-96b1-27e827b8c4b0</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;Thanks @Hung Bui. I&amp;#39;ll try your suggestion. And in &lt;a href="https://devzone.nordicsemi.com/question/103138/using-the-dfu-sdk-121-with-a-ble-command-to-jump-to-bootloader-works-every-other-time-with-nordic-connect-app/"&gt;the same question link&lt;/a&gt; @etienne said he solved the issue &amp;quot;by checking and fixing the compiler optimisation flag for the nano_ecc library&amp;quot;. You can see it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81291?ContentTypeID=1</link><pubDate>Mon, 10 Apr 2017 10:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c61cb83-8d7e-4b4f-858b-9d5ceb1d55d9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Kamisen,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry indeed for late response. I was occupied by something else and forgot to get back to the case.&lt;/p&gt;
&lt;p&gt;I checked again, it seems that if we only put the &lt;code&gt;NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;&lt;/code&gt; inside wait_for_event() it&amp;#39;s not enough as after we receive the image and then do swapping it may last longer than 2 seconds ( i tried 10seconds and it worked) and cause a WDT reset. What you can do is to put the &lt;code&gt;NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;&lt;/code&gt; also inside the while loop in nrf_dfu_app_continue() in nrf_dfu_utils.c like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_LOG_INFO(&amp;quot;Enter nrf_dfu_app_continue\r\n&amp;quot;);

    // Copy the application down safely
    do
    {   NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;

        cur_len = (length_left &amp;gt; split_size) ? split_size : length_left;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please try and let me know if it fix the issue for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81290?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2017 14:22:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99b077e6-acaa-4ceb-8532-1d96645b810f</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;@Hung Bui , any progress? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81284?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 15:35:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e32cc33b-7278-49b9-a67e-f49665f3dcfc</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks, it seems that on the first DFU we receives the application, and replaced the old application but haven&amp;#39;t finish the process properly and got a WDT reset.
I will try to reproduce the issue on the SDK v12 and get back to you tomorrow if we manage to make an example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81283?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 15:31:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1280c5b-440e-43b2-9844-5daa0d0d303b</guid><dc:creator>kamisen</dc:creator><description>&lt;ol&gt;
&lt;li&gt;The 51822 chip is running into application(WDT runs too)&lt;/li&gt;
&lt;li&gt;Use iOS nRF toolbox to do DFU with the relating secure Zip file that have application but no bootloader or softdevice in it.(The first time DFU)&lt;/li&gt;
&lt;li&gt;The DFU finish in App but the 51822 chip is still adverting as DfuTarg and run in bootloader proram not in application.&lt;/li&gt;
&lt;li&gt;Use iOS nRF toolbox to do DFU with the same secure Zip file again.(The second time DFU)&lt;/li&gt;
&lt;li&gt;The DFU finish in App and the 51822 chip runs into application.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81286?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 14:33:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d8fb97-00ce-417b-8041-4cc48cfc40e9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Sorry I was testing on SDK v13.&lt;/p&gt;
&lt;p&gt;I still don&amp;#39;t understand what you mean by &amp;quot;DFU still need to do twice&amp;quot; or &amp;quot;twice means that only entering bootloader twice by LED indicating. &amp;quot;
Could you describe what exactly you see ? until which stage the first DFU process get to before it reset ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81285?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 13:47:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:effec784-513d-4127-9dd0-cf707dcd860a</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;Sadly it is still not work for me. After adding the __WFI(); the DFU still needs to do twice. And the first time DFU&amp;#39;s transmit speed is much slower.
And I found my nrf_dfu.c doesn&amp;#39;t have sd_app_evt_wait(); in wait_for_event(). My sdk is 12.2.
I knew it can use timer to feed the dog in bootloader but when I added it, the storage is over the limit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81288?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 13:09:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db60452e-2170-4da7-b1f2-49151923be8d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Kamisen,&lt;/p&gt;
&lt;p&gt;Seems that I found the problem, it was with wait_for_event(). Inside that function we call sd_app_evt_wait();
This call won&amp;#39;t return if you don&amp;#39;t have any application event or receive Softdevice event. If you replace that function with simply __WFI(), then we can be sure the CPU wake up and do WDT feeding every time we have a BLE activity. This worked for me :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void wait_for_event()
{
    // Transport is waiting for event?
    while(true)
    {
	     NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;
        // Can&amp;#39;t be emptied like this because of lack of static variables
        __WFI();

        app_sched_execute();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A better way of doing this is to setup a timer with a timeout smaller than 2 seconds to feed the dog.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81289?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 02:43:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e7163e1-4ae1-4339-a219-393ea5181de8</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;When I debug the bootloader, I found the wait_for_event() can be entered again and agian. So the NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload will be called frequently.
Here is the code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void wait_for_event()
{
    // Transport is waiting for event?
    while(true)
    {
        NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;
        // Can&amp;#39;t be emptied like this because of lack of static variables
        app_sched_execute();
    }
}


void nrf_dfu_wait()
{
    NRF_WDT-&amp;gt;RR[0] = WDT_RR_RR_Reload;
    app_sched_execute();
}


uint32_t nrf_dfu_init()
{
    uint32_t ret_val = NRF_SUCCESS;
    uint32_t enter_bootloader_mode = 0;

    NRF_LOG_INFO(&amp;quot;In real nrf_dfu_init\r\n&amp;quot;);

    nrf_dfu_settings_init();

    // Continue ongoing DFU operations
    // Note that this part does not rely on SoftDevice interaction
    ret_val = nrf_dfu_continue(&amp;amp;enter_bootloader_mode);
    if(ret_val != NRF_SUCCESS)
    {
        NRF_LOG_INFO(&amp;quot;Could not continue DFU operation: 0x%08x\r\n&amp;quot;);
        enter_bootloader_mode = 1;
    }

    // Check if there is a reason to enter DFU mode
    // besides the effect of the continuation
    if (nrf_dfu_enter_check())
    {
        NRF_LOG_INFO(&amp;quot;Application sent bootloader request\n&amp;quot;);
        enter_bootloader_mode = 1;
    }

    if(enter_bootloader_mode != 0 || !nrf_dfu_app_is_valid())
    {
        timers_init();
        scheduler_init();

        // Initializing transports
        ret_val = nrf_dfu_transports_init();
        if (ret_val != NRF_SUCCESS)
        {
            NRF_LOG_INFO(&amp;quot;Could not initalize DFU transport: 0x%08x\r\n&amp;quot;);
            return ret_val;
        }

        (void)nrf_dfu_req_handler_init();

        // This function will never return
        NRF_LOG_INFO(&amp;quot;Waiting for events\r\n&amp;quot;);
        wait_for_event();
        NRF_LOG_INFO(&amp;quot;After waiting for events\r\n&amp;quot;);
    }

    if (nrf_dfu_app_is_valid())
    {
        NRF_LOG_INFO(&amp;quot;Jumping to: 0x%08x\r\n&amp;quot;, MAIN_APPLICATION_START_ADDR);
        nrf_bootloader_app_start(MAIN_APPLICATION_START_ADDR);
    }

    // Should not be reached!
    NRF_LOG_INFO(&amp;quot;After real nrf_dfu_init\r\n&amp;quot;);
    return NRF_SUCCESS;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81282?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2017 12:36:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65399232-e25b-4feb-a6cb-a35a006944df</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It&amp;#39;s pretty clear that the WDT was not fed properly in the bootloader , causing a reset and it enter the DFU bootloader again, this time without WDT and it works. I don&amp;#39;t know how would it enter DFU on the second reset instead of starting application. Should be pretty easy to figure out why, by debugging the bootloader.&lt;/p&gt;
&lt;p&gt;The NRF_DRV_WDT_DEAFULT_CONFIG will set the WDT timeout to 2 seconds which should be long enough. My suggestion for testing is to modify DFU mode , that instead of starting advertising, you can put an infinite loop there and do only one task of feeding the dog. Just to check if it can run normally or a reset would occurs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81281?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2017 02:45:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:743d894e-bc93-4a68-8e6f-47200dfabd35</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;I mean the default value is NRF_DRV_WDT_DEAFULT_CONFIG. DFU twice means that only entering bootloader twice by LED indicating. I think it must be related with WDT but don&amp;#39;t know how to solve it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81287?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2017 14:57:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ad544c5-ae7a-4d64-a347-0ccf3d4940ac</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;What do you mean by default value  ? What exactly was the timeout ?
When you say DFU twice, meaning it actually enter the application twice  or only once and then enter DFU bootloader twice ? I suspect that on the reset after the first trial, it enter bootloader again and this time WDT doesn&amp;#39;t run  ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81279?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2017 13:04:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82eecc80-dd0e-4ead-9d21-129e21e1c3be</guid><dc:creator>kamisen</dc:creator><description>&lt;p&gt;The WDT timeout is default value. I can be ture of feeding dog by a led showing in bootloader or in application. Even feeding not frequently enough, it can not explain the situation that needs DFU twice every time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Buttonless Secure DFU with WDT needs DFU twice</title><link>https://devzone.nordicsemi.com/thread/81278?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2017 11:00:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16ac86c0-52e5-49a4-9d3c-9fc4a3a7d0b3</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;What was your WDT timeout ? Can you be sure you will feed the dog frequently enough to avoid WDT timeout  ? When you enter wait_for_event() then get to CPU sleep mode, it will only wake up and feed the dog when there is BLE event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>