Using AVR Microprocessors Under OS/X

Matt Wright, July 4, 2005

This document explains how to install Mac OS/X versions of avr-gcc, avr-libc, avrdude, Pascal Stang's avrlib, and the other tools necessary to write programs and load (aka "flash") them onto AVR microprocessors. This is intended for people who have used these tools on the Planet CCRMA Linux environment (e.g., in the context of CCRMA's 250a class or Physical Interaction Design for Music summer workshop), but it may also be useful to others.

Contents

Easy install

At the end of the day you need to have about 58 Mb of compiler tools, libraries, and documentation in /usr/local/avr, and about another 2.4 Mb of Pascal Stang's avrlib ("AVR Library") in ~/avrlib. If you're lucky you can just download my versions, unpack them, put them in the right places, and be done with it.

  1. You need the gnumake program, and you also need a symbolic link to it called make. There are two options:
    1. Apple's developer tools include gnumake and much, much, much more. If you want to develop OSX applications you probably want these anyway. They have a fancy easy-to-use installer.
    2. Alternately, you could just download my copy of gnumake (63K), unstuff it, and install the resulting file like this:
    3. sudo mv gnumake /usr/bin
      sudo ln -s /usr/bin/gnumake /usr/bin/make
  2. Download and un-stuff these files:
  3. The contents of avrlib.sit is a folder named avrlib - put this folder at the top level of your home directory.
  4. The contents of usr-local-avr.sit is a folder named avr - put this folder in your /usr/local directory. (You may first need to make yourself a /usr/local directory and maybe even a /usr directory.) You will probably need to do this as an administrator, like this:
    sudo mv avr /usr/local
  5. Add /usr/local/avr/bin to your Unix path, define the shell variable AVR to be /usr/local/avr and define the shell variable AVRLib to be ~/avrlib For example, if you use the tcsh shell, add these three lines to the file .cshrc in your home directory:
    set path=($path /usr/local/avr/bin)
    setenv AVR /usr/local/avr
    setenv AVRLIB ~/avrlib
    setenv UISP_PORT /dev/tty.your-serial-device-here

If you use the bash shell, add these six lines to the .bashrc file in your home directory:

    PATH=$PATH:/usr/local/avr/bin
    export PATH
    AVR=/usr/local/avr
    export AVR
    AVRLIB=~/avrlib
    export AVRLIB

Why those particular directories?

It's a good idea to put the AVR tools in /usr/local/avr because they're updated frequently, so it's nice to have them all in a single location. Plus, that makes it easier to install my versions from the Stuffit archives above.

It's a convention at CCRMA that avrlib lives in each user's home directory, so if you put avrlib in your OSX home directory, you have less to change when you copy over AVR projects from your CCRMA Linux account.

Hard install

If you're even more brave, you can go to http://www.nongnu.org/avr-libc/user-manual/install_tools.html and follow the links to the latest versions of binutils, gcc, avr-libc, and uisp. The versions listed above (namely, binutils-2.17, gcc-4.1.1, avr-libc-1.4.4, and avrdude 5.1) were the most recent as of Sept. 2006 when I downloaded and compiled everything, and they seem to be mutually-compatible as far as I can tell. But by all means, if you like to be on the bleeding edge and enjoy running configure scripts and building software, go got it. Please let us know [matt at CCRMA; gurevich at CCRMA] of your experiences with this.

USB/Serial Devices

The AVRmini v4.0 has an FT232R chip from FTDI that has the ability to make a USB device appear as a "virtual com port" (serial device) on your PC. If you have the correct driver installed, this is done automatically when you connect the AVRmini v4.0 to your PC via USB and power on the AVRmini. This driver must be installed on your Mac. It can be downloaded from http://www.ftdichip.com/Drivers/VCP.htm.

Once you install the driver and plug in the AVRmini, a new Unix tty device will appear. On my computer it shows up as /dev/tty.something

It's easy to look for these files with ls from a Terminal window:

ls /dev/tty.*

You'll need to add the name of this ersatz serial port to the makefiles in your projects, for example, like this:

AVRDUDE_PORT=/dev/tty.something

or, add this line to your .cshrc file along with the other setenv lines above.

Building CCRMA's Example Programs

CCRMA's example AVR programs rely on the following to compile and load:

Where to go from here

To get the AVRmini to talk to Pd on your OSX machine via OSC over Serial over USB (!), see Jesse Fox's excellent instructions:

http://ccrma.stanford.edu/~jrobfox/OSC_PD_OSX.html

Somebody should replicate the functionality of the dumpOSCSerial object for Max/MSP.