Arduino Programming Using Atmel Studio 6.0

This article is no longer relevant.  Please follow the Arduino Template Express update to find a more mature offering to allow development of Arduino sketches in Atmel Studio 6.1.

The Arduino IDE is a good development environment to get started with microcontrollers.  It holds your hand and hides complexities that get in a novice way.  As you gain experience and want to use advance features such as refactoring, assembly language or binary libraries, working with the Arduino IDE just doesn’t cut it.  Moving to a more advance IDE is the next logical step for a mature Arduino user.  It is the equivalent of leaving your home to go to college. Jaycon Systems has a well written three part tutorial explaining how to configure Atmel Studio 6.0 to compile Arduino projects. I have taken a different approach to solve this problem and have created an installation script to accomplish the following;

  1. Distribute a binary file for the core library (libcore).
  2. Distribute binaries of the Arduino libraries (libEEprom, libEthernet, libFirmata, libLquidCrystal, libSD, libServo, libSoftwareSerial, libSPI, libStepper, libWire).
  3. Distribute a solution with projects for all the libraries specified above so libraries can be recompile and redeployed as needed.
  4. Distribute a project template for Arduino Sketch.  This allows you to do a new project and select Arduino Sketch from the list of available templates.
  5. Distribute a project template for Arduino Lib.  This allows you to do a new project and select Arduino Library from the list of available templates.
  6. Distribute a deployment scripts to write sketches to the destination chip.  This allows a one click deployment to the Arduino board.

The rest of this post covers the configuration of the installation script and the deployment scripts in the Atmel Studio environment.

Configuring Installation Script

In order to run the installation script, you need Arduino 1.0.1 or greater and Atmel Studio 6 or greater.  Both of these programs must be installed and running successfully.  The installation script is located at the Arduino Installer site at Codeplex.  It contains all the binaries and scripts required for the installation.  Follow these instructions carefully for a successful installation.

  1. Download the installation package from Codeplex
  2. Unzip in a directory of your choice.  For the purpose of this post I am going to assume you have decompressed the installation script at c:\arduino-install.
  3. Open the file c:\arduino-install\install.bat with your favorite text editor and go to the :SetUserVariables label, around line number 31
  4. By default the ATMEL_CPU is configured to ATmega328p, change this line if necessary to reflect your microcontroller.  Typical values are ATmega32u4 (Leonardo),  ATMega328p (Uno), ATmega2560 (Mega), ATmega168 (Diecimila).
  5. The CPU_FREQUENCY and ARDUINO_VERSION do not need to be changed.  I have tested with the  Arduino 1.0.1 IDE successfully with these default values CPU_FREQUENCY=16000000 and ARDUINO_VERSION=100
  6. Set the COM_PORT variable to the communication port you are using to communicate with the Arduino board.  The default is COM3.
  7. Set the COM_PORT_SPEED variable to the proper value if necessary.  The default is 115200.
  8. The VARIANT variable refers to the pin layout of the board.  Change it accordingly to reflect the type of board you have.  The values are standard (Uno, Diecimila), leonardo (Leonardo), etc.  The default value is standard.
  9. Last setup the AVRDUDE_ROOT_DIR variable with the value of the root director where the avrdude is located.  This could be done from the Arduino installation or from Winavr.  Note that the avrdude.exe would be at AVRDUDE_ROOT_DIR\bin\avrdude.exe from the path you specify.
  10. Save the file and open a command window.  Go to the directory c:\arduino-install and run install.bat.

After a few seconds you should see an output similar to that illustrated on Figure 1.  The installation script has done the following;

Installation Results

Figure 1 – Installation Results

  1. Create directory structures at C:\users\YOUR_USER_NAME\Documents\Atmel Studio\Libs and Headers.
  2. Under Libs there are three directories, ArduinoCore for the core library, Arduino for all the Arduino libraries and Public for your personal libraries.
  3. Under Headers there are three directories, ArduinoCore for the core library headers, Arduino for the different Arduino library headers and Public for your personal library headers.
  4. All binaries and header files have been deployed to these directories.
  5. There is a file named deploy.bat located at c:\users\YOUR_USER_NAME\Documents\Atmel Studio.  This file is responsible for performing generic solution and project name clean up and then invoking the localdeploy.bat file that is located in the Arduino project directory and is part of the sketch template.
  6. In the c:\users\YOUR_USER_NAME\Documents\Atmel Studio\Templates\ProjectTemplates there are two files.  Arduino and Arduino, these are the library and sketch templates for Atmel Studio.
  7. At c:\users\YOUR_USER_NAME\Documents\Atmel Studio\ArduinoLibrariesSource a solution named ArduinoLibraries.atsln has been deployed with the source code for all the Arduino libraries so you can recompile them from within Atmel Studio if you wish to update the distributed binary libraries.

Configuring Deployment Script

The configuration of the deployment script allows you to do deployment of Arduino sketches with one click or keyboard shortcut.  Sketches are deployed to the Arduino board while libraries are deployed to the Public folder of the library directory created by the installation script.  Follow these instructions to configure the deployment script in Atmel Studio;

  1. Open the External Tool manager from Tools/External Tools
  2. Setup a new entry named &Deploy with the characteristics illustrates in Figure 2.

    Deploy Tool Definition

    Figure 2 – External Tool Definition

  3. The & before the D, makes it a hot key while in the context of the Tools menu.  This means pressing ALT-T followed by D will launch the Deploy script.
  4. The parameters must be $(SolutionDir) $(ProjectDir) $(ProjectFileName).  There is a space between each parameter.
  5. Select use Output window so you can see the outcome of the deployment within Atmel Studio.
  6. The top most entry is External Tool 1, the second one is External Tool 2 and so on.  Moving the entries up or down changes the External Tool to the command located at the target position.  If you have multiple external commands registered, keep track of the position where Deploy is located because we are going to need it later.

Let’s create a custom toolbar and add some commands that will facilitate the development experience.

  1. Go to view\Toolbar\Customize and create a new toolbar.
  2. Name the toolbar Productivity.  Hit OK and make sure the checkbox is selected.

    Productivity Toolbar

    Figure 3 – Creating a Productivity toolbar

  3. Select the Commands tab and select the Toolbar radio button.
  4. In the drop down select the Productivity toolbar we just created.
  5. Add the command Build\Build Solution
  6. Add the command Tools\External Command1 (or whatever the name of the Deploy command is in your setup)
  7. Move it up and down as needed.

    Toolbar Commands

    Figure 4 – Toolbar Commands

  8. Click on the Keyboard button and select the Tools.ExternalCommand1
  9. Enter a shortcut for it and press Assign.  In my case I configured the Tools.ExternalCommand1, which is the Deploy script as CTRL+SHIFT+P

    External Tools Shortcut

    Figure 5 – External Tools Shortcut

  10. Hit OK and we are done.  You should see a toolbar with the following information.

    Deploy Toolbar

    Figure 6 – Productivity Toolbar

The option to deploy is available via a click on the Deploy button in the Productivity toolbar or via CTRL+T followed by D or via CTRL+SHIFT+P.  Any one of these three options should satisfy your workflow.

Creating Arduino Sketches

To create your first Arduino sketch in Atmel Studio 6, launch Atmel Studio, select File\New\Project.  The new project window appears similar to figure 7 with all the installed templates.

Atmel Studio New Project

Figure 7- Atmel Studio With Arduino Templates

Select Arduino Sketch, change the name to TestSketch1, change the location if necessary and press OK.  A new solution is created with a project named TestSketch1.  The project has three files, with the following content;

  1. main.cpp – contains code to blink the led on the Arduino board.  This is so you can have a quick block of functional code.
  2. localdeploy.bat – this is the local deployment script.  This file is called by the deploy.bat script located in your c:\users\your_user_name\Documents\Atmel Studio\deploy.bat.  It gives you the opportunity to customize deployment for a particular sketch.  The localdeploy.bat is ready to deploy the hex file located in the Release directory, not debug.  This script reflects the port, speed and directory information provided to the installation script.  I have submitted internal enhancement request AVRSV-3699 to Atmel to have the $(Configuration) variable exported to indicate you are running in Release or Debug mode.  Until this issue is addressed the default hex file deployed is the one in the release directory. You can change the script to deploy from the Debug directory if necessary.
  3. readme.txt – This file contains a list of the Arduino libraries, which files you need to include and which libraries you need to add to the linker.

Before compiling the code you need to open the project properties (ALT-F7),  select All Configurations and under Toolchain\AVR/GNU Linker\Libraries add libcore.  See Figure 8.  There is a bug in Atmel Studio 6 that does not include the libraries added to a project template.  I have submitted internal bug AVRSV-3701 to Atmel for this issue.  Note the Library search path is automatically populated with the directory structure where the libraries are located. After adding the library you can go ahead and compile the code, then press the deploy button in the Productivity Toolbar.  You will see avrdude copy the hex file to the Arduino board and the onboard LED start flashing.

Add Core Library

Figure 8 – Add Core Library

Creating Arduino Libraries

To create an Arduino library, select File\New\Project and select the Arduino Library template from the list of available templates.  Name the library TestLib1 and change the directory as necessary.   A new directory is created with four files.

  1. foo.h and foo.cpp contain a dummy class
  2. localdeploy.bat is the deployment script responsible for deploying the library and header files to the Public directory of the Lib and Header created during installation.  As before only the Release version is deployed for the same reasons previously stated.
  3. readme.txt contains a blank file.

If you need a reference to libcore in your library you must add it as explained for the sketch.  Deploying the library copies all the header files and *.a files to the Public directories.


Adopting Atmel Studio has the potential to increase your productivity and expose you to advance concepts such as mixed language programming (C/C++ and Assembly).  If you are a Microsoft developer familiar with Visual Studio, you will feel right at home in Atmel Studio 6.  Let me know if the script has been of assistance transitioning out of the Arduino IDE.

Print Friendly

105 thoughts on “Arduino Programming Using Atmel Studio 6.0

  1. Pingback: Programming your Arduino with Atmel Studio v6 « freetronicsblog

  2. Hello, Omar
    I’ve tried follow your instruction.
    i’ve compiled my code, everythig is fine. But whin i tried to deploy the code. Error happened in Output Window as ” CANNOT Find binary file “C:\Users\Psmlives\Documents\Atmel Studio\TestSketch2\TestSketch2\Release\TestSketch2.hex” – Aborting script”

    Thank you

  3. Hi Omar
    Congrats on an excellent post! I used it to get my Freetronics EtherMega 2560 working in Amtel Studio, complete with JTAG debugging.
    But a few extra steps are needed:
    1. Follow Omar’s instructioons.
    2. Change the board type in project properties. Try a compile – it will probably fail with “Skipping incompatible library…”
    3. Open the Ardurino IDE (Not Amtel Studio). Turn on verbose compiliation (File|Preferences), and compile the Blink example.
    4. Go to the output directory and copy core.a to {My Documents}/Atmel Studio/Libs/Ardurino/libcore.a (Note the name change)
    5. Check that the pins_arduino.h in {My Documents}/Atmel Studio/Headers/ArdurinoCore is the correct one for your board. If not, replace it with the one in the Arduino installation under the \hardware\arduino\variants tree.
    6. Open Atmel Studio, and open the library solution in {My Documents}/\Atmel Studio\ArduinoLibrariesSource
    7. Compile each library, and copy the .a output file to the {My Documents}\Atmel Studio\Libs\Arduino directory.

    You should now be able to open any sketch and make it run on your 2650 board. Two other quirks:
    1. If talking to the SD card, change the Ethernet disable line to
    pinMode(10, OUTPUT);
    digitalWrite(10, true);
    2. The Ethernet example does not like the println() method. It is something to do with separate packets being generated for CR and LF. Change the HTTP header stuff to use print() instead, and manually code \r\n on the end of each string.

    Hope this helps others – I finally have a usable system.

  4. Verify you are compiling the project in Release mode. By default this version of the upload script only looks at the Release directory.

  5. I’ve also found out that the Optimization Level setting won’t be imported for both C and C++ compilers in the toolchain.

  6. What is the full path in “Command” Field in Figure 2. it is truncated. I assume to the deploy.bat?

  7. That is correct. The full path in the command field is to the deploy.bat file. I am working on an upgrade for the installation script that can use the device, configuration and assembly name directly from the Atmel Studio environment. When I release the new script, I will upgrade the post to clarify this step.

  8. Thanks for the reply. I am getting a “System cannot find the path specified ” error. When I run the deploy this is what is on the arguments field.

    $(SolutionDir) $(ProjectDir) $(ProjectFileName)

    This is what’s on the command line field:
    C:\Users\Bryan\Documents\Atmel Studio\deploy.bat “C:\Users\Bryan\Documents\Atmel Studio\TestSketch1\\” “C:\Users\Bryan\Documents\Atmel Studio\TestSketch1\TestSketch1\\” “TestSketch1.cppproj”

  9. hi omar, ive run through everything as stated, it compiles fine, and trys to download through avrdude…
    it generates an stk500 out of sync error … can you give me an idea of where to look


  10. Check the version of AVRDUDE you are using. Maker sure you are using the avrdude that comes with the 1.0.1 Arduino environment or the latest Winavr. Comment the first line of the localdeploy.bat to view all the commands and verify the script is passing arduino as the programmer to the avrdude.

  11. This is just what I’ve been looking for since upgrading to Atmel Studio 6 today. It worked like a champ until deploying returned this:

    ‘C:\Program’ is not recognized as an internal or external command,
    operable program or batch file.

    Any help you might be able to offer would be greatly appreciated.

    Thanks for a fine contribution to Aruino enthusiasts everywhere!

  12. Hey SciFiModelmaker, I had the same issue. You have to edit the deploy.bat file. It is somewhere your Atmel Studio’s project folder, where you installed Omar’s stuffs. 31th row: set AVRDUDE_ROOT_DIR=C:\Program Files\… Replace “Program Files” with “PROGRA~1”, and it should work. Hope it helps! Tibor

  13. Hello Omar, Great Tutorial, but Strangely when I try to compile the code, it returns all sorts of errors on the libraries. I am using a XBee library, which works fine on Arduino IDE. I have copied it as-is and deployed as an Arduino Library on Atmel Studio flawlessly. Then on my “main” code, when I #include “XBee.h” a lot of errors appear, which gives me the impression that it is not recognizing the library. The code is the same as used into Arduino IDE, so I know it is correct. Do you know what is causing such problems? Thanks

  14. The deploy.bat sucks! It doesn’t work at all. It messes around with the paths and creates a impossible path. I found a command to create a deploy tool much simpler than your’s and it actually works. Other than that, nice tutorial.

  15. Try using instead of “XBee.h”. It works on the arduino ide because the source for all the libs is copied locally to your project space. When using xbee as a compiled library you need to use < >. Let me know outcome.

  16. Seems you had a bad experience with the script. There is a bug associated with spaces in the path that will be fix in the next release. If you can provide the link of the tool you found it may help someone having the same problems you encountered.

  17. Hi I have been looking for a new IDE i simply cant use the default one it is so terrible and confusing , I spend 5 hours trying to get this to work and still no luck could you plz help every time I build i simply get this error “Error 1 undefined reference to `main’ /home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/crt1/gcrt1.S 52 1 tests1
    ” even when using your example. I have and arduino uno and on Configuring Installation Script step 8 i had to chose standard cause it says the is no file for uno ,the step about Toolchain\AVR/GNU Linker\Libraries i was not sure how to do what you sugested so i simply clicked the top add item button and typed Libcore.
    Ps thanks for trying to help every one .I am very new so have no experiance with visual studiona new to arduino i played with it for 30 mins but beacuse of the IDE , I have lost interest it is so bad when ever i go over 50 lines of code i am lost cause its like looking at one solid text file and i end up making so may mistakes.

  18. Hi Omar, just wanted to thank you for the excellent tutorial. I got the system working after fixing a couple of self-inflicted wounds – like putting stuff in GNU C Compiler instead of C++ (doh!), and stumbling around with adding files instead of just the links. After that, it worked like a champ. After a little tinkering with avrdude.conf I was also able to program a 328 non-p by changing the chip type in the project and localdeploy.bat. This will now let me use them in non-power critical locations. Now to try with some other programs and other chip types. Thanks again.

  19. Hi Omar,

    I’ve tryied your suggestion (using instead of “”) and the same error happens. If on the other hand I include the .cpp instead of the .h file, everything works fine.

    #include “XBee.h” or #include does not work.
    #include “XBee.cpp” works…

  20. hi,

    i rework this tuturial and all compiles fine. But i get the same error like psmlives
    (CANNOT Find binary file “C:\Dokumente und Einstellungen\mike\Eigene Dateien\Atmel Studio\TEST\TEST\Release\TEST.hex”)
    The directory ‘Release’ is not avaiable and creating by hand don’t help too.
    Any hints?

    (there is a TEST.hex, but under C:\..\Atmel Studio\TEST\TEST\Debug..)

  21. Hi Omar,

    I have a problem with $(SolutionDir) $(ProjectDir) $(ProjectFileName) in Arguments field.
    If I run Deploy I get this error:
    Missing parameters – expecting $(SolutionDir) $(ProjectDir) – Aborting script

    Please, could you help me?

  22. Download the latest version of the installer from Codeplex. I fixes multiple bugs related to spaces in path or project names.

  23. Hello!

    Nice post, but I have a problem with error in Output window:
    “”C:\WinAVR-20100110\bin\avrdude.exe” -C”C:\WinAVR-20100110\etc\avrdude.conf” -q -q -q -pATmega328P -carduino -P\\.\COM10 -b115200 -D -Uflash:w:”c:\users\aspire\documents\atmel studio\CRIUS_MultiWii_SE\CRIUS_MultiWii_SE\Release\CRIUS_MultiWii_SE.elf”:i
    error at C:\WinAVR-20100110\etc\avrdude.conf:332 unrecognized character: “w”
    Deployment Failed”.

    In file “C:\WinAVR-20100110\etc\avrdude.conf” line 332 is “type = wiring;”


  24. Hi Omar,

    I downloaded the latest version of the installer from Codeplex. I have the Arduino Deumilanove board with Atmega 328P. I chose from Arduino board menu – Uno.
    Again I have a problem with $(SolutionDir) $(ProjectDir) $(ProjectFileName) in Arguments field.
    If I run Deploy I get this error:
    Missing parameters – expecting $(SolutionDir) $(ProjectDir) – Aborting script
    I don’t know what I have to write in Arguments field. What is wrong?
    Please, could you help me?
    Thank you.

  25. Having problems with your install script. I get to the actual installation and get a message saying ‘{path} was not expected at this time’ with the {path} being the path entered for the avrdude.exe program. I’m not sure what is causing this, but it keeps the installation from completing. Any ideas?

  26. To verify I am understanding the problem correctly, you are selecting a path for the avrdude during the install process. During the installation you get the message you indicated. Can you please provide the actual path you are selecting for the avrdude and the operating system under which you are running the script.

  27. Will this work for Duemilanove board? In your setup.exe there are only 4 options. Not sure which one to select. Please let me know.


  28. Hello Francisco. Do you know if the existent Arduino libraries will work for Arduino Due? Thank you

  29. Hello Omar. I just programmed my Arduino Uno using your script and it worked amazingly! Thank you very much for your valuable tutorial. My next step is to program the Arduino Due but I do not have a clue about where to start. COuld you enlighten me a bit about what changes should I apply for the Due? Thank you again.

  30. Which is the equivalent programmer of the AVRDude for the ARM processor of Arduino Due? Sourcery G++ Lite? Thank you, Octavio

  31. Hello Omar!
    Don`t work if change device to atmega2560:
    “skipping incompatible C:\……\Atmel Studio\Libs\ArduinoCore\libcore.a when searching for -lcore cannot find -lcore collect2: ld returned 1 exit status make: *** [UnitTest1.elf] Error 1
    Done executing task “RunCompilerTask” — FAILED.
    Done building target “CoreBuild” in project “UnitTest1.cppproj” — FAILED.
    Done building project “UnitTest1.cppproj” — FAILED.
    Build FAILED.”
    Thank you, Valery

  32. Valery, I have not tested this with the atmega2560 and I am not surprise about the library incompatibility. I will try to contact you directly next week to evaluate options.

  33. I got it to work with my Arduino ATmega 2560 Rev3. I also have an uno board so I wanted to be able to program both.
    The first thing I did was start a project with the arduino sketch template.
    I then changed the device to ATmega2560 in the project properties.
    I cleaned up the main.c so the loop and setup were empty ready for a new program. I deleted all references to the two support files for incrementing a counter and then exported the template calling it ATmega2560.
    I took a picture of my ATmega and replaced the picture in the template.
    The compile error was that the core.a that comes witht he install is not for the ATmega so I comipiled code for the ATmega in the Arduino IDE and located the core.a in its tmp directory. I placed a copy of it in the same directory as the libcore in the Amtel Studio setup calling the old file libcore libcore2.
    To compile for the ATmega2560 I put a reference to libcore in the project properties as explained, for the Uno I just put a reference to the libcore2.
    Instead of using the deployment script. I just created a external tool that calls avrdude.

    Command: C:\AVR\bin\avrdude.exe
    Arguments: -CC:\AVR\avrdude.conf -c wiring -p atmega2560 -b 115200 -P COM5 -U flash:w:”$(ProjectDir)Debug\$(ItemFileName).hex”:i

    I then created a deployment toolbar and put a reference to external Command1. I will created a second command to program the uno.

    The only minor issue with the external command is that if the main.c is highlighted and the project name is different then the external command fails. Just highlight the project name at the top of the solution explorer window the program is flashed to the Arduino Mega2560.

    I know this may seem daunting. It also is a little messy to have to keeping entering a reference to the the libcore file but once you get used to it, going back to the arduino IDE seems a bit elementary.

    I also created a template that does not make reference to the arduino.h. The nice thing is that I can import a project from amtel samples and compile and flash it just as it is downloaded. No mickey mousing around at all. Since no reference is made to arduino.h then the libcore issue does not arise. So it is pretty slick, a template the use arduino libraries and a template to use regular amtel libraries. Both uploading straight to the arduino though the usb cable.

  34. @Valery, look at Ron’s post above (8/20/2012), about this issue. I am having the same problem, and have almost gotten it to work. You basically have to have a separate copy of each of the library files for the Uno…and then a separate copy for the Mega. Not sure I’m completely clear *why* this is the case, other than that the architecture of the Uno differs from that of the Mega (found this on the AVR Freaks site). So you have to do this:

    1) Open the Arduino IDE, and then open a simple example sketch like Blinky or something. Build that for the MEGA, and note the time you built it.

    2) Now go into the AppData/Local/Temp/ directory and find the build directory for the sketch you just built. Grab the core.a file and copy that into the ArduinoCore folder as you did for the Uno. Note: I made separate directories for the Uno and Mega here–like ArduinoUno vs ArduinoMega, and ArduinoCoreUno vs ArduinoCoreMega. Then I put the new libraries for the Mega into the correct folders.

    3) For the other libraries, go into each of the folders inside the ArduinoLibrariesSource folder, and open each of the Atmel Studio project solution files. This will bring in all the necessary .cpp and .h files to build the libraries. Set your device to be the 2560 (in the Project>Properties) and then compile each library in turn: EEPROM, then Ethernet, then Firmdata…etc. Just open the correct folders and find the solution file for each library you need to build. I built them in Release mode, and so the resulting libXXX.a file was in the “Release” folder. So once the lib file has been built, I just copied them into the C:\User\MyDocuments\Atmel Studio\Libs\ArduinoMega folder that I made, naming them appropriately (“libEthernet.a” etc).

    So this is working for me, except for the libSPI.a. I build it fine and all, but I am still getting the same linking error and I haven’t yet resolved the problem. But the libcore and libEthernet linking problems I had were resolved by using this method. I will still work on the libSPI issue and report back if I get it to build. I tried both the Release and Debug builds, by the way, and neither works. So the search continues…


  35. Well, I got it to work…but not by rebuilding the libSPI.a file. No matter what I tried, it still failed. I discovered that I even missed the step where you paste in the pins_arduino.h file specific to the MCU, so I corrected that–but it still fails. Then I used avr-objdump.exe to look at the file format of libSPI.a and compare it to that of libEthernet.a, because that latter library worked after I rebuilt it. So I ran both those lib files through objdump, and the file format is identical (elf32-avr) in both cases.

    So the way I got it to work was quite straightforward. Since the library only has one .cpp file, I simply included that in my project–and then removed the reference to libSPI in the linker settings in the properties for the project. Once I did that, the project build without difficulties. I have no idea why it doesn’t like the libSPI.a that I rebuilt though.

    Hope this helps someone out, as I spent several hours on it tonight…lol.

  36. The only problem I seem to be having is with the com port. The install bat file did not have my com port on it’s list and I have been unable to open the file to change the com port. Here is the error I get when I try Deploy.
    ”C:\Robotics Downloads\Arduino\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe” -C”C:\Robotics Downloads\Arduino\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf” -q -q -q -pATmega328P -carduino -P\\.\COM24 -b115200 -D -Uflash:w:”C:\Users\Carol Lynn Hazlett\Documents\Atmel Studio\ArduinoSketch1\ArduinoSketch1\Debug\TestSketch1.elf”:i
    avrdude.exe: ser_open(): can’t open device “\\.\COM24”: The system cannot find the file specified.
    Deployment Failed
    Is that what this is telling me? Everything else seems to be working and the software seems to be finding all it’s paths okay. Thanks for your hard work on this project as I like Atmel Studio much better than the bare bones Arduino IDE.

  37. Hello Francisco,
    I can’t get it to work on german XP installations because the %USERPROFILE%Documents – Path is %USERPROFILE%Eigene Dateien on German Installations. I can’t edit the .bat in the exe of the install script. Do you have a chanche to help me? Your tool seems to be wonderful!
    BR, Norbert

  38. I will ping you over the weekend to see what can be done. Worst case scenario I can give you the source code so you can make the necessary modifications.

  39. There is no install.bat on downloaded file, just setup.exec. Running it I received the following error:

    Arduino Installer For Atmel Studio 6 – Version 1.02
    Created by Omar Francisco – 09/22/2012
    – Checking Input Files Exist
    – Setting User Variables
    – Setting Script Variables
    – Checking Files And Directories
    C:\Documents and Settings\BOJAN\Documents\Atmel Studio not found. – aborting installation script

  40. This is an indication Atmel Studio is is not installed in your computer. At least not in the default directory. Please install Atmel Studio 6.0 to install all the templates.

  41. Hello Francisco,
    Thanks for last help. I make it work up to deploy. Now I get not in sync error. I saw your suggestion to Ray, both points are good on my case.

    Any suggetion?
    Thanks and regards.

    “C:\Users\ARDUINO\IDE\arduino-1.0.1\hardware\tools\avr\bin\avrdude.exe” -C”C:\Users\ARDUINO\IDE\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf” -q -q -q -pATmega1280 -carduino -P\\.\COM5 -b115200 -D -Uflash:w:”C:\Documents and Settings\BOJAN\my documents\atmel studio\ArduinoSketch1\ArduinoSketch1\Debug\ArduinoSketch1.elf”:i
    avrdude.exe: stk500_getsync(): not in sync: resp=0x00
    Deployment Failed

  42. Hi Omar
    Thank you very much for your valuable tutorial. I installed your setup based on your manual.pdf.
    My platform is an Arduino uno, the first project could be created without any problems, the compile runs without any errors.
    When I try to deploy the compiled project, the file “ld-program.bat” could not be found. But the file is listed in the Solution Explorer of the Atmel Studio 6.6.1996

    I have set the DEBUG_FLAG=”ON” in the “deploy.bat” to display the calculated path and for me it looks correct:
    Debug Mode: ON
    Deploy Script: “D:\Workspaces\AtmelStudio\ArduinoSketch1\ArduinoSketch1\scripts\localdeploy.bat”
    Deploy Script Exist: Yes
    Solution Directory: “D:\Workspaces\AtmelStudio\ArduinoSketch1\”
    Solution Directory Exist: Yes
    Project Directory: “D:\Workspaces\AtmelStudio\ArduinoSketch1\ArduinoSketch1\”
    Project Directory Exist: Yes
    AVRDUDE Path: “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe”
    AVRDUDE Path Exist: Yes
    AVRDUDE Config Path: “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf”
    AVRDUDE Config Path Exist: Yes
    ATPROGRAM Path: “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe”
    ATPROGRAM Path Exist: Yes
    Library Path: “C:\Users\eismeraldo\Documents\Atmel Studio\Libs\”
    Library Path Exist: Yes
    Header Path: “C:\Users\eismeraldo\Documents\Atmel Studio\Headers\”
    Header Path Exist: Yes
    call to scripts\localdeploy.bat
    “D:\Workspaces\AtmelStudio\ArduinoSketch1\ArduinoSketch1\scripts\localdeploy.bat” “D:\Workspaces\AtmelStudio\ArduinoSketch1\” “D:\Workspaces\AtmelStudio\ArduinoSketch1\ArduinoSketch1\” “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe” “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf” “D:\Elektronik\IDE\arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe” “C:\Users\eismeraldo\Documents\Atmel Studio\Libs\” “C:\Users\eismeraldo\Documents\Atmel Studio\Headers\”

    Did you have any idea, where to define the path to the bat?
    Thank you

  43. Hello Omar,
    Is there a way to change the default clock frequency? I have tried several methods (change it in the project settings, add a #define before the main Arduino.h include, change it in the arduino files), but my delay function still not works properly. It should be 50 ms but it is actually 100 ms due to the 16 MHz / 8 MHz difference.

    I am using AVR Dragon to program the IC, and I set the fuses to use the internal 8 Mhz clock source.

  44. Hi Omar
    The problem is solved. My workspace is not on drive C, like the installation of Atmel Studio, but on drive D. I think the cd command in the localdeploy.bat must be extended with /D like:


    cd %2
    cd scripts
    call ld-program.bat …

    cd /D %2
    cd scripts
    call ld-program.bat …

    Thank you for your work 🙂

  45. Hi
    How can I change the path for the “Atmel Studio” library, because I don’t have it in the standard path.

  46. Hello Omar
    thank you for getting me started with Atmel studio. Good job setting up those bat files.

    I elaborated a bit on you setup and got it working for Arduino DUE sketches now.
    I hope also to have DUE libraries working in a day or two..

    I enhanced you setup to allow for multiple different boards. You’ll of cause need different core, pins_arduino and libraires. I recompiled core and libraries w. garbage collection and saved a couple of kB’s in the final image.

    Building libraries w. garbage collection outputs larger libraries, but the resulting image is smaller. Could be worth the effort.

    Drop me a mail if you’re interested in including some of my ideas in the next release.


  47. @Tibor Simon:
    You need to recompile wireing.c in core library.
    F_CPU is used to determine number of clock cycles pr. millisec.
    core.a distributed by Omar has a wireing.c compiled w. F_CPU @ 16MHz.


  48. Hi Omar,

    Similar Problem to those above – under XP there is no %USERPROFILE%Documents directory by default – it is %USERPROFILE%My Documents instead and so the setup installer fails.

    If I create a %USERPROFILE%Documents directory with the appropriate Atmel Studio sub directories the setup installer succeeds – but is copying all the installed files back to the true location going to do the job?



  49. 1) Admiration for all the hard work and support you have put into this.
    I am new to the Arduino and haven’t touched C for about 15 years so rusty to the point of fatal corrosion. Have installed Atmel Studio 6 & run your latest script. All went swimmingly compiled and then tried to deploy…
    I am using a Mega 2560 and have compiled ‘Blink’ in Arduino IDE and rescued the core.a and renamed to libcore.a and read trough the posts. This is the output from S6
    ”C:\arduino\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe” -C”C:\arduino\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf” -q -q -q -pATmega2560 -carduino -P\\.\COM3 -b115200 -D -Uflash:w:”C:\Users\Richard\Documents\Atmel Studio\ArduinoSketch1\ArduinoSketch1\Release\ArduinoSketch1.elf”:i
    avrdude.exe: stk500_getsync(): not in sync: resp=0x00
    Deployment Failed

    I note in the posts that there is a reference to changing carduino to cwiring – but I can not trace this line down in any of the .bat files – any help you can give would be appreciated, and once again thanks for all the hard work

  50. I am facing the same problem as Norbert but then with a Dutch installation.
    To overcome this, I have manually created a path as was specified by the script and thus managed to install the files.
    Then moved the data from the location where it was installed to the correct AtmelStudio location.
    Changed the paths in the deploy script to match the new locations.
    Now AtmelStudio is able to see and run the templates.
    Started a new project using the Arduino 1.0.1 sketch.
    Changed all the paths in the toolchain settings of the project.

    However I still can not compile the (standard hello world) sketch and receive the error below:

    The command “..\scripts\prebuild.bat “ArduinoSketch2” “ArduinoSketch2.elf” ATmega328P Debug “ArduinoSketch2.cppproj” “C:\Documents and Settings\ikke\Mijn documenten\Atmel Studio\ArduinoSketch2\” “C:\Documents and Settings\ikke\Mijn documenten\Atmel Studio\ArduinoSketch2\ArduinoSketch2\”” exited with code 1.

    The file giving the error is: C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Avr.common.targets
    at line 22:

    Using AtmelStudio with other (non Arduino projects / directly on the MCU is working fine) As is creating and working with sketches using the standard arduino software.

    Do you have any suggestions on how to fix this?

    AtmelStudio version 6.0.1996 service pack 2
    arduino version 1.0.3

  51. hey omar, first off, Thanks so much for doing this. you’ve made me and my colleagues lives much easier!

    That said, i’m working from ArduinoSketch1, the sketch that’s supposed to display Hello World! on the terminal window.

    it builds fine, it compiles fine (no errors at all) but it won’t display anything on my terminal window. I connect at com3 baud 9600. not only that but I noticed there’s a high/low pull on the LED and that isn’t showing up on my UNO unit either.

    any thoughts on where i’m getting this disconnect? Thanks for your time,

  52. Pingback: Arduino su ATmelStudio + AVR ISPv2 su Arduino Mega 2560 | Programmatore esperto in Magento. Riccardo Tempesta

  53. with respect to the above post I have been changing things and at least managed to achieve different failure levels!
    I can generate sync errors from 0x00 to 0x4a depending on what speed I set Com3 to but still cannot get Atmal to upload to the Arduino: Message is ;
    “C:\arduino\arduino-1.0.3\hardware\tools\avr\bin\avrdude.exe” -C”C:\arduino\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf” -q -q -q -pATmega2560 -carduino -P\\.\COM3 -b115200 -D -Uflash:w:”C:\Users\Richard\Documents\Atmel Studio\ArduinoSketch1\ArduinoSketch1\Release\ArduinoSketch1.elf”:i
    avrdude.exe: stk500_getsync(): not in sync: resp=0x43
    Deployment Failed:
    I have spent more time trying to get Atmel running than writing code. Uploading from the Arduino IDE runs fine everytime. Any suggestions please?

  54. Hello Omar,
    thank you for this tutorial. Now I have arduino due and to use it with atmel studio I create a standard project “GCC g++ executable project” I select the correct device, I also include standard libraries for arduino due and core.a for the linker, the file was built succesfully but the programm doesn’t run correctly on the board (it is the blink led project). I would like to know if it is an other way like the older arduino boad to compile and upload the project.
    Thank you
    Sorry for the bad english

  55. Hi Omar do you have a gmail account that I can add you there and exchange email or chat over there because I have some questions about programming my mega2560 using avr studio please

  56. I installed your super system and everything worked fine. But then something with Atmel 6 burped and I couldn’t upload to my Uno. So I’ve been trying to reinstall everything. Atmel 6 reinstalled fine but this is what I get when I run your setup file…

    Arduino Installer For Atmel Studio 6 – Version 1.02
    Created by Omar Francisco – 09/22/2012
    – Checking Input Files Exist
    – Setting User Variables
    \Arduino\arduino-1.0.3\hardware\tools\avr was unexpected at this time.

    None of the subdirectories and files were created.. :-((

    I’m running W7 x64


  57. Your explanation about installation of Arduino on ATMEL 6 is perfect and I have it already done and working.
    Now, I am facing problems to use my Libraries (created by myself with sucess) because when I am building an application always I am receiving a final message referring “file InameOfLib not found”, being nameOfLib the name of the library.
    Could you help me?
    Best regards.

  58. Please forget my comment of April 21,2013 at 2:37pm.
    I was not able to create a library by my mistake.
    Everything is working perfect with my Arduino Uno.
    Congratulations!! You have done a great job.

  59. I found the setup.exe worked much more nicely than the instructions indicated.

    But, I am totally dead in the water right now. Somehow, it gets the network path (\\host\path) that hosts my account (windows is a virtual machine).

    Both deploy.bat and the usages of CMD itself refuse to accept this style of path.

  60. I was able to change the paths in Atmel Studio 6.1 to avoid the network paths.

    I also found that I had to manually import the sample projects. That wasn’t obvious and they ended up in the wrong place.

    I had to figure out how to install the driver for the Arduino (it was listed on the Arduino site’s directions).

    I had to figure out where to look for the binaries setup.exe wanted to know about. Some info would have helped there (i.e. one was in the Atmel Studio 6.1 installation and one was in the Arduino IDE installation).

  61. Can we also get a project template for an assembly-based project right down to the interrupt vectors? I know Arduino heavily discourages the use of Assembly. I wouldn’t care except I want to brush up on assembly for a job and my arduino is a lot better than buying the raw chip, programmer and such.

  62. My sugestion is to add arduino core as a library to generate the libcore.a for any hardware variant inside AVRStudio. I did it my self.

    1º Create a new project with template ‘Arduino Static Library’. Save it to MyDocuments\Atmel Studio\ArduinoLibrariesSource\Core .

    2º Copy all .C and .CPP files from \arduino-1.0.4\hardware\arduino\cores\arduino\ to the created project folder at MyDocuments\Atmel Studio\ArduinoLibrariesSource\Core.

    3º Copy all .H files from \arduino-1.0.4\hardware\arduino\cores\arduino\
    to MyDocuments\Atmel Studio\Headers\ArduinoCore.

    4º Add all C and CPP files just copied to the project folder to the project (right click on solution explorer project Core / add / existing item / select all files)

    5º Copy the file pins_arduino.h for your hardware in \arduino-1.0.4\hardware\arduino\variants\* to MyDocuments\Atmel Studio\Headers\ArduinoCore.

    6º Build the solution. It will generate all libs.

  63. Even better solution than above should be to create a template for each board variant like this :

    Create a template for each board that includes the Core lib above as a project inside the created solution and adds the pins_arduino.h to the new project that matches the template variant.

    Remove pins_arduino.h from MyDocuments\Atmel Studio\Headers\ArduinoCore.

    Any needed lib should be added as a project reference inside your solution.
    All libs are always compiled and solution build. (not realy slow)

    So you can have a full supported IDE can compile multiple arduino variants without changing a file.

  64. Hello Omar,
    great job! I had to change a few things concerning avrdude but awsome anyway! Thanks, Barney

  65. Hi,

    i’m from Germany and i just installed your Tool for my Arduino Uno.

    Now i wan’t to use the Arduino Libaries in AtmelStudio6 for other AVRs, like the Mega8. In the ArduinoIDE i only choose the old Board. But, how i can i do this in the AtmelStudio? “Change Device” doesn’t work.

  66. Hi Omar,
    Does this work with Atmel Studio 6.1? I tried setup.exe from codeplex. I am using Atmel Studio 6.1. After following the instruction in pdf, I dont see any template added. Infact, none of the below exists. I am using Win7. Please suggest.

    None of the below exists.
    1. Deploy 7 templates to c:\users\[user]\Documents\Atmel Studio\Templates\ProjectTemplates
    2. Deploy 1 item template at c:\users\[user]\Documents\Atmel Studio\Templates\ItemTemplates
    3. Deploy a deploy.bat to c:\users\[user]\Documents\Atmel Studio\deploy.bat
    4. Deploy the Arduino libcore library to c:\users\[user]\Documents\Atmel Studio\Libs\ArduinoCore\
    5. Deploy all Arduino headers for libcore to c:\users\[user]\Documents\Atmel Studio\Headers\ArduinoCore
    6. Deploy all Aduino libraries binaries that come with the Arduino IDE to c:\users\[user]\Documents\Atmel Studio\Libs\Arduino\

  67. Does anyone have Atmel Studio working with the Arduino Due (ARM version, not the AVR-based Duemilanove)?

    My project outgrew the Uno, then the Mega2560, and so now I’m porting to the Due. I successfully recompiled the ArduinoLibrariesSource files from Uno to Mega2560, but I’m not sure the best way to go about this for the Due.

    I’m guessing I need to setup a new G++ Static Library project within Atmel Studio for each library in C:\Program Files\arduino-1.5.2\hardware\arduino\sam\libraries? Then mimic the Arduino IDE, which calls to bossac.exe, instead of avrdude.exe, for flash programming. Anything else I’m missing?

    Ideally I’d like to be able to do step-by-step debugging within Atmel Studio using SAM-ICE (

    If anyone else has experience with the Due and Atmel Studio, your advise is welcomed! Thanks!


  68. Pingback: How to: Step by step guide to setting up Atmel Studio (AVR Studio 6) for Arduino | aSensar

  69. I’m trying to install this on Atmel studio 6.1 running on win 8 but get the following.
    Arduino Installer For Atmel Studio 6 – Version 1.02
    Created by Omar Francisco – 09/22/2012
    – Checking Input Files Exist
    – Setting User Variables
    \Arduino\hardware\tools\avr was unexpected at this time.

    Can you help?

  70. Tried to download new beta version but get page not available errors

  71. Pingback: Step by step guide to setting up Atmel Studio for Arduino development - Inspired by Nature

Leave a Reply

Your email address will not be published. Required fields are marked *

Please solve the equation to verify you are human * Time limit is exhausted. Please reload the CAPTCHA.