using avrdude from the command line

I've searched the forums and found lots of references to avrdude but none seem to solve my problem. I have an Arduino Uno Rev 1 board and it works fine through the Arduino IDE. However, I'd like to use the command line tools to build my project and hence I'd like to use avrdude directly to load my board. I've tried a number of different baud rates and options but I can't seem to get the loader's attention. Whenever I try to load my board ends up running the blink demo that I loaded into it using the Arduino IDE. I've tried pressing the reset button just before running avrdude but it looks like the blink program starts so fast that avrdude doesn't get a chance to initialize. Can someone tell me the correct command line to load an Arduino Uno Rev 1 board using avrdude directly?

Options I've tried:

avrdude -F -v -v -v -v -p m328p -c stk500v1 -P/dev/cu.usbmodemfd131 -b 57600 -D -Uflash:w:avrvm.hex:i

I've also tried writing a simple program to reset the Arduino by toggling DTR but running that program immediately before avrdude from a makefile doesn't seem to work either.

I get the following output:

./reset /dev/cu.usbmodemfd131 /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -F -v -v -v -v -p m328p -c stk500v1 -P/dev/cu.usbmodemfd131 -b 57600 -D -Uflash:w:bin/vmavr.hex:i

avrdude: Version 5.11, compiled on Sep 2 2011 at 18:52:52 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf" User configuration file is "/Users/dbetz/.avrduderc" User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodemfd131 Using Programmer : stk500v1 Overriding Baud Rate : 57600 avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

avrdude done. Thank you.

Thanks, David

I've figured out one of my problems which is that I need to use "-p atmega328p" and "-c arduino" instead of the options I was using before. The write phase of the load now completes to 93% but then fails. Any idea what might be going wrong now?

Thanks! David

Writing | ############################################### | 93% 0.90s avrdude: Send: U [55] . [00] 8 [38] [20] avrdude: Recv: . [14] avrdude: Recv: . [10] avrdude: Send: d [64] . [00] . [80] F [46] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] [20] avrdude: Recv: \ [5c]

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x5c avrdude: Send: V [56] @ [40] . [00] . [00] . [0c] [20] avrdude: Recv: } [7d] avrdude: stk500_cmd(): programmer is out of sync

I'm now wondering if I'm attempting to write over the boot loader. My program occupies 0x0000-0x77ff. Doesn't the boot loader occupy 0x7800-0x7fff (2k)? Should I be able to write data all of the way to 0x77ff?

I finally figured it out. I wasn't passing the correct parameters to avr-objcopy. This seems to work:

avr-objcopy -O ihex -j .text -j .data vmavr.elf vmavr.hex