<?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 switch from application mode to bootloader mode again in OTA</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48243/how-to-switch-from-application-mode-to-bootloader-mode-again-in-ota</link><description>Hi, 
 I am using nRF52832 DK and also my custom board based on nRF52832. 
 I have uploaded the application file into my device using OTA-DFU. 
 Now my device goes in application mode and advertising as nordic_blinky as my application. 
 And now I want</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Jun 2019 11:47:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48243/how-to-switch-from-application-mode-to-bootloader-mode-again-in-ota" /><item><title>RE: How to switch from application mode to bootloader mode again in OTA</title><link>https://devzone.nordicsemi.com/thread/191334?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2019 11:47:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c5fd845-3494-4e86-b045-6b0cc94a1f31</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Archana&lt;/p&gt;
&lt;p&gt;in the&amp;nbsp;dfu_enter_check() function, which is called by&amp;nbsp;nrf_bootloader_init(), the bootloader checks&amp;nbsp;if one of the&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_xxxx has been used to trigger the device to stay in bootloader mode and not start the application( if there is a valid one).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static bool dfu_enter_check(void)
{
    if (!app_is_valid(crc_on_valid_app_required()))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode because app is not valid.&amp;quot;);
        return true;
    }

    if (NRF_BL_DFU_ENTER_METHOD_BUTTON &amp;amp;&amp;amp;
       (nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 0))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode requested via button.&amp;quot;);
        return true;
    }

    if (NRF_BL_DFU_ENTER_METHOD_PINRESET &amp;amp;&amp;amp;
       (NRF_POWER-&amp;gt;RESETREAS &amp;amp; POWER_RESETREAS_RESETPIN_Msk))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode requested via pin-reset.&amp;quot;);
        return true;
    }

    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;
    }

    if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS &amp;amp;&amp;amp;
       (s_dfu_settings.enter_buttonless_dfu == 1))
    {
        NRF_LOG_DEBUG(&amp;quot;DFU mode requested via bootloader settings.&amp;quot;);
        return true;
    }

    return false;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The method used in our buttonless DFU application example is the&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_GPREGRET, see the ble_dfu_buttonless_bootloader_start_finalize() function below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
uint32_t ble_dfu_buttonless_bootloader_start_finalize(void)
{
    uint32_t err_code;

    NRF_LOG_DEBUG(&amp;quot;In ble_dfu_buttonless_bootloader_start_finalize\r\n&amp;quot;);

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    VERIFY_SUCCESS(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    VERIFY_SUCCESS(err_code);

    // Indicate that the Secure DFU bootloader will be entered
    m_dfu.evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER);

    // Signal that DFU mode is to be enter to the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>