# How do I program an AVR Raven with Linux or a Mac?

This tutorial starts with programming the Ravens and Jackdaw with a Windows box. Can I do those initial steps with a Linux or OS X machine instead? If so, how? Is there any risk of bricking the hardware if I just try?

I have a USB JTAG ICE MKii clone, which is supposed to work for this.

I'm totally new to AVR, but very experienced with C/C++ programming on Linux or OS X, up to and including kernel programming.

## 3 Answers

Under Linux, you'd probably use avrdude to program them. It supports most programmers and most AVR chips. The main thing to watch out for, is that I think you need to use avr-objcopy to extract the data from the 'ELF' binary files, you can't program the 'ELF' directly with avrdude.

Random googling for avr-objcopy / avrdude commandlines comes up with this, which looks like it might work:

# create demo.bin from demo.elf
avr-objcopy -j .text -j .data -O binary demo.elf demo.bin

# program demo.bin to the 'flash' memory in an 'atmega128' chip,
# using a 'stk200' programmer connected to the 'lpt1' port on your computer
avrdude -p atmega128 -c stk200 -P lpt1 -U flash:w:demo.bin:r

• Ok. Do you know the exact avr-objcopy incantation to do that splitting? I've figured out quite a bit of the avrdude part, I think, but not what the right way of splitting the ELF files is. – Andrew McGregor Feb 12 '10 at 2:42
• Did some random googling, above is what I found – davr Feb 12 '10 at 6:45
• Thanks, that got me most of the way. For the record, you also have to extract the eeprom section from the elf files, and of course set the fuses right. – Andrew McGregor Feb 12 '10 at 8:22
• Ah ok, I haven't programmed eeprom from the PC before (I've always had my software program its own eeprom), so I didn't think of that. – davr Feb 12 '10 at 19:16

If you're developing projects on Linux, do some searching for a good Makefile that supports avr-gcc and avrdude. You should then just have to edit the Makefile to specify your hardware and source files and you're away.

To build a binary you generally just call make, to program a device is often make program and sometimes make fuse to set the fuses on the AVR.

I've used Mfile for generating Makefiles on Windows, but it looks like they support *nix also.

Avrdude works just fine on OSX too. Just,

port install avrdude avr-gcc avr-binutils avr-gdb avr-libc


And you're ready to do everything that WinAVR does.