<?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>UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54373/uart-logging-backend-hangs-in-nrf_bootloader_app_start</link><description>Hi Community, 
 I want to use the UART Logging backend in my bootloader. Whenever I want to start the actual application via nrf_bootloader_app_start(), the bootloader hangs in nrf_fprintf_buffer_flush in a while loop. 
 
 while (m_async_mode &amp;amp;&amp;amp; (m_xfer_done</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Aug 2022 07:40:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54373/uart-logging-backend-hangs-in-nrf_bootloader_app_start" /><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/380515?ContentTypeID=1</link><pubDate>Mon, 08 Aug 2022 07:40:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ceae2a87-7c3a-4d41-b0da-5c6348b8927f</guid><dc:creator>Dmitry Polshaklov</dc:creator><description>&lt;p&gt;Probably this wouldn&amp;#39;t be fixed. See:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/57536/freeze-in-nrf_bootloader_app_start-on-nrf_log_flush"&gt;devzone.nordicsemi.com/.../freeze-in-nrf_bootloader_app_start-on-nrf_log_flush&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/379241?ContentTypeID=1</link><pubDate>Fri, 29 Jul 2022 07:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5414e2ae-5da9-4e77-b9b5-03da70197e81</guid><dc:creator>Anne van Rossum</dc:creator><description>&lt;p&gt;I still think that NRF_LOG_FLUSH in the nrf_bootloader_app_start should be removed. If interrupts are disabled, it will hang.&lt;/p&gt;
&lt;p&gt;Didn&amp;#39;t see a bug fix in SDK 17.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/263459?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 13:34:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9650edf-33d3-4ae8-8946-50b0b4a68d05</guid><dc:creator>pineapple pizza</dc:creator><description>&lt;p&gt;Hi, I found the same issue here. If&amp;nbsp;NRF_LOG_DEFERRED is set to 1 the backend in `nrf_log_backend_uart.c` uses interrupts to set `m_xfer_done` to true once the UART transfer is done, this is done via the even handler `uart_evt_handler` in that file.&lt;/p&gt;
&lt;p&gt;However, in `nrf_bootloader_app_start` the code is disabling the interrupts and calling NRF_LOG_FLUSH which then hangs because the `uart_evt_handler` is never called (the interrupt is probably pending).&lt;/p&gt;
&lt;p&gt;This is a bug in the SDK code.&lt;/p&gt;
&lt;p&gt;One option is to set NRF_LOG_DEFERRED to 0 as mentioned here, this will not use the event handler/interrupts. This doesn&amp;#39;t require any code changes.&lt;/p&gt;
&lt;p&gt;The other option would be for nordic to fix the SDK code. I think that one&amp;nbsp;way to fix this&amp;nbsp;in this case would be to call the log messages and flush before we disable the interrupts. Another option is to fix the flush logic to not rely on the interrupt being attended since it is doing a busy loop anyway. In&amp;nbsp;`nrf_log_backend_uart.c`, function&amp;nbsp;serial_tx there&amp;#39;s this while() loop waiting for the event handler to be done. I think that if your message is too long you need several interrupts to trigger before you get a call to the event handler, so maybe forcing an interrupt call (just calling directly the equivalent function from the loop body) would work, but this is not exposed at all in the driver.&lt;/p&gt;
&lt;p&gt;Should we create a support case for this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/232858?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 14:10:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58555d51-1fbd-462f-8507-61829ff16cfd</guid><dc:creator>Dmitry Polshaklov</dc:creator><description>&lt;p&gt;Hello. I have the same issue with&amp;nbsp;nRF5_SDK_for_Thread_and_Zigbee_v4.0.0_dc7186b and&amp;nbsp;nRF52840-DK.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt; Are you calling&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LOG_FLUSH&lt;/span&gt;&lt;span&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;NRF_LOG_PROCESS from any other places in your code except main()?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes. But with gdb I checked, that freeze happens in&amp;nbsp;nrf_bootloader_app_start.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#0  0x000e0b1a in serial_tx (p_context=&amp;lt;optimized out&amp;gt;, p_buffer=&amp;lt;optimized out&amp;gt;, len=&amp;lt;optimized out&amp;gt;) at ../../../../../components/libraries/log/src/nrf_log_backend_uart.c:88
#1  0x000e614e in nrf_fprintf_buffer_flush (p_ctx=p_ctx@entry=0x2003ff58) at ../../../../../external/fprintf/nrf_fprintf.c:56
#2  0x000e19b0 in postfix_process (p_params=p_params@entry=0x2003ff4c, p_ctx=p_ctx@entry=0x2003ff58, newline=newline@entry=false) at ../../../../../components/libraries/log/src/nrf_log_str_formatter.c:150
#3  0x000e1a1a in nrf_log_std_entry_process (p_str=p_str@entry=0xf2b44 &amp;quot;In nrf_bootloader_init&amp;quot;, p_args=p_args@entry=0x2003ff28, nargs=nargs@entry=0, p_params=p_params@entry=0x2003ff4c, p_ctx=p_ctx@entry=0x2003ff58) at ../../../../../components/libraries/log/src/nrf_log_str_formatter.c:192
#4  0x000e0a0c in nrf_log_backend_serial_put (p_backend=&amp;lt;optimized out&amp;gt;, p_msg=0x20001a9c &amp;lt;log_mempool_nrf_balloc_pool_mem&amp;gt;, p_buffer=p_buffer@entry=0x20001a50 &amp;lt;m_string_buff&amp;gt; &amp;quot;&amp;lt;debug&amp;gt; app: In nrf_bootloader_init\r\r\ner]==========\r\r\n&amp;quot;, length=length@entry=64, tx_func=tx_func@entry=0xe0afd &amp;lt;serial_tx&amp;gt;) at ../../../../../components/libraries/log/src/nrf_log_backend_serial.c:87
#5  0x000e0aec in nrf_log_backend_uart_put (p_backend=&amp;lt;optimized out&amp;gt;, p_msg=&amp;lt;optimized out&amp;gt;) at ../../../../../components/libraries/log/src/nrf_log_backend_uart.c:95
#6  0x000e0fc6 in nrf_log_backend_put (p_msg=0x20001a9c &amp;lt;log_mempool_nrf_balloc_pool_mem&amp;gt;, p_backend=0xf4b4c &amp;lt;uart_log_backend&amp;gt;) at ../../../../../components/libraries/log/nrf_log_backend_interface.h:225
#7  nrf_log_frontend_dequeue () at ../../../../../components/libraries/log/src/nrf_log_frontend.c:862
#8  0x000eb708 in nrf_bootloader_app_start () at ../../../../../../../bootloader/nrf_bootloader_app_start.c:75
#9  0x000eb62a in nrf_bootloader_init_ext (observer=observer@entry=0xeb07d &amp;lt;dfu_observer&amp;gt;, image_copy=image_copy@entry=0x0, copy_bl=copy_bl@entry=0x0) at ../../../../../../../bootloader/nrf_bootloader.c:528
#10 0x000eb6c6 in nrf_bootloader_init (observer=observer@entry=0xeb07d &amp;lt;dfu_observer&amp;gt;) at ../../../../../../../bootloader/nrf_bootloader.c:425
#11 0x000eb1fe in main () at ../../main.c:226&lt;/pre&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt; Does commenting out the&amp;nbsp;NRF_LOG_FLUSH&amp;nbsp;call in&amp;nbsp;nrf_bootloader_app_start allow you to jump to the application?&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;What can I do to avoid SDK code change? Or should I create a new topic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/221467?ContentTypeID=1</link><pubDate>Fri, 22 Nov 2019 07:01:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bdfd01b-9cbc-405d-8049-18744b63e5f6</guid><dc:creator>niecore</dc:creator><description>&lt;p&gt;I quick fixed my problem by setting NRF_LOG_DEFERRED to &amp;quot;0&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/221373?ContentTypeID=1</link><pubDate>Thu, 21 Nov 2019 15:14:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db9a1e5e-2cc7-41bf-8515-44ccdff2d31e</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/schef"&gt;schef&lt;/a&gt;: Please post the code where the assert originated from, i.e.&amp;nbsp;nRF5_SDK_15.2.0_9412b96/modules/nrfx/drivers/src/nrfx_uarte.c: line 269&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/221333?ContentTypeID=1</link><pubDate>Thu, 21 Nov 2019 13:21:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:043c254b-0e26-45b3-ab3c-757c197efe8b</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;I have something similar:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;debug&amp;gt; nrf_dfu_req_handler: Whole firmware image received. Postvalidating.
&amp;lt;debug&amp;gt; nrf_dfu_validation: Hash verification. Firmware start address: 0x73000, size: 0x4B888
&amp;lt;debug&amp;gt; nrf_dfu_validation: Invalidating old application in bank 0.
&amp;lt;debug&amp;gt; nrf_dfu_serial: Sending Response: [0x4, 0x1]
&amp;lt;debug&amp;gt; nrf_dfu_settings: Erasing old settings at: 0x000FF000
&amp;lt;debug&amp;gt; nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x000FF000, len=1 pages), queue usage: 1
&amp;lt;debug&amp;gt; nrf_dfu_flash: Flash erase success: addr=0x000FF000, pending 0
&amp;lt;debug&amp;gt; nrf_dfu_flash: nrf_fstorage_write(addr=0x000FF000, src=0x20000B64, len=348 bytes), queue usage: 1
&amp;lt;debug&amp;gt; nrf_dfu_flash: Flash write success: addr=0x000FF000, pending 0
&amp;lt;info&amp;gt; nrf_dfu_settings: Backing up settings page to address 0xFE000.
&amp;lt;debug&amp;gt; nrf_dfu_settings: Writing settings...
&amp;lt;debug&amp;gt; nrf_dfu_settings: Erasing old settings at: 0x000FE000
&amp;lt;debug&amp;gt; nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x000FE000, len=1 pages), queue usage: 1
&amp;lt;debug&amp;gt; nrf_dfu_flash: Flash erase success: addr=0x000FE000, pending 0
&amp;lt;debug&amp;gt; nrf_dfu_flash: nrf_fstorage_write(addr=0x000FE000, src=0x20000CC0, len=348 bytes), queue usage: 1
&amp;lt;debug&amp;gt; nrf_dfu_flash: Flash write success: addr=0x000FE000, pending 0
&amp;lt;debug&amp;gt; nrf_dfu_req_handler: All flash operations have completed. DFU completed.
&amp;lt;debug&amp;gt; app: Shutting down transports (found: 1)
&amp;lt;debug&amp;gt; app: Resetting bootloader.
&amp;lt;info&amp;gt; nrf_dfu_settings: Backing up settings page to address 0xFE000.
&amp;lt;debug&amp;gt; nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
&amp;lt;error&amp;gt; app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2003FD18
&amp;lt;error&amp;gt; app: ASSERTION FAILED at ../../../../firmware_nrf52_sdk_15_2/src/nRF5_SDK_15.2.0_9412b96/modules/nrfx/drivers/src/nrfx_uarte.c:269
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I use nrf52840 with sdk15.2 and &lt;strong&gt;pca10056_uart_debug.&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART Logging Backend hangs in nrf_bootloader_app_start</title><link>https://devzone.nordicsemi.com/thread/220132?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2019 15:35:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e73a297a-72dd-4197-b4a4-c36bb3ffeb09</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Niecore,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NRF_LOG_FLUSH should return when the queued log data has been emptied. THis is not an issue in our DFU debug examples that uses the UART backend for logging. Are you calling&amp;nbsp;&lt;span&gt;NRF_LOG_FLUSH&lt;/span&gt;&lt;span&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt; NRF_LOG_PROCESS from any other places in your code except main()?&amp;nbsp; Does commenting out the&amp;nbsp;&lt;span&gt;NRF_LOG_FLUSH&amp;nbsp;call in&amp;nbsp;nrf_bootloader_app_start allow you to jump to the application?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrf_bootloader_app_start(void)
{
    uint32_t start_addr = MBR_SIZE; // Always boot from end of MBR. If a SoftDevice is present, it will boot the app.
    NRF_LOG_DEBUG(&amp;quot;Running nrf_bootloader_app_start with address: 0x%08x&amp;quot;, start_addr);
    uint32_t err_code;

    // Disable and clear interrupts
    // Notice that this disables only &amp;#39;external&amp;#39; interrupts (positive IRQn).
    NRF_LOG_DEBUG(&amp;quot;Disabling interrupts. NVIC-&amp;gt;ICER[0]: 0x%x&amp;quot;, NVIC-&amp;gt;ICER[0]);

    NVIC-&amp;gt;ICER[0]=0xFFFFFFFF;
    NVIC-&amp;gt;ICPR[0]=0xFFFFFFFF;
#if defined(__NRF_NVIC_ISER_COUNT) &amp;amp;&amp;amp; __NRF_NVIC_ISER_COUNT == 2
    NVIC-&amp;gt;ICER[1]=0xFFFFFFFF;
    NVIC-&amp;gt;ICPR[1]=0xFFFFFFFF;
#endif

    err_code = nrf_dfu_mbr_irq_forward_address_set();
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;Failed running nrf_dfu_mbr_irq_forward_address_set()&amp;quot;);
    }

    NRF_LOG_FLUSH();
    nrf_bootloader_app_start_final(start_addr);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>