<?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>GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105435/gpio-interrupt-stopped-working-after-adding-bootloader</link><description>Hi, 
 I have implemented OTA on nrf52840. I am using sdk 17.0.2 
 Currently in my project I have added buttonless DFU. The application involves USB MSC driver along with FreeRTOS. However I observed that the GPIO interrupt on NRF_GPIO_PIN_MAP(1,15) worked</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Nov 2023 03:48:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105435/gpio-interrupt-stopped-working-after-adding-bootloader" /><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454817?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2023 03:48:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdcbff02-2632-4726-b514-5fe6f59a680d</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Anyways I have solved the issue. Same pin was being accessed in bootloader as well as application fw which caused the issue. Thanks for your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454690?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2023 13:27:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c08e5952-9467-4ddc-b1ed-60795b9e5a37</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Snehal,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;What change you are talking about ?&lt;br /&gt;I don&amp;#39;t see why you point to these code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454572?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2023 05:49:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c124f03-0099-4b7e-8cb4-63d3ac65a861</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The changes you mentioned:-&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.bootLoader&amp;quot; start=&amp;quot;$(FLASH_BOOTLOADER_START)&amp;quot; size=&amp;quot;$(FLASH_BOOTLOADER_END)-$(FLASH_BOOTLOADER_START)&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.mbrSettings&amp;quot; start=&amp;quot;$(FLASH_MBRSETTINGS_START)&amp;quot; size=&amp;quot;$(FLASH_MBRSETTINGS_END)-$(FLASH_MBRSETTINGS_START)&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.bootLoaderSettings&amp;quot; start=&amp;quot;$(FLASH_BOOTLOADERSETTINGS_START)&amp;quot; size=&amp;quot;$(FLASH_BOOTLOADERSETTINGS_END)-$(FLASH_BOOTLOADERSETTINGS_START)&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/MemorySegment&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are for bootloader xml right?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454529?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 15:25:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:529efb80-c788-4797-ad4d-6f458cf1203b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Snehal,&amp;nbsp;&lt;br /&gt;I&amp;#39;m not so sure what could be wrong here, but please try to simplify the application down so we can narrow down the root cause.&amp;nbsp;&lt;br /&gt;One thing to be careful about the bootloader is that the bootloader expect the application to clear any register before use. Meaning the bootloader doesn&amp;#39;t reset all the registers before it jumps to the application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But I don&amp;#39;t see the reason why the bootloader would affect the USB MSC or the GPIO. But you need to pay extra attention to reconfigure the register, interrupt in the application as it might be modified by the bootloader.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454482?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 13:57:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48eb454f-1752-465e-92a0-8d725e22204f</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Does other functionality of the application still work and only the GPIO interrupt stops ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; yes other functionality works.. only GPIO interrupt not working.&lt;/p&gt;
&lt;p&gt;I assume you also generate bootloader setting when you test with merged hex ? I would suggest to test doing DFU with flashing SD + BL first and then update the application instead of merge them .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; Yes I also generate settings.hex when I merge the files. I have tried both options, with merged and without merged files. With both same is happening.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also one more thing I am also using USB MSC code. So in my main file I had to initialize USB drivers first.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
        bool erase_bonds;
    ret_code_t err_code;
    // Initialize modules.
    log_init();
    timers_init();


    //err_code = nrf_drv_power_init(NULL);
    //APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_power_init(NULL);
    if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED))
    {
        /* This should never happen */
        APP_ERROR_HANDLER(err_code);
    }

    clock_init();
    nrf_drv_clock_lfclk_request(NULL);

    while(!nrf_drv_clock_lfclk_is_running())
    {
        /* Just waiting */
    }
    
  usbd_config_init(); 
  spi_init_flash();
  usb_msc_init();


    // Initialize the async SVCI interface to bootloader before any interrupts are enabled.
    // We don&amp;#39;t check for error in case bootloader not in place
    ble_dfu_buttonless_async_svci_init();

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

     // Do not start any interrupt that uses system functions before system initialisation.
    // The best solution is to start the OS before any other initalisation.

#if NRF_LOG_ENABLED
    // Start execution.
    m_logger_thread = xTaskCreateStatic(logger_thread, &amp;quot;LOGGER&amp;quot;, sizeof(xLoggerStack) / sizeof(xLoggerStack[0]), NULL, LOGGER_TASK_PRIORITY, xLoggerStack, &amp;amp;xLoggerTaskBuffer);
    if (m_logger_thread == NULL) {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
#endif

NRF_LOG_INFO(&amp;quot;TESTING NEW FIRMWARE&amp;quot;);
    
      //init_device_storage();

    // Activate deep sleep mode.
    SCB-&amp;gt;SCR |= SCB_SCR_SLEEPDEEP_Msk;

    device_storage_init();
    clinitraq_load_settings();
  

    memset(app_fw_version, 0, sizeof(app_fw_version));
    app_version_str(app_fw_version, sizeof(app_fw_version));

    mem_init();

 /* Enable interrupt for FPU so we can clear it */
    NVIC_SetPriority(FPU_IRQn, APP_IRQ_PRIORITY_LOW);
    NVIC_EnableIRQ(FPU_IRQn);

    // Configure and initialize the BLE stack.
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();

    // Initialize modules.
    
 
    
    
    application_timers_start();

 /* Set TX Output Power to +4dBm */
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 4); 
    APP_ERROR_CHECK(err_code);

    // Create a FreeRTOS task for the BLE stack.
    // The task will run advertising_start() before entering its loop.
    nrf_sdh_freertos_init(advertising_start, &amp;amp;erase_bonds);

    
    init_usb_msc_task();
    init_led_button_task();
    init_system_task();


    
     // Start FreeRTOS scheduler.
    vTaskStartScheduler();

    for (;;) {
        APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
    }
}


void usbd_config_init(void)
{
   ret_code_t ret;

   static const app_usbd_config_t usbd_config = {
        .ev_isr_handler = usb_new_event_isr_handler,
        .ev_state_proc = usbd_user_ev_handler
    };

    ret = app_usbd_init(&amp;amp;usbd_config);
    APP_ERROR_CHECK(ret);

    app_usbd_class_inst_t const * class_inst_msc = app_usbd_msc_class_inst_get(&amp;amp;m_app_msc);
    ret = app_usbd_class_append(class_inst_msc);
    APP_ERROR_CHECK(ret);

}


void spi_init_flash(void)
{

     nrf_gpio_cfg_output(SPI_WP);
     nrf_gpio_cfg_output(SPI_HOLD);
     nrf_gpio_cfg_output(SPI_SS);
     
     nrf_gpio_pin_clear(SPI_SS);//enable all slaves
     nrf_gpio_pin_clear(SPI_WP);

     nrf_gpio_pin_set(SPI_HOLD);
     nrf_gpio_pin_set(SPI_SS_USB);
     nrf_drv_spi_uninit(&amp;amp;m_spi);
}


void usb_msc_init(void)
{

    ret_code_t ret;

    

    if (fatfs_init())
    {
          //fatfs_mkfs();
          fatfs_ls();
    }




    NRF_LOG_INFO(&amp;quot;USBD MSC example started.&amp;quot;);

    nrf_qspi_cinstr_conf_t cinstr_cfg = {
        .opcode    = 0x9F,
        .length    = 4,
        .io2_level = true,
        .io3_level = true,
        .wipwait   = true,
        .wren      = true
    };

    uint8_t rdid_buf[3] = {0, 0, 0};
    ret = nrf_drv_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, rdid_buf);
    if (ret != NRF_SUCCESS)
    {
        NRF_LOG_INFO(&amp;quot;read eror.&amp;quot;);
        //NRF_LOG_INST_ERROR(p_qspi_dev-&amp;gt;p_log, &amp;quot;QSPI get 3 byte id error: %&amp;quot;PRIu32&amp;quot;&amp;quot;, ret);
        //return ret;
    }
    NRF_LOG_INFO(&amp;quot;rdid_buf [%02x %02x %02x]&amp;quot;, rdid_buf[0], rdid_buf[1], rdid_buf[2]);
    

    get_memory_space(&amp;amp;total,&amp;amp;free1);
    NRF_LOG_INFO(&amp;quot;total %d,free %d&amp;quot;,total,free1);

    if(file_found_on_sdcard == 0)
    {
    fatfs_file_create();
    write_header();
    }

    //write_data_in_file(15,0.1234);

    //write_data_in_file(16,0.0001);
    get_memory_space(&amp;amp;total,&amp;amp;free1);

    if(MAX_ID_DETECTED == 0)
    {
      if (USBD_POWER_DETECTION)
      {
          ret = app_usbd_power_events_enable();
          APP_ERROR_CHECK(ret);
      }
      else
      {
          NRF_LOG_INFO(&amp;quot;No USB power detection enabled\r\nStarting USB now&amp;quot;);

          app_usbd_enable();
          app_usbd_start();
          m_usb_connected = true;
      }
    }
}



&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;These 3 functions:-&lt;/p&gt;
&lt;p&gt;usbd_config_init();&lt;br /&gt; spi_init_flash();&lt;br /&gt; usb_msc_init();&lt;/p&gt;
&lt;p&gt;were first called inside&amp;nbsp;init_usb_msc_task() -&amp;gt;usb_msc_task&lt;/p&gt;
&lt;p&gt;But I had to call it inside main.c before BLE stack init as it was causing issues in advertising and code used to hang,&lt;/p&gt;
&lt;p&gt;I am doubting USB MSC drivers might be causing the GPIO issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454434?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 12:04:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43ce71da-fb42-44e6-851d-bf892b6f2ef1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Does other functionality of the application still work and only the GPIO interrupt stops ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Please try a quick test by making a very simple application that handle GPIO input in P1.15&amp;nbsp; (make sure it run with the softdevice).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then test it with the unmodified bootloader.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I assume you also generate bootloader setting when you test with merged hex ? I would suggest to test doing DFU with flashing SD + BL first and then update the application instead of merge them .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As far as I know the bootloader doesn&amp;#39;t touch P1.15 . There is no reason it should affect the application.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454428?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 11:50:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:198a37b5-7f25-40e2-adb3-004e01412d6c</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;I am able to do OTA and the bootloader jumps to the application without any issue. I can see it in the logs. The application I2C,SPI runs properly. Only GPIO interrupts are not working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454423?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 11:38:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dcde2056-a374-4ba5-a89d-470c57991800</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Also have you blocked off the memory for the bootloader within segger in the same way that you must for softdevice, so that when the app is compiled it doesn&amp;#39;t use the memory registers?&lt;br /&gt;&lt;br /&gt;You should have something like this in flash_placement.xml...&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.bootLoader&amp;quot; start=&amp;quot;$(FLASH_BOOTLOADER_START)&amp;quot; size=&amp;quot;$(FLASH_BOOTLOADER_END)-$(FLASH_BOOTLOADER_START)&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.mbrSettings&amp;quot; start=&amp;quot;$(FLASH_MBRSETTINGS_START)&amp;quot; size=&amp;quot;$(FLASH_MBRSETTINGS_END)-$(FLASH_MBRSETTINGS_START)&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProgramSection keep=&amp;quot;Yes&amp;quot; load=&amp;quot;No&amp;quot; name=&amp;quot;.bootLoaderSettings&amp;quot; start=&amp;quot;$(FLASH_BOOTLOADERSETTINGS_START)&amp;quot; size=&amp;quot;$(FLASH_BOOTLOADERSETTINGS_END)-$(FLASH_BOOTLOADERSETTINGS_START)&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/MemorySegment&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454421?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 11:34:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f09e286b-abf0-472d-9f7d-b75f59c00859</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Debugging?&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t know your application, but I&amp;#39;d take a step back - is anything working, i.e has the bootloader passed over to the app?&lt;br /&gt;&lt;br /&gt;One thing I have found in the past which sounds similar is when using all three and testing the bootloader for the first time, with a OTA flash, it writes a CRC value (enabled by default) into flash. If you then update the App manually say over Segger the CRC code fails and it&amp;#39;s stuck in bootloader mode, which may not be as obvious as it appears &amp;#39;nothing works&amp;#39;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454416?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 11:12:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e033c4af-d289-495b-ac5d-aa7cc3d77117</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;How do I check that if its looping inside handler or if interrupt handler is not fired?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt stopped working after adding bootloader</title><link>https://devzone.nordicsemi.com/thread/454414?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 11:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a23e1f66-61ba-42b5-bc33-fde5aadf3cf3</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;I guess you mean GPIOTE interrupt as GPIO doesn&amp;#39;t have such a feature. Anyhow, there&amp;#39;s nothing in SD and bootloader that controls or takes over the output pins or usage of the GPIOTE interrupt handler, so my guess is the interrupt handler is firing but isn&amp;#39;t being serviced maybe due to code looping inside an interrupt handler at a higher priority level, something like that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>