<?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>Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76449/not-able-to-allocate-uart-receive-buffer</link><description>I use our designed board with control chip nrf5340 to test ncs1.5.0 sample peripheral_uart , I not changed a word of sample .but when debug program, show :Not able to allocate UART receive buffer. this buffer is only 20 bytes length!!!! .our board can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Jun 2021 13:33:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76449/not-able-to-allocate-uart-receive-buffer" /><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/316091?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 13:33:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d21eacf-aec3-416c-a85a-d740a652098a</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Have you followed the guide her for testing;&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html#testing"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html#testing&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What terminal are you&amp;nbsp;using?&lt;br /&gt;&lt;br /&gt;It works for me, i have tested on a nrf5340 DK v0.11.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Could you try to du a update of the NCS repository?&lt;br /&gt;&lt;br /&gt;Using the &amp;quot;west update&amp;quot; command?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/316046?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 10:08:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69a5c92f-ebdf-4805-b1d5-552f37365d87</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;If have to reverse my statement here - the code is just too hard to understand.&lt;/p&gt;
&lt;p&gt;While &amp;quot;buf&amp;quot; goes out of scope, it it reinstaded via macro after the UART RX handler runs. Very confusing, and not part of OP submission either. &lt;strong&gt;PLEASE DON&amp;#39;T SUBMIT CODE AS IMAGE, EVER!&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/316045?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 10:07:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03fb8950-d0f7-442d-bde8-f6bfdf27ec2e</guid><dc:creator>zhouhaifang</dc:creator><description>&lt;p&gt;neither using ncs1.5.0 nor using ncs1.5.1 ,peripheral_uart sample uart code is the same .i use nrf5340dk and ncs1.5.1 ,encount this situation and&amp;nbsp;spending several days to resolve,but have no result . you show three same code,do not understand what&amp;#39;s your meaning.&lt;/p&gt;
&lt;p&gt;I have re-unzip my ncs1.5.0(former run well), sample peripheral_uart code i do not change a char, but when debug ,log information pop out&amp;nbsp;&lt;span&gt;&amp;quot;Not able to allocate UART receive buffer&amp;quot;. maybe i should re-mount may computer operating system???&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/316040?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 09:41:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02075638-a55b-4567-b9bd-e18c73d0fc7f</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;What version of the nrf53 are you using, are you on a DK that is earlier&amp;nbsp;then 0.11.0 ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is the different places where the its used&lt;br /&gt;&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1624008688394v1.png" alt=" " /&gt;&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L137"&gt;https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L137&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L153"&gt;https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L153&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1624008707668v2.png" alt=" " /&gt;&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L194"&gt;https://github.com/nrfconnect/sdk-nrf/blob/a18b84ef0c7231291ca718b5876af50ed33b7923/samples/bluetooth/peripheral_uart/src/main.c#L194&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Did it work in NCS 1.5.0 for you?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/315900?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2021 13:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2073a9a4-f056-41e3-81ff-81f8f8efb474</guid><dc:creator>zhouhaifang</dc:creator><description>&lt;p&gt;in ncs1.5.0,there is two samples use this way to deal with uart receive event , in sample peripheral_uart&amp;nbsp; function void uart_cb(xxxx)&amp;nbsp; ,there are&amp;nbsp;two place&amp;nbsp;like below code:&lt;/p&gt;
&lt;p&gt;struct uart_data_t *buf&lt;/p&gt;
&lt;p&gt;buf = k_malloc(sizeof(*buf));&lt;br /&gt; if (buf) {&lt;br /&gt; &amp;nbsp;buf-&amp;gt;len = 0;&lt;br /&gt; } else {&lt;br /&gt; &amp;nbsp;LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);&lt;br /&gt; k_delayed_work_submit(&amp;amp;uart_work,UART_WAIT_FOR_BUF_DELAY);&lt;br /&gt; &amp;nbsp;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;when using nrf5340 debug ,every encount this situation . program all run to else branching ，not run to if branching&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NORDIC&amp;nbsp;code style is&amp;nbsp; difficult&amp;nbsp; than all other chip manufacture code style ,nordic code always turn a thousand turns,very difficult to understand .a mini change always mean many error.i&amp;nbsp;declare&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static struct uart_data_t *buf&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;a globle variable of in main.c&amp;nbsp; , and delete all code&amp;nbsp;as below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;buf = k_malloc(sizeof(*buf));&lt;br /&gt;if (buf) {&lt;br /&gt;&amp;nbsp;buf-&amp;gt;len = 0;&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp;LOG_WRN(&amp;quot;Not able to allocate UART receive buffer&amp;quot;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;but can not work well .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i do not change a word of sample peripherart_uart in NCS1.5.0 !!!&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><item><title>RE: Not able to allocate UART receive buffer</title><link>https://devzone.nordicsemi.com/thread/315811?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2021 09:59:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbd96363-5bda-462b-90ae-6ab2d8be1168</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Heap overflow. The pointer &amp;quot;buf&amp;quot; goes out-of-scope without the corresponding &amp;quot;k_free&amp;quot; call.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>