2003-02-06 19:08:33 +00:00
|
|
|
/*
|
2003-02-08 04:17:25 +00:00
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
2004-12-22 01:52:45 +00:00
|
|
|
* Copyright (C) 2003-2004 Brian S. Dean <bsd@bsdhome.com>
|
2003-02-06 19:08:33 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
#ifndef __avrpart_h__
|
|
|
|
#define __avrpart_h__
|
|
|
|
|
2003-02-22 16:45:13 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
#include "lists.h"
|
|
|
|
|
2004-07-05 15:04:19 +00:00
|
|
|
|
|
|
|
extern LISTID part_list;
|
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
/*
|
|
|
|
* AVR serial programming instructions
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
AVR_OP_READ,
|
|
|
|
AVR_OP_WRITE,
|
|
|
|
AVR_OP_READ_LO,
|
|
|
|
AVR_OP_READ_HI,
|
|
|
|
AVR_OP_WRITE_LO,
|
|
|
|
AVR_OP_WRITE_HI,
|
|
|
|
AVR_OP_LOADPAGE_LO,
|
|
|
|
AVR_OP_LOADPAGE_HI,
|
|
|
|
AVR_OP_WRITEPAGE,
|
|
|
|
AVR_OP_CHIP_ERASE,
|
|
|
|
AVR_OP_PGM_ENABLE,
|
|
|
|
AVR_OP_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
AVR_CMDBIT_IGNORE, /* bit is ignored on input and output */
|
|
|
|
AVR_CMDBIT_VALUE, /* bit is set to 0 or 1 for input or output */
|
|
|
|
AVR_CMDBIT_ADDRESS, /* this bit represents an input address bit */
|
|
|
|
AVR_CMDBIT_INPUT, /* this bit is an input bit */
|
|
|
|
AVR_CMDBIT_OUTPUT /* this bit is an output bit */
|
|
|
|
};
|
|
|
|
|
2003-02-20 14:11:34 +00:00
|
|
|
enum { /* these are assigned to reset_disposition of AVRPART */
|
|
|
|
RESET_DEDICATED, /* reset pin is dedicated */
|
|
|
|
RESET_IO /* reset pin might be configured as an I/O pin */
|
|
|
|
};
|
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
/*
|
|
|
|
* serial programming instruction bit specifications
|
|
|
|
*/
|
|
|
|
typedef struct cmdbit {
|
|
|
|
int type; /* AVR_CMDBIT_* */
|
|
|
|
int bitno; /* which input bit to use for this command bit */
|
|
|
|
int value; /* bit value if type == AVR_CMDBIT_VALUD */
|
|
|
|
} CMDBIT;
|
|
|
|
|
|
|
|
typedef struct opcode {
|
|
|
|
CMDBIT bit[32]; /* opcode bit specs */
|
|
|
|
} OPCODE;
|
|
|
|
|
|
|
|
|
2003-02-20 19:46:23 +00:00
|
|
|
#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */
|
|
|
|
#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */
|
|
|
|
#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */
|
|
|
|
#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */
|
|
|
|
#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */
|
2003-02-20 19:46:23 +00:00
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
#define AVR_DESCLEN 64
|
|
|
|
#define AVR_IDLEN 32
|
|
|
|
typedef struct avrpart {
|
|
|
|
char desc[AVR_DESCLEN]; /* long part name */
|
|
|
|
char id[AVR_IDLEN]; /* short part name */
|
2003-03-17 06:20:02 +00:00
|
|
|
int stk500_devcode; /* stk500 device code */
|
|
|
|
int avr910_devcode; /* avr910 device code */
|
2002-12-01 04:30:01 +00:00
|
|
|
int chip_erase_delay; /* microseconds */
|
2003-02-20 14:11:34 +00:00
|
|
|
unsigned char pagel; /* for parallel programming */
|
|
|
|
unsigned char bs2; /* for parallel programming */
|
|
|
|
int reset_disposition; /* see RESET_ enums */
|
2003-02-21 17:24:47 +00:00
|
|
|
int retry_pulse; /* retry program enable by pulsing
|
|
|
|
this pin (PIN_AVR_*) */
|
2003-02-20 19:46:23 +00:00
|
|
|
unsigned flags; /* see AVRPART_ masks */
|
2003-02-20 14:11:34 +00:00
|
|
|
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
int timeout; /* stk500 v2 xml file parameter */
|
|
|
|
int stabdelay; /* stk500 v2 xml file parameter */
|
|
|
|
int cmdexedelay; /* stk500 v2 xml file parameter */
|
|
|
|
int synchloops; /* stk500 v2 xml file parameter */
|
|
|
|
int bytedelay; /* stk500 v2 xml file parameter */
|
|
|
|
int pollindex; /* stk500 v2 xml file parameter */
|
|
|
|
unsigned char pollvalue; /* stk500 v2 xml file parameter */
|
|
|
|
int predelay; /* stk500 v2 xml file parameter */
|
|
|
|
int postdelay; /* stk500 v2 xml file parameter */
|
|
|
|
int pollmethod; /* stk500 v2 xml file parameter */
|
|
|
|
|
|
|
|
unsigned char idr; /* JTAG ICE mkII XML file parameter */
|
|
|
|
unsigned char rampz; /* JTAG ICE mkII XML file parameter */
|
|
|
|
unsigned char spmcr; /* JTAG ICE mkII XML file parameter */
|
Quite some cleanup of the JTAG ICE mkII stuff.
. Implement the new EECRAddress field in the device descriptor that is
required by the 4.x firmware; make an uneducated guess about what
firmware requires what length of device descriptor -- perhaps Atmel
can be convinced to publish an official matrix for that.
. Specify EECR in the config file where required. Obviously, only
locations that differ from the 0x3c default are mentioned in the
XML files, so by now, this only affects the AT90CAN128 for us.
. After clarification with Atmel, EnablePageProgramming should really
default to 1, and only cleared if specified by an XML parameter. So
far, only the XML files for the ATmega256x and ATmega406 do specify
it at all, and they specify a 1, too.
. Drop the entire OCDEN fuse heuristic. If OCDEN is unprogrammed at
startup, issue a warning that single-byte EEPROM updates won't be
possible. Leave it to the user to program the fuse if desired.
That way, we won't run into any issue of prematurely wearing out the
hfuse EEPROM cell. Interestingly enough, this also solved the
problem of the target not restarting from scratch upon sign-off.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@461 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 20:06:23 +00:00
|
|
|
unsigned short eecr; /* JTAC ICE mkII XML file parameter */
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
|
|
|
|
|
|
|
LISTID mem; /* avr memory definitions */
|
2003-02-22 16:45:13 +00:00
|
|
|
char config_file[PATH_MAX]; /* config file where defined */
|
|
|
|
int lineno; /* config file line number */
|
2002-12-01 04:30:01 +00:00
|
|
|
} AVRPART;
|
|
|
|
|
2002-12-01 06:35:18 +00:00
|
|
|
#define AVR_MEMDESCLEN 64
|
|
|
|
typedef struct avrmem {
|
|
|
|
char desc[AVR_MEMDESCLEN]; /* memory description ("flash", "eeprom", etc) */
|
|
|
|
int paged; /* page addressed (e.g. ATmega flash) */
|
|
|
|
int size; /* total memory size in bytes */
|
|
|
|
int page_size; /* size of memory page (if page addressed) */
|
|
|
|
int num_pages; /* number of pages (if page addressed) */
|
|
|
|
int min_write_delay; /* microseconds */
|
|
|
|
int max_write_delay; /* microseconds */
|
|
|
|
int pwroff_after_write; /* after this memory type is written to,
|
|
|
|
the device must be powered off and
|
|
|
|
back on, see errata
|
|
|
|
http://www.atmel.com/atmel/acrobat/doc1280.pdf */
|
|
|
|
unsigned char readback[2]; /* polled read-back values */
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
|
|
|
|
int mode; /* stk500 v2 xml file parameter */
|
|
|
|
int delay; /* stk500 v2 xml file parameter */
|
|
|
|
int blocksize; /* stk500 v2 xml file parameter */
|
|
|
|
int readsize; /* stk500 v2 xml file parameter */
|
|
|
|
int pollindex; /* stk500 v2 xml file parameter */
|
|
|
|
|
2002-12-01 06:35:18 +00:00
|
|
|
unsigned char * buf; /* pointer to memory buffer */
|
|
|
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
|
|
|
} AVRMEM;
|
|
|
|
|
2003-11-30 16:42:10 +00:00
|
|
|
/* Functions for OPCODE structures */
|
|
|
|
OPCODE * avr_new_opcode(void);
|
|
|
|
int avr_set_bits(OPCODE * op, unsigned char * cmd);
|
|
|
|
int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr);
|
|
|
|
int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data);
|
|
|
|
int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data);
|
|
|
|
|
|
|
|
/* Functions for AVRMEM structures */
|
|
|
|
AVRMEM * avr_new_memtype(void);
|
|
|
|
int avr_initmem(AVRPART * p);
|
|
|
|
AVRMEM * avr_dup_mem(AVRMEM * m);
|
|
|
|
AVRMEM * avr_locate_mem(AVRPART * p, char * desc);
|
|
|
|
void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type,
|
|
|
|
int verbose);
|
|
|
|
|
|
|
|
/* Functions for AVRPART structures */
|
|
|
|
AVRPART * avr_new_part(void);
|
|
|
|
AVRPART * avr_dup_part(AVRPART * d);
|
2003-11-30 16:49:00 +00:00
|
|
|
AVRPART * locate_part(LISTID parts, char * partdesc);
|
2004-01-12 22:48:50 +00:00
|
|
|
AVRPART * locate_part_by_avr910_devcode(LISTID parts, int devcode);
|
2003-11-30 16:49:00 +00:00
|
|
|
void list_parts(FILE * f, char * prefix, LISTID parts);
|
2003-11-30 16:42:10 +00:00
|
|
|
void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose);
|
|
|
|
|
2002-12-01 04:30:01 +00:00
|
|
|
#endif
|