]> rtime.felk.cvut.cz Git - arc.git/commitdiff
hcs12 memory usage print when building
authortojo <devnull@localhost>
Thu, 11 Mar 2010 16:48:17 +0000 (17:48 +0100)
committertojo <devnull@localhost>
Thu, 11 Mar 2010 16:48:17 +0000 (17:48 +0100)
scripts/hc1x_memory.awk [new file with mode: 0644]
scripts/rules.mk

diff --git a/scripts/hc1x_memory.awk b/scripts/hc1x_memory.awk
new file mode 100644 (file)
index 0000000..46bcfb5
--- /dev/null
@@ -0,0 +1,69 @@
+\r
+# Awk program for parsing "objdump -h" output\r
+# Copyright ArcCore AB\r
+\r
+BEGIN {\r
+\r
+       # Constants\r
+       kilobyte = 1024\r
+\r
+       # Arch constants\r
+       flash_total_size = 128 * kilobytes\r
+       ram_total_size = 8 * kilobytes\r
+\r
+       # Setup\r
+       flash_start_hex = "0x4000"\r
+       ram_start_hex = "0x2000"\r
+       flash_start_n = strtonum(flash_start_hex)\r
+\r
+       print ""\r
+       print "-- Setup -------------------"\r
+       printf "%-15s %10s\n", "Ram start:", ram_start_hex\r
+       printf "%-15s %10s\n", "Flash start:", flash_start_hex\r
+       print ""\r
+       print "-- Layout ------------------"\r
+\r
+       flash_size = 0\r
+       ram_size = 0\r
+}\r
+\r
+{\r
+       if ( $1 ~ /[0-9]+/ && $2 ~ /\./ ) {\r
+\r
+               name = $2\r
+\r
+               size = "0x" $3\r
+               size_n = strtonum(size)\r
+\r
+               vma = "0x" $4\r
+               vma_n = strtonum(vma)\r
+\r
+               lma = "0x" $5\r
+               lma_n = strtonum(lma)\r
+\r
+               type = "-"\r
+\r
+               if (lma_n != 0) {\r
+                       if (vma_n >= flash_start_n) {\r
+                               flash_size += size_n\r
+                               type = "flash"\r
+                       } else {\r
+                               ram_size += size_n\r
+                               type = "ram"\r
+                       }\r
+\r
+                       printf "%-10s %10s %10.1f %s %10s\n", name, size_n " B", size_n/kilobyte, "kB", "[" type "]"\r
+\r
+               }\r
+\r
+       }\r
+}\r
+\r
+END {\r
+       print ""\r
+       print "-- Totals ------------------"\r
+\r
+       printf "%-10s %10s %10.1f %s\n", "Flash:", flash_size " B", flash_size/kilobyte, "kB"\r
+\r
+       printf "%-10s %10s %10.1f %s\n", "Ram:", ram_size " B", ram_size/kilobyte, "kB"\r
+}
\ No newline at end of file
index cb833f7328c4898f2c06d5e851f4b9b84d290379..708d1f7116fc9c45d9157dbf766507e583dd4ead 100644 (file)
@@ -131,11 +131,15 @@ $(build-hex-y): $(build-exe-y)
 $(build-exe-y): $(dep-y) $(obj-y) $(sim-y) $(libitem-y) $(ldcmdfile-y)\r
        @echo "  >> LD $@"\r
        $(Q)$(LD) $(LDFLAGS) -T $(ldcmdfile-y) -o $@ $(libpath-y) --start-group $(obj-y) $(lib-y) $(libitem-y) --end-group $(LDMAPFILE)\r
+ifdef CFG_MC912DG128A\r
+       @$(CROSS_COMPILE)objdump -h $@ | gawk -f $(ROOTDIR)/scripts/hc1x_memory.awk\r
+else\r
        @echo "Image size: (decimal)"\r
        @gawk --non-decimal-data        '/^\.text/ { print "  text:"  $$3+0 " bytes"; rom+=$$3 };\\r
                                                                /^\.data/ { print "  data:"  $$3+0 " bytes"; rom+=$$3; ram+=$$3}; \\r
                                                                /^\.bss/ { print "  bss :"  $$3+0 " bytes"; ram+=$$3}; \\r
                                                                END { print "  ROM: ~" rom " bytes"; print "  RAM: ~" ram " bytes"}' $(subst .elf,.map,$@)\r
+endif\r
        @echo "  >>>>>>>  DONE  <<<<<<<<<"\r
        \r
 \r