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 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 of work. (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 at it.
Let’s start! Open Eclipse…
Configuring AVRDude
The 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 window that opens, on the left side open section AVR>Paths.
- On the right side of the window, you will see a list, find the AVRDude element. Click on it and press the Edit… button at the 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 this:
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 this:
C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf
- On the list below, 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 according to your platform, something like Arduino Mega2560.
This configuration is horizontal to all the projects in the same platform always that the COM port doesn’t change, COM port could change if you connect the Arduino board to another USB port! - The parameters that you should change are listed here:
- Programmer Hardware Wiring… WIRING
Other tutorials suggest using 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 this:
\\.\COM15
- 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 section AVR>AVRDude on the left tree.
- Select the Programmer page on the right side of the window.
- Set the Programmer configuration to the configuration that we have created in previous steps.
- Now, and this is important, go to the 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 the 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 well 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!
Wow, it’s so interesting. Thank you for to share with us
[…] binary code in your computer, the last step is to upload it into your board! Continue with “Developing for Arduino from eclipse (Part III)” to know […]