Uploading Code

To upload the code we are going to use the version of AVRdude that comes with the Arduino software. AVR Studio 5 lets you add external tools such as AVRdude to speed up your workflow.

Arduino Uploader

If you haven’t already follow the instructions to install the Arduino environment and make sure you can program the board with the blink application using the Arduino software.

UPDATE: The good folks at Arduino have updated the software from version 0022 to version 1.0.2 Fortunately I also show you how to set this up with AVR studio 5

Install External upload tool into AVR studio 5

Select Tools>External Tools to open the dialog window shown below

External tools dialogue

Click Add to add a new tool and edit the title to something like Arduino Uno Upload. Edit the command to run AVRdude this should be the location of AVRdude on your computer if you unzipped the Arduino files directly on your C; drive then this should be

C:\arduino-0022\hardware\tools\avr\bin\avrdude.exe

Or for Arduino version 1.0.2

C:\arduino-1.0.2-windows\arduino-1.0.2\hardware/tools/avr/bin/avrdude.exe

Or for Arduino version 1.0.3

C:\arduino-1.0.3\hardware/tools/avr/bin/avrdude.exe

You then need to paste the following command into Arguments box

For the UNO:

-C"C:\arduino-0022\hardware\tools\avr\etc\avrdude.conf" -F -v -p m328p -c stk500v1 -P\\.\COM9 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

For the MEGA1280:

-C"C:\arduino-0022\hardware\tools\avr\etc\avrdude.conf" -F -v -patmega1280 -cstk500v1 -P\\.\COM11 -b57600 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

For the MEGA2560:

-C"C:\arduino-0022\hardware\tools\avr\etc\avrdude.conf" -F -v -p atmega2560 -c stk500v2 -P\\.\COM10 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

If using Arduino Version 1.0.2 then

For the MEGA2560:

-CC:\arduino-1.0.2-windows\arduino-1.0.2\hardware/tools/avr/etc/avrdude.conf -patmega2560 -cwiring -P\\.\COM10 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

Or for Arduino version 1.0.3

-CC:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\\.\COM9 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

Or for the UNO and Arduino version 1.0.3

-CC:\arduino-1.0.3-windows\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM9 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

You will also need to edit the:

  • Path for the avrdude.conf file to make sure it points to the correct file on you system.
  • -p flag this needs to be set to specify the correct arduino hardware( e.g. –p m328p for the UNO, –p atmega2560 for the MEGA2560 and –p atmega1280 for the MEGA1280)
  • -c flag determines the uploader type you need to set this to -c stk500v1 for the UNO and MEGA1280 and -c stk500v2 for the MEGA2560
  • -P\\.\COMX com port number to match that shown in windows device manager for your hardware. This will also correspond to the port number that you had to choose in the Arduino software.

Finally tick Use Output window so that the results of the upload are displayed in the output window of the IDE.

The full list of AVRdude options can be found here.

The options that we use here are obtained by observing the verbose output of the compile and upload functions in the Arduino IDE. To see these, when using the Arduino IDE to upload a program, add the following statements to the end of the preferences.txt file in the Arduino lib folder. You will need to close and restart the Arduino application before these take effect.

build.verbose=true 
upload.verbose=true

The upload external tool can now be used to upload your complied code by selecting tools>Arduino UNO Upload. To add a shortcut button to the toolbar click on the device toolbar dropdown and select Add or Remove buttons>Customize… to bring up the following dialogue window.

Add button to toolbar

Then select the commands tab. Click the Add button and select the tools category in the window that pops up. The external tool that you just added will be called External Command 1. Note subsequently added tools will have the number incremented. Select the one you want and click OK. And then close the customize window the button will now be in the toolbar.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s