Arduino to Atmel Studio 7 external programmers, ISP and serial programming

Go To Last Post
4 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Hopefully this will help someone on a similar transition from Arduino to AS7, took a couple days to piece this together from various sources.


Moving from Arduino to AS7.

For me it was not immediately clear how to program with the hardware that I had, which is a USB FTDI cable for serial upload, and a sparkfun pocket programmer.

The pocket programmer can be used to burn fuses, upload an entire sketch, or a bootloader like optiboot.

With a bootloader burned, the FTDI cable can load a program over serial in AS7 just like Arduino.



in AS7

Tools-> External tools

Enter these items for atmega 328 programming.

Of course tools, fuse values, and chips can be changed, refer to avrdude documentation to adjust arguments.



title: "name of programmer"

command: " location of avrdude.exe"

arguments: " avrdude command line arguments including fuses if desired"



This is for ISP programming with no bootloader and the Sparkfun pocket programmer.

Title: PocketAVR m328p 4.3v 

Command: G:\AVRDude\avrdude.exe  

arguments: c usbtiny -p m328p -v -v -v -U flash:w:$(TargetDir)$(TargetName).hex:i -c usbtiny -p m328p -v -U efuse:w:0xFC:m -c usbtiny -p m328p -v -U lfuse:w:0xF7:m -c usbtiny -p m328p -v -U hfuse:w:0xD6:m

These particular arguments program a 328p with the current project and sets e l h fuse values.


This is for programming a 328p that has optiboot loaded on it already using USB FTDI cable

Title: FTDI serial uploader for Optiboot

Command: G:\AVRDude\avrdude.exe

arguments: -C  "G:\AVRdude\avrdude.conf"  -v -v -v  -p atmega328p -c arduino -P\\.\COM3 -b 115200 -D -U flash:w:$(TargetDir)$(TargetName).hex:i

*my ftdi cable mounts to COM3, yours may differ


This is for burning the optiboot bootloader and fuses on a 328p

Title: Burn Bootloader Optiboot m328 4.3v

Command: G:\AVRDude\avrdude.exe

arguments: -c usbtiny -p m328p -v -v -v -U flash:w:"G:\AVRdude\optiboot_atmega328.hex":i -c usbtiny -p m328p -v -U efuse:w:0xFC:m -c usbtiny -p m328p -v -U lfuse:w:0xF7:m -c usbtiny -p m328p -v -U hfuse:w:0xD6:m


Note that the bootloader argument includes the path to the optiboot hex file.

Compiled optiboot hex files available on github.

Adjust fuse values to suit your needs.


These tools are not integrated with AS7 and to program with them click on them in the Tools menu after compiling.

Sure eventually I will get an Atmel Microchip programmer but this was a pretty easy way to get going for low $$.








Last Edited: Mon. Aug 6, 2018 - 01:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A candidate for the Tutorial Forum, +1! 


FF = PI > S.E.T


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hi BugMaster,

I've seen a more universal solution on when searching how to flash Leonardo from AS. It's a python script and seem to work with all the boards, however, it needs Arduino IDE and Python to be installed.  Here is my slightly modified version:

import sys
import subprocess as sub
from time import sleep
# command line arguments are:
# first is the arduino IDE installation dir
# second is the arduino board type
# third is the .hex file
# fourth is the upload port
# fifth *** only used if Leonardo; omit otherwise *** serial port used to put leonardo into bootloader mode 
arduinoPath = sys.argv[1]
boardType = sys.argv[2]
hexFile = sys.argv[3]
port2 = sys.argv[4]
if(boardType == 'leonardo'): #TODO check for Micro (also 32u4 based)
   import serial
   port = sys.argv[len(sys.argv)-1]
avrconf = arduinoPath + '/hardware/tools/avr/etc/avrdude.conf'
avrdude = arduinoPath + '/hardware/tools/avr/bin/avrdude'
avrsize = arduinoPath + '/hardware/tools/avr/bin/avr-size'
boardsFile = open(arduinoPath + '/hardware/arduino/avr/boards.txt',
boardSettings = {}
for line in boardsFile:
          # strip board name, period and \n
        setting = line.replace(boardType + '.', '', 1).strip()
        [key, sign, val] = setting.rpartition('=')
        boardSettings[key] = val
    # check program size against maximum size
p = sub.Popen([avrsize,hexFile], stdout=sub.PIPE, stderr=sub.PIPE)#, shell=True)
output, errors = p.communicate()
if errors != "":
    print 'avr-size error: ' + errors + '\n'
    print ('Progam size: ' + output.split()[7] +
    ' bytes out of max ' + boardSettings['upload.maximum_size'] + '\n')
programCommand = [avrdude,
     '-F' ,
     '-p'+boardSettings['build.mcu'] ,
     '-c'+ boardSettings['upload.protocol'] ,
     '-b' + boardSettings['upload.speed'] ,
    # open and close serial port at 1200 baud. This resets the Arduino Leonardo
if(boardType == 'leonardo'):
    ser = serial.Serial(port, 1200)
    sleep(4)  # give the bootloader time to start up
p = sub.Popen(programCommand, stdout=sub.PIPE, stderr=sub.PIPE)#, shell=True)
output, errors = p.communicate()
# avrdude only uses stderr, append it
print errors

So in your External tools for Arduino Leonardo you should have smth like

Command: C:\Python27\python.exe

Arguments: "D:\coding\mcu\" "C:\Program Files (x86)\Arduino" leonardo "$(ProjectDir)Debug\$(TargetName).hex" COM16 COM14

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using the FTDI232 module for programming my 

Arduino Pro Mini or Deek Robot Banggood clone

This board has an Atmega328P. It is a clone of the Deek Robot or Arduino Pro Mini.

In the Arduino IDE I am using 

Board            : Arduino Pro Mini            Processor : Atmega328P 

Programmer: USBtinyISP                       Port           : "COM4"

I can easily program the AT328 board , no problem. I want to migrate to Studio 7 

I instinctively selected the second configuration mentioned by BugMaster above without any success 

Here is my configuration in Studio 7 External tools: 

    Title : FTDI_232
Command: C:\Cadence\WinAVR\bin\avrdude.exe
Arguments: -C  "C:\Cadence\WinAVR\bin\avrdude.conf"
           -v  -v  -v  -p atmega328p  -c arduino
           -P\\.\COM4  -b 9600  -D  -U flash:w:$(TargetDir)$(TargetName).hex:i

The Code:

 #include "AT328CPUspeed.h" /* 16 MHz cpu speed*/
 #include <avr/io.h>
 #include <util/delay.h>
 int main(void)  {
	 DDRB |= (1<<DDB1);
	while (1)
		PORTB |= (1<<PORTB1);
		PORTB &= ~ (1<<PORTB1);
 return 0 ;  }

The above code will compile correctly, no error.

Here is Studio 7 behavior when I want to upload the compilation:

avrdude.exe: Version 5.10, compiled on Jan 19 2010 at 10:45:23
             Copyright (c) 2000-2005 Brian Dean,
             Copyright (c) 2007-2009 Joerg Wunsch
             System wide configuration file is "C:\Cadence\WinAVR\bin\avrdude.conf"
             Using Port                    : \\.\COM4
             Using Programmer              : arduino
             Overriding Baud Rate          : 9600
avrdude.exe: stk500_getsync(): not in sync: resp=0x00
avrdude.exe done.  Thank you.

The Questions:  

 Am I using the correct configuration ?

 What is Optiboot and should I be concerned about Optiboot ?

Is the -c arduino argument questionnable since I am now using Studio 7 ?


Much appreciation,

Last Edited: Sun. Sep 5, 2021 - 01:00 AM