How to configure AVRDude to upload binaries to Arduino.
This tutorial is based on a Windows 64 bit system. But the fact that eclipse is multi-platform should ease the things.
Uploading compiled code to Arduino Mega2560 from Eclipse
I’ve been following a lot of different tutorials about how to make this done. But no specific information about Mega2560 the configuration of the different tools drives me crazy after one day working. (No tutorial describes exactly what I’m looking for!!) However I need to say that the official tutorial is great and you should take a look on it.
Let’s start! Open Eclipse…
First thing to notice, AVRDude in WinAVR is not valid for Mega2560 so you need to use the one included in Arduino IDE.
- On Eclipse go to menu Window>Preferences. On the Preferences windows that opens, on the left side open section AVR>Paths.
- On the right side of the window you will see a list, find AVRDude element. Click on it and the press the Edit… button at right of the list.
- A window called Change Path for AVRDude opens. Select Custom on Path source enumeration.
- Browse for your Arduino IDE path and from it go to ‘\hardware\tools\avr\bin’. In my case looks like:
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin
- Confirm the path and Apply the changes in the Preferences window.
- Still in Preferences go to section AVR>AVRDude.
- Check the Use custom configuration file for AVRDude and Browse… to the Arduino IDE path and from there to ‘\hardware\tools\avr\etc\avrdude.conf’. In my case looks like:
C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf
- On the list bellow, Programmer configurations click on the Add… button at right. A window called Edit AVRDude Programmer Configuration <Configuration name> opens.
- Put a configuration name and a description acording to your platform, something as Arduino Mega2560.
This configuration is horizontal to all the projects in the same platform allways that the COM port doesn’t change, COM port could change if you connect Arduino board to other USB port!
- Parameter that you should change are listed here:
- Programmer Hardware Wiring… WIRING
Other tutorials sugest to use STK500v2 or Arduino but… NO. Please don’t. Because, as written in the file ‘avrdude.conf’:
# http://wiring.org.co/ # Basically STK500v2 protocol, with some glue to trigger the bootloader.
- Override default port ‘\\.\<arduino COM port>’, in my case looks like:
- Override default baudrate 115200
- Other options -v -v
This option will enable verbose mode, useful to see what is happening on the Eclipse console.
- Programmer Hardware Wiring… WIRING
Configuring the project
The general configuration for the AVRDude is done, but still some other changes should be applied to our project.
- Open the Project>Properties.
- Navigate to setcion AVR>AVRDude on the left tree.
- Select Programmer page on the right side of the window.
- Set Programmer configuration to the configuration that we have created on previous steps.
- Now, and this is important, go to Advanced page. And check the Auto Chip Erase Cycle (-D) option!
No tutorial that I’ve checked has this step, and this will crash the uploading procedure with next output.
avrdude: erasing chip avrdude: stk500v2_command(): command failed avrdude done. Thank you.
- Navigate to section AVR>Target Hardware on the left tree again.
- Set next parameters
- MCU Type ATmega2560
- MCU Clock Frequency 16 000 000 (six zeroes)
- Apply and confirm the configuration.
If everything went good you now can use the AVR upload button ().
You can make auto-upload when building if you check Project>Properties>C/C++ Build>Settings>Additional Tools in Toolchain>AVRDude.
This is my first post (yes, I started with part II) and tutorial on this blog! So… Hello world!