1.4. Programming Your Processor

There are several applications that will burn your .hex files into an AVR processor. This section covers these tools.

1.4.1. Using avrprog

(This section was contributed by Brian Dean .)

avrprog is a program that is used to update or read the flash and EEPROM memories of Atmel AVR microcontrollers on FreeBSD Unix. It supports the Atmel serial programming protocol using the PC'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 EEPROM 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 AVR 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 AVRPROG's -e option).

avrprog is part of the FreeBSD ports system. To install it, simply do the following:

    # cd /usr/ports/devel/avrprog
    # make install

Once installed, avrprog can program processors using the contents of the .hex file specified on the command line. In this example, the file main.hex is burned into the flash memory:

    # avrprog -p 2313 -e -m flash -i main.hex
    
    avrprog: AVR device initialized and ready to accept instructions
    
    avrprog: Device signature = 0x1e9101
    
    avrprog: erasing chip
    avrprog: done.
    avrprog: reading input file "main.hex"
    avrprog: input file main.hex auto detected as Intel Hex
    
    avrprog: writing flash:
    1749 0x00
    avrprog: 1750 bytes of flash written
    avrprog: verifying flash memory against main.hex:
    avrprog: reading on-chip flash data:
    1749  0x00
    avrprog: verifying ...
    avrprog: 1750 bytes of flash verified
    
    avrprog done.  Thank you.

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

The EEPROM is uploaded in the same way, the only difference is that you would use "-m eeprom" instead of "-m flash".

To use interactive mode, use the "-t" option:

    # avrprog -p 2313 -t
    avrprog: AVR device initialized and ready to accept instructions
    avrprog: Device signature = 0x1e9101
    avrprog>

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

    avrprog> ?
    >>> ?
    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.
    
    avrprog>

1.4.2. Using uisp

(This section hasn't been written yet. Sorry!)