AVR Resources for Mac OS X
Kok Chen, W7AY
[w7ay@arrl.net]
Last updated: May 23, 2008
AVR Tool Chain for Mac
OS X
The AVR Tools can be obtained from various sources on the
web. The following is one that has been bundled into a Mac
OS X installer, so you would not need to use Terminal.app
to download the files.
http://www.eecs.berkeley.edu/~mseeman/resources/macmicro.html
The above package includes the gcc compiler and library to
support the AVR. Please note that the pre-Leopard package
does not include avrdude.
The tool chain will assume that you already have Xcode
tools installed on your machine, even if you don't intend
to use the Xcode IDE itself. XCode Tools should be on your
Leopard DVD. Whenever needed, you can update the version
from your Leopard DVD by going to http://developer.apple.com/tools/xcode/ .
AVR Project Template for Xcode
There are various Xcode templates that you can use with the
AVR tool chain to do all of your code development (edit,
compile, flagging errors, etc) with the Xcode IDE from Apple. I have created
a set of Xcode template from what I have culled from the
web into a set that blends neatly with AVR Tools.
Currently the set only has templates for the ATtiny85
and the ATmega168. In many instances, all you will need
to do to create a template for a different AVR device is
to change the definition for the MCU variable in the
Makefile in the template:
Or, you can simply tell Xcode to create a project for the
ATmega168 and then editing the above line in your own the
project.
This set of templates assumes that there is a file called
program.c. If your program contains other files, you will
need to add other dependencies into the Makefile manually.
For example, the following will include a file uart.c as
part of your firmware:
To obtain this set of Xcode templates, download the disk image from here and
then copy the AVR folder from the disk image into the
following folder on your hard disk:
/Developer/Library/Xcode/Project Templates/
Once the AVR templates are installed, you should see
AVR item listed when you ask Xcode to create a New
Project:
If you add more templates for other Atmel devices into the
AVR template folder, they too will appear in the New
Project list.
When you create a new ATtiny85 Project, you should see
something like this:
As seen above, a program.c file appears in the
project, so does the Makefile.
Note the Make Executable item in the Active
Target popup menu at the top left of the project
window. This selects the Make Executable target that you
can see in the list view below the popup menu. When you
click on the Build button (the hammer icon in the
Xcode window's shelf), Xcode will execute this target.
If you double click on the Make Executable target
(the concentric red circles) itself, you will find that
Make Executable simply runs the Makefile
("/usr/bin/make"):
If you double click on the Clean target, you will find
this:
Thus, if you were to change the Active Target menu
to select Clean, clicking on Build will execute
the "clean" objective in the makefile (i.e., "/usr/bin/make
clean") . In the Makefile, you will notice that "clean"
runs the Unix command "rm
-f *.o *.hex *.elf *.map *~", which you can see when
you open the Makefile in the Xcode editor:
i.e., if you select Clean as your Active Target
and click on the Build button, Xcode will run the
Unix command to remove all the files that Make
Executable has created.
You can add other targets that you want, adding more
entries to the Makefile and save the Project as an Xcode
template in the Developer folder. Once you have a usable
Xcode template, adding other templates is as easy as making
changes and saving the Project itself as a template.