<?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>printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102922/printk-becomes-slow-when-config_log-y-and-trying-to-recieve-serial-communication-over-uart</link><description>I&amp;#39;m using a nRF52840 with the nRF Connect SDK version 2.4.1. I&amp;#39;ve been using Zephyr&amp;#39;s logging module however now I want to also receive data over UART. I followed the Serial Communication (UART) example in nRF Connect SDK Fundamentals course however I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Aug 2023 14:24:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102922/printk-becomes-slow-when-config_log-y-and-trying-to-recieve-serial-communication-over-uart" /><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442612?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 14:24:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3aa5799-2e45-4cdd-980a-1d05dd01993c</guid><dc:creator>poplitard</dc:creator><description>&lt;p&gt;Hey, so the first screenshot shows a batch of prints at 50s followed by a second batch of prints at 51s. The second screenshot shows printks without buffering.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I think I figured it out, it seems like in ncs 2.2.0 i didnt have to explicitly use&amp;nbsp;CONFIG_LOG_PRINTK=n&amp;nbsp; because it was disabled by default&lt;/p&gt;
&lt;p&gt;the newer version of zephyr in ncs 2.4.0 has CONFIG_LOG_PRINTK enabled by default, so you have to disable it to prevent printk buffering&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;printk and logs share the same output backend according to the documentation, which means that printks will be buffered before they outputting anything&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/services/logging/index.html#printk"&gt;https://docs.zephyrproject.org/latest/services/logging/index.html#printk&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the config files in the lesson needs to include CONFIG_LOG_PRINTK= to reflect this change (to print instantly)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;im a relatively new dev, and i havent really contributed to opensource projects yet, let me know if I can open a pr for this and contribute, thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442604?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 13:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9b2d64c-6288-49f7-aa71-d03efcc91b2e</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello Richard,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;I was answering to the other person(poplitard) who pasted a screenshot with time stamps. Yes, I tried devacademy sample and I can see the delay that you mentioned (not exactly sure how much). I am still on this case and will try to find the cause of delay happening.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442591?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 13:36:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89ac4dd5-c34e-4d6c-b052-db28062f169c</guid><dc:creator>Richard11115</dc:creator><description>&lt;p&gt;Are you using a nrf52840 with the modified Lesson 5 Exercise 1 Solution repo code from the course NRF Connect Fundamentals? Millisecond delays would be fine but these are second delays so are causing serious issues&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442580?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 13:15:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d12ff1ab-5145-4909-9dc9-7b5128e7fe4a</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;While checking the time stamps I can see some milliseconds delay but isn&amp;#39;t that usual? I can&amp;#39;t find a delay greater than or equal to 1 second like you pointed out. Please excuse if I missed something.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442364?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 14:58:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1c6df67-04ae-411b-8427-30a242f81949</guid><dc:creator>poplitard</dc:creator><description>&lt;p&gt;Im running the following piece of code:&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#c586c0;"&gt;#include&lt;/span&gt;&lt;span style="color:#569cd6;"&gt; &lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;lt;zephyr/kernel.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#569cd6;"&gt;int&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;main&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;font-size:75%;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#c586c0;"&gt;while&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;1&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;font-size:75%;"&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;printk&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;Hello World&lt;/span&gt;&lt;span style="color:#d7ba7d;"&gt;\n&lt;/span&gt;&lt;span style="color:#ce9178;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;k_sleep&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;K_MSEC&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;(&lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;100&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;font-size:75%;"&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#c586c0;"&gt;return&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;0&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#cccccc;font-size:75%;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;with the following configs:&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_LOG&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_PRINTK&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_SERIAL&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and what i see is that is takes about a second before it actually sends anything over uart:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1692629805336v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if i include this (or disable logs entirely):&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="font-size:75%;"&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_LOG_PRINTK&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=n&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it runs consistently:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1692629916223v2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442348?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 14:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efb4150c-fc3f-4de6-a401-94e3c2356543</guid><dc:creator>Richard11115</dc:creator><description>&lt;p&gt;Yes, I tested it just roughly with a timer it averages around 1.5 seconds when CONFIG_LOG is enabled while it&amp;#39;s virtually instant when CONFIG_LOG is disabled&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442346?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 14:14:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a2c06ea-5208-4758-a709-4421f4baf7df</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes, I can see a very slight delay in printing while enabling the log module. For me, it is very slight; I probably can&amp;#39;t say it is 2 seconds because I haven&amp;#39;t checked how much difference in time it creates with CONFIG_LOG enabled. But have you tested this and found that it is taking 2 seconds?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442317?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 13:21:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9ab8739-5b1b-4a92-9de7-3d64997fc1b9</guid><dc:creator>poplitard</dc:creator><description>&lt;p&gt;Having the same problem over here, except im usnig the uart backend for logs&lt;/p&gt;
&lt;p&gt;Enabling config_log holds back some printks and seems to print only when a certain amount of data has accumulated in the buffer&lt;/p&gt;
&lt;p&gt;When I print frequently i have a lot of messages that get dropped as a result&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart</title><link>https://devzone.nordicsemi.com/thread/442071?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 11:43:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b191077-9e8b-4efb-bd05-e8dae3c2b44f</guid><dc:creator>Menon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am letting you know that I have been assigned to this case, and I will try to test this here.&lt;/p&gt;
&lt;p&gt;I will get back to you after testing this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Abhijith&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>