<?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_tx api crashing issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86924/uart_tx-api-crashing-issue</link><description>Hi, All 
 I try to modify the central uart example - mainly focus on uart function instead of BLE, I try to send a message back to uart use uart_tx() api instead of printk(), it seems working fine like this 
 
 
 
 
 
 But when I try to replace the uart_tx</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Apr 2022 13:41:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86924/uart_tx-api-crashing-issue" /><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/364266?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 13:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22d45778-5834-47d9-a4f2-89356050a744</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I am not able to reproduce the error&amp;nbsp;using a nRF52833DK in NCS v1.9.1 in VS Code and changing only&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data, K_FOREVER);
    
    if (uart_tx(uart, buf-&amp;gt;data, buf-&amp;gt;len, SYS_FOREVER_MS)) {
		LOG_WRN(&amp;quot;Failed to send data over UART&amp;quot;);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data, K_FOREVER);
    
    if (uart_tx(uart, &amp;quot;UartDataRxed\n&amp;quot;, 13, SYS_FOREVER_MS)) {
		LOG_WRN(&amp;quot;Failed to send data over UART&amp;quot;);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I was able to force a bus fault by adding &amp;quot;&amp;nbsp;&lt;span&gt;uart_tx&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uart&lt;/span&gt;&lt;span&gt;, &amp;quot;&lt;/span&gt;&lt;span&gt;UartDataRxed\n&amp;quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;13&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;SYS_FOREVER_MS&lt;/span&gt;&lt;span&gt;);&amp;quot; in the case UART_TX_DONE: before any checks are done,&amp;nbsp;&lt;/span&gt;which results in a thread interruption fault with the same zephyr error you got caused by. This error and crash is triggered by ,C:/Nordic/SDKs/ncs/v1.9.1/zephyr/kernel/thread.c:819(r15/pc) and&amp;nbsp;C:/Nordic/SDKs/ncs/v1.9.1/zephyr/include/spinlock.h:129 (r14/lr), but I can&amp;#39;t guarantee that this interruption error is what&amp;nbsp; caused the issue for you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you can add the central_uart project with the modifications and add it here, I can take a closer look if I either have misunderstood where you&amp;#39;ve done the change or if any other changes has happened by a mistake.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/364099?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 07:14:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9a5fc4f-d10c-4a19-95db-3a534cc72231</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Hi, Andreas&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t change anything except that line. I use nrf Connect SDK v1.9.1, and VS Code.&lt;/p&gt;
&lt;p&gt;Regards!&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/363859?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 10:38:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc860be7-00ed-47ab-b005-a347abef9017</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="PingISTL"]here is what I did, and cannot go any further - did I misunderstand you?[/quote]
&lt;p&gt;&lt;br /&gt;You did it correct. This just means that gnuarmemb is not added to the your system variables, which we need to run the two other lines. If we need to/or you want to try this yourself while we look on the next possible solution, you could perform this&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_installing.html#install-the-gnu-arm-embedded-toolchain"&gt;step in the manual installation guide&lt;/a&gt;. It should allow you to run the two missing lines lines in the prior suggestion.&lt;/p&gt;
[quote user="PingISTL"]Thanks for your reply, I changed the length to 14, and it still crashes. don&amp;#39;t think it is the length issue.[/quote]
&lt;p&gt;Before we started the command line investigation, you said that your code still crashes. Have you changed anything else in central_uart than than line 162 illustrated as seen below? I am not able to recreate any error by simply editing that line. If your project does not contain any sensitive information, you could add the .c file you&amp;#39;re working in by inserting it in a code-snippet in a reply, and I&amp;#39;ll take a look.&lt;/p&gt;
&lt;p&gt;Also, I should have asked this question earlier: What version of nRF Connect SDK are you working with?&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;...

// if (uart_tx(uart, buf-&amp;gt;data, buf-&amp;gt;len, SYS_FOREVER_MS)) {
if (uart_tx(uart, &amp;quot;UartDataRxed\n&amp;quot;, 14, SYS_FOREVER_MS)){
	LOG_WRN(&amp;quot;Failed to send data over UART&amp;quot;);
}

break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/363790?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 08:27:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d6638c8-5e83-42e6-93aa-4bebb4649aaa</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Thanks for reply, Andreas&lt;/p&gt;
&lt;p&gt;here is what I did, and cannot go any further - did I misunderstand you?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1650443179512v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/363527?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 10:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4ce4852-27f1-4ba8-b878-d4e41a22f92a</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Ping,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Apologies for the delay in response. The office has been closed due to&amp;nbsp;the recent holidays. Have you figure out the issue since your last reply?&lt;/p&gt;
&lt;p&gt;If not, lets check out if the error you&amp;#39;ve pasted may help us. Could you open a command line window and write the following&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1) &amp;quot;where arm-none-eabi-addr2line&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This should return something like&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin\arm-none-eabi-addr2line.exe&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If it does not return something like this, then we can&amp;#39;t do the next steps.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt;&amp;nbsp;We now want to know what causes the error you&amp;#39;ve pasted. Write now:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;arm-none-eabi-addr2line -e &amp;lt;path to _build\zephyr\zephyr.elf&amp;gt; &amp;lt;0xaddr&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;where you replace &amp;quot;&amp;lt;path to build&amp;gt;&amp;quot; with your path and &amp;lt;0xaddr&amp;gt; with the R15/pc and R14/lr adress&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;quot;arm-none-eabi-addr2line -e &amp;lt;path to _build\zephyr\zephyr.elf&amp;gt; &amp;lt;0x0001e533&amp;gt;&amp;quot;&lt;/strong&gt;&lt;/em&gt; for r15/pc&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;quot;arm-none-eabi-addr2line -e &amp;lt;path to _build\zephyr\zephyr.elf&amp;gt; &amp;lt;0x0001e820&amp;gt;&amp;quot; &lt;/strong&gt;&lt;/em&gt;for r14/lr&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This should (hopefully) return a function or variable that could point to why the cpu has crashed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Let me know about the progress.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/363228?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 15:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dfbadab-a5a6-4abb-a991-5bbea9361b8c</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Hi, Andreas&lt;/p&gt;
&lt;p&gt;Thanks for your reply, I changed the length to 14, and it still crashes. don&amp;#39;t think it is the length issue.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;tried the ehco_bot sample, it is based on interrupt, and it works fine, thank you for sending it.&amp;nbsp;The other sample uses uart_tx function too - not based on interrupt, so for me it has same issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart_tx api crashing issue</title><link>https://devzone.nordicsemi.com/thread/363193?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 12:33:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ce19007-5e6d-46f7-ae09-9e8a3228a322</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Ping,&lt;/p&gt;
&lt;p&gt;The string you&amp;#39;re trying to pass is not of length 13, but&amp;nbsp;rather it is length 14. Try to change it to 14 and see if it works!&lt;br /&gt;&lt;br /&gt;If it does not work, I would recommend you take a look at&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/lessons/lesson-4-serial-communication-uart/"&gt;this NCS Course topic concerning UART&lt;/a&gt;&amp;nbsp;to both read up on the essentials as well as examine&amp;nbsp;if the sample in &lt;a href="https://academy.nordicsemi.com/topic/exercise-1-5/"&gt;exercise 1&amp;nbsp;&lt;/a&gt;could explain what you&amp;#39;re missing. Additionally,&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/uart/echo_bot"&gt;this uart echo sample&lt;/a&gt;&amp;nbsp;might be of help&lt;br /&gt;&lt;br /&gt;Let me know if any of this helps!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>