<?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>System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61212/system-hangs-switching-from-application-to-bootloader</link><description>I&amp;#39;ve implemented a Application and Bootloader. I have the Bootloader set to Buttonless. However when I try to transition from the Application to Bootloader via: 
 /* Sets Flags for DFU Triggering */ uint8_t reg_val = nrf_power_gpregret_get(); reg_val</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 May 2020 09:21:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61212/system-hangs-switching-from-application-to-bootloader" /><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249635?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 09:21:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ae491da-bc83-4640-90c9-a9291a418297</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Glad to hear that you found the issue!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Just one comment regarding the delay after you set the gpregret register. Perhaps it is even safer to use a while() to check the register:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t reg_val = nrf_power_gpregret_get();
reg_val = reg_val | 0xB1; /* Set bit 1 to trigger DFU */
nrf_power_gpregret_set(reg_val);

reg_val = 0x00; /* reset test value */
while ((reg_val &amp;amp; 0xB1) != 0xB1)
{
    reg_val = nrf_power_gpregret_get();
}
NVIC_Systemreset();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The point of the delay is to not reset until the register is properly written, so reading the register until it is correct would give the accurate delay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249582?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 23:36:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05a8bbc0-fbfe-4f0a-ade4-741e3ae55447</guid><dc:creator>Locky</dc:creator><description>&lt;p&gt;Found the issue.&amp;nbsp;The Flash memory section which contains the MDR and Settings seems to be corrupted.&amp;nbsp; Not entire unexpected as the PCA10040 I&amp;#39;m using has be developed on for years..&amp;nbsp; I verified that some sections of the Flash for the MBR and Bootsettings were not saving properly.&amp;nbsp;&amp;nbsp;Caused issued with system resets but not power resets oddly enough.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249550?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 16:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3704069-e80a-4bcf-88b6-e6306ed1aaa8</guid><dc:creator>Locky</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;As I previously mentioned, I did this and it works the same as my bootloader.&amp;nbsp; Successfully updates the Application.&amp;nbsp; But when I triigger a new update from the Application via&lt;/p&gt;
&lt;p&gt;&lt;span&gt;/* Sets Flags for DFU Triggering */&lt;/span&gt;&lt;br /&gt;&lt;span&gt;uint8_t reg_val = nrf_power_gpregret_get();&lt;/span&gt;&lt;br /&gt;&lt;span&gt;reg_val = reg_val | 0xB1; /* Set bit 1 to triger DFU */&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;vTaskDelay(10);&lt;br /&gt;&lt;span&gt;nrf_power_gpregret_set(reg_val);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;The system hangs instead of starting the bootloader.&amp;nbsp; No led toggles, no Advertising.&amp;nbsp; Upon power reset the Application starts&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249372?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 08:35:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8548675c-294a-44fe-ad04-5db1f6b96bd8</guid><dc:creator>Edvin</dc:creator><description>[quote user="Edvin Holmseth"]Can you please try to use the bootloader project found in pca10040_ble_debug, and monitor the RTT log when you try to enter the bootloader?[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249294?ContentTypeID=1</link><pubDate>Mon, 11 May 2020 18:55:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:912bdee0-99e4-44af-9d05-64054afd58b9</guid><dc:creator>Locky</dc:creator><description>&lt;p&gt;When&amp;nbsp;I program the softdevice and my bootloader or the example bootlaoder everything runs fine and the Application updates and runs.&amp;nbsp; But when I try and trigger a DFU update from the Application,&amp;nbsp; everything freezes again after the&amp;nbsp;&lt;span&gt;sd_nvic_SystemReset().&amp;nbsp; I added a delay after setting the retention register (though I&amp;#39;ve never had to do this before) but the effect is the same.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I suspect there are two possible issues.&amp;nbsp; Either for some reason the MBR doesn&amp;#39;t contain the right vector to jump to the bootloader, or somehow the bootloader gets corrupts upon Application update.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: System hangs switching from Application to Bootloader</title><link>https://devzone.nordicsemi.com/thread/249173?ContentTypeID=1</link><pubDate>Mon, 11 May 2020 11:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f48669f-ad2a-41fb-865e-41c0cad9a8b3</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Can you please try to use the bootloader project found in pca10040_ble_debug, and monitor the RTT log when you try to enter the bootloader?&lt;/p&gt;
&lt;p&gt;The log from the bootloader may say something about why it stops.&lt;/p&gt;
&lt;p&gt;Either, the bootloader is not started properly, because of a bug there, or if the register is not set correctly, or it restarts the application, but this crashes, causing you to have an infinite app_error-&amp;gt;reboot loop.&lt;/p&gt;
&lt;p&gt;Did you do any changes in the bootloader project?&lt;/p&gt;
&lt;p&gt;Have you checked out the ble_app_buttonless_dfu example in the SDK, which has a separate BLE service to put the device in DFU mode? You can see there how it tells the bootloader to stay in DFU mode on the next reset.&lt;/p&gt;
&lt;p&gt;Perhaps you don&amp;#39;t wait long enough between the&amp;nbsp;&lt;span&gt;nrf_power_gpregret_set() and&amp;nbsp;sd_nvic_SystemReset()? I suspect this is the case if the implementation is like you describe in the snippet, with nothing else in between.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Try to add a few ms of delay before you reset, so that the register has time to be written before you reset.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>