<?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>nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87240/nrf9160-using-uart-with-printf-without-all-the-debugging-outputs-from-zephyr</link><description>How do I use printf to output my own messages, and read incoming data, from a UART port that is separate from Zephyr&amp;#39;s debugging outputs? This UART line will be connected to another microcontroller for custom commands. 
 Here is what I have so far: 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Jun 2022 18:28:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87240/nrf9160-using-uart-with-printf-without-all-the-debugging-outputs-from-zephyr" /><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/373320?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 18:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cbf1df6-98b9-43f1-8548-d39a7ab39c97</guid><dc:creator>JonnyMN</dc:creator><description>&lt;p&gt;Hi tedhavelka,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the details response!&amp;nbsp;Unfortunately, I won&amp;#39;t have time to try out your suggestions until later this year. But I will make note of this when development picks up again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/373319?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 18:15:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4630e152-3571-4e20-bc95-960f02abf28d</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hello JonnyMN,&lt;/p&gt;
&lt;p&gt;Did you resolve your custom communication channel issue?&amp;nbsp; I happened to be searching for answers to a related Nordic ncs and Zephyr RTOS question when I came across your post.&lt;/p&gt;
&lt;p&gt;To your latest question about a month ago, from my research and experiments it is easier to a UART1 or UART2, something other than Zephyr&amp;#39;s chosen UART for its kernel messages.&lt;/p&gt;
&lt;p&gt;I ran into this matter about nine months ago, where I had both Zephyr messages and nRF9160 LTE modem diagnostics printing to UART0.&amp;nbsp; I wanted a serial port for a simple command line interface for development purposes, a little different than your needs.&amp;nbsp; The specific problem I faced was not in seeing some extra messages from the modem and RTOS, but that a part of aws_iot sample app code was consuming my typed input and passing that along to the modem.&lt;/p&gt;
&lt;p&gt;As a first step toward message free UART, I enabled a second UART in device tree.&amp;nbsp; Then I added some boiler plate Zephyr macro code to be to say `static const struct device *cli_uart`.&amp;nbsp; This is a device pointer in one of my firmware modules to the second, app-dedicated UART.&lt;/p&gt;
&lt;p&gt;With these in place I was yet not able to find a way to redirect printf() or printk() to my alternate UART.&amp;nbsp; In place of relying on printk() I ended up using something you may find useful, or it may be too limited.&amp;nbsp; I use Zephyr&amp;#39;s lower lever uart_poll_in() and uart_poll_out() APIs.&amp;nbsp; Here are links to pertinent lines in an open source project of my own on github:&lt;/p&gt;
&lt;p&gt;1075 # &lt;a href="https://github.com/tedhavelka/kionix-driver-demo/blob/main/src/thread-simple-cli.c#L305"&gt;github.com/.../thread-simple-cli.c&lt;/a&gt;&lt;br /&gt; 1076 # &lt;a href="https://github.com/tedhavelka/kionix-driver-demo/blob/main/src/thread-simple-cli.c#L1002"&gt;github.com/.../thread-simple-cli.c&lt;/a&gt;&lt;br /&gt; 1077 # &lt;a href="https://github.com/tedhavelka/kionix-driver-demo/blob/main/src/thread-simple-cli.c#L105"&gt;https://github.com/tedhavelka/kionix-driver-demo/blob/main/src/thread-simple-cli.c#L105&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This code is a few months old and in need of clean up for sure.&lt;/p&gt;
&lt;p&gt;With my Zephyr based project I&amp;#39;ve had ample microcontroller memory resources to enable printf() family functions of newlibc.&amp;nbsp; The effective replacement for printk() which I implement around uart_poll_out() is not equivalent to printk() in its signature.&amp;nbsp; My function is very simple and just takes a constant string type.&amp;nbsp; As you likely know, printk() and printf() are variadic and allow for fancier string formatting.&amp;nbsp; You can still use my solution in conjunction with snprintf() to build your messages, then pass the completed string to the wrapper I mentioned.&lt;/p&gt;
&lt;p&gt;Alternately if you are very memory constrained and can build your messages without printf() functions, you can leverage the above code at the cost of a smaller memory footprint in your project.&lt;/p&gt;
&lt;p&gt;Not sure whether this will help, but I try to answer a question here every few times I search and get answers from the Devzone community.&amp;nbsp; Hope this can help.&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/367263?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 21:42:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:598238ec-7866-495a-a666-05bf0aebff88</guid><dc:creator>JonnyMN</dc:creator><description>&lt;p&gt;I tried your suggestion, but I&amp;#39;m still getting this output from UART0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Bootloader chainload address offset: 0x10000
I: Jumping to the first image slot
+CEREG: 2,&amp;quot;4603&amp;quot;,&amp;quot;04EE0211&amp;quot;,7
+CSCON: 1
+CEREG: 5,&amp;quot;4603&amp;quot;,&amp;quot;04EE0211&amp;quot;,7,,,&amp;quot;11100000&amp;quot;,&amp;quot;11100000&amp;quot;
%XTIME: &amp;quot;0A&amp;quot;,&amp;quot;2250011293210A&amp;quot;,&amp;quot;01&amp;quot;
+CSCON: 0
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Would it be easier to use UART1 or UART2 for a custom communication channel instead? Is there any documentation on how to do this? (When I&amp;#39;ve tried to use UART1 or UART2 be modifying the dts or kconfig files, the program crashes).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/367091?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 08:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cc62675-4c00-4024-86a8-64a0e0a67298</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;My apologies for the late answer. Can you please add the following folder and file to your project folder:&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;child_image/spm.conf&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In this file, add the following line:&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span&gt;CONFIG_SERIAL=n&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Then, in your prj.conf add the following:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span&gt;CONFIG_UART_CONSOLE=n&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span&gt;CONFIG_RTT_CONSOLE=y&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Let me know how that works for you.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/366767?ContentTypeID=1</link><pubDate>Fri, 06 May 2022 14:58:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdfbe906-4c54-4691-a604-ac5449f39b9e</guid><dc:creator>JonnyMN</dc:creator><description>&lt;p&gt;Are there any updates on this? Again, I want to silence all outputs to the UART0, and only transmit data I send out via a printf() function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/365462?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 14:38:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57e5a30d-e61e-44b9-bd31-2638e2299ed7</guid><dc:creator>JonnyMN</dc:creator><description>&lt;p&gt;I added the following to my prj.conf file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BOOT_BANNER=n

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But it had no effect. Boot banner and all the Zephyr start-up messages are still present on UART0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/365313?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 07:37:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1652183-7e65-46d8-b82c-854f53cefe04</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Ok, I see. You could use e.g. RTT for logs. See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/nrf/ug_logging.html#rtt"&gt;RTT chapter in Logging in nRF Connect SDK&lt;/a&gt;. To turn off the &amp;quot;boot banner&amp;quot; you can add CONFIG_BOOT_BANNER=n.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Also, please &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/logging/index.html#logging-api"&gt;see the Zephyr Logging API&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/364755?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 14:17:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d95c1c4-c917-41cd-8007-9a2fc5bcc0f3</guid><dc:creator>JonnyMN</dc:creator><description>&lt;p&gt;This did not&amp;nbsp;fix my problem, unfortunately.&lt;/p&gt;
&lt;p&gt;Just to clear up any confusion, this is what I&amp;#39;m seeing as the device starts up:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Bootloader chainload address offset: 0x10000
I: Jumping to the first image slot
*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
Flash regions..Domain..Permissions
00 03 0x00000 0x20000 .Secure..rwxl
04 31 0x20000 0x100000 .Non-Secure.rwxl

Non-secure callable region 0 placed in flash region 3 with size 32.

SRAM region..Domain..Permissions
00 03 0x00000 0x08000 .Secure..rwxl
04 31 0x08000 0x40000 .Non-Secure.rwxl

Peripheral..Domain..Status
00 NRF_P0               Non-Secure.OK
01 NRF_CLOCK            Non-Secure.OK
02 NRF_RTC0             Non-Secure.OK
03 NRF_RTC1             Non-Secure.OK
04 NRF_NVMC             Non-Secure.OK
05 NRF_UARTE1           Non-Secure.OK
06 NRF_UARTE2           Secure..SKIP
07 NRF_TWIM2            Non-Secure.OK
08 NRF_SPIM3            Non-Secure.OK
09 NRF_TIMER0           Non-Secure.OK
10 NRF_TIMER1           Non-Secure.OK
11 NRF_TIMER2           Non-Secure.OK
12 NRF_SAADC            Non-Secure.OK
13 NRF_PWM0             Non-Secure.OK
14 NRF_PWM1             Non-Secure.OK
15 NRF_PWM2             Non-Secure.OK
16 NRF_PWM3             Non-Secure.OK
17 NRF_WDT              Non-Secure.OK
18 NRF_IPC              Non-Secure.OK
19 NRF_VMC              Non-Secure.OK
20 NRF_FPU              Non-Secure.OK
21 NRF_EGU0             Non-Secure.OK
22 NRF_EGU1             Non-Secure.OK
23 NRF_EGU2             Non-Secure.OK
24 NRF_EGU3             Non-Secure.OK
25 NRF_EGU4             Non-Secure.OK
26 NRF_EGU5             Non-Secure.OK
27 NRF_DPPIC            Non-Secure.OK
28 NRF_REGULATORS       Non-Secure.OK
29 NRF_PDM              Non-Secure.OK
30 NRF_I2S              Non-Secure.OK
31 NRF_GPIOTE1          Non-Secure.OK

SPM: NS image at 0x20200
SPM: NS MSP at 0x20015338
SPM: NS reset vector at 0x25ec1
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t want any of these messages on my UART 0 port. I only want messages that I send using printf() function in my code only.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is what I want to see during device startup:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// nothing, but I had to put something here since the code block wont let me post without any text.&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 Using UART with printf without all the debugging outputs from Zephyr</title><link>https://devzone.nordicsemi.com/thread/364623?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 08:06:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aeba2b92-dd10-46ed-8263-cf771a60ec69</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can enable the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/logging/index.html#logging-api"&gt;Logging module of Zephyr&lt;/a&gt; by adding&amp;nbsp;&lt;span&gt;#include &amp;lt;logging/log.h&amp;gt; to e.g. main.c and the following lines to prj.conf&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Configure logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_DEFAULT_LEVEL=4
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are four severity levels available in the system: error, warning, info and debug. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In your main.c add the following lines just before your main loop.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define LOG_MODULE_NAME app
LOG_MODULE_REGISTER(LOG_MODULE_NAME);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In you application you should be able to replace e.g the printk() with LOG_INF() for debug/logging information.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This should provide you with the following output&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1650873963135v1.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Let me know how that works for you&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>