Programming Arduino using AVRDude

Published on in Series Arduino Development with Atmel Studio


In this article we will see how to program Arduino boards using AVRDude

Create command-line parameter for AVRdude

avrdude is a command-line program, we need to pass correct command-line arguments to program the Arduino.

D:/arduino-1.0.4/hardwaretools/avr/bin> avrdude.exe
Usage: avrdude.exe [options]
Options:
-p                        Required. Specify AVR device.
-b                        Override RS-232 baud rate.
-B                        Specify JTAG/STK500v2 bit clock period (us).
-C                        Specify location of configuration file.
-c                        Specify programmer type.
-D                         Disable auto erase for flash memory
-i                        ISP Clock Delay [in microseconds]
-P                        Specify connection port.
-F                         Override invalid signature check.
-e                         Perform a chip erase.
-O                         Perform calibration (see AVR053).
-U :r|w|v:[:format]
Memory operation specification.
Multiple -U options are allowed, each request
is performed in the order specified.
-n                         Do not write anything to the device.
-V                         Do not verify.
-u                         Disable safemode, default when running from a script.
-s                         Silent safemode operation, will not ask you if
fuses should be changed back.
-t                         Enter terminal mode.
-E [,]                     List programmer exit specifications.
-x <extended_param>        Pass <extended_param> to programmer.
-y                         Count # erase cycles in EEPROM
-Y                         Initialize erase cycle # in EEPROM.
-v                         Verbose output. -v -v for more.
-q                         Quell progress output. -q -q for less.
-?                         Display this usage.

avrdude version 5.11, URL:

We can extract the avrdude command arguments in two methods

Method 1: from Arduino IDE verbose upload (easy way)

Running Arduino IDE in verbose mode will print the actual command like argument in the output window, then customize it.

  • Enable verbose mode – in Arduino IDE from menu select File > Preference
  • Check the Show verbose output during: upload as shown in the screenshot
  • Compile and upload any Arduino sketch and observed the output window. (I have used Blink sketch from example).

Programming Arduino using AVRDude

The actual command will be printed at the top of upload verbose log in the output window. This is what I got.

Binary sketch size: 1,084 bytes (of a 30,720 byte maximum)
D:/arduino-1.0.4/hardware/tools/avr/bin/avrdude -CD:/arduino-1.0.4/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P.COM22 -b57600 -D -Uflash:w:C:/Users/aSensar/AppData/Local/Tempbuild1227546797508918322.tmpBlink.cpp.hex:i

From this I can extract the parameters

-CD:/arduino-1.0.4/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P.COM22 -b57600 -D -Uflash:w:<hex filename>:i

Note: each -v increases the level of verbose output, you can remove -v altogether If you don’t need complete log.

Method 2: from boards.txt (some feel this a hard way)

Here is the working command of mine, we need to fill in parameters properly.

avrdude.exe -F -v -p <partno> -c <programmer> -P <port> -b <baudrate> -D -U <memtype>:w:<filename>[:format] -C <config-file>

The parameter’s can be decoded from the Arduino IDE package itself. Open board.txt file D:\arduino-1.0.4\hardware\arduino\boards.txt Scroll down and look for your board, In my case it is Arduino Nano 3.0. Below is configuration for Arduino Nano 3.0.

 ##############################################################
nano328.name=Arduino Nano w/ ATmega328
nano328.upload.protocol=arduino
nano328.upload.maximum_size=30720
nano328.upload.speed=57600
nano328.bootloader.low_fuses=0xFF
nano328.bootloader.high_fuses=0xDA
nano328.bootloader.extended_fuses=0x05
nano328.bootloader.path=atmega
nano328.bootloader.file=ATmegaBOOT_168_atmega328.hex
nano328.bootloader.unlock_bits=0x3F
nano328.bootloader.lock_bits=0x0F
nano328.build.mcu=atmega328p
nano328.build.f_cpu=16000000L
nano328.build.core=arduino
nano328.build.variant=eightanaloginputs
 ##############################################################

From the above I got the details as below.

  • = mcu = atmega328p
  • = protocol = arduino
  • = speed = 57600
  • :w:[:format] = flash:w::i

We should use the config file from Arduino.

  • = D:/arduino-1.0.4/hardware/tools/avr/etc/avrdude.conf

So now my command becomes like this.

Getting the COMM port number

<port> = This depends on the system, We need to get it from Windows Device Manager

If you are unsure which comm port is for Arduino, then keeping Windows Device Manager open, unplug the Arduino board, the port that belong to Arduino will disappear, On connect it will reappear.

Programming Arduino using AVRDude

From the above screenshot comm port for Arduino in my PC is 22.

If the comm port number is less than 10, then simply specify the comm port. Example if comm port = 4, then your argument will -PCOM4

In case it is greater then 10, then you should pass it like this -P.COMXX. Example, in my PC comm port = 22, hence I have to use -P.COM22

avrdude.exe -F -v -patmega328p -carduino -P.COM22 -b57600 -D -Uflash:w:"testfile.hex":i -CD:/arduino-1.0.4/hardware/tools/avr/etc/avrdude.conf


This article is part of Arduino Development with Atmel Studio series.

  1. How to integrate AVRDude with Atmel Studio
  2. Programming Arduino using AVRDude [This Article]
  3. How to setup Atmel Studio for Arduino development

TAGS: arduino avrdude

Share on: Email Facebook Twitter


View/Write Comments