Archive for September, 2006

Packaging Avr Tool Chain

Monday, September 25th, 2006

General outline for creating AVR development environment for OSX.

Since the gcc chain serves a much greater community than just the avr and its stability is critical to the stability of the entire open software community the avr community has elected to maintain patches. The avr-binutils, avr-gcc and patches used are all to be found in the freebsd ports collection. The avr-libc does not require patching as it is seperate from gcc.

(If you would rather just download and install the resulting package it is here)

Process for multiple installations

  1. create a staging directory.
  2. patch, build and install (in order)
    1. avr-binutils
    2. avr-gcc
  3. clean and then rebuild them into the staging directory.
  4. build avr-libc into ste staging directory.
  5. use PackageMaker to build a package.
  6. add README and other utilities you want to include
  7. use disk-utility to create DMG
  8. mount and install the package
  9. put the dmg where it can be shared.


The the binary utilities make up the loader and assemblers and other tools needed by gcc to create usable code for the target. Like gcc the binary utilities are not specific to the target but are built for the target. I built the binutilities out of the freebsd currents distfiles (, and then applied all of the patches from the freebsd cvs directory ( The patch that changes most often is the new-devices patch which Jeorg Wunsch updates in order to keep the avr-libc current. Then the source tree is unpacked and “./configure”d with the –targe=avr flag. (For some reason I also had to –disable-nls to get this to work).

# tar -xzvf binutils-xxx
# cd binutils-xxx
# for p in ${avr-binutils-patches}/* ;do
# /configure --target=avr --disable-nls
# make && make install && make clean


Once the avr-binutils are built and installed gcc is built exactly the same way.

# tar -xzvf gcc-xxx
# cd gcc-xxx
# for p in ${avr-gcc-patches}/* ;do
# /configure --target=avr --disable-nls


The libc for avr avr-libc is a seperate package from binutils and gcc and it is updated often. You can build this directly into the staging directory. If you are not preparing the code for packaging then you can build the libc directly into the target directory.

# tar -xzvf avr-libc-xxxx
# cd avr-libc-xxxx
# ./configure CC=avr-gcc --host=avr
# make && make install && make clean

Preparing the code for packaging.

If you are going to deploy the avrgcc chain on more than one system or if you want to back up and or share the software then you should at this point rebuild both binutils and gcc into a staging directory.

# rm -rf /usr/local/staging
# mkdir /usr/local/staging
# cd /usr/local/src/avr-gcc/binutils-xxx
# /configure --target=avr --prefix=/usr/local/staging --disable-nls
# make && make install && make clean
# cd ../../avr-gcc/gcc-xxx
# /configure --target=avr --prefix=/usr/local/staging --disable-nls
# make && make install && make clean
# cd ../../avr-libc/
# tar -xzvf avr-libc-xxxx
# cd avr-libc-xxxx
# ./configure CC=avr-gcc --host=avr --prefix=/usr/local/staging
# make && make install && make clean


One of the applications included in the X-code suite is packagemaker. On my installation it is found under the folder in Developer->Applications->Utilities. PackageMaker can also ge called from the command line but this will require further investigation. .

  1. open packagemaker
    1. in the first tab describe the software.
    2. in the second tab (files) type the path of the staging directory (in our case /usr/local/staging)
    3. in the forth tab (info)
      1. put the default location of the software (/usr/local/)
      2. set the authorization required to “root authorization required”
    4. fill out the information as appropriate.
  2. create the package (command-K)

Creating the Disk image.

Once the package is created

  1. copy the resulting package into its own folder.
  2. You should probably create a readme file
  3. add any other software you want in your archive.
  4. open the Disk Utility (under Applications->Utilities)
  5. under the images menue select New->Image from folder