Program Arduino Due with Atmel Studio 7 Elecrom December 1, 2016; Updated On: February 13th, 2017 22 Overview Atmel’s SAM3X series MCUs are great for beginners to advance users who want to move further from the the world of 8bit/16bit microcontrollers to 32bit ARM Cortex core MCUs. One of the most famous device in this series is SAM3X8E, Atmel’s Smart ARM microcontroller. The development platform of the choice for getting started with SAM3X8E is Arduino Due board (also known as Arduino ARM). The SAM3X8E MCUs have ARM Cortex-M3 processor, which can run at 84 MHz, have 512 KB of flash, and 100 KB of SRAM. They also have a rich set of on chip peripherals such as, High Speed USB MiniHost and with on-chip PHY, Ethernet, dual CAN, high speed SD/SDIO/MMC, and multiple serial interfaces (USARTs, SPIs, TWIs (I2C), and one I2S). The SAM3X8E also features a 12-bit ADC/DAC, temperature sensor, 32-bit timers, PWM timer and RTC. The 16-bit external bus interface supports SRAM, PSRAM, NOR and NAND Flash with error code correction. The Atmel QTouch® Library is available for the SAM3X8E for easy implementation of buttons, sliders and wheels. These solid set of features make it one of the best microcontrollers for IoT (Internet of Things) applications. Also, there is an Arduino kit available for this controller. This kit is known as Arduino Due. To harness full power of this chip, many developers choose to use Atmel Studio. However, there is no direct support to download (i.e. to flash or burn) the code to Arduino Due in Atmel Studio. In this post we will see how to (download or) program Arduino Due using Atmel Studio. We will use enumerated COM port, which is identified as Arduino Due’s BOSSA program port when you connect the board to laptop via ‘Native USB’ port on the Due board. The Arduino Due Board Software and Tools required Arduino Due board (Low cost boards can be brought from here) Atmel Studio 7 (http://www.atmel.com/microsite/atmel-studio/) Arduino 1.6.0 (https://www.arduino.cc/en/Main/OldSoftwareReleases) We specifically need this version to program Arduino Due. This will simplify lot of things. It includes a bossac programmer which is required to download the code to Arduino due. Steps One time setup: Create a MS Dos batch file with the name ‘DueProgrammer.bat’ and save it in Arduino installation path. To do this, open any text editor (Notepad) and type the following code mode %1:1200,n,8,1,p "C:\Program Files (x86)\Arduino\hardware\tools\bossac.exe" --port=%1 -i -e -w -v -b %2 -R Explanation: mode : A Dos command to switch serial port mode. This is required for enter into programming mode. –port : COM port used for programming. %1 is the argument passed to the batch file -i : displays the device information during programming -e : erase the entire flash content on the device -w : write given file to the flash. File name is passed as an argument to the batch file (%2) -v : verify after writing -b : boot from flash -R : reset CPU Save this file with the name DueProgrammer.bat and save it in Arduino installation path (for example: C:\Program Files (x86)\Arduino\DueProgrammer.bat) bossac.exe : BOSSA is a microcontroller flash programming software for Atmel’s SAM microcontrollers. The name, BOSSA, is an acronym for Basic Open Source SAM-BA Application. Software’s homepage can be found here. Open Atmel Studio and click on Tools > External Tools. We will add this batch file as an external tool and tell Atmel Studio to pass required arguments to this batch file. Click Add to add a new external tool, and provide following information: Title: Due Programmer Command: C:\Program Files (x86)\Arduino\DueProgrammer.bat Note: If you are using a different path, provide the same. Arguments: COM3 $(TargetDir)$(TargetName).bin NOTE: COM3 is used as an example, you need to provide correct port. To find out exact COM port of the due board, plug-in micro USB connector to the “NATIVE USB -> SAM3X” connector of the due board, and insert the other end of the USB cable in any of the free USB ports on your computer. Check Device Manager for the COM port number. TIP: If you connect your same Arduino Due board to the same USB port of your computer, the COM port number will always be the same ! Initial Directory: “` $(TargetDir) “` Select the check box ‘Use Output Window‘ You can refer to the screenshot below: Adding Due Programmer Click OK, and then click YES to save changes you have made. Now you will find the new external programmer tool listed as “Due Programmer” under the Tools menu. Adding Arduino Due Programmer to Atmel Studio 7 Burning/Downloading the code Build your solution (press F7) Note: If you do not have any code ready, you can download the sample project from: https://github.com/elecrom/el_due_ADC_sample_code and build it. Make sure USB cable is connected to the Native USB port of the Arduino due board (See the following image), and COM port value specified for the tool Arguments is correct. USB Connection for Burning Code to Arduino Due Board Press and hold ERASE button on the Due board for two seconds and then release it. After that press RESET button. This will erase the MCU and activate BOSSA programming port. Flashing Arduino Due – Erase sequence To Program Arduino Due (i.e. to download/flash the hex code to MCU) Click Tools > Due Programmer It should start the programming. The output window will show the log similar to the one shown below : F:\Source_Atmel_SAM\Blink-atmel-studio\GETTING-STARTED3\GETTING-STARTED3\Debug>mode COM3:1200,n,8,1,p Status for device COM3: ----------------------- Baud: 115200 Parity: None Data Bits: 8 Stop Bits: 1 Timeout: OFF XON/XOFF: OFF CTS handshaking: ON DSR handshaking: ON DSR sensitivity: OFF DTR circuit: HANDSHAKE RTS circuit: HANDSHAKEF:\Source_Atmel_SAM\Blink-atmel-studio\GETTING-STARTED3\GETTING-STARTED3\Debug>"C:\Program Files (x86)\Arduino\hardware\tools\bossac.exe" --port=COM3 -i -e -w -v -b "F:\Source_Atmel_SAM\Blink-atmel-studio\GETTING-STARTED3\GETTING-STARTED3\Debug\GETTING-STARTED3.bin" -R Erase flash Write 19204 bytes to flash[ ] 0% (0/76 pages) [=== ] 13% (10/76 pages) [======= ] 26% (20/76 pages) [=========== ] 39% (30/76 pages) [=============== ] 52% (40/76 pages) [=================== ] 65% (50/76 pages) [======================= ] 78% (60/76 pages) [=========================== ] 92% (70/76 pages) [==============================] 100% (76/76 pages) Verify 19204 bytes of flash[ ] 0% (0/76 pages) [=== ] 13% (10/76 pages) [======= ] 26% (20/76 pages) [=========== ] 39% (30/76 pages) [=============== ] 52% (40/76 pages) [=================== ] 65% (50/76 pages) [======================= ] 78% (60/76 pages) [=========================== ] 92% (70/76 pages) [==============================] 100% (76/76 pages) Verify successful Set boot flash true Device : ATSAM3X8 Chip ID : 285e0a60 Version : v1.1 Dec 15 2010 19:25:04 Address : 524288 Pages : 2048 Page Size : 256 bytes Total Size : 512KB Planes : 2 Lock Regions : 32 Locked : none Security : false Boot Flash : true CPU reset. That’s it 🙂 … now you can utilize the full power of Adruino Due and SAM3X8E MCU 🙂 Flashing Arduino Due using Atmel Studio 7 Note: This post has attempted to answer queries related to following topics: How to go about Using Arduino Due in Atmel Studio 7 Programming Arduino Due with Atmel Studio 7 How to flash Arduino Due using Atmel Studio 7 How to download hex file in Arduino Due using Atmel Studio 7 Arduino Due Programming using Atmel Studio 7 Using bossac.exe to program Arduino Due with Atmel Studio 7 Using Atmel Studio 7 to Program Arduino Due If you have any suggestions or comments, please feel free to share 🙂 Happy Burning ! 🙂 References: Arduino Due Datasheet: https://www.arduino.cc/en/Main/ArduinoBoardDue SAM3X8E Datasheet: http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf BOSSA Homepage: http://www.shumatech.com/web/products/bossa #atmel-sam #sam3x83 #atmel-studio #arduino-due #burning #flashing #programming #downloading