Customizing Atmel Studio6 for the Due auto-erase bootloader

Hi guys,

because I want to use Atmel-Studio6 instead of the Arduino IDE (way to much restrictions for me ;-) I have built a little tool - a batch job which erases and flashes the Due automatically. So no more pushbutton work has to be done. Also the the functionality of Bossac is now embedded in the ATmel IDE toolbar. Maybe someone can use this tool, too.

Howto: 1.Create a batch-file Create a batch-file, name it Arduino_Due.bat C&P these lines:

  • - - - - - - - - cut here - - - - - - - - - @echo Automatic erase-button for flashing Arduino Due with ATMEL-Studio, (c) Transistorfips 2013 @echo off ::Set COM port, filename + pathname for the file to be flashed. ::Example: set flashfile=C:\ARM_ARDUINO\Dir1\Dir2\debug\hello_world.bin

set flashfile=C:\ARM_ARDUINO\Versuch\Test2\GETTING-STARTED2\GETTING-STARTED2\Debug\GETTING-STARTED2.bin set comport=%COM14 mode %comport%:1200,N,8,1,P C:\bossa\bossac.exe --port=%comport% %flashfile% -U false -e -w -v -b -R - - - - - - - - - cut here - - - - - - - - -

Please read and follow the instructions in the batch file when using it. Unfortunately I haven't found a correct syntax for relative variables like $(ProjectDir)Debug\$(ItemFileName).bin or so. So the full path name must be hard coded instead. If you find out how to set a relative target name usable in a batch file then please let me know.

  1. Make a Directory c:\bossa. Copy the command line tool "bossac.exe" (not the file with the same name used by the windows version, this won't work) and the new batch file "Arduino_Due.bat" in the directory.

  2. Embed the bootloader sequence in Atmel Studio6 Click Tools -> External Tools... Select Title: Bossa

Select Command: C:\Bossa\Arduino_Due.bat (make sure path, file etc is correct)

Atmel Studio has created a new item now, bossac can be used from the "Tools" menu. If you want to have a funky little button in the toolbar also (yes!!) then do step 4 additionally.

  1. Make a new button for Atmel Studio Find the "build toolbar" in the toolbar (the buttons the code is crunched with). On the left edge right-click the arrow for the "build toolbar options". The pull-down menu appear. Select "Customize..." In the pop-up window select the tab "commands". Click the radio button for "Toolbar". Select "Build" from the corresponding drop-down menu. Click "Add Command...". In the left box, select "Tools" in the categories menu. The right box now is filled with selectable commands. Find "External Command 1" and click it.

Now a new button in the build toolbar has been created and Bossac is ready to use. If you want to change the position inside the toolbar then re-open the command tab and use the up/down buttons for positioning. Be sure the appropriate item is selected.


Thanks for figuring this out and sharing, if you find the correct magical var's: $(ProjectDir) etc please update.


i use this batch-file in Atmel Studio 6

autodetect of arduino due programming port

external tool arguments:
path to bossac.exe
(ProjectDir) (ProjectFileName)
Debug or Release

for more info see description in the batch-file


BossacArduinoDue.bat (6.5 KB)

Thanx, I'll try to test it tomorrow.

Hi Transistorfips,

The batch-file is now on GitHub.

If you have some suggestions for improvement, please let me know.

Hi Transistorfips,

The batch-file is now on GitHub.

If you have some suggestions for improvement, please let me know.

I tried your batch-file and it worked for debugging but when I use the release I get this error:

------ External tool BossacArduinoDue started ------
Error: bin file “C:\Users\Muradi\Documents\Atmel Studio\PortingFreeRTOS\PortingFreeRTOS\Release\PortingFreeRTOS.bin” not exist!
======================== Done ========================

Do you know what the problem is? What does the release do?


Select Release as active build configuration and rebuild your project. Procect -> Settings -> Build -> Configuration Manger -> Active configuration (Release)

Now you can exectute BossacArduinoDue(Release) without the error message.

By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled.

Hello ctbenergy, I still have probs with the Dos syntax. How can I transform set flashfile= C:\ARM_ARDUINO\Versuch\Test4\CHIPID_EXAMPLE1\CHIPID_EXAMPLE1\Debug\CHIPID_EXAMPLE1.bin

into something like this: set flashfile= "$(ProjectDir) $(ProjectFileName)"

It might be even more sexy to modify the toolchain. Can we append the batchjob to the toolchain so when the "Build Solution" button is clicked the loader ensues?

Hi Transistorfips,

Thanks, append the batchjob in the "Build Solution" was a good idear.

I Update the batch-file on GitHub

Now you can add a "post build command" in the "Build Event" (Debug and Release) "$(DevEnvDir)\BossacArduinoDue.bat" "C:\Program Files (x86)\arduino-1.5.2\hardware\tools\bossac.exe" "$(OutputDirectory)\$(OutputFileName).bin"

For more information see the README file

Hello Ewald, after adjusting to my system the post build event ran on first glance. Great work! Seems you have heck a lot of experience in Dosbox programming stuff.

Have a drink (on me ;-) this evening.


Hi Joachim,

you can customize the wait time for memory erased.

REM Wait X second for memory on Arduino Due is erased. SET WAIT_ERASED=4

i tested with "SET WAIT_ERASED=2" and it works well.

2 seconds faster :-)

Hi, symply parse the Variables to the Batch-File: modify Batch and Commands to your requirements.

-------- batch starts here ----------------- @echo Automatic erase-button for flashing Arduino Due with ATMEL-Studio, (c) Transistorfips 2013 @echo Arguments-Extension by Souko Hiabuto 2013

set flashfile=%1 set comport=%2 mode %comport%:1200,N,8,1,P C:\bossa\bossac.exe --port=%comport% %flashfile% -U false -e -w -v -b -R -------- batch ends here -----------------

Atmel Studio 6 configuration:

Tools -> External Tools -> Title: Bossa (or what you want as title) Command: Path\to\your\Arduino_Due.bat Arguments: $(TargetDir)$(TargetName).bin COM6 (modify COM6 to your requirements) Mark Checkbox "Use Output window"

klick OK -> Done