<?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>Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48151/enter-bootloader-from-app-on-stock-nrf52840-dongle</link><description>Hi, 
 using a stock nRF52840 dongle and willing to enter bootloader (same as pushing the relevant button on the dongle) from app. How can that be done, using stock bootloader? 
 Regards, 
 Andrea</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Jun 2019 07:35:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48151/enter-bootloader-from-app-on-stock-nrf52840-dongle" /><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191518?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2019 07:35:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aaf916cd-1f06-47ea-9a37-4b0c49fc306e</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Excellent :) Happy to help.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191368?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2019 12:49:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cced40fb-7972-4eb3-b75b-20faf76025fc</guid><dc:creator>Andrea Aizza</dc:creator><description>&lt;p&gt;Works like a charm. Well done!&lt;/p&gt;
&lt;p&gt;Ciao,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Andrea&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191333?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2019 11:45:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96e090a6-4c28-4258-955f-2baabdab1404</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Andrea,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;it turns out that you were correct, the bootloader used on the nRF52840 dongle does not have the&amp;nbsp;&lt;span&gt;NRF_BL_DFU_ENTER_METHOD_GPREGRET. It only enables&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_PINRESET and&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I knew that we are able to switch from application to bootloader without manually pressing the button on the nRF52840 when programming it with nRF Connect: Programmer. So I took a look at the schematic file(attached) of the nRF52840 dongle and saw that several GPIOs were connected directly to the RESET pin, which is how nRF Connect is able to switch from app to bootloader. We have a dedicated USB library for this, called the&amp;nbsp;&lt;a title="DFU Trigger Library (USB)" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_dfu_trigger_usb.html?cp=5_5_1_3_5_3"&gt;DFU Trigger Library (USB)&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I do not know how you want to trigger the nRF52840 to go to bootloader moder, but in essence you only have to pull on of the GPIOs connected to the RESET pin low, i.e.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)

// Call the following functions at the start of main()
nrf_gpio_cfg_output(BSP_SELF_PINRESET_PIN);
nrf_gpio_pin_set(BSP_SELF_PINRESET_PIN);

// Call the following function when you want to switch to BL mode. 
nrf_gpio_pin_clear(BSP_SELF_PINRESET_PIN);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have verified this on a nRF52840 Dongle with the factory bootloader.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3c1681006fcb4062849f05bbdf698af5/PCA10059_5F00_Schematic_5F00_And_5F00_PCB.pdf"&gt;devzone.nordicsemi.com/.../PCA10059_5F00_Schematic_5F00_And_5F00_PCB.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191158?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 14:21:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:020c9ca5-624a-480e-bc1b-6e7254974133</guid><dc:creator>Andrea Aizza</dc:creator><description>&lt;p&gt;Hi Bjorn,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thanks! Best would be if you could confirm your APP code puts a factory dongle in bootloader mode... then I need to figure out what problem I have here...&lt;/p&gt;
&lt;p&gt;Takk,&lt;/p&gt;
&lt;p&gt;Andrea&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191152?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 14:01:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:437fdc3a-d5a6-4eb9-976f-3c120e2400f7</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The bootloader that is factory programmed should be more or less use the same configuration as the SDK bootloader. I will have to take a look at the source code that was used to generate the bootloader hex that is programmed at the factory.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191113?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:47:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b22ea501-283e-4f84-9661-ce04acea7da8</guid><dc:creator>Andrea Aizza</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thanks for the clarification, but my question is not yet answered. When I use a&amp;nbsp;factory new (stock) dongle, bought on Mouser, what code should I use to enter bootloader from the APP?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The code above seems not to work. Could it be the bootloader which is flashed from factory does not have&amp;nbsp;&lt;span&gt;NRF_BL_DFU_ENTER_METHOD_GPREGRET enabled?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Andrea&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enter bootloader from app on stock nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/191110?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:38:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89d0edf3-1cc9-44a2-8f02-9113d0230d74</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Andrea&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>