<?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>GPIOTE and secure bootloader</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72504/gpiote-and-secure-bootloader</link><description>I am using nRF52832 on my custom board. The SoftDevice, secure bootloader and my custom BLE application are flashed on my flash. 
 After processing a single GPIOTE event, my firmware gets stuck in GPIOTE_IRQHandler. 
 It all worked fine when I was testing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Mar 2021 16:03:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72504/gpiote-and-secure-bootloader" /><item><title>RE: GPIOTE and secure bootloader</title><link>https://devzone.nordicsemi.com/thread/298797?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 16:03:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34b2bf45-b2ce-4d6b-afe6-d69ee32e6384</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;It looks like the button that is set up in the bootloader is not handled in the application&amp;#39;s gpiote handler. In case you want to use the button to enter bootloader, I suggest just doing a cleanup of that pin before you start the application. You can use the same function that is used in the uart bootloader&amp;#39;s transport_close() function:&lt;/p&gt;
&lt;p&gt;nrf_gpio_cfg_default(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN);&lt;/p&gt;
&lt;p&gt;before the application is started.&lt;/p&gt;
&lt;p&gt;Actually, you can probably do it right after it is read in dfu_enter_check:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
{
    NRF_LOG_DEBUG(&amp;quot;In nrf_bootloader_init&amp;quot;);

    ret_code_t                            ret_val;
    nrf_bootloader_fw_activation_result_t activation_result;
    uint32_t                              initial_timeout;
    bool                                  dfu_enter = false;

    m_user_observer = observer;

    if (NRF_BL_DEBUG_PORT_DISABLE)
    {
        nrf_bootloader_debug_port_disable();
    }

#if NRF_BL_DFU_ENTER_METHOD_BUTTON
    dfu_enter_button_init();
#endif

    ret_val = nrf_dfu_settings_init(false);
    if (ret_val != NRF_SUCCESS)
    {
        return NRF_ERROR_INTERNAL;
    }

    #if NRF_BL_DFU_ALLOW_UPDATE_FROM_APP
    // Postvalidate if DFU has signaled that update is ready.
    if (s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1)
    {
        postvalidate();
    }
    #endif

    // Check if an update needs to be activated and activate it.
    activation_result = nrf_bootloader_fw_activate();

    switch (activation_result)
    {
        case ACTIVATION_NONE:
            initial_timeout = NRF_BOOTLOADER_MS_TO_TICKS(NRF_BL_DFU_INACTIVITY_TIMEOUT_MS);
            dfu_enter       = dfu_enter_check();    // The NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN is read inside dfu_enter_check().
            break;

        case ACTIVATION_SUCCESS_EXPECT_ADDITIONAL_UPDATE:
            initial_timeout = NRF_BOOTLOADER_MS_TO_TICKS(NRF_BL_DFU_CONTINUATION_TIMEOUT_MS);
            dfu_enter       = true;
            break;

        case ACTIVATION_SUCCESS:
            bootloader_reset(true);
            NRF_LOG_ERROR(&amp;quot;Unreachable&amp;quot;);
            return NRF_ERROR_INTERNAL; // Should not reach this.

        case ACTIVATION_ERROR:
        default:
            return NRF_ERROR_INTERNAL;
    }
    
#if NRF_BL_DFU_ENTER_METHOD_BUTTON
    nrf_gpio_cfg_default(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN);
#endif

...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE and secure bootloader</title><link>https://devzone.nordicsemi.com/thread/298765?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 14:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6b10b9c-b746-47bb-87b0-ed3cd08caf90</guid><dc:creator>Ivo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;When the lock-up happens, when reading registers with nrfjprog, I get the same &amp;quot;PC:&amp;quot; value within nrfx_gpiote_irq_handler, on successive runs of &amp;quot;nrfjprog&amp;quot;, but a different &amp;quot;PC:&amp;quot; value after resetting the board and triggering the lock-up.&lt;/p&gt;
&lt;p&gt;When debugging with Segger Ozone, it&amp;#39;s stuck in nrfx_gpiote.c::nrfx_gpiote_irq_handler, in port_event_handle(input), the debugger can step through the code, but never steps out.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/gpiote_2D00_hang.png" /&gt;&lt;/p&gt;
&lt;p&gt;Note that when trying to resume the firmware from Ozone, I get a HardFault error.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/gpiote_2D00_hardfault.png" /&gt;&lt;/p&gt;
&lt;p&gt;Setting NRF_BL_DFU_ENTER_METHOD_BUTTON to 0 seemed to have made the issue go away: now I no longer get stuck in GPIOTE IRQ handler, with or without bootloader.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Ivo.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE and secure bootloader</title><link>https://devzone.nordicsemi.com/thread/298527?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 22:35:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77885172-4011-427d-afd1-27a26196d5e7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What bootloader are you using?&amp;nbsp;pca10040_s132_ble or&amp;nbsp;pca10040_uart?&lt;/p&gt;
&lt;p&gt;What does it look like when you are stuck in the&amp;nbsp;&lt;span&gt;GPIOTE_IRQHandler()? Is there some while loop that you are not getting out of? Perhaps you can show me a screenshot?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A wild guess:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;About the only gpiote related changes I can think of in the bootloaders are:&lt;/p&gt;
&lt;p&gt;BLE and uart: DFU enter button,&lt;/p&gt;
&lt;p&gt;uart: UART pins.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try the following. First, only for testing purposes, and we can look into the solution if any of them seems to be the cause:&lt;/p&gt;
&lt;p&gt;DFU enter button: In the sdk_config.h file of your bootloader, locate&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_BUTTON and set it to 0. (If you are struggling to enter the application without being able to upload it via DFU, let me know, but there is something called bootloader settings that you can generate using the nrfutil command &amp;quot;nrfutil settings generate --help&amp;quot; which you can program together with your application to make the bootloader accept the application).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;UART pins:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As far as I can tell, the UART pins are already being disconnected through the&amp;nbsp;uart_dfu_transport_close() function. Is the&amp;nbsp;NRF_DRV_UART_USE_UARTE set to true in your project? (in nrf_drv_uart.h)? Which of the functions, nrfx_uarte_uninit() or nrfx_uart_uninit() are called?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try to power cycle the DK after you have updated the application via DFU. Then, the transport should not be initialized, and we can check whether it is the UART pins that trigger your application&amp;#39;s GPIOTE_IRQHandler() or not.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>