<?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>How to stay in bootloader in case of faulty app?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29458/how-to-stay-in-bootloader-in-case-of-faulty-app</link><description>Hello, 
 I want to prevent a scenario where I successfully perform a DFU with a faulty firmware image. I have a bootloader that handles firmware updates both for the NRF5 itself and another external chipset. It once happened that we accidentally flashed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Aug 2020 11:18:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29458/how-to-stay-in-bootloader-in-case-of-faulty-app" /><item><title>RE: How to stay in bootloader in case of faulty app?</title><link>https://devzone.nordicsemi.com/thread/264598?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2020 11:18:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eea0197e-3647-48ac-b77d-d49f456c2cbb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jerome,&amp;nbsp;&lt;br /&gt;This is a very old case. Please create a new case for your issue.&amp;nbsp;&lt;br /&gt;From what I can see you are doing a 10 seconds delay. It&amp;#39;s not a timer. Please look for how we do the inactivity app timer in our bootloader. You can configure a similar app timer that does the wait. It&amp;#39;s the same app timer that you can find in our example, for example battery update timer in ble_app_hrs.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stay in bootloader in case of faulty app?</title><link>https://devzone.nordicsemi.com/thread/264531?ContentTypeID=1</link><pubDate>Thu, 13 Aug 2020 20:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dd4c5ff-7165-4e4c-95ba-3cca5da86a64</guid><dc:creator>JayLynkz</dc:creator><description>&lt;p&gt;Hi !&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried to insert a timer in the bootloader. The result is that the MCU does wait for the indicated delay before launching the app, but it does not advertise as a DFU targ.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried to insert the timer at different places in the bootloader code (which is the &amp;#39;secure_bootloader_ble_s132_pca10040&amp;#39;) and it does not work (I&amp;#39;ve inserted the &amp;#39;main&amp;#39; function of this code below).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My questions are :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Where should I insert the timer so it still advertise ?&lt;/p&gt;
&lt;p&gt;2. Where in the bootloader is the avdertisement managed ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am using SES on windows for a nrf52832&lt;/p&gt;
&lt;p&gt;Thank you !&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    uint32_t ret_val;

    // Must happen before flash protection is applied, since it edits a protected page.
    nrf_bootloader_mbr_addrs_populate();
    
    // Protect MBR and bootloader code from being overwritten.
    ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
    APP_ERROR_CHECK(ret_val);
    ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
    APP_ERROR_CHECK(ret_val);

    (void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;Inside main&amp;quot;);

    ret_val = nrf_bootloader_init(dfu_observer);
    APP_ERROR_CHECK(ret_val);

    nrf_delay_ms(10000);

    NRF_LOG_FLUSH();

    NRF_LOG_ERROR(&amp;quot;After main, should never be reached.&amp;quot;);
    NRF_LOG_FLUSH();

    APP_ERROR_CHECK_BOOL(false);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stay in bootloader in case of faulty app?</title><link>https://devzone.nordicsemi.com/thread/117134?ContentTypeID=1</link><pubDate>Mon, 15 Jan 2018 14:49:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a30b4cb-8d3e-44d3-b441-1927b6d0351f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I think it&amp;#39;s a good idea.&lt;/p&gt;
&lt;p&gt;In your bootloader you can simply check if the GPREGRET flag is set then it should be something wrong with the app and stay in DFU mode. If it&amp;#39;s not set then you set it and start the WDT expecting the flag to be cleared when the app start.&lt;/p&gt;
&lt;p&gt;Another option is to set a timer when bootloader start, for example it waits for 5 seconds if there is no DFU connection, then it will start the application. So you can recover if there is anything wrong. The draw back is a latency of a few seconds after the device powered until it operates.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>