{"id":3045,"date":"2010-08-31T22:17:29","date_gmt":"2010-09-01T03:17:29","guid":{"rendered":"http:\/\/mightyohm.com\/blog\/?p=3045"},"modified":"2015-09-26T11:11:02","modified_gmt":"2015-09-26T18:11:02","slug":"fix-for-broken-avr-size-in-ubuntu-10-04-lucid","status":"publish","type":"post","link":"https:\/\/mightyohm.com\/blog\/2010\/08\/fix-for-broken-avr-size-in-ubuntu-10-04-lucid\/","title":{"rendered":"Fix for broken avr-size in Ubuntu 10.04 (Lucid Lynx)"},"content":{"rendered":"<p>If you have never used it before,\u00a0<a href=\"http:\/\/ccrma.stanford.edu\/planetccrma\/man\/man1\/avr-size.1.html\">avr-size<\/a> is a very useful command that\u00a0does a relatively simple thing &#8211; it tells you how large your compiled avr-gcc programs are. \u00a0This is very useful knowledge when you are trying to fit as much code as possible into a part with only a few K of flash memory. \u00a0Additionally, the actual flash footprint of an AVR program is not something you can easily distill from a .hex file. \u00a0Hex files are usually much larger than the actual compiled code due to the overhead of that file format.<\/p>\n<p>avr-size comes with the binutils-avr package in Ubuntu (and is installed as part of WinAVR and CrossPack on Windows and OSX, respectively). \u00a0Unfortunately, Ubuntu 10.04 (Lucid Lynx) ships with a broken version of avr-size that doesn&#8217;t include the necessary patches to support the AVR.<\/p>\n<p>To see if your avr-size is working, open a Terminal in Lucid and try executing this command on a compiled avr-gcc .elf file of your choice:<\/p>\n<p><code><strong>avr-size -C --mcu=attiny2313 main.elf<\/strong><\/code><\/p>\n<p>You&#8217;ll probably see something like this:<\/p>\n<p><code>avr-size: invalid option -- 'C'<br \/>\nUsage: avr-size [option(s)] [file(s)]<br \/>\nDisplays the sizes of sections inside binary files<br \/>\nIf no input file(s) are specified, a.out is assumed<br \/>\nThe options are:<br \/>\n-A|-B \u00a0 \u00a0 --format={sysv|berkeley} \u00a0Select output style (default is berkeley)<br \/>\n-o|-d|-x \u00a0--radix={8|10|16} \u00a0 \u00a0 \u00a0 \u00a0 Display numbers in octal, decimal or hex<br \/>\n-t \u00a0 \u00a0 \u00a0 \u00a0--totals \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display the total sizes (Berkeley only)<br \/>\n--common \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display total size for *COM* syms<br \/>\n--target=&lt;bfdname&gt; \u00a0 \u00a0 \u00a0 \u00a0Set the binary file format<br \/>\n@&lt;file&gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Read options from &lt;file&gt;<br \/>\n-h \u00a0 \u00a0 \u00a0 \u00a0--help \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display this information<br \/>\n-v \u00a0 \u00a0 \u00a0 \u00a0--version \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Display the program's version<br \/>\navr-size: supported targets: elf32-avr elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex<br \/>\n<\/code><\/p>\n<p>Bad news, but it&#8217;s not surprising.  You have the broken version of avr-size that comes with binutils-avr for Lucid.<\/p>\n<h3>The solution:<\/h3>\n<p>I was able to fix this issue by installing the binutils-avr package for Debian Squeeze, an approach I learned about from\u00a0<a href=\"https:\/\/bugs.launchpad.net\/ubuntu\/+source\/binutils-avr\/+bug\/576676\">this Ubuntu bug report<\/a>.<\/p>\n<p>To download the Debian binutils-avr package, either go to the <a href=\"http:\/\/packages.debian.org\/squeeze\/amd64\/binutils-avr\/download\">Debian package repository<\/a> or execute this command:<\/p>\n<p><code><strong>wget \"http:\/\/ftp.us.debian.org\/debian\/pool\/main\/b\/binutils-avr\/binutils-avr_2.20.1-1_amd64.deb\"<\/strong><\/code><\/p>\n<p>Now install the package by double clicking on it or executing:<\/p>\n<p><code><strong>sudo dpkg -i binutils-avr_2.20.1-1_amd64.deb<\/strong><\/code><\/p>\n<p>If you tell Ubuntu to &#8220;hold&#8221; the package you just installed, it should stop trying to revert to the broken version in the Lucid repository every time you run a system update:<\/p>\n<p><code><strong>echo \"binutils-avr hold\" | sudo dpkg --set-selections<\/strong><\/code><\/p>\n<p>You can check the hold status by running<\/p>\n<p><code><strong>sudo dpkg --get-selections | grep binutils-avr<br \/>\n<\/strong><\/code><\/p>\n<p>The status should be shown as &#8220;hold&#8221; (not &#8220;install&#8221;).<\/p>\n<p>Now if you run avr-size, you should see the special AVR option &#8216;-C&#8217; is now present.<\/p>\n<p><code>jkeyzer@atom:~$<strong> avr-size --help<\/strong><\/code><\/p>\n<p><code>Usage: avr-size [option(s)] [file(s)]<br \/>\nDisplays the sizes of sections inside binary files<br \/>\nIf no input file(s) are specified, a.out is assumed<br \/>\nThe options are:<br \/>\n-A|-B|-C \u00a0--format={sysv|berkeley|avr} \u00a0Select output style (default is berkeley)<br \/>\n--mcu=&lt;avrmcu&gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0MCU name for AVR format only<br \/>\n-o|-d|-x \u00a0--radix={8|10|16} \u00a0 \u00a0 \u00a0 \u00a0 Display numbers in octal, decimal or hex<br \/>\n-t \u00a0 \u00a0 \u00a0 \u00a0--totals \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display the total sizes (Berkeley only)<br \/>\n--common \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display total size for *COM* syms<br \/>\n--target=&lt;bfdname&gt; \u00a0 \u00a0 \u00a0 \u00a0Set the binary file format<br \/>\n@&lt;file&gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Read options from &lt;file&gt;<br \/>\n-h \u00a0 \u00a0 \u00a0 \u00a0--help \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Display this information<br \/>\n-v \u00a0 \u00a0 \u00a0 \u00a0--version \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Display the program's version<br \/>\navr-size: supported targets: elf32-avr coff-avr coff-ext-avr elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex<\/code><\/p>\n<p><code> <\/code><\/p>\n<p><code>Report bugs to &lt;http:\/\/www.sourceware.org\/bugzilla\/&gt;<\/code><\/p>\n<p>You can also test it out on a compiled .elf file:<\/p>\n<p><code><strong><span style=\"font-weight: normal;\">jkeyzer@atom:~$<\/span> avr-size -C --mcu=attiny2313 main.elf<\/strong><\/code><\/p>\n<p><code>AVR Memory Usage<br \/>\n----------------<br \/>\nDevice: attiny2313<\/code><\/p>\n<p><code> <\/code><\/p>\n<p><code>Program:    2008 bytes (98.0% Full)<br \/>\n(.text + .data + .bootloader)<\/code><\/p>\n<p><code> <\/code><\/p>\n<p><code>Data:         23 bytes (18.0% Full)<br \/>\n(.data + .bss + .noinit)<\/code><\/p>\n<p>It works! \u00a0You now have a working avr-size command for Ubuntu.<\/p>\n<p>There is a good chance this package will eventually be fixed in the Lucid repository, but based on the bug report above, it could be a while (2012?) before we see an update. \u00a0Until then, installing the Debian package seems to be a good solution.<\/p>\n<p>If anyone reading this is close to the Ubuntu package maintainers, can you please kick them about this issue?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have never used it before,\u00a0avr-size is a very useful command that\u00a0does a relatively simple thing &#8211; it tells you how large your compiled avr-gcc programs are. \u00a0This is very useful knowledge when you are trying to fit as much code as possible into a part with only a few K of flash memory. &hellip; <a href=\"https:\/\/mightyohm.com\/blog\/2010\/08\/fix-for-broken-avr-size-in-ubuntu-10-04-lucid\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Fix for broken avr-size in Ubuntu 10.04 (Lucid Lynx)<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[10],"tags":[61,343,332],"class_list":["post-3045","post","type-post","status-publish","format-standard","hentry","category-microcontrollers","tag-avr","tag-avr-gcc","tag-ubuntu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pioCd-N7","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3304,"url":"https:\/\/mightyohm.com\/blog\/2010\/10\/avr-toolchain-installation-instructions-for-windows-mac-os-x-linux\/","url_meta":{"origin":3045,"position":0},"title":"AVR Toolchain Installation Instructions for Windows, Mac OS X, Linux","author":"Jeff","date":"October 29, 2010","format":false,"excerpt":"Mitch Altman and I are in the process of writing a book about Making Cool Things with Microcontrollers (for people who know nothing.) The book features several DIY projects that use AVR microcontrollers. \u00a0We're aiming to teach absolute beginners how to solder, basic electronics, and the process of turning a\u2026","rel":"","context":"In &quot;Microcontrollers&quot;","block_context":{"text":"Microcontrollers","link":"https:\/\/mightyohm.com\/blog\/category\/microcontrollers\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2010\/10\/winavr-500x336.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":822,"url":"https:\/\/mightyohm.com\/blog\/2008\/12\/building-a-wifi-radio-part-7-building-an-lcd-display\/","url_meta":{"origin":3045,"position":1},"title":"Building a Wifi Radio &#8211; Part 7, Building an LCD Display","author":"Jeff","date":"December 18, 2008","format":false,"excerpt":"This is the seventh part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 If you haven\u2019t already, check out the previous parts (see the links at the end of this article) for some background about the project. In part six, we used OpenWrt's UNIX-style\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"http:\/\/www.lduhtrp.net\/image-3238164-10440897","width":350,"height":200},"classes":[]},{"id":3090,"url":"https:\/\/mightyohm.com\/blog\/2010\/09\/improved-firmware-for-usbtinyisp-fixes-usb-issues-in-virtualbox\/","url_meta":{"origin":3045,"position":2},"title":"Improved firmware for USBTinyISP fixes USB issues","author":"Jeff","date":"September 20, 2010","format":false,"excerpt":"I am a big fan of VirtualBox. \u00a0I have used it in various forms over the past couple years: to run Windows within Linux, Linux within Windows, Linux within OSX, Windows within OSX, etc. \u00a0It is fast, powerful, configurable, and best of all, free. However, there is one major disadvantage\u2026","rel":"","context":"In &quot;Microcontrollers&quot;","block_context":{"text":"Microcontrollers","link":"https:\/\/mightyohm.com\/blog\/category\/microcontrollers\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2010\/09\/virtualbox-500x394.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2530,"url":"https:\/\/mightyohm.com\/blog\/2009\/11\/minor-updates-to-avr-hv-rescue-shield\/","url_meta":{"origin":3045,"position":3},"title":"Minor updates to the AVR HV Rescue Shield","author":"Jeff","date":"November 3, 2009","format":false,"excerpt":"This week there have been a couple minor updates to the AVR HV Rescue Shield: I just uploaded version 1.1 of the Arduino sketch, which fixes an issue with garbage being printed in the serial monitor between burn cycles.\u00a0 I also made some minor changes to try to reduce the\u2026","rel":"","context":"In &quot;Kits&quot;","block_context":{"text":"Kits","link":"https:\/\/mightyohm.com\/blog\/category\/kits\/"},"img":{"alt_text":"AVR HV Rescue Shield with ATmega168 target ","src":"https:\/\/i0.wp.com\/www.mightyohm.com\/blog\/wp-content\/uploads\/2009\/03\/rescue-shield-with-atmega2_scaled-500x375.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1419,"url":"https:\/\/mightyohm.com\/blog\/2009\/03\/introducing-the-avr-hv-rescue-shield\/","url_meta":{"origin":3045,"position":4},"title":"Introducing the AVR HV Rescue Shield","author":"Jeff","date":"March 11, 2009","format":false,"excerpt":"This all started last year, when I was playing with an ATmega168 microcontroller and did something silly.\u00a0 I programmed the RSTDISBL fuse bit, which effectively makes it impossible to reflash the chip using an ordinary (serial) programmer. Instead of giving up and throwing out the \"dead\" chip,\u00a0 I decided to\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"AVR HV Rescue Shield with ATmega168 target ","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2009\/03\/rescue-shield-with-atmega2_scaled-500x375.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":294,"url":"https:\/\/mightyohm.com\/blog\/2008\/09\/arduino-based-avr-high-voltage-programmer\/","url_meta":{"origin":3045,"position":5},"title":"Arduino-based AVR High Voltage Programmer","author":"Jeff","date":"September 24, 2008","format":false,"excerpt":"Update 01\/02\/09: A PCB version of this circuit is in the design stages - some preliminary information is here. Update 03\/11\/09: Kits based on this design are now for sale! Update 12\/14\/10: The original AVR HV Rescue Shield kit has been replaced by the new and improved HV Rescue Shield\u2026","rel":"","context":"In &quot;Kits&quot;","block_context":{"text":"Kits","link":"https:\/\/mightyohm.com\/blog\/category\/kits\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/09\/hvfuse_fixed.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/09\/hvfuse_fixed.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/09\/hvfuse_fixed.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/09\/hvfuse_fixed.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/09\/hvfuse_fixed.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/3045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/comments?post=3045"}],"version-history":[{"count":8,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/3045\/revisions"}],"predecessor-version":[{"id":7826,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/3045\/revisions\/7826"}],"wp:attachment":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/media?parent=3045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/categories?post=3045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/tags?post=3045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}