<?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>How do I read my .map file?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42048/how-do-i-read-my-map-file</link><description>I am trying to free up some RAM on my nRF because I am getting Fatal error 0x4, NRF_ERROR_NO_MEM when I try to increase the size of a 2D array. 
 I do not understand how to read my map file. This is the file that contains all my symbols, correct? I sorted</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Jan 2019 09:02:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42048/how-do-i-read-my-map-file" /><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/164454?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 09:02:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cd891c2-137d-4fb4-9701-ccf504407910</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you get&amp;nbsp;NRF_ERR_NO_MEM returned from a call to&amp;nbsp;sd_ble_gatts_characteristic_add(), then this is because the GATT table is too small as you have noted. In that case you need to increase it and adjust the application start address as you have done.&amp;nbsp;&lt;/p&gt;
[quote user="androng"]Why do I only get an NRF_ERR_NO_MEM from the char_add() function when I try to increase my array size?[/quote]
&lt;p&gt;&amp;nbsp;Please always specify from which function you get the error code. That way we can better understand the issue. How do you try to allocate this array, and&amp;nbsp;from where do you get&amp;nbsp;NRF_ERR_NO_MEM in this case?&lt;/p&gt;
[quote user="androng"]Why does&amp;nbsp;an array allocated outside of the SoftDevice RAM affect the Softdevice RAM?[/quote]
&lt;p&gt;It does not. There is a strict separation between SoftDevice an application RAM, which is why you have to configure the application RAM start address to be after the end of the RAM used by the SoftDevice (which depend on its configuration).&lt;/p&gt;
[quote user="androng"]How do I know if I have&amp;nbsp;unallocated physical RAM left? Do I just&amp;nbsp;add up everything in the memory addresses0x20002A38-0x20010000 and sum up their sizes + 0x2A38 for the SoftDevice RAM?[/quote]
&lt;p&gt;Yes. However, if you use for instance&amp;nbsp;Segger Embedded Studio (or most other IDEs for that matter) it would present you the memory usage automatically after every build so that you will not have to do the calculations yourself. For that and other reasons I suggest you consider migrating to &lt;span&gt;Segger Embedded Studio unless you have a strong inclination to continue using GCC directly.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/164089?ContentTypeID=1</link><pubDate>Sat, 05 Jan 2019 08:30:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb0c9ec1-1cb1-4efb-b76d-1288ea0a1b69</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;I did not know that RAM from&amp;nbsp;&lt;span&gt;0x20000000-0x20002400 is allocated to the SoftDevice. That would have helped my calculations.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I was able to eliminate my NRF_ERR_NO_MEM error by increasing the size of the GATT table by increasing NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE and from 1408 to 3000 and increasing the RAM limits to RAM (rwx) :&amp;nbsp; ORIGIN = 0x20002A38, LENGTH = 0xD5C8. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why do I only get an NRF_ERR_NO_MEM from the char_add() function when I try to increase my array size? My array is allocated&amp;nbsp;with&amp;nbsp;RAM outside of the SoftDevice RAM: address 0x20005f20. Why does&amp;nbsp;an array allocated outside of the SoftDevice RAM affect the Softdevice RAM?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How do I know if I have&amp;nbsp;unallocated physical RAM left? Do I just&amp;nbsp;add up everything in the memory addresses0x20002A38-0x20010000 and sum up their sizes + 0x2A38 for the SoftDevice RAM?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/164004?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 15:13:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac329d34-a1a3-4de7-bca7-61dfbad4cdab</guid><dc:creator>UnicycleBloke</dc:creator><description>&lt;p&gt;What is the actual code that fails?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/163981?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 14:05:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60a8b108-a9cf-4c26-8613-00a930e566dd</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I did not follow your calculations and reasoning about why you would expect to fill all the RAM.&lt;/p&gt;
&lt;p&gt;Regarding the physical size, the application can typically not use all the RAM of the device. If you have a SoftDevice, then that will need some RAM as well. In your case the application RAM starts from&amp;nbsp;0x20002400, which I assume is because the SoftDevice use the RAM from&amp;nbsp;0x20000000 and upto&amp;nbsp;0x200023FF. I expect this matches your linker configuration.&lt;/p&gt;
&lt;p&gt;Regarding the original question: Note that there is no direct link between free space on the device and you getting&amp;nbsp;NRF_ERROR_NO_MEM. If there is no more space in the heap, then you cannot allocate any more. That is regardless of if there is available space on the device or not, as long as that is not configured to be used for the heap.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/163895?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 08:32:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9de84ab5-9062-4b50-b869-80cf54b8d6fc</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;I made a symbol table of everything in my map file from RAM start address 0x20002400 to (0x20002400 + 0xDC00).&amp;nbsp;They&amp;nbsp;add up to&amp;nbsp;21556 bytes, not the expected 56kbytes. And why&amp;nbsp;is the RAM&amp;nbsp;length only 56k bytes? Why isn&amp;#39;t it 64k bytes since the chip has 64k RAM?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/163893?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 08:29:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6758b39a-7776-45e8-9617-9e477079cd2d</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;This was helpful. I didn&amp;#39;t know &amp;quot;.bss.ucHeap&amp;quot; is the FreeRTOS heap. Mine was set to 8192. I lowered it to 4096 and FreeRTOS crashed. I lowered it to 8000 and FreeRTOS seemed to run, but then when I increased my array size from 140 to 280, I still got a runtime error NRF_ERR_NO_MEM even though I can see in the map file that my array is now 0x112 = 280 bytes as expected. So I&amp;#39;m not clear as to why disallocating&amp;nbsp;192 bytes and then reallocating 140 bytes causes a runtime error.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/163324?ContentTypeID=1</link><pubDate>Tue, 01 Jan 2019 15:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33dca502-79b9-4609-9683-cdfefa7c74f5</guid><dc:creator>awneil</dc:creator><description>[quote userid="10637" url="~/f/nordic-q-a/42048/how-do-i-read-my-map-file"]Apparently all the &amp;quot;.debug_str&amp;quot; take up 11 MB total? That&amp;#39;s a lot but if it&amp;#39;s all in flash[/quote]
&lt;p&gt;The nRF52832 only has 512K of Flash - so they clearly can&amp;#39;t be in Flash!&lt;/p&gt;
&lt;p&gt;These are debug symbols - not loaded into the device at all.&lt;/p&gt;
[quote userid="10637" url="~/f/nordic-q-a/42048/how-do-i-read-my-map-file"]Do I just delete the entire &amp;quot;.text&amp;quot; section from the .map file?[/quote]
&lt;p&gt;&lt;strong&gt;No!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The .text section is where the code goes!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Code_segment"&gt;https://en.wikipedia.org/wiki/Code_segment&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another useful tool for seeing what&amp;#39;s using up memory is &lt;strong&gt;nm&lt;/strong&gt;:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Nm_(Unix)"&gt;https://en.wikipedia.org/wiki/Nm_(Unix)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See your toolchain documentation for details&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT&lt;/p&gt;
&lt;p&gt;Try this:&amp;nbsp;&lt;a href="https://www.google.com/search?q=gcc+how+to+read+map+file"&gt;www.google.com/search&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I read my .map file?</title><link>https://devzone.nordicsemi.com/thread/163322?ContentTypeID=1</link><pubDate>Tue, 01 Jan 2019 12:45:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d6f0d67-f1f1-4a01-a136-31fa06ac1337</guid><dc:creator>UnicycleBloke</dc:creator><description>&lt;p&gt;You should consider using objdump. I found it useful to dump all the symbols from the ELF file, sort or grep them by type (data, code, whatever), and then by size. In my case, I quickly realised that the heap reserved by the linker script was huge and unnecessary, and that the heap reserved by FreeRTOS was also huge. I&amp;#39;ve switched to static allocation for pretty much all objects as this means that the linker will complain long before I have to deal with runtime error codes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>