<?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>lpuart with log enabled</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80898/lpuart-with-log-enabled</link><description>Hello, 
 I am quite new to NCS. I am trying to sending UART data from nRF52dk_52832 to PC. 
 The example is nrf\samples\peripheral\lpuart. 
 If I enable the example with CONFIG_LOG=y, the program crash with Stacking error (context area might be not valid</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Oct 2021 01:50:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80898/lpuart-with-log-enabled" /><item><title>RE: lpuart with log enabled</title><link>https://devzone.nordicsemi.com/thread/335837?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 01:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70d3e491-cff2-4dc2-9354-7d5dd64dc5b2</guid><dc:creator>kclauah</dc:creator><description>&lt;p&gt;Wow, that not only solve my problem but also showcase how to probably debug a program.&lt;/p&gt;
&lt;p&gt;Thank you for your excellent explanation, Simon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lpuart with log enabled</title><link>https://devzone.nordicsemi.com/thread/335709?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 11:47:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e31afea6-af77-4132-ab09-b5018f7b7767</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The solution is to set&amp;nbsp;&lt;code&gt;&lt;span&gt;CONFIG_LOG_PROCESS_THREAD_STACK_SIZE&lt;/span&gt;&lt;span&gt;=8192&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;span&gt;Explanation:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;First I added CONFIG_THREAD_NAME=y to your samples prj.conf&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Then&amp;nbsp;I ran your sample, and got the following output:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:01.865,539] &amp;lt;inf&amp;gt; app: Received data 5 bytes
[00:00:02.269,866] &amp;lt;err&amp;gt; os: ***** MPU FAULT *****
[00:00:02.269,866] &amp;lt;err&amp;gt; os:   Stacking error (context area might be not valid)
[00:00:02.269,897] &amp;lt;err&amp;gt; os: r0/a1:  0xe5b87cf6  r1/a2:  0x5889934f  r2/a3:  0xfdf17dfc
[00:00:02.269,897] &amp;lt;err&amp;gt; os: r3/a4:  0x67cba936 r12/ip:  0x7fa9b996 r14/lr:  0x004d4b6e
[00:00:02.269,927] &amp;lt;err&amp;gt; os:  xpsr:  0x61000000
[00:00:02.269,927] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x000046ac
[00:00:02.269,958] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[00:00:02.269,989] &amp;lt;err&amp;gt; os: Current thread: 0x200001d0 (logging)
[00:00:02.667,999] &amp;lt;err&amp;gt; fatal_error: Resetting system
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can see that a stack overflow happened, this is probably due to the config&amp;nbsp;&lt;code&gt;CONFIG_NO_OPTIMIZATIONS=y&lt;/code&gt;, which I didn&amp;#39;t have in my sample. Which will turn off optimizations, and the code will occupy more memory.&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Since I enabled CONFIG_THREAD_NAME, I could see that the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/20ac60fb967003e1eb3f6d296721d076c814982a/subsys/logging/log_core.c#L1426"&gt;logging thread&lt;/a&gt;&amp;nbsp;caused the issue (&lt;em&gt;Current thread: 0x200001d0 (logging)&lt;/em&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Next, I increased the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/20ac60fb967003e1eb3f6d296721d076c814982a/subsys/logging/log_core.c#L1408"&gt;stack size&lt;/a&gt; of the logging thread by adding&amp;nbsp;CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=8192 to the prj.conf file and the issue disappeared&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lpuart with log enabled</title><link>https://devzone.nordicsemi.com/thread/335603?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 01:36:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:debeb9f2-e72e-41e6-b4c1-89746e14a5f7</guid><dc:creator>kclauah</dc:creator><description>&lt;p&gt;Hi, I am sorry to bother you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Would you mind to have a look on my project?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think I have modified the project exactly like you have mentioned.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lpuart.7z"&gt;devzone.nordicsemi.com/.../lpuart.7z&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lpuart with log enabled</title><link>https://devzone.nordicsemi.com/thread/335487?ContentTypeID=1</link><pubDate>Fri, 22 Oct 2021 12:37:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:212e5299-2909-4f23-8f39-e3e402cb3df3</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I was able to get RTT Log (seems like that is what you&amp;#39;re trying to do) to work with the nrf52 DK nRF52832 in the following manner:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Modify the lpuart accordingly:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/compare/v1.7.0...simon-iversen:lpuart_rtt_log"&gt;https://github.com/nrfconnect/sdk-nrf/compare/v1.7.0...simon-iversen:lpuart_rtt_log&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Connect &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/peripheral/lpuart/boards/nrf52dk_nrf52832.overlay#L4"&gt;P0.22&lt;/a&gt; to &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/peripheral/lpuart/boards/nrf52dk_nrf52832.overlay#L5"&gt;P0.23&lt;/a&gt; and &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/peripheral/lpuart/boards/nrf52dk_nrf52832.overlay#L14"&gt;P0.24&lt;/a&gt; to &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/peripheral/lpuart/boards/nrf52dk_nrf52832.overlay#L15"&gt;P0.25&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Build the sample with nrf52dk_nrf52832&lt;/li&gt;
&lt;li&gt;Open &lt;a href="https://www.segger.com/products/debug-probes/j-link/tools/rtt-viewer/"&gt;RTT viewer&lt;/a&gt; on computer and flash the sample to the chip&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: lpuart with log enabled</title><link>https://devzone.nordicsemi.com/thread/335376?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 23:09:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfdcfc43-5d34-4d09-b2b1-aa95f97744a9</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll take a look at this tomorrow.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>