<?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>Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38048/bug-in-how-bootloader-treats-gpregret</link><description>I suspect this is related to https://devzone.nordicsemi.com/f/nordic-q-a/36601/gpregret-and-nrf_bootloader-c-evolution-proposal (Case ID: 211047) 
 In nrf_bootloader_info.h you find this: 
 #define BOOTLOADER_DFU_GPREGRET_MASK ( 0xB0 ) /**&amp;lt; Magic pattern</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 13 Jun 2021 05:50:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38048/bug-in-how-bootloader-treats-gpregret" /><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/315012?ContentTypeID=1</link><pubDate>Sun, 13 Jun 2021 05:50:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9da22c84-c5a9-4ee8-b9eb-d1dcd26a0a00</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;thanks &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/314827?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2021 07:16:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c5ae161-b57a-4bf3-95e5-45901a35845d</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsds_s132%2FSDS%2Fs1xx%2Fsd_resource_reqs%2Fhw_block_interrupt_vector.html"&gt;POWER peripheral is restricted&lt;/a&gt; when the SoftDevice is enabled, so then you must use the SoftDevice API instead of accessing the registers directly.&lt;/p&gt;
&lt;p&gt;For setting GPREGRET, see &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v7.2.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga62737e6515d380aa3eeba6582d061592"&gt;sd_power_gpregret_set()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/314709?ContentTypeID=1</link><pubDate>Thu, 10 Jun 2021 12:59:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e9fa14c-01f8-43e2-b97f-5312737ce8b2</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi David&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regardless of the bootloader issue entering DFU mode, in my application, when i use this command:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_POWER-&amp;gt;GPREGRET = 0xB1;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i get asserted,&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1623329867915v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;any idea why ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/277934?ContentTypeID=1</link><pubDate>Sun, 01 Nov 2020 16:36:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b5dbd14-8183-4d72-a86a-0a4873d6d525</guid><dc:creator>Pete W</dc:creator><description>&lt;p&gt;Ah, I get it now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/277933?ContentTypeID=1</link><pubDate>Sun, 01 Nov 2020 16:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ec2b665-fba0-4946-8981-4d3810a90b7d</guid><dc:creator>Pete W</dc:creator><description>&lt;p&gt;Caught me out as well.&lt;/p&gt;
&lt;p&gt;Surely it should just simply use the start bit mask (0x01), i.e.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &amp;amp;&amp;amp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(nrf_power_gpregret_get() &amp;amp; BOOTLOADER_DFU_START_BIT_MASK)&lt;br /&gt; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;NRF_LOG_DEBUG(&amp;quot;DFU mode requested via GPREGRET.&amp;quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;br /&gt; }&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/271833?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 14:06:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f4f0145-78f9-486a-8ce2-490f3721480a</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;+1 noted.&lt;/p&gt;
&lt;p&gt;Can be fixed by changing nrf_bootloader.c lines 377-382:&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &amp;amp;&amp;amp;
       (nrf_power_gpregret_get() &amp;amp; BOOTLOADER_DFU_START))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode requested via GPREGRET.&amp;quot;);
        return true;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To this:&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &amp;amp;&amp;amp;
       (nrf_power_gpregret_get() &amp;amp; BOOTLOADER_DFU_GPREGRET_MASK) == BOOTLOADER_DFU_GPREGRET)
            &amp;amp;&amp;amp; (nrf_power_gpregret_get() &amp;amp; BOOTLOADER_DFU_START_BIT_MASK))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode requested via GPREGRET.&amp;quot;);
        return true;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/271433?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 06:53:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ba0fd96-9ddb-4fae-9c26-d6cbb86cb226</guid><dc:creator>David Meiklejohn</dc:creator><description>&lt;p&gt;Just a &amp;#39;+1&amp;#39; on this: I&amp;#39;m a bit annoyed that I spent half an afternoon debugging what I thought was an error in my code, to find that my bootloader was incorrectly entering DFU mode due to this bug.&lt;/p&gt;
&lt;p&gt;I do understand that bugs happen - just a bit concerned that this was first reported more than 2 years ago, and still persists in SDK17, even though it&amp;#39;s really easy to fix.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll need to make my own custom copy of nrfbootloader.c to fix this.&amp;nbsp; Oh well...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/265833?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2020 16:46:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4c7fa04-96f7-4faa-ab6a-bef34c7722e0</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You are entirely correct. In this location, the same approach to testing magic word + signal should be used as is correctly done in crc_on_valid_app_required() and in dfu_enter_flags_clear() in the same file. I have notified the SDK team.&lt;/p&gt;
&lt;p&gt;Thank you for the reports.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/265428?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 00:08:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae343c66-20fa-484b-9e44-59659eee6460</guid><dc:creator>Richard D.</dc:creator><description>&lt;p&gt;The bug still exists in SDK 17.0.&lt;/p&gt;
&lt;p&gt;nrf_bootloader.c, line #377&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &amp;amp;&amp;amp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (nrf_power_gpregret_get() &amp;amp; BOOTLOADER_DFU_START))&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/219342?ContentTypeID=1</link><pubDate>Fri, 08 Nov 2019 20:51:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb3471be-29a3-46ef-be8e-ed439a1528ca</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;We are using SDKv15.3.0 and I found this error accidentally.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We wanted to put a value in GPREGRET that the bootloader would ignore so the application would run and read the GPREGRET register and restore an operating mode that was active before reset.&lt;/p&gt;
&lt;p&gt;We found that almost any combination of bits &lt;span&gt;GPREGRET&amp;nbsp;&lt;/span&gt;caused the device to enter boot-mode after reset, but could only exit after a power off/on. I found the fault due to the bitmask operation, and corrected it as described above.&lt;/p&gt;
&lt;p&gt;If we had deployed this code on on devices in the field it would have been impossible to cause them to exit boot-loader mode once the value in GPREGET doesn&amp;#39;t have the bits set according to the bitmask.&amp;nbsp; We deploy hundreds of devices in remote sites.&amp;nbsp; This would have been a major problem for us.&lt;/p&gt;
&lt;p&gt;This is a typical case where it works correctly when tested in the way it&amp;#39;s supposed to work.&amp;nbsp; Clearly this was never tested with combinations of bits other that what is specified to get into and out of boot-loader mode.&lt;/p&gt;
&lt;p&gt;This is such an amateurish error.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If the boot-loader source code wasn&amp;#39;t available, we would not have been able to fix it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/219268?ContentTypeID=1</link><pubDate>Fri, 08 Nov 2019 11:58:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ad11bc9-2477-42fb-83bd-050c32868053</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes. This was fixed prior to nRF5 SDK v15.3.0. It is not an issue for v15.3.0 and newer.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/219191?ContentTypeID=1</link><pubDate>Fri, 08 Nov 2019 02:39:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d1096d-849d-462f-a2d7-5ed13ae895c8</guid><dc:creator>Steven Jian</dc:creator><description>&lt;p&gt;Have you fix this issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/154475?ContentTypeID=1</link><pubDate>Thu, 25 Oct 2018 11:28:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87153c35-74b7-4b95-bd83-06df2bc2bce2</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the feedback! Agreed, and noted. Your points have been forwarded to the SDK team. We do take testing seriously, and any feedback, also on test coverage, is appreciated.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/154443?ContentTypeID=1</link><pubDate>Thu, 25 Oct 2018 10:03:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96da5c56-c626-4872-9933-10a1cd3a28d5</guid><dc:creator>DerPMO</dc:creator><description>&lt;p&gt;This is a SERIOUS Problem! We&amp;#39;ve just stumbled on this by ourselves and you confirmed it here. To be honest, this kind of destroys my trust in the bootloader and the SDK because it seems like a basic lack of understanding binary operators.&lt;/p&gt;
&lt;p&gt;Also, I expect that you do at least some sort of testing of such features and if you do, there is a major part missing:&lt;/p&gt;
&lt;p&gt;In this case I suspect the devs checked that the correct magic byte indeed does trigger the DFU, and maybe even if 0x00 doesn&amp;#39;t trigger it. But apparently nobody ever checked if any other byte could trigger this as well! I can only hope that Nordic recognizes this problem and adds something to the standard testing definitions to also check for &amp;quot;false positives&amp;quot; not only true positives and false negatives!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in how bootloader treats GPREGRET</title><link>https://devzone.nordicsemi.com/thread/147236?ContentTypeID=1</link><pubDate>Tue, 04 Sep 2018 18:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca3d4479-cee6-4972-866d-542ff52457fb</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry for the delay. Thank you very much, bug reports of this nature are always appreciated!&lt;/p&gt;
&lt;p&gt;Looking into the matter I agree this is very likely to be a bug. Just as you write, the comments on the defines implies that there is a five bit magic pattern to signal it is a message from a buttonless DFU service to the DFU bootloader, and a three bit signal. But in dfu_enter_check, setting any of bits 7, 5, 4 or 0 will trigger DFU mode. This must be wrong.&lt;/p&gt;
&lt;p&gt;I have updated the feature request that was registered based on the other thread, and it is now a bug report including your observations and my own. Hopefully it will be fixed before too long.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>