\index{avrprog, usage@{avrprog, usage}} \index{avrdude, usage@{avrdude, usage}}

\begin{DoxyNote}{Note}
This section was contributed by Brian Dean \mbox{[} \href{mailto:bsd@bsdhome.com}{\texttt{ bsd@bsdhome.\+com}} \mbox{]}.

The avrdude program was previously called avrprog. The name was changed to avoid confusion with the avrprog program that Atmel ships with Avr\+Studio.
\end{DoxyNote}
{\ttfamily avrdude} is a program that is used to update or read the flash and E\+E\+P\+R\+OM memories of Atmel A\+VR microcontrollers on Free\+B\+SD Unix. It supports the Atmel serial programming protocol using the PC\textquotesingle{}s parallel port and can upload either a raw binary file or an Intel Hex format file. It can also be used in an interactive mode to individually update E\+E\+P\+R\+OM cells, fuse bits, and/or lock bits (if their access is supported by the Atmel serial programming protocol.) The main flash instruction memory of the A\+VR can also be programmed in interactive mode, however this is not very useful because one can only turn bits off. The only way to turn flash bits on is to erase the entire memory (using {\ttfamily avrdude}\textquotesingle{}s {\ttfamily -\/e} option).

{\ttfamily avrdude} is part of the Free\+B\+SD ports system. To install it, simply do the following\+:

\begin{DoxyVerb}# cd /usr/ports/devel/avrdude
# make install
\end{DoxyVerb}


Once installed, {\ttfamily avrdude} can program processors using the contents of the {\ttfamily }.hex file specified on the command line. In this example, the file {\ttfamily main.\+hex} is burned into the flash memory\+:

\begin{DoxyVerb}# avrdude -p 2313 -e -m flash -i main.hex

avrdude: AVR device initialized and ready to accept instructions

avrdude: Device signature = 0x1e9101

avrdude: erasing chip
avrdude: done.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex

avrdude: writing flash:
1749 0x00
avrdude: 1750 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: reading on-chip flash data:
1749  0x00
avrdude: verifying ...
avrdude: 1750 bytes of flash verified

avrdude done.  Thank you.
\end{DoxyVerb}


The {\ttfamily -\/p 2313} option lets {\ttfamily avrdude} know that we are operating on an A\+T90\+S2313 chip. This option specifies the device id and is matched up with the device of the same id in {\ttfamily avrdude}\textquotesingle{}s configuration file ( {\ttfamily /usr/local/etc/avrdude}.conf ). To list valid parts, specify the {\ttfamily -\/v} option. The {\ttfamily -\/e} option instructs {\ttfamily avrdude} to perform a chip-\/erase before programming; this is almost always necessary before programming the flash. The {\ttfamily -\/m flash} option indicates that we want to upload data into the flash memory, while {\ttfamily -\/i main.\+hex} specifies the name of the input file.

The E\+E\+P\+R\+OM is uploaded in the same way, the only difference is that you would use {\ttfamily -\/m eeprom} instead of {\ttfamily -\/m flash}.

To use interactive mode, use the {\ttfamily -\/t} option\+:

\begin{DoxyVerb}# avrdude -p 2313 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9101
avrdude>

The '?' command displays a list of valid
commands:

avrdude> ?
>>> ?
Valid commands:

  dump   : dump memory  : dump <memtype> <addr> <N-Bytes>
  read   : alias for dump
  write  : write memory : write <memtype> <addr> <b1> <b2> ... <bN>
  erase  : perform a chip erase
  sig    : display device signature bytes
  part   : display the current part information
  send   : send a raw command : send <b1> <b2> <b3> <b4>
  help   : help
  ?      : help
  quit   : quit

Use the 'part' command to display valid memory types for use with the
'dump' and 'write' commands.

avrdude>
\end{DoxyVerb}
 