<?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>Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57184/bootloader-wdt-issues</link><description>Hi all, 
 I am using a nRF52840 with SDK v16.0 on SES. I am trying to understand the flow of code in the secure Booloader(/SDK_v16\examples\dfu\secure_bootloader\pca10056_s140_ble\ses\) 
 I have a application with buttonless DFU implemented. Application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Jan 2020 14:32:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57184/bootloader-wdt-issues" /><item><title>RE: Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/thread/231931?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 14:32:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba047834-643c-4cbc-9c58-bbaeb984ad3a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Yes. The bootloader does not start the WDT, so the WDT will not be running when the bootloader runs immediately after a power-on reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/thread/231929?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 14:26:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cca9353f-1abe-4017-bacf-a50ce1491d50</guid><dc:creator>dev_000</dc:creator><description>&lt;p&gt;Thanks. Your answer makes sense when WDT is enabled in application and then resetting into bootloader. My query was about the edge case when lets a power on happens, bootloader wouldnt know that WDT is enabled(as its not). It will come to know only from the second cycle. Am I correct in that assumption? &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/thread/231926?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 14:14:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bdb8adc-5db4-49fb-930e-5697cb848eee</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="dev_000"]How does the bootloader initially know if WDT is enabled in the application when it runs for the first time? Because I am configuring the WDT in the application. Control flow as you mentioned is power-on--&amp;gt; Bootloader --&amp;gt; application.[/quote]
&lt;p&gt;If the application enabled the WDT it is still running after resetting into the bootloader, since the WDT is not reset by a soft reset (see &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_5_7#concept_res_behav"&gt;reset behavior&lt;/a&gt;). Then the bootloader simply checks the WDT registers to see if it is enabled and what the reload counter value is. If it is enabled, the bootloader will start feeding it regularly at an interval determined by the reload counter value. You can see this from the implementation of&amp;nbsp;nrf_bootloader_wdt_init().&lt;/p&gt;
[quote user="dev_000"]One more query, in the SDK 16 while OTA is happening what happens to the WDT? Does it keep feeding the WDT to prevent a reset or is it paused?[/quote]
&lt;p&gt;It is not possible to pause the WDT once it has been started. The bootloader will continue to feed it (which is basically the only thing the bootloader does with the WDT), since the bootloader itself never starts it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/thread/231908?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 13:41:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f70aab4-0354-44a9-bbf7-b23a073e56b2</guid><dc:creator>dev_000</dc:creator><description>&lt;p&gt;Thanks a lot for the clarification regarding SDK 16 and WDT. I will remove the extra code from the bootloader main.c section &lt;br /&gt;Question of why the reset is happening is still strange. &lt;br /&gt;&lt;br /&gt;How does the bootloader initially know if WDT is enabled in the application when it runs for the first time? Because I am configuring the WDT in the application. Control flow as you mentioned is power-on--&amp;gt; Bootloader --&amp;gt; application. &lt;br /&gt;&lt;br /&gt;One more query, in the SDK 16 while OTA is happening what happens to the WDT? Does it keep feeding the WDT to prevent a reset or is it paused?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bootloader WDT Issues</title><link>https://devzone.nordicsemi.com/thread/231902?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 13:24:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cb91404-e81c-4f63-a6c7-cf9ed681bea9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]1. Can anyone help in figuring out what seems to the bug which is causing the device to get reset once?[/quote]
&lt;p&gt;The bootloader in SDK 16 automatically feeds of the watchdog timer without any configuration (see &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__bootloader__wdt.html"&gt;Automated feeding of the watchdog&lt;/a&gt;). Therefore you do not need to do anything in order to prevent the WDT from resetting the device while in the bootloader and should remove the code you have added for that.&lt;/p&gt;
&lt;p&gt;Regarding it only resetting once, that would be because a WDT reset causes the WDT to be disabled. And the bootloader does not enable the WDT, just continues to feed it if allready enabled.&amp;nbsp;But&amp;nbsp;I do not see why this code should cause the WDT to reset. The code you added just looks useless, but not harmfull (since an enabled WDT cannot be reconfigured, only feed/reloaded or timeout and reset).&lt;/p&gt;
[quote user=""]2. Will someone be able to explain the code flow for the bootloader? I mean how does the bootloader transfer the control to app and how does WDT work in between?[/quote]
&lt;p&gt;Regarding the WDT, the bootloader just checks the configuration of the WDT peripheral and uses an app_timer to feed it regularly if it is enabled. You can see all the details by looking at the implementation in &amp;lt;SDK&amp;gt;\components\libraries\bootloader\nrf_bootloader_wdt.c.&lt;/p&gt;
&lt;p&gt;Regarding the general flow of the bootloader that is not really related to the WDT. But it goes like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;At startup, MBR runs and if the bootloader is present, jumps to the bootloader.&lt;/li&gt;
&lt;li&gt;The bootloader checks if it should enter DFU mode by checking if any of the DFU triggers are present, of if there is no valid application.&lt;/li&gt;
&lt;li&gt;If not entering DFU mode, it starts the application. In short, it disables all interrupts, configures the MBR to forward interrupts to the application and jumps to the application.&amp;nbsp;You can refer to&amp;nbsp;nrf_bootloader_app_start() in &amp;lt;SDK&amp;gt;\components\libraries\bootloader\nrf_bootloader_app_start.c and the function it calls to see the details of how it is done.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>