<?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>Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67267/watchdog-reset-during-bootloader-dfu</link><description>Hello, 
 I am working on using the open_bootloader with our application and running into a problem. 
 We are using the GP_REG to jump from our application back to the bootloader to perform DFU, Our application uses the watchdog timer upon for monitoring</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 18 Jul 2021 23:33:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67267/watchdog-reset-during-bootloader-dfu" /><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/320577?ContentTypeID=1</link><pubDate>Sun, 18 Jul 2021 23:33:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f2323b1-65ce-4a5e-bc5c-e218ce6110ad</guid><dc:creator>ANewman</dc:creator><description>&lt;p&gt;Hi Omid and Einar&lt;/p&gt;
&lt;p&gt;I wanted to share that I experienced the exact same issue as originally reported by Omid and the fix was as Einar suggested.&lt;/p&gt;
&lt;p&gt;When entering DFU mode from the application, using GPREGRET register, DFU mode would successfully enter but the device would reset shortly thereafter.&lt;/p&gt;
&lt;p&gt;I was able to determine that the reason for the reset was a watchdog timeout. The application starts the watchdog. Temporarily not starting the watchdog in the application would solve the reset problem after entering DFU. I didn&amp;#39;t expect this as the loop_forever() function in the bootloader is supposed to feed the watchdog, and it was clearly not doing so, despite LFCLK running.&lt;/p&gt;
&lt;p&gt;By including the suggested line below in the bootloader main.c to trigger the clock task, the bootloader then starts feeding the watchdog, resolving my issue:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This applies to SDK 17.0.2 on an nRF52840.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/277412?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 13:58:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:981ee15b-dcd7-40d2-aec1-af977f72b1ad</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="OmidAthari"]Is there a way to package my new bootloader so we can get the correct or expected signature?[/quote]
&lt;p&gt;The bootloader that the nRF52840 dongle ships with requires bootloader updates to be signed. (This is to prevent customers from accidentally bricking it). We do not distribute that key, so f you need to replace the bootloader on the dongle you need to do that via SWD the first time, programming it with a bootloader with your own public key. Please note that there are some pitfalls using SWD and the dongle, described in the last part of the &lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial"&gt;nRF52840 dongle programming tutorial&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/277237?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 19:30:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d89a44d9-8e7a-4598-8fe0-edb3473d2b2d</guid><dc:creator>OmidAthari</dc:creator><description>&lt;p&gt;Hi Einar&lt;/p&gt;
&lt;p&gt;Another question related to loading the bootloader.&lt;/p&gt;
&lt;p&gt;I have a nrf52840 Dongle and I need to update its bootloader with the one I just built.&amp;nbsp; I generated a boot loader package successfully using nrfutil as following command:&lt;/p&gt;
&lt;p&gt;nrfutil pkg generate --debug-mode --hw-version 52 --bootloader ./open_bootloader_usb_mbr_pca10059_debug.hex --sd-id 0xCA bootloader.zip&lt;/p&gt;
&lt;p&gt;When I attempt to load this new bootloader I get an error: here is the complete output:&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#339966;"&gt;~/gitlabRepo/ble-fw-sd/dongle ᐅ nrfutil dfu usb-serial -p /dev/ttyACM1 -pkg ./bootloader.zip&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#339966;"&gt;Traceback (most recent call last):&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/bin/nrfutil&amp;quot;, line 33, in &amp;lt;module&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; sys.exit(load_entry_point(&amp;#39;nrfutil==6.1.0&amp;#39;, &amp;#39;console_scripts&amp;#39;, &amp;#39;nrfutil&amp;#39;)())&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 829, in __call__&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; return self.main(*args, **kwargs)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 782, in main&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; rv = self.invoke(ctx)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 1259, in invoke&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; return _process_result(sub_ctx.command.invoke(sub_ctx))&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 1259, in invoke&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; return _process_result(sub_ctx.command.invoke(sub_ctx))&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 1066, in invoke&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; return ctx.invoke(self.callback, **ctx.params)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/usr/lib/python3.8/site-packages/click/core.py&amp;quot;, line 610, in invoke&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; return callback(*args, **kwargs)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/__main__.py&amp;quot;, line 1014, in usb_serial&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, False,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/__main__.py&amp;quot;, line 970, in do_serial&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; dfu.dfu_send_images()&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py&amp;quot;, line 123, in dfu_send_images&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; self._dfu_send_image(self.manifest.bootloader)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py&amp;quot;, line 95, in _dfu_send_image&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; self.dfu_transport.send_init_packet(data)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py&amp;quot;, line 256, in send_init_packet&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; self.__execute()&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py&amp;quot;, line 421, in __execute&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; self.__get_response(DfuTransportSerial.OP_CODE['Execute'])&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; File &amp;quot;/home/nikola/.local/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py&amp;quot;, line 502, in __get_response&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt; raise NordicSemiException(&amp;#39;Extended Error 0x{:02X}: {}&amp;#39;.format(resp[3], data))&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#339966;"&gt;pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x08: The init packet does not contain a signature, but this bootloader requires all updates to have one.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Obviously the current bootloader requires that the new bootloader have a signature.&lt;/p&gt;
&lt;p&gt;Is there a way to package my new bootloader so we can get the correct or expected signature?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/276013?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 16:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a0eb0b3-247e-43b3-850b-910e7cf2a5cf</guid><dc:creator>OmidAthari</dc:creator><description>&lt;p&gt;That was it.&lt;/p&gt;
&lt;p&gt;Thanks for all your help&amp;#39;&lt;/p&gt;
&lt;p&gt;Omid&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/275769?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 07:44:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd75893e-5970-4e8b-b355-e2baa3e65b9c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Omid,&lt;/p&gt;
[quote user="OmidAthari"]When I say the bootloader hangs I mean it seems to remain stuck in the &amp;quot;loop_forever()&amp;quot; function. Nothing else even the led_soft_blink is not happening at that point.[/quote]
&lt;p&gt;I suspect (though I am not sure) that the issue you are seeing is related to a bug in the bootloader, which does not handle a special case with the WDT and LFCLK. If the WDT is active and a soft reset occurs, the WDT will ensure that the LFCLK is kept active. However, the clock is only distributed to the WDT in this case, and not to other &amp;quot;users&amp;quot; of the LFCLK. So this would also explain why you do not see LED blinking etc. In this case the&amp;nbsp;LFCLKSTAT will indicate that the clock is running (which is correct), and that will cause the bootloader to not start it in this code snippet from&amp;nbsp;timer_init() in &amp;lt;SDK 16&amp;gt;\components\libraries\bootloader\nrf_bootloader_dfu_timers.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        if (!nrf_clock_lf_is_running())
        {
            nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Triggering the start task would fix this issue, so this should be rewritten as just:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Do you still see the same issue after doing this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/275731?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 23:54:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9531742c-64b5-4ca0-9b7e-9c828c94621b</guid><dc:creator>OmidAthari</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Yes you understood correctly.&amp;nbsp; I know it seems inexplicable but when I set a breakpoint before the point where the bootloader enters the &amp;quot;loop_forever();&amp;quot; function, and then continue execution in the debugger, then the bootloader works fine and enters the DFU mode and continually feeds the watchdog and all is good.&amp;nbsp; I put some debug code in the loop_forever() function and I can see the debug message streaming on the terminal without&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In contrast if I don&amp;#39;t put a breakpoint at all or if I put a breakpoint inside or after the &amp;quot;loop_forever();&amp;quot; function, then the processor hangs for the WD period and then resets the board.&amp;nbsp; When I say the bootloader hangs I mean it seems to remain stuck in the &amp;quot;loop_forever()&amp;quot; function. Nothing else even the led_soft_blink is not happening at that point. I can see that the debug message in the loop_forever() gets printed several times before the processor gets stuck and no longer prints the message either.&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I know that the reset reason is the WD because the board remains in that stuck state for exactly the WD period.&amp;nbsp; I verified this by changing the WD period several times to different values.&amp;nbsp; Also if I do not start the WD in the application then there is no issue at all and the bootloader behaves perfectly.&lt;/p&gt;
&lt;p&gt;I can demonstrate this for you if you have a way to do screen sharing etc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am in Phoenix Arizona (Mountain Standard Time).&amp;nbsp; If we can setup a web meet of sorts, it would be very helpful.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please let me know if that is a possibility.&lt;/p&gt;
&lt;p&gt;Omid&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/275609?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 12:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fab8a0d-857f-45c1-be45-51889c77ca45</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Omid,&lt;/p&gt;
[quote user="OmidAthari"]HOWEVER if I don&amp;#39;t put a breakpoint there, then the bootloader just hangs for the watchdog period (same as running without debugger) and then the board resets.&amp;nbsp; (This might have nothing to do with anything but putting a breakpoint does make the difference in this case.).&amp;nbsp;&amp;nbsp;[/quote]
&lt;p&gt;Does this mean that if you put a breakpoint (and continue shortly before the WDT times out I assume, unless WDT is configured to pause while debugging), then the WDT does not reset the board? But if not debugging or not setting the breakpoint you get a WDT reset? I am not able to find an explanation for that.&lt;/p&gt;
&lt;p&gt;I am also wondering about the &amp;quot;bootloader just hangs for the watchdog period&amp;quot;. What state is the bootloader in at this time? What is it doing, where is it &amp;quot;hanging&amp;quot;?&lt;/p&gt;
&lt;p&gt;Have you verified that the reset reason is WDT reset, by looking at the RESETREAS register?&lt;/p&gt;
[quote user="OmidAthari"]Can you recommend a setting for the&amp;nbsp;NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS[/quote]
&lt;p&gt;This is not relevant as you are using SDK 16 where it is no longer in use (though unfortunately it is still present in sdk_config.h and documentation).&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/275434?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 20:59:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19278773-f8c1-417a-9100-0be70ef3647b</guid><dc:creator>OmidAthari</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thanks for the help.&amp;nbsp; I am using sdk version 16.0.0 and I do see that it has the watchdog hooks and I see the &amp;quot;nrf_bootloader_wdt_feed()&amp;quot; function called.&lt;/p&gt;
&lt;p&gt;I ran the bootloader in the SES debugger and I see that when the application jumps over to the bootloader for DFU it actually hits the following code in &amp;quot;nrf_bootloader.c line 483&amp;quot; where I placed a breakpoint&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;   if (dfu_enter)
    {
        nrf_bootloader_wdt_init(); // break point here
        scheduler_init();
        dfu_enter_flags_clear();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and then continues to the dfu correctly and continues to feed the watchdog and all seems fine.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff0000;"&gt;HOWEVER if I don&amp;#39;t put a breakpoint there, then the bootloader just hangs for the watchdog period (same as running without debugger) and then the board resets.&amp;nbsp; (This might have nothing to do with anything but putting a breakpoint does make the difference in this case.).&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I tried setting the WD timeout to 5000ms in the application and the I see that the &amp;quot;&lt;span&gt;NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS&amp;quot; is set to 10000ms in the bootloader.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you recommend a setting for the&amp;nbsp;NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your help&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Omid&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog reset during bootloader dfu</title><link>https://devzone.nordicsemi.com/thread/275266?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 07:41:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:797892f0-6413-4718-bc3f-8edd03148223</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Omid,&lt;/p&gt;
[quote user=""]1- Is there a way to disable the watchdog in our application before we attempt the DFU?[/quote]
&lt;p&gt;No. The only way to disable the WDT is by&amp;nbsp;watchdog reset, pin reset or BOR/POR, as you can see from the &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 table&lt;/a&gt;. None of those are typically alternatives when entering DFU mode (at least not in the field). Other then that, the WDT cannot be stopped or configuration changed once it has been started.&lt;/p&gt;
[quote user=""]2- Is there a way to configure the open_bootloader to utilizes the watchdog or do we have to create our own bootloader?[/quote]
&lt;p&gt;Yes, you can and should modify the bootloader to feed the watchdog regularly if you use an old SDK. If you have a fairly recent SDK ( version &amp;gt;= 15.0.0), the bootloader supports this out of the box. It will automatically feed the WDT in that case. However, you must make sure not to have a too short WDT timeout (reload value), as particularly flash operations take a bit of time. You may also need to adjust&amp;nbsp;NRF_BL_WDT_MAX_SCHEDULER_LATENCY_MS in the bootloader&amp;#39;s sdk_config.h.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>