FS#32504 - [avr-binutils] avr-size lacks the -C and --mcu options

Attached to Project: Community Packages
Opened by bobpaul (bobpaul) - Tuesday, 06 November 2012, 22:33 GMT
Last edited by Jakob Gruber (schuay) - Tuesday, 13 November 2012, 22:23 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Jakob Gruber (schuay)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
avr-size in other distributions (winavr, debian/ubuntu packages, fedora packages) include a patch to include a "-C | --format=avr" and "--mcu=avrmcu". This allows someone to do, for example, "avr-size -C --mcu=xmega16d4" and get platform specific output like:

Device: atxmega16d4

Program: 10880 bytes (53.1% Full)
(.text + .data + .bootloader)

Data: 1154 bytes (56.3% Full)
(.data + .bss + .noinit)

In paranthesis you can see the elf sections included in the summation output, allong with a percentage specific to that platform. In this output, "Program:" is a sum of everything stored in program space (flash memory) whereas "Data:" corresponds to allocated staticly allocated RAM. This is a much more useful summary than the sysv or berkeley format that just gives .text, .data, .bootloader, .fuse, etc individually.

Additional info:
* Ubuntu forgot to apply the patches back in release 10.10 (lucid). There's blogs (ex: http://mightyohm.com/blog/2010/08/fix-for-broken-avr-size-in-ubuntu-10-04-lucid/) and at least 1 bug report (https://bugs.launchpad.net/ubuntu/+source/binutils-avr/+bug/576676) about the issue.
* I believe upstream source of the patches come from the WinAVR project. From the bug report, it sounds they can also be found in the Debian/Ubuntu source .deb files.

Steps to reproduce:
1. pacman -S avr-size
2. avr-size --help
3. note "-A|-B --format={sysv|berkeley}"
This task depends upon

Closed by  Jakob Gruber (schuay)
Tuesday, 13 November 2012, 22:23 GMT
Reason for closing:  Fixed
Additional comments about closing:  avr-binutils 2.23-2
Comment by Jonathan Kotta (jpkotta) - Wednesday, 07 November 2012, 22:11 GMT
Attached is a modified patch file from Ubuntu (in binutils-avr_2.20-2.tar.gz at http://packages.ubuntu.com/source/lucid/binutils-avr) and a PKGBUILD that uses it.

Changes from the Ubuntu patch:

Fix global/local variable name clash.
Add atxmega16d4 size info.
Comment by Greg (dolby) - Wednesday, 07 November 2012, 22:39 GMT
Has the patch been submitted upstream?
Comment by Jonathan Kotta (jpkotta) - Wednesday, 07 November 2012, 23:51 GMT
I just submitted it to the binutils mailing list, but I have a feeling that it will be unpopular because it does an architecture-specific patch to source code that is for all arches. I'm unsure how to do it in such a way that it only applies when building AVR, though. Hopefully someone will help me with that.
Comment by Jakob Gruber (schuay) - Sunday, 11 November 2012, 13:13 GMT
Could you post a link to the binutils mailing list post?
Comment by Jonathan Kotta (jpkotta) - Monday, 12 November 2012, 05:53 GMT
http://sourceware.org/ml/binutils/2012-11/msg00096.html
http://sourceware.org/ml/binutils/2012-11/msg00097.html

As expected, it was not appreciated. Maybe I'll take his advice and make a separate utility. The problem is that there's lots of guides and documentation out there that assume you're using WinAVR and you have the patched avr-size, plus other distros add the patch.
Comment by bobpaul (bobpaul) - Tuesday, 13 November 2012, 16:30 GMT
Not just WinAVR (which is a dead project, by the way), but also the GCC based "AVR-Toolchain", which replaces WinAVR, as well as "AVR Studio 6" (both from Atmel's website) both include the patched avr-size. Since much of the embedded development community uses Windows, the community support (from AVR Freaks webforums, etc) expect you to have patched avr-size.

If someone's helping another developer debug an issue and they see from the make output that 95% of the data space is full, they're more likely to lead you towards an issue related to low memory than they are if they just see the raw values for .data, .bss, .noinit, .text, .bootloader, .fuse, etc. It's less obvious, and the symptoms caused by out of memory can also happen due to a variety of other reasons (interrupts setup incorrectly, etc). Not everyone knows how to estimate the static memory usage of every Atmel AVR product, but the patched avr-size does.

Jon - Much appreciation on the patch! Perhaps another course of action would be to try and convince Atmel (they seem to be maintaining what used to be WinAVR) to try and satisfy upstream or spin avr-size off to a seperate, official utility. I'm sure you don't want to have to keep tabs on every new Atmel product so you can update your patch for new microcontrollers.
Comment by Jakob Gruber (schuay) - Tuesday, 13 November 2012, 21:50 GMT
I'm tending towards adding towards adding this patch, as it seems to be fairly standard and useful. However, what I don't want to do is maintain the patch in case conflicts appear in new binutils versions.

Taking this upstream in some form sounds great, I'd suggest you keep pursuing that and let us know in case of any progress.

Loading...