<?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>SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18389/sdk12-2-secure-dfu-timeout</link><description>I want to add a timeout to the secure DFU bootloader if I enter it from the application. I found this post here devzone.nordicsemi.com/.../ but unfortuately I can&amp;#39;t use the WDT because my application is using it with a quick timeout. What&amp;#39;s the best way</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Jul 2017 07:19:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18389/sdk12-2-secure-dfu-timeout" /><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70991?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2017 07:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:972caf0d-bb5a-4277-aabf-beed7b6f38d0</guid><dc:creator>dpa</dc:creator><description>&lt;p&gt;The RTc must be disabled also on a DFU complete action?&lt;/p&gt;
&lt;p&gt;i mean if we are disabling it on rtc_handler() and exiting bootloader on normal operations, is there any other place where it should be disabled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70990?ContentTypeID=1</link><pubDate>Fri, 03 Mar 2017 20:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e817325-0a6d-4f2c-8544-387a2da84ba4</guid><dc:creator>Kevin s</dc:creator><description>&lt;p&gt;You also must disable the RTC2 before you exit the bootloader under normal conditions.
Put the commands in the if(nrf_dfu_app_is_valid()) branch of the nrf_dfu_init function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70989?ContentTypeID=1</link><pubDate>Thu, 29 Dec 2016 10:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2d7914d-f7c6-4d43-934b-495cf47dc4ac</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@jeff : It is possible to use the application timer to create a one-shot timer, but there is no app_timer API to reset the counter at a regular interval like the WDT does. You could clear the RTC1 counter by writing to the peripheral registers directly, but that might affect the application scheduler.
Therefore, I opted to use one of the unused RTCs directly where you can clear the counter without worrying about interfering with the application scheduler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70988?ContentTypeID=1</link><pubDate>Thu, 22 Dec 2016 01:15:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7115cfd8-649e-4a57-b79d-3791f97f0adc</guid><dc:creator>WestCoastDaz</dc:creator><description>&lt;p&gt;Jeff,&lt;/p&gt;
&lt;p&gt;It may be due to the fact that it seems like Nordic isn&amp;#39;t using the timers in the DFU bootloader.  Maybe the are going to remove them in a feature version.  Even though there is a call to &lt;code&gt;APP_TIMER_APPSH_INIT&lt;/code&gt; I can find &lt;code&gt;app_timer_create()&lt;/code&gt; or &lt;code&gt;app_timer_start()&lt;/code&gt; used in the bootloader.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70987?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2016 19:23:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:179544fa-db48-4df2-9c2f-86f4c80220c5</guid><dc:creator>Jeff</dc:creator><description>&lt;p&gt;I also want to add a timeout in 12.2.0 secure bootloader.  I see that all the app_timer files and init is already done in the default project.  I just added app_timer_create() and app_timer_start() to timers_init() in nrf_dfu.c and call sd_nvic_SystemReset() when the timer expires.  It seems to work.  Is there a reason to go through all the trouble of using RTC?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70986?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 08:01:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:486f0655-74b5-40ca-9917-65eb3169bc85</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, that is a good suggestion, call &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__nrf__drv__rtc.html#gaf89ea2e1440cbeb59d3b09ba44391c2a"&gt;nrf_drv_rtc_disable&lt;/a&gt; and then &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__nrf__drv__rtc.html#gae755b59399ab32f8bb655cbaa3f49a89"&gt;nrf_drv_rtc_uninit&lt;/a&gt; in the &lt;code&gt;rtc_handler()&lt;/code&gt;. Not sure if you must call &lt;code&gt;nrf_drv_rtc_disable&lt;/code&gt; before calling &lt;code&gt;nrf_drv_rtc_uninit&lt;/code&gt;, but better safe than sorry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70985?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2016 16:43:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7401c21b-de03-4dae-8cad-80e23564a942</guid><dc:creator>WestCoastDaz</dc:creator><description>&lt;p&gt;Bjorn,&lt;/p&gt;
&lt;p&gt;Thanks for your help, you solution is great!  Would it be a good idea to disable the timer in the rtc_handler() before resetting?  I don&amp;#39;t want that timer running in the application code.&lt;/p&gt;
&lt;p&gt;Thanks,
Darren&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70984?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2016 12:55:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a64229b3-dd37-4467-9ebd-8a7702c381a7</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;You are correct, the WDT cannot be re-configured once it has been started. Using the app_timer module for this is overkill, I suggest using the RTC driver instead and then resetting the counter everytime the bootloader is handling a request.&lt;/p&gt;
&lt;p&gt;In order to do this you have to add the following snippets to &lt;code&gt;nrf_dfu.c&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf_drv_rtc.h&amp;quot;
const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(2);

static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
{
    if (int_type == NRF_DRV_RTC_INT_COMPARE0)
    {
        sd_nvic_SystemReset();
    }
}

static void rtc_init()
{
    uint32_t err_code;

    nrf_drv_rtc_config_t rtc_config = NRF_DRV_RTC_DEFAULT_CONFIG;
    // Set counter frequency to 8, given by (32768/(PRESCALER+1)) 
    rtc_config.prescaler = 4095;

    //Initialize the RTC peripheral 
    err_code = nrf_drv_rtc_init(&amp;amp;rtc,&amp;amp;rtc_config, rtc_handler);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_INFO(&amp;quot;Could not initalize RTC: \r\n&amp;quot;);
    }
    
    //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
    err_code = nrf_drv_rtc_cc_set(&amp;amp;rtc, 0, 120*8 , true);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_INFO(&amp;quot;Could not initalize CC value: \r\n&amp;quot;);
    }
    
    nrf_drv_rtc_enable(&amp;amp;rtc);   
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After adding the code above you only have to call &lt;code&gt;rtc_init()&lt;/code&gt; in &lt;code&gt;nrf_dfu_init()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Resetting the counter is done writing directly by triggering the RTC2 Clear task, i.e. call the following snippet in &lt;code&gt;nrf_dfu_req_handler_on_req()&lt;/code&gt; in &lt;code&gt;nrf_dfu_req_handling.c&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Clear the counter variable
NRF_RTC2-&amp;gt;TASKS_CLEAR = 1;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70983?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2016 18:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcd2217e-c0f9-4619-812e-8c6996a04a18</guid><dc:creator>WestCoastDaz</dc:creator><description>&lt;p&gt;Bjorn,&lt;/p&gt;
&lt;p&gt;My understanding is there is no way to disable or change the watchdog once it has be started, correct?  Right now I start the watchdog in my application, and then when I enter the bootloader from the app via DFU, I kick the watchdog in nrf_dfu::wait_for_event.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK12.2 Secure DFU Timeout</title><link>https://devzone.nordicsemi.com/thread/70982?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2016 09:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bf54855-1220-45d6-a675-05e0c419cc74</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are you disabling the WDT before you jump to the bootloader or are you feeding the WDT in the bootloader? If its the first, then I was thinking that you could just reinitialize the WDT in the bootloader with a longer timeout.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>