<?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>Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74232/rerouting-printf-to-uart</link><description>Hi, 
 Currently our system is using printf() to print some debug messages to the Segger debug terminal. Now we would like to reroute these messages to a UART port. 
 We are already using 1 UART for communication with chip on the board. We would like to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Apr 2021 12:06:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74232/rerouting-printf-to-uart" /><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/307471?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 12:06:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e46afe58-9291-47a0-bac4-522815cb0d00</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Does your Ubuntu colleague use an older version of Segger embedded studio by any chance? In that case, you may need to build with the &amp;#39;NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED&amp;#39; setting disabled in sdk_config&lt;/p&gt;
&lt;p&gt;Issue with RTT logs not being displayed in SES debug terminal: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45985/nrf_log-not-working-on-segger-embedded-studio/182742#182742"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/45985/nrf_log-not-working-on-segger-embedded-studio/182742#182742&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/307465?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 12:01:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc83adc3-474d-4c7d-a77d-abaf4c6629af</guid><dc:creator>newUser</dc:creator><description>&lt;p&gt;We have tried, but our Ubuntu colleague doesn&amp;#39;t get any data to the debug terminal when using NRF_LOG_*. (RTT backend enabled and UART backend disabled in sdk_config).&lt;br /&gt;For our Windows people, it works.&lt;/p&gt;
&lt;p&gt;If we can get NRF_LOG_* to work on both Windows and Linux, we would like that very much. It would indeed solve all our problems.&lt;/p&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/307454?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 11:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d288495-aea8-4d60-8a8c-e8194149aa27</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I see, but shouldn&amp;#39;t it be quick and easy to replace the printf&amp;#39;s with NRF_LOG_INFO or equivalent if you do a &amp;quot;search and replace&amp;quot; across your source files?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/307450?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 11:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc56af9-9ea5-4d0b-afd1-dc5e1108623e</guid><dc:creator>newUser</dc:creator><description>&lt;p&gt;We started to use printf() because NRF_LOG_* did not print any text in the debug terminal.&lt;br /&gt;To change all of printf in the source code takes a lot of time and has a huge impact on our source code.&lt;br /&gt;This is why we prefer to reroute printf()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306806?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 12:55:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea572ae6-545f-42bc-8e7a-0bd6beb1a69b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;But instance 0 is used by the logger module. Could you not use the NRF_LOG_* macros instead of printfs then?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306791?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 12:13:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dad6d34-29da-467c-8124-8229836753a9</guid><dc:creator>newUser</dc:creator><description>&lt;p&gt;The instance is 0.&amp;nbsp;Instance 1 is used by our communication chip, after the suggested changes, so indeed we need retarget on 0.&lt;/p&gt;
&lt;p&gt;In retarget.c I see that app_uart_put is used, but that function is used to send data to our modem.&amp;nbsp;&lt;br /&gt;We have also tried replacing app_uart_put with app_uart_put2, which is our function to transmit to the other uart fifo, but this suddenly yields garbage data (we are using the baudrate from the SDK config: 115200). Furthermore, how is this instance then initialized?&lt;/p&gt;
&lt;p&gt;If we disable retarget, we see printf() in the debug terminal and NRF log in the debug UART.&amp;nbsp;&lt;br /&gt;When enabling retarget so that printf also goes to the debug UART, we get the garbage data (also NRF LOG is no longer showing)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306628?ContentTypeID=1</link><pubDate>Sat, 24 Apr 2021 06:45:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22b79df6-cec4-4299-aad6-5f115810d9cb</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;nrfx_uart.c:nrfx_uart_tx() shouldn&amp;#39;t get called when using UARTE1, so I&amp;#39;m not sure why you are getting the assert. Could you try to place the 2 breakpoints as shown in the screenshot below, then check if the UARTE instance is 0 or 1 when nrf_uart_tx() gets called in your application?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1619246698101v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306541?ContentTypeID=1</link><pubDate>Fri, 23 Apr 2021 12:40:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34136b49-d6f1-4a30-8008-874693e24946</guid><dc:creator>newUser</dc:creator><description>&lt;p&gt;&lt;span&gt;I have included the retarget.c file.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;When I add the following to sdk_config.h file:&lt;/span&gt;&lt;br /&gt;&lt;code class="c-mrkdwn__code"&gt;#ifndef RETARGET_ENABLED&lt;/code&gt;&lt;br /&gt;&lt;code class="c-mrkdwn__code"&gt;#define RETARGET_ENABLED 1&lt;/code&gt;&lt;br /&gt;&lt;code class="c-mrkdwn__code"&gt;#endif&lt;/code&gt;&lt;br /&gt;&lt;span&gt;I get a breakpoint with the following error:&lt;/span&gt;&lt;br /&gt;&lt;code class="c-mrkdwn__code"&gt;&amp;lt;error&amp;gt; app: ERROR 3735928559 [Unknown error code] at /sdk/modules/nrfx/drivers/src/nrfx_uart.c:280&lt;/code&gt;&lt;span class="c-mrkdwn__br"&gt;&lt;/span&gt;&lt;code class="c-mrkdwn__code"&gt;14:33:01.012 -&amp;gt; PC at: 0x0002BC97&lt;/code&gt;&lt;span class="c-mrkdwn__br"&gt;&lt;/span&gt;&lt;code class="c-mrkdwn__code"&gt;14:33:01.012 -&amp;gt; &amp;lt;error&amp;gt; app: End of error report&lt;/code&gt;&lt;br /&gt;&lt;span&gt;Line 280:&lt;/span&gt;&lt;br /&gt;&lt;code class="c-mrkdwn__code"&gt;NRFX_ASSERT(p_cb-&amp;gt;state == NRFX_DRV_STATE_INITIALIZED);&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306493?ContentTypeID=1</link><pubDate>Fri, 23 Apr 2021 09:29:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:805f8cfc-db75-4384-9abb-c07c94ebf5bc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It should work if you include our retarget.c file your project (\components\libraries\uart\retarget.c). Printf will go out on UARTE1 if everything works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306482?ContentTypeID=1</link><pubDate>Fri, 23 Apr 2021 08:14:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f18af8a-84bf-4bd9-be44-23d07f42e02d</guid><dc:creator>newUser</dc:creator><description>&lt;p&gt;Thank you &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;, this got us a bit further. We see all NRF_LOG messages going to UART now.&lt;br /&gt;However, we would like printf() to go to UART too.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;What extra step do we need?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rerouting printf() to UART</title><link>https://devzone.nordicsemi.com/thread/306283?ContentTypeID=1</link><pubDate>Thu, 22 Apr 2021 10:20:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9a85c6e-38cd-4cf0-bb2b-3e2feff64bea</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Maybe both are trying to use the same UARTE instance? The &lt;span&gt;&lt;a title="Logger module" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_nrf_log.html?cp=7_1_3_27"&gt;Logger module&lt;/a&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;UART backend is hardcoded to use the UARTE0, same&amp;nbsp; instance as the app_uart library uses by default.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please make sure APP_UART_DRIVER_INSTANCE is set to &amp;#39;1&amp;#39; in your sdk_config.h file. This will make APP_UART_FIFO_INIT() initialize UARTE1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Vidar&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></channel></rss>