<?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>DFU HELP - .MAP file to find Application size in Flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6934/dfu-help---map-file-to-find-application-size-in-flash</link><description>Enlight of the increase in 8.0 SD size, I am concerned that my application size may soon grow too large to utilize Dual Bank DFU. I know the actual size of the .Hex files are not indicative of the actual FLASH size the Application will take up. 
 Using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 May 2015 03:24:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6934/dfu-help---map-file-to-find-application-size-in-flash" /><item><title>RE: DFU HELP - .MAP file to find Application size in Flash</title><link>https://devzone.nordicsemi.com/thread/24455?ContentTypeID=1</link><pubDate>Thu, 14 May 2015 03:24:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ba05111-50b6-4219-af5a-36b482fdbaf8</guid><dc:creator>Clem Taylor</dc:creator><description>&lt;p&gt;If you are using gcc, then you use the size utility:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;arm-none-eabi-size xxxboot.elf
   text	   data	    bss	    dec	    hex	filename
  24862	   1760	  15016	  41638	   a2a6	xxxboot.elf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In my case I just use objcopy to extract the data from the elf and get the size from that (mostly because I already need to extract the data to compute the embedded CRCs).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ arm-none-eabi-objcopy -Obinary --gap-fill=0xFF xxxboot.elf xxxboot.bin
$ stat -c %s xxxboot.bin 
26624
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I use the linker file to pad the data out to the maximum section size. So the size is always 26624, but if I extract just the filler section I can figure out how much space is &amp;#39;free&amp;#39;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ arm-none-eabi-objcopy -Obinary -j .fill xxxboot.elf xxxfill.bin
$ stat -c %s xxxfill.bin 
1660
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The final step in my .elf compile rule prints:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;xxxboot.elf: 1660 free of 26620 CRC: fcb4576c
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I generate a map file but parsing it is a bit of a pain, so instead I use a combination of &amp;#39;nm&amp;#39; and &amp;#39;readelf&amp;#39; to pull out interesting data.&lt;/p&gt;
&lt;p&gt;I have a script &amp;#39;elfFlash&amp;#39; which will find out where all your flash is going:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/sh
# print all non-empty symbols in flash (addresses beginning in 0x00??????)
ME=&amp;quot;${0##*/}&amp;quot; # my name
elf=$1

if [ $# -ne 1 -o ! -x &amp;quot;$1&amp;quot; ]; then
    echo &amp;quot;Usage: $ME &amp;lt;elf file&amp;gt;&amp;quot;
    exit
fi

arm-none-eabi-readelf --wide --symbols $elf | \
    awk &amp;#39;$2 ~/^00/ &amp;amp;&amp;amp; $3 != 0&amp;#39; | \
    sed &amp;#39;s/^[ 0-9]\+:\s\+//&amp;#39; | \
    sort | uniq -w 8

exit 0  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This just pulls all the symbols in the elf file, picks out symbols whose address starts with 0x00 and whose size is non-zero. Then it sorts by address and strips out duplicate (overlapping) symbols.&lt;/p&gt;
&lt;p&gt;You can also sort by size with &amp;#39;sort -k2nr&amp;#39; to find the big size offenders.&lt;/p&gt;
&lt;p&gt;FWI, if you are using &amp;#39;-Os -flto&amp;#39; the size of various functions can be a bit miss-leading because gcc will recursively collapse leaf functions, so things like main() and your BLE event handlers can be end up being fairly large.&lt;/p&gt;
&lt;p&gt;If you are interested in symbols that end up in SRAM you can do something like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;arm-none-eabi-readelf --wide --symbols $elf | \
    awk &amp;#39;$2 ~/^20/ &amp;amp;&amp;amp; $3 != 0 &amp;amp;&amp;amp; $4 ~/OBJECT/&amp;#39; | \
    sed &amp;#39;s/^[ 0-9]\+:\s\+//&amp;#39; | \
    sort | uniq -w 8
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU HELP - .MAP file to find Application size in Flash</title><link>https://devzone.nordicsemi.com/thread/24454?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 08:39:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78c792bc-f21d-4de1-ba25-237cd34f93e5</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Dave: Correct, the .bin file tell the size of the code.
If you use gcc, you can also use arm-none-eabi-size.exe [.out file ] to find the size of the code (text+data). Have a look &lt;a href="http://mcuoneclipse.com/2012/09/24/code-size-information-with-gcc-for-armkinetis/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU HELP - .MAP file to find Application size in Flash</title><link>https://devzone.nordicsemi.com/thread/24453?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 05:12:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e0592e5-56c5-4847-8a98-275750a1a195</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I am using Eclipse with GNU.   Could I used the *.bin file size as a guide for the size?   I can&amp;#39;t seem to find a way to analyze the data in the *.MAP file for indication.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU HELP - .MAP file to find Application size in Flash</title><link>https://devzone.nordicsemi.com/thread/24452?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 13:41:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35d53554-fab0-4a75-99ab-eecc59fd3c6c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Dave: If you use KEIL to compile, you can scrool all the way down, and can find the ROM size at the bottom of the .map file:
Total ROM Size  = Code + RO Data + RW Data&lt;/p&gt;
&lt;p&gt;You can also convert your hex/asf file to .bin binary file. The size of the binary file tells the size of actual code on flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>