Introduction
This page details how to use the Arduino bootloader from AtmelStudio.
Specifically an Arduino Mega2560 and AtmelStudio 6.
Information
The Arduino Integrated Development Environment (IDE) uses a program named avrdude.exe, which is supplied with the IDE to program Arduino boards via a serial bootloader via the USB COM port from within the Arduino environment.
Avrdude can also be used / called from within the AtmelStudio environment to allow programming and downloading to be undertaken in AtmelStudio, pretty well in the same fashion as the Arduino IDE environment does.
Note: This guide only provides the arguments to avrdude.exe to program the Flash file to the Atmel microcontroller. If the user also requires to program the Atmel microcontroller EEPROM then the additional arguments required for this will need to be added by the user.
Pre-Requisites
It is assumed that the following are already installed (and working correctly).
- Arduino IDE
- AtmelStudio 6
AtmelStudio + Avrdude Configuration
There are a number of ways to configure AtmelStudio to call avrdude.exe, some of these include:
- Calling the Arduino version of avrdude.exe that is located within the Arduino directory
- Placing a separate version of avrdude.exe within the AtmelStudio directory
- Placing a separate version of avrdude.exe within the AtmelStudio project directory
Avrdude will be setup as an "External Tool" within the AtmelStudio.
Once setup the programming method will be accessible from within AtmelStudio
Tools -> <Just Above> External Tools
To start the configuration navigate to the following within AtmelStudio
Tools -> External Tools
A screen similar to below should be displayed (you can see that I already have Avrdude configured to be used from AtmelStudio).
Note: If the Arduino Mega2560 version of the Arduino IDE is 1.0 or greater then the user will be required to manually press the reset button on the Arduino Mega2560 board prior to running avrdude.exe from within AtmelStudio. avrdude.exe as included in versions prior to Arduino IDE version 1.0 does not require the user to manually press the reset button to program the board.
A zip file containing the arduino-0023, avrdude.exe files is located below.
Avrdude.zip
Configuring avrdude.exe (Version Included With Arduino IDE)
The following values can be used to complete the required sections of the External Tools screen when calling the version of avrdude.exe that is provided with the Arduino IDE.
Title:
Something relevant to describe the External Tool being used.
Suggested Value:
ArduinoMega2560Bootloader_COM3(Arduino Avrdude)
Command:
This section requires the direct path to the location of the avrdude.exe program.
This path will vary depending on where the user has installed the Arduino IDE to. The location of the avrdude.exe file may also change within Arduino releases, if the avrdude.exe program cannot be found it may need to be searched for.
Suggested Value:
C:\Program Files (x86)\Atmel\arduino-1.0.1\hardware\tools\avr\bin\avrdude.exe
Arguments:
This section specifies the arguments used to supply information to avrdude.exe such as the chip type, COM port, BAUD rate, hex file to program etc.
See the below section of this page titled Determining Arduino Avrdude Arguments for further information.
Note: In the Arduino IDE the avrdude.conf file is located in a different directory to the avrdude.exe program, as a result that path to the config file must be supplied.
Note: $(ProjectDir) and $(ItemFileName) are defined by AtmelStudio.
Suggested Value:
avrdude -C"C:\Program Files (x86)\Atmel\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf" -patmega2560 -cstk500v2 -P\\.\COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
Configuring avrdude.exe (Version Located Elsewhere)
The following values can be used to complete the required sections of the External Tools screen when calling a version of avrdude.exe that is different to that supplied with the Arduino IDE.
Note: It maybe useful to use the version of avrdude.exe as supplied with version 0023 of the Arduino IDE to remove the requirement to manually reset the Arduino Mega2560 during programming.
This example will detail using the arduino-0023 version of avrdude.exe saved to the following path (Note, your path may differ) C:\Program Files (x86)\Atmel\Atmel Studio 6.0\tools\Avrdude
A copy of the arduino-0023, avrdude.exe files is available at the below link
Avrdude.zip
Title:
Something relevant to describe the External Tool being used.
Suggested Value:
ArduinoMega2560Bootloader_COM3(AtmelStudio Avrdude)
Command:
This section requires the direct path to the location of the avrdude.exe program.
This path will vary depending on where the user has installed the Arduino IDE to. The location of the avrdude.exe file may also change within Arduino releases, if the avrdude.exe program cannot be found it may need to be searched for.
Suggested Value:
C:\Program Files (x86)\Atmel\Atmel Studio 6.0\tools\Avrdude\avrdude.exe
Arguments:
This section specifies the arguments used to supply information to avrdude.exe such as the chip type, COM port, BAUD rate, hex file to program etc.
See the below section of this page titled Determining Arduino Avrdude Arguments for further information.
Note: As the avrdude.conf file is located in the same directory to the avrdude.exe program the path to the config file does not need to be supplied.
Note: $(ProjectDir) and $(ItemFileName) are defined by AtmelStudio.
Suggested Value:
avrdude -patmega2560 -cstk500v2 -P\\.\COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
Determining Arduino Avrdude Arguments
The exact avrdude.exe command that is used from within the Arduino IDE can be determined by the following steps. This can be useful to ensure that the correct arguments are used when avrdude.exe is called from within AtmelStudio.
- Turn Verbose mode ON
- File -> Preferences
- Check Show verbose output during: upload
- Open the Arduino IDE preferences file
- File -> Preferences
- Click on link at the bottom to the preferences.txt file (Path will be similar to C:\Users\<user>\AppData\Roaming\Arduino\preferences.txt)
- Increase the setting that controls the number of lines that are displayed within the console. This will enable the calling of avrdude.exe can be observed in the console.
- console.length=5000 (default is 300)
- Download a file to the Arduino via the Arduino IDE, this will allow us to see the avrdude call that is undertaken to program the Arduino board.
- Scroll to the top of the Arduino IDE console and look for the avrdude call. An example for Arduino Mega2560 is below.
- C:\Program Files (x86)\Atmel\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Atmel\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\\.\COM3 -b115200 -D -Uflash:w:C:\Users\<user>\AppData\Local\Temp\build2646225547185526994.tmp\Blink.cpp.hex:i
Avrdude.exe Arguments
C:\Program Files (x86)\Atmel\Atmel Studio 6.0\tools\Avrdude>avrdude -?
Usage: avrdude [options]
Options:
-p <partno> Required. Specify AVR device.
-b <baudrate> Override RS-232 baud rate.
-B <bitclock> Specify JTAG/STK500v2 bit clock period (us).
-C <config-file> Specify location of configuration file.
-c <programmer> Specify programmer type.
-D Disable auto erase for flash memory
-i <delay> ISP Clock Delay [in microseconds]
-P <port> Specify connection port.
-F Override invalid signature check.
-e Perform a chip erase.
-O Perform RC oscillator calibration (see AVR053).
-U <memtype>:r|w|v:<filename>[:format]
Memory operation specification.
Multiple -U options are allowed, each request
is performed in the order specified.
-n Do not write anything to the device.
-V Do not verify.
-u Disable safemode, default when running from a script.
-s Silent safemode operation, will not ask you if
fuses should be changed back.
-t Enter terminal mode.
-E <exitspec>[,<exitspec>] List programmer exit specifications.
-y Count # erase cycles in EEPROM.
-Y <number> Initialize erase cycle # in EEPROM.
-v Verbose output. -v -v for more.
-q Quell progress output. -q -q for less.
-? Display this usage.
AtmelStudio Test Files
A zip file containing a small AtmelStudio, Blink program for Arduino Mega2560 can be found at the below link.
AtmelStudio ArduinoMega2560 Blink.zip
References
http://www.jayconsystems.com/tutorial/atmerpt1/
http://arduino.cc/en/Main/Software
http://arduino.googlecode.com/files/arduino-0023.zip
www.atmel.com/Images/as6installer-6.0.1703-full.exe
http://www.atmel.com/Images/as6installer-6.0.1843.exe
Views:
Comments (0)
You don't have permission to comment on this page.