<?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>Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics</link><description>Hi all! 
 I am working on the SDK 15.2, with S132 6.0, and i use the SES IDE. 
 I have created a custom service with 32 characteristics for now. The goal in the future is to have 3 custom services and to use few SIG-adopted services. 
 I have met a problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Aug 2020 09:20:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics" /><item><title>RE: Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/thread/265711?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2020 09:20:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24cf1cc4-3d28-4e13-a1da-d8e3960954b6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;MTU (&lt;span&gt;Maximum Transmission Unit)&lt;/span&gt; is the maximum allowed packet size in a BLE connection. Basically how long messages you can send. In BLE4.0 this was fixed to 23 bytes, which means 3 bytes of header, and 20 bytes of payload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In BLE4.2&amp;nbsp;this was updated to support up to 247 bytes, allowing for a lot higher throughput and lower current consumption, because you can send longer packets with higher payload/headers ratio.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Beldramma"]Do you know if there is a way to know the content of the GATT Table ?[/quote]
&lt;p&gt;&amp;nbsp;The GATT table is stored in the softdevice, so you can&amp;#39;t access it directly.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/thread/265600?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 14:55:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e3ac42c-69bf-48f9-a0c8-7bd3f651e123</guid><dc:creator>Beldramma</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265597"]To be honest,&amp;nbsp;I am not sure what all of the sections mean. They are partly compiler (IDE) specific and partly Nordic specific. the important thing is to set the ram start and size according to what is printed in the log.[/quote]
&lt;p&gt;Hum Ok. Do you know if there is a way to know the content of the GATT Table ?&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265597"]So the underlying issue here is that you have some issues with the UART, right?[/quote]
&lt;p&gt;Yes I had, but today, idk why it works back. I hope it is due to flashing problem. But I am still interested about RAM content, and particularly my previous question. Also, I have seen that the NUS service use the MTU,what is it exactly ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Antoine Kristanek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/thread/265597?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 14:46:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6bfa9a4-8d5f-4ce6-ae4d-9b324a430736</guid><dc:creator>Edvin</dc:creator><description>[quote user="Beldramma"]Yes, but I don&amp;#39;t know the content of every partition, and their goal.&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;To be honest,&amp;nbsp;I am not sure what all of the sections mean. They are partly compiler (IDE) specific and partly Nordic specific. the important thing is to set the ram start and size according to what is printed in the log.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[quote user="Beldramma"][/quote]&lt;/p&gt;
&lt;p&gt;When I get the program, there were only one custom service ( NUS). At this time, my RAM values were :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;RAM_START = 2000 2A98&lt;/p&gt;
&lt;p&gt;RAM_SIZE = d568&lt;/p&gt;
&lt;p&gt;I think that the default value is&amp;nbsp;&lt;/p&gt;
&lt;p&gt;RAM_START = 2000 2218&lt;/p&gt;
&lt;p&gt;RAM_SIZE = dde8&lt;/p&gt;
&lt;p&gt;Is it coherent ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;If you change it back, does the log suggest that you should change it to start: 0x20002a98 and size:&amp;nbsp; 0xd568?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So the underlying issue here is that you have some issues with the UART, right?&lt;/p&gt;
&lt;p&gt;Can you set a breakpoint after you enable the UART, and read out the register&amp;nbsp;&lt;span&gt;0x40002&lt;/span&gt;&lt;span&gt;544 and&amp;nbsp;0x40002534? These should point to the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uarte.html?cp=4_2_0_34_9#topic" rel="noopener noreferrer" target="_blank"&gt;UART TX and RX buffer&lt;/a&gt;. In Segger Embedded Studio, you should be able to see them directly in the IDE if you click &amp;quot;Groups&amp;quot; under the &amp;quot;Registers&amp;quot;&amp;nbsp; window. Depending on what UART you are using, select that one:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c5cf5c12734b4a07ac0e9d5d8d451451/pastedimage1597934660817v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR,&lt;br /&gt;Edvin&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: Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/thread/265388?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 15:18:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee5b0eb0-5a9c-434d-9ed7-871010e51aa6</guid><dc:creator>Beldramma</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265374"]I am sorry. I don&amp;#39;t have a way of calculating this. Set it high enough, and decrease it until it complains again.[/quote]
&lt;p&gt;Good idea.&amp;nbsp;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265374"]What are your RAM settings, and how do you set up the UART? I can see if I can find any conflicts.[/quote]
&lt;p&gt;My RAM Settings are :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;RAM_START=0x20002CF8&lt;/p&gt;
&lt;p&gt;RAM_SIZE=0xd308&lt;/p&gt;
&lt;p&gt;The uart is initialized with the uart_host_init function from the uart_host library. Normally the Nordic is in low power mode, but when we receive an interruption signal on pin 3, we switch on the nordic and activate the uart handler. We use the&amp;nbsp;uart_host_data_receive function to receive the data and uart_cde_treatment to process it.&amp;nbsp;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265374"]Do you mean how much RAM the softdevice needs? Or your application? In case of the softdevice, this depends heavily on what services and characteristics you have, how long the data field of the characteristics are, what MTU you use, how many connections you support, to mention some.[/quote]
&lt;p&gt;I mean, I want to know if there is enough memory allocated.&amp;nbsp;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265374"]I am not sure I understood this question. Doesn&amp;#39;t the picture show you what the partitions of the RAM consists of?[/quote]
&lt;p&gt;Yes, but I don&amp;#39;t know the content of every partition, and their goal.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/64987/bug-with-ram-when-adding-new-services-and-characteristics/265374"]he NUS service doesn&amp;#39;t require more RAM than most services, but it supports a large packet size, so it needs to set aside RAM in the softdevice for this. [/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;oh ok.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I get the program, there were only one custom service ( NUS). At this time, my RAM values were :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;RAM_START = 2000 2A98&lt;/p&gt;
&lt;p&gt;RAM_SIZE = d568&lt;/p&gt;
&lt;p&gt;I think that the default value is&amp;nbsp;&lt;/p&gt;
&lt;p&gt;RAM_START = 2000 2218&lt;/p&gt;
&lt;p&gt;RAM_SIZE = dde8&lt;/p&gt;
&lt;p&gt;Is it coherent ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Antoine Kristanek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug with RAM when adding new services and characteristics</title><link>https://devzone.nordicsemi.com/thread/265374?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 14:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4a0bd11-955d-4e4c-a5d4-f532ff0661ba</guid><dc:creator>Edvin</dc:creator><description>[quote user=""]My first question is: How do we know which size do we have to choose&amp;nbsp; when adding new services? First it was at 1408, i have put at 2000. Is there a proper way to calculate it ?[/quote]
&lt;p&gt;&amp;nbsp;I am sorry. I don&amp;#39;t have a way of calculating this. Set it high enough, and decrease it until it complains again.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]So I have also changed the RAM size and RAM start, and my app is working, I have no more problem with the NO_MEMORY message and the stack_init but I have met another problem: normally every minute, my processor receive data through UART from another processor. Normally it works, but now not amymore. Because I have changed only the RAM part, I think the problem come from there.[/quote]
&lt;p&gt;&amp;nbsp;What are your RAM settings, and how do you set up the UART? I can see if I can find any conflicts.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]My second question is How many minimum RAM size do we need&amp;nbsp; for the program to work ? I think now there is not enough RAM to do that and I don&amp;#39;t know what to do.[/quote]
&lt;p&gt;&amp;nbsp;Do you mean how much RAM the softdevice needs? Or your application? In case of the softdevice, this depends heavily on what services and characteristics you have, how long the data field of the characteristics are, what MTU you use, how many connections you support, to mention some.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]My third question is, is there a way to know what constitues each partition in the RAM? With SES I can see this picture of my RAM:[/quote]
&lt;p&gt;&amp;nbsp;I am not sure I understood this question. Doesn&amp;#39;t the picture show you what the partitions of the RAM consists of?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]I would like to know what there is in each partirtion. Indeed, with that, one of the things that I would like to know is: I have taken an existing program, and the programmer modified the RAM size and start, but there were only the NUS custom Service, otherwise the others services were the SIG adopted ones GAP, Generic Attribute, and Device Information. The NUS service needs a lot of memory ?[/quote]
&lt;p&gt;&amp;nbsp;The NUS service doesn&amp;#39;t require more RAM than most services, but it supports a large packet size, so it needs to set aside RAM in the softdevice for this. Other than that, the custom BLE services requires more RAM than the Bluetooth SIG services. The reason for this is that the UUIDs which identify the services are shorter in the Bluetooth defined services, while they are longer in the custom services. Bluetooth SIG services have a UUID consisting of 16 bit, while custom services have a UUID of 128 bit.&lt;/p&gt;
&lt;p&gt;So the difference here is 14 bytes, so it doesn&amp;#39;t really take up a lot, but the main reason you need more for the NUS service is the characteristic&amp;#39;s max length (data). Check out ble_nus.c and the lines saying:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; add_char_params.max_len&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = BLE_NUS_MAX_RX_CHAR_LEN;&lt;br /&gt;and&lt;br /&gt;&amp;nbsp; &amp;nbsp; add_char_params.max_len&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= BLE_NUS_MAX_TX_CHAR_LEN;&lt;/p&gt;
&lt;p&gt;Both of these are 247 bytes, so that is where most of your RAM went &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>