5.c. Programming AVRs in Mac OS X

If you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide instead of this tutorial.

Installing prerequisites

To program AVRs in Mac OS X, you will need the free avr-gcc compiler, avr-libc, AVRDUDE, and other associated tools.

To obtain these tools, we recommend first installing Homebrew. Then run the following commands to install AVRDUDE and homebrew-avr:

brew install avrdude
xcode-select --install
brew tap osx-cross/avr
brew install avr-gcc

You can now compile programs for the AVR at the command line using the avr-gcc or avr-g++ compilers.

Using AVRDUDE

Once an AVR program has been compiled to a .hex file, it is ready to be flashed to the AVR. The AVRDUDE program may be used for this purpose.

To see the full command-line syntax for AVRDUDE, type avrdude --help at the command line, or consult the AVRDUDE documentation. Typical usage would be as follows:

avrdude -p <partno> -c avrisp2 -P <port> -U flash:w:<filename>.hex

For example:

avrdude -p m328p -c avrisp2 -P /dev/cu.usbmodem00022331 -U flash:w:test.hex

If all goes well, the output should look something like this:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "test.hex"
avrdude: input file test.hex auto detected as Intel Hex
avrdude: writing flash (3392 bytes):

Writing | ################################################## | 100% 0.88s

avrdude: 3392 bytes of flash written
avrdude: verifying flash memory against test.hex:
avrdude: load data flash data from input file test.hex:
avrdude: input file test.hex auto detected as Intel Hex
avrdude: input file test.hex contains 3392 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.72s

avrdude: verifying ...
avrdude: 3392 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Related Products

Pololu USB AVR Programmer
Orangutan SV-328 + USB Programmer Combo
Orangutan LV-168 + USB Programmer Combo
Baby Orangutan B-328 + USB AVR Programmer Combo
Baby Orangutan B-48 + USB Programmer Combo
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors