AVR Programming Methods
There are many ways to program AVR microcontrollers. Since many people ask about
different ones at one time or another, I thought I'd outline them here so that
their questions can be answered quickly and efficiently. Please forgive me if I
miss a method or make an error.
METHOD 1: In System Programming (ISP)
Supported By: Vast
majority of AVRs (see below posts)
Supported Programmers: AVRISP
MKI/II, JTAG MKII, STK500, STK600, Dragon, AVRISP clones, AVR910 Programmers,
AVRONE
METHOD 2: JTAG
Supported By: See
AVRStudio Tools help for MKI and MKII device support
Supported Programmers: JTAG-ICE,
JTAG-ICE MKII, Dragon, JTAG-ICE clones, AVRONE, STK600 (programming only)
METHOD 3: DebugWire
Supported By: Many
smaller AVRs
Supported Programmers: JTAG-ICE
MKII, Dragon, AVRONE
METHOD 4: Bootloader
Supported By: Most
newer AVRs
Supported Programmers: N/A
METHOD 5: High Voltage Parallel Programming (HVPP)
Supported By: Most
non-TINY AVRs (with exceptions)
Supported Programmers: STK500,
STK600, Dragon, Homebrew Dongles, AVRONE
METHOD 6: High Voltage Serial Programming (HVSP)
Supported By: Many
TINY AVRs (with exceptions)
Supported Programmers: STK500,
STK600, Dragon, Homebrew Dongles, AVRONE
METHOD 7: PDI
Supported By: XMEGA
AVRs
Supported Programmers: STK600,
AVRONE, JTAG MKII, Dragon, AVRISP MKII
METHOD 8: TPI
Supported By: 6-Pin
TINY AVRs (ATTINY10, etc.)
Supported Programmers: STK600,
Dragon, AVRISP MKII
Bonus FAQ Section!
1) Which is the best method?
There is no universal "best" method. ISP programming is simple and
extremely popular, however all the above methods will work. The two high voltage
programming modes (whichever is applicable to your device) are the most feature
rich, as they allow for the repair of an AVR which has had its fuses
misconfigured. However, those methods are a pain to set up, hence the reason
most users go with with ISP.
2) I've made a parallel port
dongle. Can I use it with AVRStudio?
I'm afraid not. AVRStudio cannot interface with any "dumb" dongles -
it requires a smart programming device - containing a microcontroller itself -
to decipher the communication protocol it sends. Simple dongles without a
microcontroller must be "bit-banged" (ie. the appropriate signals
simulated through the dongle via the computer) itself.
3) So my dongle's useless then?
No. You can still program through a home made dongle with a third party
programming software tool. AVRDude is a good, known, free command line utility -
and it comes included with the WinAVR package.
4) What are my options if I want
my programmer to work with AVRStudio?
Choose a programmer that uses an AVRStudio-supported protocol. This can be the
simple "AVR910" protocol (deprecated) or a custom implementation of
the protocol used by the STK500/AVRISP. Note that these programmers require a
micro controller in them, leading to a catch-22 situation. This may be solved by
having the programmer's AVR pre-programmed at time of purchase with the
appropriate firmware, or by having the AVR pre-programmed with a bootloader.
5) Ok, I want to use a
bootloader. How do I get it in there in the first place?!
To use a bootloader in an AVR, you first have to have the bootloader programmed
in. If you do not have an existing programmer (even a simple dumb dongle will
suffice for the initial programming), you can alternatively purchase AVRs
pre-programmed with a bootloader from several suppliers.
Atmel also manufactures the Butterfly demo board, whose MEGA169 AVR comes
pre-loaded with an AVR-Studio compatible bootloader.
6) Help! I've messed with the
fuses and knackered my AVR while using ISP!
The most common mistake is changing the clock selection fuses to an invalid
setting. Try putting an external clock on the AVR's XTAL1 pin and see if that
helps.
Failing that, if possible use one of the high-voltage methods. These will fix
any misconfiguration, including ones involving the clock source as the
high-voltage methods provides its own clock to the AVR for programming.
7) How do I interface with my
programmer?
Which software you use to interface with your programmer depends on the type of
programmer you are using.
Simple "dumb" dongles require third party software, such as PonyProg
or AVRDude. These may be command line or GUI tools - look around on the web and
you will fine one to fit your needs.
Programmers and bootloaders based on the AVR910 protocol can be used within
AVRStudio. From the Tools menu, select the "AVRProg" option to open up
a GUI screen to interface with your programmer. As an alternative, third party
tools such as AVRDude are also AVR910 compatible.
Official tools are tightly integrated into AVRStudio, especially in the case of
the debugging variants (JTAG/Dragon/etc). From the AVRStudio Tools menu, select
the "Program AVR..." submenu and click the "Connect" item.
From the new window, select your tool and its connection interface and click ok.
As is the case with the dumb dongles and AVR910 programmers, the official tools
may also be used with third party programming software.
- Dean