Programming Arduino Due with Atmel Studio 6.1 and ASF

Sometimes Arduino Sketches concept is just not enough:

  1. You want to make a full scale use of ASF (Atmel Software Framework)
  2. You are willing to work with regular Static libraries and create a modular code
  3. You are willing to make a full use of Atmel Studio features

This tutorial is based on the following discussion explaining how to reuse Arduino Bootloader to download code to the board without use of external programmers.

 Prerequisites

  • You need Arduino environment 1.5.* installed
  • Connect your Arduino Due to Programming USB port

Creating a project

  1. File -> New -> Project -> C/C++ -> Arduino-Board -> Arduino Due/X – ATSAM2X8E
  2. F7 -> Make sure it is built correctly and you have *.bin file in your Debug/Release directory

Adding programmer support

  1. Create Batch file DueProgrammer.bat at some location with the following content:

    * change <PATH TO ARDUINO ENV> to your arduino environment installation path
  2. In Atmel Studio go to Tools -> External Tools
  3. Fill the following values:
    • Title: “Arduino Due Programmer”
    • Command: Select the file DueProgrammer.bat you created
    • Arguments: “COM6 $(TargetDir)$(TargetName).bin” (where COM6 is your Arduino programming port
    • Initial directory: $(TargetDir)
    • Mark “Use Output window” (all other checkboxes are unmarked)
  4. Click OK

For UDOO board users only

The process of programming Arduino Due on UDOO board from within Atmel Studio is a little different:

  1. You need to make use of bossac.exe provided by Udoo team (or taken from UDOO patched version of Arduino IDE)
  2. Batch file (UdooDueProgrammer.bat) that worked for me is a little different as well:

     

Now you should be able to program your board by clicking Tools -> Arduino Due Programmer

Good luck!

BTW

  • A good example of things that can be done with Atmel ASF / Arduino Due and usually cannot be reproduced with native Arduino libraries.
  • There is an issue when communicating with the board over programming port after the image is loaded (the board does not receive user inputs). The issue is addressed here

7 thoughts on “Programming Arduino Due with Atmel Studio 6.1 and ASF

  1. Hello. So far I was able to setup my Atmel Studio, will try how it works on ASF examples when I’m at home today.

    There is an error – .bat file, not .nat file in sentence: Command: Select the file DureProgrammer.nat you created

  2. Pingback: Arduino Due in Atmel Studio using C + LED blinking | CodeTron

  3. Hi!
    I write this:
    C:\Program Files(x86)\Arduino\hardware\tools\bossac.exe –port=%1 -U false -e -w -v -b %2 -R

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

    can someone tell me what I did wrong!
    Thanks!

  4. It would also be helpful to post or direct the readers to an example DUE
    project that has been created in the Atmel Studio the ASF examples I have tried for SAM3X compile and load but do nothing on the DUE. Otherwise good job on showing us how to get uploading from Atmel Studio going. Thanks dan

Leave a Reply

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