I am using an external editor (AVR studio) to design and compile my software, but I have been unsuccessful loading the software onto the APM stack using AVRdude (via WINavr. I try to call AVRdude through the Windows 7 command console, but I can't get it to work because I don't know what programmer to call of those listed in the AVRdude option. If anyone has gotten this programming method to work please let me know what parameters you used when invoking the AVRdude executable through the command console. Below are some links to the process that I have been referencing.
Replies
Assuming you are got a hex file you can load, you call avrdude like this:
avrdude -Cavrdude.conf -v -V -patmega2560 -cstk500v2 -P/dev/tty.usbserial-A400CZEV -b115200 -D -Uflash:w:ArduPilotMega.hex:i
-Cavrdude.conf <-- the location of the avrdude.conf file, avrdude ships with one by default you might make a copy and modify it
-v <-- verbose
-V <-- don't verify after upload (faster, but you might want to remove this flag)
-patmega2560 <-- identifies the atmel chip
-cstk500v2 <-- identifies the boot loader, this section is in avrdude.conf
-Pport <-- the serial port, this one is from OSX, yours will be different
-b115200 <-- the baud rate to run the upload at
-D <-- don't use chip erase
-U <-- specify flash, specify write, specify file name, specify intel hex format
If you get the serial port wrong it looks like
avrdude: ser_open(): can't open device
(instant quit)
If you get the baud rate wrong (your serial port rate != arduino port rate), it looks like this:
avrdude: stk500_2_ReceiveMessage(): timeout
(repeated)
I've had situations where the board does not listen. I can't seem to pin down exactly why. For example right now, no matter what I do, avrdude uploads successfully. I can power it off, I can remove the USB cable from my PC and re-insert, recreating the device.
I can set the port baud rate on the mac to 9600, or I can write some Init_Ardupilot code to set the serial port baud rate to 57600 and then hang in an infinite loop, and avrdude STILL uploads without any extra drama at all.
However it has certainly not been this well behaved before and if so you might need to encourage it by telling avrdude to reset the port, to prep the bootloader:
edit avrdude.conf and add reset = ~4;
so it looks like
programmer
id = "stk500v2";
desc = "Atmel STK500 Version 2.x firmware";
type = stk500v2;
reset = ~4;
BTW I've tried using avrdude version 5.4-arduino (comes bundled with arduino)
and freshly compiled vanilla avrdude version 5.10 (current version)
both seem to work fine.
I have been successful with the bus pirate in SPI mode with the command line interface to Atmega's so far using AVRdude.
Most recent was programming a added 328P on a Ardupilot. It worked however the Mux light flashes. There is a little history to my hardware problem. .As long as AVRdude is compatible with your programmer and has the processing device you are using it will work. There are some sequences to connect such as USB first then the programming interface and its variables set proper to it such as baud rate. I looked at the the STK500 emulation to work with the bus pirate but have determined that it will open up incompatibilities in the future. The STK500 would allow the AVR Studio to work.
Also in the future there may be some that want to upgrade to the ATMega 2560 on their older boards. Having these program interfaces documented along with fuse defintion and bootloaders will help.
I figured out how to do this and have posted an attachment in word document format. The tutorial is geared for the APM specifically. When solving this issue, I referenced the tutorial at the link provided below. The tutorial link provided is not geared towards the APM.
http://hekilledmywire.wordpress.com/2010/12/04/22/
How to Setup an External Editor for the APM.docx