Makefile avr-size issue

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
jss
Posts: 5
Joined: Wed Jan 21, 2009 8:28 pm

Makefile avr-size issue

Post by jss » Fri Jan 23, 2009 5:19 am

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.

User avatar
uze6666
Site Admin
Posts: 4449
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Makefile avr-size issue

Post by uze6666 » Fri Jan 23, 2009 9:23 pm

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

orthopteroid
Posts: 12
Joined: Mon Jan 18, 2010 8:08 am
Location: Vancouver, Canada

Re: Makefile avr-size issue

Post by orthopteroid » Tue Feb 23, 2010 8:50 pm

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.

orthopteroid
Posts: 12
Joined: Mon Jan 18, 2010 8:08 am
Location: Vancouver, Canada

Re: Makefile avr-size issue

Post by orthopteroid » Tue Feb 23, 2010 8:53 pm

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.

User avatar
nebososo
Posts: 188
Joined: Sun Oct 04, 2009 10:33 pm
Location: Curitiba, Paraná, Brazil
Contact:

Re: Makefile avr-size issue

Post by nebososo » Tue Feb 23, 2010 10:52 pm

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}

RogerBlake
Posts: 1
Joined: Wed Dec 22, 2010 5:14 pm

Re: Makefile avr-size issue

Post by RogerBlake » Wed Dec 22, 2010 5:29 pm

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)

kipfow
Posts: 1
Joined: Fri Oct 28, 2011 2:24 pm

Re: Makefile avr-size issue

Post by kipfow » Fri Oct 28, 2011 2:26 pm

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 ...
Last edited by kipfow on Fri Jun 22, 2012 8:23 am, edited 3 times in total.

User avatar
uze6666
Site Admin
Posts: 4449
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Makefile avr-size issue

Post by uze6666 » Fri Oct 28, 2011 3:01 pm

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

User avatar
uze6666
Site Admin
Posts: 4449
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Makefile avr-size issue

Post by uze6666 » Mon Aug 06, 2018 12:41 am

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.
Attachments
avr-size-patch-v2_19.zip
(225.69 KiB) Downloaded 71 times

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests