Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

AVRDUDE: Command Line and Batch Programming of Microcontrollers

Contents

AVRDUDE is a powerful command-line-driven tool for downloading hex files to your microcontrollers. Read along to find out how to use AVRDUDE and to do batch programming of microcontrollers.

Introduction

Some users may prefer a different programming environment rather than using the Arduino IDE for programming their MCUs. The reasons may vary. Some may want total control of the programming software, which includes programming the memories, FUSE bits, tweaking the programming speed, and others. Others need an automated script to do batch programming of multiple microcontrollers. Whatever the reason, the command-line feature of AVRDUDE gives the user more control of their programming environment. In this article, you’ll learn how to use AVRDUDE.

WHat is AVRDUDE?

AVRDUDE stands for AVR Downloader/UploDEr. It’s a command-line utility used to program AVR microcontrollers. This tool can access different memory areas of your MCUs, such as Flash, EEPROM, FUSE, and lock bits. Additionally, you’ll be able to use different kinds of hardware programmers with AVRDUDE.

How to Get AVRDUDE?

AVRDUDE has a GitHub page. However, if you want to install the program on your PC, visit the releases page. There are available versions for Linux, Windows, and macOS. For example, if you want to install AVRDUDE on your 64-bit Windows machine, you can download avrdude-v8.0-windows-x64.zip.

Install it on your PC

For Windows, you’ll need to unzip the downloaded files to a folder. After which, you’ll be able to execute the file avrdude.exe through a command or PowerShell prompt. It’s best to add the path of the folder to your system environment variable so that you can run AVRDUDE from any directory.

Testing the Command Line

There are several command-line options for AVRDUDE, as can be seen below.

				
					Usage: avrdude [options]
Options:
  -p <partno>            Specify AVR device; -p ? lists all known parts
  -p <wildcard>/<flags>  Run developer options for matched AVR devices,
                         e.g., -p ATmega328P/s or /S for part definition
  -b <baudrate>          Override RS-232 baud rate
  -B <bitclock>          Specify bit clock period (us)
  -C <config-file>       Specify location of configuration file
  -C +<config-file>      Specify additional config file, can be repeated
  -N                     Do not load config file
  -c <programmer>        Specify programmer; -c ? and -c ?type list all
  -c <wildcard>/<flags>  Run developer options for matched programmers,
                         e.g., -c 'ur*'/s for programmer info/definition
  -A                     Disable trailing-0xff removal for file/AVR read
  -D                     Disable auto-erase for flash memory; implies -A
  -i <delay>             ISP Clock Delay [in microseconds]
  -P <port>              Connection; -P ?s or -P ?sa lists serial ones
  -r                     Reconnect to -P port after "touching" it; wait
                         400 ms for each -r; needed for some USB boards
  -F                     Override invalid signature or initial checks
  -e                     Perform a chip erase at the beginning
  -O                     Perform RC oscillator calibration (see AVR053)
  -t                     Run an interactive terminal when it is its turn
  -T <terminal cmd line> Run terminal line when it is its turn
  -U <memstr>:r|w|v:<filename>[:format]
                         Carry out memory operation when it is its turn
                         Multiple -t, -T and -U options can be specified
  -n                     Do not write to the device whilst processing -U
  -V                     Do not automatically verify during -U
  -E <exitsp>[,<exitsp>] List programmer exit specifications
  -x <extended_param>    Pass <extended_param> to programmer, see -x help
  -v                     Verbose output; -v -v for more
  -q                     Quell progress output; -q -q for less
  -l logfile             Use logfile rather than stderr for diagnostics
  -?                     Display this usage

avrdude version 8.0, https://github.com/avrdudes/avrdude
				
			

Programming an Arduino UNO

To program a simple blink program to an Arduino UNO (with bootloader), you’ll first need to know where the compiler-generated outputs are stored. Go to File -> Preferences, then tick the compile option from Show verbose output during compilation.

Below is an example verbose output during compile time where the hex file’s location is shown.

				
					"C:\\Users\\super\\AppData\\Local\\arduino\\sketches\\0CA8A107FACF294EC2CA0681560D61FF/Blink.ino.hex"
				
			

Open a terminal or command prompt in this directory. You should be able to run a sample command as seen below to program a file to an Arduino UNO.

				
					avrdude -p atmega328p -c arduino -P COMx -b 115200 -U flash:w:filename.hex:i
				
			

where the actual parameters and outputs are:

  • -p is the AVR part number.
  • -c is the kind of programmer.
  • -P is the serial port.
  • -b is the bitrate (115200)
  • -U flash:w:filename.hex:i means a memory location in flash using a write operation in Intel hex format.
				
					PS C:\Users\super\AppData\Local\arduino\sketches\0CA8A107FACF294EC2CA0681560D61FF> avrdude -p atmega328p -c arduino -P COM6 -b 115200 -U flash:w:Blink.ino.hex:i
Reading 924 bytes for flash from input file Blink.ino.hex
Writing 924 bytes to flash
Writing | ################################################## | 100% 0.17 s
Reading | ################################################## | 100% 0.12 s
924 bytes of flash verified
				
			

Programming an ATtiny85 using a USBTinyISP Programmer

Here is another example of programming an ATtiny85 using a USBTinyISP programmer. Notice that the kind of programmer is a usbtiny (USBtiny simple USB programmer (TPI, ISP)). 

				
					avrdude -p attiny85 -c usbtiny -U flash:w:SpaceAttackAttiny.ino.hex
				
			

And the output would be:

				
					C:\Users\super>avrdude -p attiny85 -c usbtiny -U flash:w:SpaceAttackAttiny.ino.hex:i
Reading 1118 bytes for flash from input file SpaceAttackAttiny.ino.hex
Writing 1118 bytes to flash
Writing | ################################################## | 100% 1.95 s
Reading | ################################################## | 100% 1.07 s
1118 bytes of flash verified
				
			

Use the command avrdude -c? to display all kinds of programmers available for AVRDUDE.

				
					C:\Users\super>avrdude -c?

Valid programmers are:
  2232hio            = 2232hio based on FT2232H with buffer and LEDs (TPI, ISP)
  4232h              = FT4232H based generic programmer (TPI, ISP)
  adafruit_gemma     = Trinket Gemma bootloader disguised as USBtiny (SPM)
  arduino            = Arduino bootloader using STK500 v1 protocol (SPM)
  arduino-ft232r     = Arduino: FT232R connected to ISP (TPI, ISP)
  diecimila          = Arduino: FT232R connected to ISP (TPI, ISP)
  arduino_as_isp     = AVR as programmer with Arduino-as-ISP FW (ISP)
  arduino_gemma      = Arduino Gemma bootloader disguised as USBtiny (SPM)
  arduinoisp         = Arduino-branded USBtiny ISP Programmer (TPI, ISP)
  arduinoisporg      = Arduino-branded USBtiny ISP Programmer (TPI, ISP)
  atmelice           = Atmel-ICE (JTAG, XMEGAJTAG, AVR32JTAG)
  atmelice_jtag      = Atmel-ICE (JTAG, XMEGAJTAG, AVR32JTAG)
  atmelice_dw        = Atmel-ICE (debugWIRE)
  atmelice_isp       = Atmel-ICE (ISP)
  atmelice_pdi       = Atmel-ICE (PDI)
  atmelice_tpi       = Atmel-ICE (TPI)
  atmelice_updi      = Atmel-ICE (UPDI)
  avr109             = Atmel bootloader (AVR109, AVR911) (SPM)
  avr911             = Atmel bootloader (AVR109, AVR911) (SPM)
  avr910             = Atmel Low Cost Serial Programmer (ISP)
  avrftdi            = FT2232H/D based generic programmer (TPI, ISP)
  2232h              = FT2232H/D based generic programmer (TPI, ISP)
  avrisp             = Serial Atmel AVR ISP using STK500 (ISP)
  avrisp-u           = Kanda AVRISP-U (TPI, ISP)
  avrispmkII         = USB Atmel AVR ISP mkII (TPI, ISP, PDI)
  avrisp2            = USB Atmel AVR ISP mkII (TPI, ISP, PDI)
  avrispv2           = Serial Atmel AVR ISP using STK500v2 (TPI, ISP)
  buspirate          = The Bus Pirate in AVR programming mode (ISP)
  buspirate_bb       = The Bus Pirate in bitbang mode (TPI, ISP)
  butterfly          = Atmel bootloader (Butterfly Development Board) (SPM)
  butterfly_mk       = Mikrokopter.de Butterfly bootloader (SPM)
  mkbutterfly        = Mikrokopter.de Butterfly bootloader (SPM)
  bwmega             = BitWizard ftdi_atmega builtin programmer (TPI, ISP)
  c232hm             = C232HM cable from FTDI (TPI, ISP)
  c2n232i            = serial port: reset=dtr sck=!rts sdo=!txd sdi=!cts (TPI, ISP)
  ch341a             = CH341A programmer: note AVR F_CPU > 6.8 MHz (ISP)
  dasa               = serial port: reset=rts sck=dtr sdo=txd sdi=cts (TPI, ISP)
  dasa3              = serial port: reset=!dtr sck=rts sdo=txd sdi=cts (TPI, ISP)
  digilent-hs2       = Digilent JTAG HS2 (MPSSE) (TPI, ISP)
  dragon_dw          = Atmel AVR Dragon (debugWIRE)
  dragon_hvsp        = Atmel AVR Dragon (HVSP)
  dragon_isp         = Atmel AVR Dragon (TPI, ISP)
  dragon_jtag        = Atmel AVR Dragon (JTAG, XMEGAJTAG, AVR32JTAG)
  dragon_pdi         = Atmel AVR Dragon (PDI)
  dragon_pp          = Atmel AVR Dragon (HVPP)
  dryboot            = Emulates bootloader programming without the part (SPM)
  dryrun             = Emulates programming without a programmer (TPI, ISP, PDI, UPDI, HVSP, HVPP, aWire)
  ehajo-isp          = AVR ISP programmer from eHaJo.de (TPI, ISP)
  flip1              = FLIP bootloader using USB DFU v1 (doc7618) (SPM)
  flip2              = FLIP bootloader using USB DFU v2 (AVR4023) (SPM)
  flyswatter2        = TinCan Tools Flyswatter 2 (TPI, ISP)
  ft2232h            = FT2232H/D based generic programmer (TPI, ISP)
  ft2232h_jtag       = FT2232H based generic JTAG programmer (JTAG)
  ft232h             = FT232H based generic programmer (TPI, ISP)
  ft232h_jtag        = FT232H based generic JTAG programmer (JTAG)
  ft232r             = FT232R based generic programmer (TPI, ISP)
  ft245r             = FT245R based generic programmer (TPI, ISP)
  ft4232h            = FT4232H based generic programmer (TPI, ISP)
  iseavrprog         = AVR ISP programmer from iascaled.com (TPI, ISP)
  jtag1slow          = Atmel JTAG ICE mkI (JTAGmkI)
  jtag2dw            = Atmel JTAG ICE mkII (debugWIRE)
  jtag2fast          = Atmel JTAG ICE mkII (JTAG, XMEGAJTAG, AVR32JTAG)
  jtag2              = Atmel JTAG ICE mkII (JTAG, XMEGAJTAG, AVR32JTAG)
  jtag2isp           = Atmel JTAG ICE mkII (TPI, ISP)
  jtag2pdi           = Atmel JTAG ICE mkII (PDI)
  jtag2slow          = Atmel JTAG ICE mkII (JTAG, XMEGAJTAG, AVR32JTAG)
  jtag2updi          = JTAGv2 to UPDI bridge (UPDI)
  nanoevery          = JTAGv2 to UPDI bridge (UPDI)
  jtag3              = Atmel AVR JTAGICE3 (JTAG, XMEGAJTAG, AVR32JTAG)
  jtag3dw            = Atmel AVR JTAGICE3 (debugWIRE)
  jtag3isp           = Atmel AVR JTAGICE3 (ISP)
  jtag3pdi           = Atmel AVR JTAGICE3 (PDI)
  jtag3updi          = Atmel AVR JTAGICE3 (UPDI)
  jtagkey            = Amontec JTAGKey/JTAGKey-Tiny/JTAGKey2 (TPI, ISP)
  jtagmkI            = Atmel JTAG ICE mkI (JTAGmkI)
  jtag1              = Atmel JTAG ICE mkI (JTAGmkI)
  jtagmkII           = Atmel JTAG ICE mkII (JTAG, XMEGAJTAG, AVR32JTAG)
  jtagmkII_avr32     = Atmel JTAG ICE mkII (aWire)
  jtag2avr32         = Atmel JTAG ICE mkII (aWire)
  ktlink             = KT-LINK FT2232H: IO switching, voltage buffers (TPI, ISP)
  lm3s811            = Luminary Micro LM3S811 Eval Board (Rev. A) (TPI, ISP)
  mib510             = Crossbow MIB510 programming board (TPI, ISP)
  micronucleus       = Micronucleus bootloader (SPM)
  nibobee            = NIBObee (TPI, ISP)
  o-link             = O-Link, OpenJTAG ARM JTAG USB (TPI, ISP)
  openmoko           = Openmoko debug board (v3) (TPI, ISP)
  pavr               = Jason Kyle's pAVR Serial Programmer (ISP)
  pickit2            = Microchip PICkit 2 programmer (ISP)
  pickit4            = MPLAB(R) PICkit 4 (JTAG, XMEGAJTAG)
  pickit4_jtag       = MPLAB(R) PICkit 4 (JTAG, XMEGAJTAG)
  pickit4_isp        = MPLAB(R) PICkit 4 (ISP)
  pickit4_pdi        = MPLAB(R) PICkit 4 (PDI)
  pickit4_tpi        = MPLAB(R) PICkit 4 (TPI)
  pickit4_updi       = MPLAB(R) PICkit 4 (UPDI)
  pickit5_updi       = MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC) (UPDI)
  pkobn_updi         = Curiosity nano (nEDBG) (UPDI)
  ponyser            = ponyprog serial: reset=!txd sck=rts sdo=dtr sdi=cts (TPI, ISP)
  powerdebugger      = Atmel PowerDebugger (JTAG, XMEGAJTAG, AVR32JTAG)
  powerdebugger_jtag = Atmel PowerDebugger (JTAG, XMEGAJTAG, AVR32JTAG)
  powerdebugger_dw   = Atmel PowerDebugger (debugWIRE)
  powerdebugger_isp  = Atmel PowerDebugger (ISP)
  powerdebugger_pdi  = Atmel PowerDebugger (PDI)
  powerdebugger_tpi  = Atmel PowerDebugger (TPI)
  powerdebugger_updi = Atmel PowerDebugger (UPDI)
  serialupdi         = SerialUPDI (UPDI)
  serprog            = Program via the Serprog protocol from Flashrom (ISP)
  siprog             = Lancos SI-Prog (same as ponyser) (TPI, ISP)
  snap               = MPLAB(R) SNAP (JTAG, XMEGAJTAG)
  snap_jtag          = MPLAB(R) SNAP (JTAG, XMEGAJTAG)
  snap_isp           = MPLAB(R) SNAP (ISP)
  snap_pdi           = MPLAB(R) SNAP (PDI)
  snap_tpi           = MPLAB(R) SNAP (TPI)
  snap_updi          = MPLAB(R) SNAP (UPDI)
  stk500             = Atmel STK500 (probes v2 first then v1) (ISP)
  stk500hvsp         = Atmel STK500 v2 (HVSP)
  scratchmonkey_hvsp = Atmel STK500 v2 (HVSP)
  stk500pp           = Atmel STK500 v2 (HVPP)
  scratchmonkey_pp   = Atmel STK500 v2 (HVPP)
  stk500v1           = Atmel STK500 v1 (ISP)
  stk500v2           = Atmel STK500 v2 (TPI, ISP)
  scratchmonkey      = Atmel STK500 v2 (TPI, ISP)
  stk600             = Atmel STK600 (TPI, ISP, PDI)
  stk600hvsp         = Atmel STK600 (HVSP)
  stk600pp           = Atmel STK600 (HVPP)
  tc2030             = Tag-Connect TC2030 (TPI, ISP)
  teensy             = Teensy bootloader (SPM)
  tigard             = Tigard interface board (TPI, ISP)
  ttl232r            = FTDI TTL232R-5V with ICSP adapter (TPI, ISP)
  tumpa              = TIAO USB Multi-Protocol Adapter (TPI, ISP)
  tumpa-b            = TIAO USB Multi-Protocol Adapter (TPI, ISP)
  tumpa_jtag         = TIAO USB Multi-Protocol Adapter (JTAG)
  um232h             = UM232H module from FTDI (TPI, ISP)
  uncompatino        = uncompatino with all pairs of pins shorted (TPI, ISP)
  urclock            = Urboot bootloaders using urprotocol (SPM)
  usbasp             = USBasp ISP and TPI programmer (TPI, ISP)
  usbasp-clone       = Any usbasp clone with correct VID/PID (TPI, ISP)
  usbtiny            = USBtiny simple USB programmer (TPI, ISP)
  wiring             = Wiring bootloader using STK500 v2 protocol (SPM)
  xbee               = XBeeBoot Over-The-Air bootloader (STK500 v1) (SPM)
  xplainedmini       = Atmel XplainedMini (ISP)
  xplainedmini_isp   = Atmel XplainedMini (ISP)
  xplainedmini_dw    = Atmel XplainedMini (debugWIRE)
  xplainedmini_tpi   = Atmel XplainedMini (TPI)
  xplainedmini_updi  = Atmel XplainedMini (UPDI)
  xplainedpro        = Atmel XplainedPro (JTAG, XMEGAJTAG, AVR32JTAG)
  xplainedpro_jtag   = Atmel XplainedPro (JTAG, XMEGAJTAG, AVR32JTAG)
  xplainedpro_pdi    = Atmel XplainedPro (PDI)
  xplainedpro_updi   = Atmel XplainedPro (UPDI)
				
			

Batch Programming

The command-line nature of AVRDUDE suits batch programming of microcontrollers. To do this, in Windows, simply save a batch file (with .bat extension) that goes on a loop, such as batch.bat. You may also do scripting if you are in a Linux environment.

				
					@echo off
:loop
echo Ready to program ATtiny85. Press any key to begin or close the window to exit.
pause
avrdude -p attiny85 -c usbtiny -U flash:w:SpaceAttackAttiny.ino.hex:i
echo Programming complete. Returning to the start...
goto loop

				
			

The batch file above waits for user input before continuing with any programming operation. Below is a sample run of the batch.bat batch file.

CONCLUSION

This article presented ways on how to use AVRDUDE for programming your MCUs and to do simple batch programming. Go ahead and download the AVRDUDE program for your machine on their GitHub releases page.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top