Quellcode durchsuchen

Show device-specific flash/RAM usage percentages in the size report

avr-size on this toolchain doesn't support --mcu/--format=avr (that's an
Atmel/Microchip binutils patch, not upstream), so compute the percentages
directly from the section sizes against the atmega644p's known flash/RAM
capacity instead.
k4be vor 1 Woche
Ursprung
Commit
e34bc70c88
1 geänderte Dateien mit 14 neuen und 1 gelöschten Zeilen
  1. 14 1
      soft/Makefile

+ 14 - 1
soft/Makefile

@@ -13,6 +13,11 @@ VPATH   =
 ### Target device
 DEVICE  = atmega644p
 
+### Device memory sizes, for the size report below (bytes)
+FLASH_SIZE = 65536
+RAM_SIZE   = 4096
+EEPROM_SIZE = 2048
+
 ### Bootloader port
 PROGPORT ?= /dev/ttyUSB0
 
@@ -139,11 +144,19 @@ version :
 	@echo
 	$(NM) -n $< > $@
 
-# Display size of file.
+# Display size of file, with a device-specific (DEVICE) usage summary.
 size:
 	@echo
 	$(SIZE) $(PROJECT).elf
 	$(SIZE) $(PROJECT).hex
+	@echo
+	@$(SIZE) -A $(PROJECT).elf | awk '\
+		$$1==".text" || $$1==".data" { prog += $$2 } \
+		$$1==".data" || $$1==".bss" || $$1==".noinit" { ram += $$2 } \
+		END { \
+			printf "Program: %6d bytes (%5.1f%% of %d byte flash on $(DEVICE))\n", prog, prog*100.0/$(FLASH_SIZE), $(FLASH_SIZE); \
+			printf "Data:    %6d bytes (%5.1f%% of %d byte RAM on $(DEVICE))\n", ram, ram*100.0/$(RAM_SIZE), $(RAM_SIZE); \
+		}'
 
 
 # Link: create ELF output file from object files.