adding "AVR Memory Usage" to makefile

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i've always used the default winavr-avrstudio makefile. With this i always have the "AVR Memory Usage" summary after a build.

How can i add this function to another attached makefile?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not either (a) use Mfile or (b) copy the AVR-SIZE stuff from the Mfile template.

It has:

SIZE = avr-size

MSG_SIZE_BEFORE = Size before: 
MSG_SIZE_AFTER = Size after:

# Default target.
all: begin gccversion sizebefore build sizeafter end

# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf

sizebefore:
	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
	2>/dev/null; echo; fi

sizeafter:
	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
	2>/dev/null; echo; fi

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i tried ading something similar (but from the default avrstudio makefile) but i can't figure out where to put these lines

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try adding this last line to the existing rule:

$(PRG).elf: $(OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
	avr-size -C --mcu=$(MCU_TARGET) $(PRG).elf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If i remember correctly

sizebefore:
   @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
   2>/dev/null; echo; fi

sizeafter:
   @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
   2>/dev/null; echo; fi 

The "indents" in the above section has to be "tabs" not spaces ... See
https://www.avrfreaks.net/index.p...

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Try adding this last line to the existing rule:

$(PRG).elf: $(OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
	avr-size -C --mcu=$(MCU_TARGET) $(PRG).elf

this is it! thanks!