Page 1 of 1

Makefile avr-size issue

Posted: Fri Jan 23, 2009 5:19 am
by jss
While trying to fix my compiling issues I noticed that avr-size is being called with invalid options:

Code: Select all

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}
To avoid error I changed the last line to:

Code: Select all

@avr-size -A ${TARGET}
EDIT: I should also mention that I am running OS X.

Re: Makefile avr-size issue

Posted: Fri Jan 23, 2009 9:23 pm
by uze6666
avr-size is known to have issues too on Linux. Search this forums for more on that. If you don't give the MCU model, the tool can't determine (and warn you) if the RAM or FLASH consumption of your program has exceeded what's on the device.

Uze

Re: Makefile avr-size issue

Posted: Tue Feb 23, 2010 8:50 pm
by orthopteroid
Not really an issue, but makefile related...

My makefile automatically runs my game in the after a build, but I occasionally get weird problems which I've tracked down to overflowing the 4k RAM limit as I don't have a makefile check for this. If it helps anyone else, here is a way of using gawk to detect when my program data exceeds 3800 bytes:

@avr-size -C --mcu=${MCU} ${TARGET}.elf | gawk '/Data:/ {if($$2>"3800"){exit(1)}}'

This will halt execution of the makefile. You would typically want to place a call to the emulator at the next line.

My build setup is on windows. If this doesn't work on another platform I'd be interested to hear.

Re: Makefile avr-size issue

Posted: Tue Feb 23, 2010 8:53 pm
by orthopteroid
Not really an issue, but makefile related...

My makefile automatically runs my game in the after a build, but I occasionally get weird problems which I've tracked down to overflowing the 4k RAM limit as I don't have a makefile check for this. If it helps anyone else, here is a way of using gawk to detect when my program data exceeds 3800 bytes and bail out of the makefile:

Code: Select all

@avr-size -C --mcu=${MCU} ${TARGET}.elf | gawk '/Data:/ {if($$2>"3800"){exit(1)}}'
You would typically want to place a call to the emulator at the next line. YMMV

My build setup is on windows.

Re: Makefile avr-size issue

Posted: Tue Feb 23, 2010 10:52 pm
by nebososo
Avr-size for Linux won't let me set the mcu, I'm guessing it's the same for OS X.
I made this hacky OS check based on uzem's Makefile, I haven't tested it on Windows, but (assuming uzem's Makefile doesn't have any problems) it should work:

Code: Select all

UNAME := $(shell sh -c 'uname -s 2>/dev/null || echo not')
AVRSIZEFLAGS := -A ${TARGET}
ifneq (,$(findstring MINGW,$(UNAME)))
AVRSIZEFLAGS := -C --mcu=${MCU} ${TARGET}
endif

size: ${TARGET}
	@echo
	@avr-size ${AVRSIZEFLAGS}

Re: Makefile avr-size issue

Posted: Wed Dec 22, 2010 5:29 pm
by RogerBlake
I was going to put forward that you go to the Build menu and "Export Makefile" then edit the Studio generated Makefile and back in Project-Config then set this as an outside makefile to be used (and I know you'd have to re-do this every time you add files to the project - so it's not the best answer) but it won't work anyway as the chant of avr-size does not appear in that Makefile anyway. Presumably Studio invokes make on the auto-Makefile and then unconnectedly runs avr-size? As such I don't think there's going to be anyway to change it's behavior (short, maybe, of using a binary editor on the avr-gcc plugin DLL file, ruling the avr-size invocation and changing it there)

Re: Makefile avr-size issue

Posted: Fri Oct 28, 2011 2:26 pm
by kipfow
I did a fresh install of AVR Studio 4.18SP3 and now the call in the generated makefile from studio to avr-size isn't there anymore. I didn't get any memory usage information. On older studio versions everything works fine ...

Re: Makefile avr-size issue

Posted: Fri Oct 28, 2011 3:01 pm
by uze6666
Hmmm interesting. However we don't use generated makefiles for the Uzebox projects. Just start from the makefile in one of the demo projects and everything will be fine again.

-Uze

Re: Makefile avr-size issue

Posted: Mon Aug 06, 2018 12:41 am
by uze6666
I was rebuilding my tool chain on Windows and ran in this problem again, so I decided to document the fix and make a patched version of avr-make available. In case someone search for this issue in the futur...here is a patched version of avr-size for Windows that support the -C and --mcu switches.

Replace the old version under your win-avr/bin directory with this one and you are good to go.