<?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>Heap size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47579/heap-size</link><description>Hi, 
 I&amp;#39;m using the latest everything for the nrf52840 with SES. 
 When I define a global variable that require substantial memory I get the linkage errors: 
 . bss is too large to fit in RAM memory segment 
 .heap is too large to fit in RAM memory segment</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 May 2019 19:41:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47579/heap-size" /><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/189116?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 19:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a0cfb39-6add-45b0-865e-7eaf6ceeefb4</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;I managed to do doing something like&amp;nbsp;&lt;/p&gt;
&lt;p&gt;struct T {&lt;br /&gt; char t = 0;&lt;br /&gt;};&lt;br /&gt;static const T a[500000];&lt;br /&gt;char* b = (char*)&amp;amp;a;&lt;/p&gt;
&lt;p&gt;Sigurd, thanks so much for all your help,&lt;/p&gt;
&lt;p&gt;Daniel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/189098?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 15:10:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c273ccd-7bc5-45f1-8a57-337bd9ea6969</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;If you want to store it in flash, use #define or const keyword.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define MY_VAR 0x10
const uint8_t my_data[5] = {0x70, 0xDC, 0x9B, 0xDD ,0xBB };
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/189092?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 14:45:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a81c310-190a-4a34-b34e-d8d9ade6b420</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;Thanks! you are right of course :) I did manage to use all the RAM memory.&lt;/p&gt;
&lt;p&gt;Would you kindly explain how can I define variables in the flash?&lt;/p&gt;
&lt;p&gt;Daniel&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/189068?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 13:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c20c2e4-044e-4a9c-9c33-b53478854fcc</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="67166" url="~/f/nordic-q-a/47579/heap-size/188959"]&lt;p&gt;A simplified example:&lt;/p&gt;&lt;p&gt;static int x[100000];&lt;br /&gt;int y = x[0];&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That won&amp;#39;t work. Each int is 4 bytes, so that would consume 400KB RAM!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188959?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 07:32:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:980f30c6-988e-4fb8-ab70-3ea50f642bd8</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;A simplified example:&lt;/p&gt;
&lt;p&gt;static int x[100000];&lt;br /&gt;int y = x[0];&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188880?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 14:43:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:185c2545-bcf3-45c9-92e3-f7b0ea41686f</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="67166" url="~/f/nordic-q-a/47579/heap-size"]When I define a global variable that require substantial memory[/quote]
&lt;p&gt;Could you post some code that shows how you are doing this ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188676?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 04:38:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48749bb0-6008-4f63-88df-d0452e6ad2c9</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;I would like to declare as large as possible variables. I have the following motivations: (1) Having an expected behaviour; (2) Using data management schemes such as fifo rather than heap; (3) Knowing in advance the expected storage available and using the maximal possible (since BLE connection may be intermittent); (4) Utilizing both RAM and flash.&lt;/p&gt;
&lt;p&gt;My problems:&amp;nbsp; I don&amp;#39;t know (1) what are the various memory sections and if they are needed; (2) how to define those (SES is using GCC under the hood but in your examples it has different&amp;nbsp; assembly file and no makefile)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Daniel&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188665?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 23:59:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1a5a05d-b9e2-44f9-ae73-245a894a76a8</guid><dc:creator>tlongeri</dc:creator><description>&lt;p&gt;Right, sorry, I forget IDEs are different. I shouldn&amp;#39;t have assumed you were using GCC.&lt;/p&gt;
&lt;p&gt;Sorry, but I&amp;#39;ve never used SES, so I can&amp;#39;t help you with that.&lt;/p&gt;
&lt;p&gt;I think it would help if you gave more details about what you are trying to do. For instance, are you trying to allocate a huge array of something? If so, how big is your array exactly? (or are you trying to figure out how big you can make it?)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188566?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 12:44:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58ab7db9-12bd-46b2-b4c2-2d3d71b9c8a7</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;I understand how to get to the right place in the IDE (I&amp;#39;m using my own code). When I get there the info provided is:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span&gt;Section Placement Macros&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Macro values to substitue in section placement nodes - MACRO1=value1;MACRO2=value2.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span&gt;Inherits&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;quot;FLASH_PH_START=0x0;FLASH_PH_SIZE=0x100000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x40000;FLASH_START=0x26000;FLASH_SIZE=0xda000;RAM_START=0x200022e0;RAM_SIZE=0x3dd20&amp;quot; from project in Common configuration&lt;br /&gt;&amp;quot;FLASH_START=0x26000;FLASH_SIZE=0x5a000;SRAM_START=0x20002a98;SRAM_SIZE=0xd568&amp;quot; from solution in Debug configuration&lt;/p&gt;
&lt;p&gt;The issues I don&amp;#39;t understand:&lt;/p&gt;
&lt;p&gt;1. How to define the &amp;quot;.data&amp;quot;, &amp;quot;.bss&amp;quot; etc. sections?&lt;/p&gt;
&lt;p&gt;2. Which section is related to static variables? (I guess it is the &amp;quot;.bss&amp;quot;. right?)&lt;/p&gt;
&lt;p&gt;3. Which sections correspond to static variables on the flash.&lt;/p&gt;
&lt;p&gt;Are my questions clear?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Daniel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188559?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 12:33:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a384463-7665-4a62-bc0b-24b5731b4ffc</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;For the project options, right click on &amp;quot;Project &amp;#39;&amp;lt;example you are using&amp;gt;&amp;quot;, and click Options..:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1558528314645v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;For Memory Usage: View -&amp;gt;&amp;nbsp;&lt;span&gt;Memory Usage, or CTRL+ALT+Z&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What example in the SDK are you using ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188551?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 12:12:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce992e4a-0a7e-4912-8b87-1bdc196f7223</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;Sigurd,&lt;/p&gt;
&lt;p&gt;Can you kindly share the configuration that created the example you showed (or a similar example)? I don&amp;#39;t understand which keys to use.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Daniel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188530?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 11:33:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5ca27be-f43c-424b-9538-6899260e0b61</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;This is SDK 15.3?&lt;/p&gt;
&lt;p&gt;How does your section placement macros look like ?&lt;/p&gt;
&lt;p&gt;Something like this ?&lt;br /&gt;&amp;nbsp;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1558524592163v1.png" alt=" " /&gt;&lt;/p&gt;
[quote userid="67166" url="~/f/nordic-q-a/47579/heap-size/188467"]Would you kindly check how to do so using SES and double check the dynamic memory usage of the Softdevice?[/quote]
&lt;p&gt;The RAM usage of&amp;nbsp;the SD is printed in&amp;nbsp;nrf_sdh_ble_enable(), but you should be able to compile your project even if this is not correctly configured.&lt;/p&gt;
&lt;p&gt;How does the Memoery Usage display in SES looke like?&lt;/p&gt;
&lt;p&gt;If configured correctly, it should looke something like this;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1558524790750v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188467?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 08:40:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43a2a02c-b07d-4943-8ad2-a96cd548f0ea</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;Tlongeri,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using global variables (of course not in header files) in order to have full control of memory, and I would like to use the full capacity of the RAM and Flash (which I cannot do if using the out of the box definitions). It is vital to my application and I would hate adding external memory where there is sufficient memory in the soc.&lt;/p&gt;
&lt;p&gt;It seems SES is utilizing &amp;quot;thumb_ct0.s&amp;quot; rather than the ld files. I would like avoiding messing assembly files and there must be a clean way to do so.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Would you kindly check how to do so using SES and double check the dynamic memory usage of the Softdevice? Please also refer to the Flash side.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Daniel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heap size</title><link>https://devzone.nordicsemi.com/thread/188339?ContentTypeID=1</link><pubDate>Tue, 21 May 2019 15:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d210d2a-7202-4d3b-b45a-b9fc896fc127</guid><dc:creator>tlongeri</dc:creator><description>&lt;p&gt;I haven&amp;#39;t used the latest SDK, but I think you should look at your linker script (.ld) file. At the beginning it should define the RAM and FLASH memory regions which determine the amount of memory available to the applications (they are offset from the flash/RAM start addresses to leave room for the SoftDevice). It should also have the line &amp;#39;#include &amp;quot;nrf_common.ld&amp;quot;&amp;#39; which refers to &amp;lt;sdk dir&amp;gt;/modules/nrfx/mdk/nrf_common.ld. That file determines how sections like .bss and .data are allocated, and may clear things up if you know or can learn how to read linker scripts.&lt;/p&gt;
[quote userid="67166" url="~/f/nordic-q-a/47579/heap-size"]3. Does Softdevice use heap memory?[/quote]
&lt;p&gt;Nope (at least not the same heap that your application uses, although I nevertheless don&amp;#39;t expect that it uses a heap), if you are not using malloc then you should be able to safely eliminate the heap by adding -D__HEAP_SIZE=0 to your compiler flags (I&amp;#39;ve done that without any trouble, albeit using SDK v12.3.0). &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/3351/nrf51822-with-gcc---stacksize-and-heapsize"&gt;This old question&lt;/a&gt; talks a bit about that.&lt;/p&gt;
&lt;p&gt;Removing the heap won&amp;#39;t solve your problem if .bss alone is too large, though. It seems like the variable you&amp;#39;re defining really is &lt;strong&gt;too&lt;/strong&gt; large to fit in memory (you&amp;#39;re not defining global variables in header files, are you?).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>