This page contains the source code and a hardware interface example for
the programming of the Atmel AVR family of microcontrollers. These
programs were inteded for use under Linux, but also a preliminary
windows port via Cygwin is under way.
Download: avrprg.tgz
Last changes (Changelog.txt)
Supported chips:
- AT90S2313
- AT90S1200 (untested)
- ATTiny2313
- ATTiny24
- ATTiny44 (untested)
- ATTiny84 (untested)
- ATMega8
- ATMega16 (untested)
- ATMega32
- ATMega48
- ATMega88
- ATMega168 (untested)
Adding new chips:
The supported chip database is
stored in the source file id.c.
The addition of new chips should be straigh forward provided no new
weird programming commands were invented by Atmel ;-)
// Chip specific definitions:
// int
id;
-> The 3 signature bytes of the chip
// int
flash_size; -> The size of the flash
memory (bytes)
// int
eeprom_size; -> The size of the EEPROM
memory (bytes)
// int
page_size; -> The size of a
Flash page (words)
//
0 means no pages at all (older chips)
// char
p0;
-> The value read during flash programming while busy
// char
p1;
-> The value read during EEPROM erase while busy
// char
p2;
-> The value read during EEPROM programming while busy
//
0x1 means to use POLL/RDY command
// char
fuses; -> Fuse
mask bits:
//
0:fuses, 1:fusesh, 2:fusesEX, 3:lock
// char
*name; -> A
name for the chip
const
chip_id idt[]={
0xfffffe, 0, 0, 0,0xff,0xff,0xff,0,"NONE",
// Old small chips
0x1e9101, 2048, 128, 0,0x7f,0x80,0x7f,0,"AT90S2313",
0x1e9001, 1024, 64, 0,0xff,0x00,0xff,0,"AT90S1200",
// Old Mega chips
0x1e9307, 8192, 512,32,0xff,0xff,0xff,0x0b,"ATMEGA8",
0x1e9403,16384, 512,64,0xff,0xff,0xff,0x0b,"ATMEGA16",
0x1e9502,32768,1024,64,0xff,0xff,0xff,0x0b,"ATMEGA32",
// New small chips
0x1e910A, 2048, 128,16,0x01,0x01,0x01,0x0f,"ATtiny2313",
// New mega chips
0x1e9205, 4096, 256,32,0x01,0x01,0x01,0x0f,"ATMega48",
0x1e939a, 8192, 512,32,0x01,0x01,0x01,0x0f,"ATMega88",
0x1e9406,16384, 512,64,0x01,0x01,0x01,0x0f,"ATMega168",
// Tiny24/44/84
0x1e910B, 2048,
128,16,0x01,0x01,0x01,0x0f,"ATtiny24",
0x1e9107, 4096,
256,32,0x01,0x01,0x01,0x0f,"ATtiny44",
0x1e910C, 8192,
512,32,0x01,0x01,0x01,0x0f,"ATtiny84",
// Table terminator
0,0,0,0,0,0,0,0,NULL
};
Supported Hardware interfaces:
The programs:
avrprg:
This program uses a graphical interface built around the XForms
library. Here are some snapshots:
avrpcmd:
This is a command-line only program. A
port to Windows based on the Cygwin enviroment is possible. This
program is much more suited for its use in scripts and makefiles.
Help dump:
$avrpcmd
Usage
avrpcmd [options/commands]
==
Options:
-dev
<dev> : Use the <dev> device for
programmer
-fmt
<format> : Specify output data format: (ihex,srec,bin)
-v
: Verbose log
==
Commands:
-id
: Only print the chip ID and exit
-rdf
<file> : Read Flash memory to <file>
-rde
<file> : Read EEPROM memory to <file>
-blk
: Check if Flash memory is Blank
-ver
<file> : Compare Flash memory content to
<file> (Verify)
-wrf
<file> : Write <file> to Flash memory
-wre
<file> : Write <file> to EEPROM memory
-erase
: Erase chip
-rdfuses
: Read FUSES byte
-rdfusesh
: Read FUSES High byte
-rdfusesx
: Read FUSES Extended byte
-rdlock
: Read LOCK byte
-rdcal
<n> : Read Calibration value <n>
for internal Osc.
== Fuse
values are binary (e.g. 11100100) or hex. (e.g. 0xE4)==
-wrfuses
<val> : Write FUSES byte with <val>
-wrfusesh
<val>: Write FUSES High byte with <val>
-wrfusesx
<val>: Write FUSES Extended byte with <val>
-wrlock
<val> : Write LOCK byte with <val>
Usage dump (reading an internal oscillator
calibration value):
$avrpcmd
-v -rdcal 1
----- Calibrating delay ...
> 260 loops per us interval
----- Reading Parallel Port
Configuration (parallel.cfg)...
VCC: 0x04
RESET: 0x10 Inv.
SCK: 0x20
Inv.
MOSI: 0x40 Inv.
MISO: 0x80
----- Opening Parallel Port...
----- IO Base: 0x378
----- Identifying Device...
<> Device_ID = 0x1E910A
<> device found:
ATtiny2313
Chip: ATtiny2313
Signature: 1E910A
Flash: 2048 bytes
EEPROM: 128 bytes
>>>>>
Calibration value #1 : 79 (0x4F)
OK