2014-05-19 10:01:59 +00:00
|
|
|
/*
|
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
|
|
|
* Copyright (C) Joerg Wunsch
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef libavrdude_h
|
|
|
|
#define libavrdude_h
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-01-07 12:15:55 +00:00
|
|
|
typedef uint32_t pinmask_t;
|
2022-06-15 21:32:22 +00:00
|
|
|
/*
|
|
|
|
* Values returned by library functions.
|
|
|
|
* Some library functions also return a count, i.e. a positive
|
|
|
|
* number greater than 0.
|
|
|
|
*/
|
|
|
|
#define LIBAVRDUDE_SUCCESS 0
|
|
|
|
#define LIBAVRDUDE_GENERAL_FAILURE (-1)
|
|
|
|
#define LIBAVRDUDE_NOTSUPPORTED (-2) // operation not supported
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
#define LIBAVRDUDE_SOFTFAIL (-3) // returned, eg, by avr_signature() if caller
|
2022-06-15 21:32:22 +00:00
|
|
|
// might proceed with chip erase
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
/* formerly lists.h */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
General purpose linked list routines - header file declarations.
|
|
|
|
|
|
|
|
Author : Brian Dean
|
|
|
|
Date : 10 January, 1990
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
typedef void * LISTID;
|
|
|
|
typedef void * LNODEID;
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
several defines to access the LIST structure as as stack or a queue
|
|
|
|
--- use for program readability
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
#define STACKID LISTID
|
|
|
|
#define SNODEID LNODEID
|
|
|
|
#define QUEUEID LISTID
|
|
|
|
#define QNODEID LNODEID
|
|
|
|
|
|
|
|
|
|
|
|
#define PUSH(s,d) lins_n(s,d,1) /* push 'd' onto the stack */
|
|
|
|
#define POP(s) lrmv_n(s,1) /* pop the stack */
|
|
|
|
#define LOOKSTACK(s) lget_n(s,1) /* look at the top of the stack,
|
|
|
|
but don't pop */
|
|
|
|
|
|
|
|
|
|
|
|
#define ENQUEUE(q,d) lins_n(q,d,1) /* put 'd' on the end of the queue */
|
|
|
|
#define DEQUEUE(q) lrmv(q) /* remove next item from the front of
|
|
|
|
the queue */
|
|
|
|
#define REQUEUE(q,d) ladd(q,d) /* re-insert (push) item back on the
|
|
|
|
front of the queue */
|
|
|
|
#define LOOKQUEUE(q) lget(q) /* return next item on the queue,
|
|
|
|
but don't dequeue */
|
|
|
|
#define QUEUELEN(q) lsize(q) /* length of the queue */
|
|
|
|
|
|
|
|
|
|
|
|
#define LISTADD(l,d) ladd(l,d) /* add to end of the list */
|
|
|
|
#define LISTRMV(l,d) lrmv_d(l,d) /* remove from end of the list */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* .................... Function Prototypes .................... */
|
|
|
|
|
|
|
|
LISTID lcreat ( void * liststruct, int poolsize );
|
|
|
|
void ldestroy ( LISTID lid );
|
|
|
|
void ldestroy_cb ( LISTID lid, void (*ucleanup)(void * data_ptr) );
|
|
|
|
|
|
|
|
LNODEID lfirst ( LISTID ); /* head of the list */
|
|
|
|
LNODEID llast ( LISTID ); /* tail of the list */
|
|
|
|
LNODEID lnext ( LNODEID ); /* next item in the list */
|
|
|
|
LNODEID lprev ( LNODEID ); /* previous item in the list */
|
|
|
|
void * ldata ( LNODEID ); /* data at the current position */
|
|
|
|
int lsize ( LISTID ); /* number of elements in the list */
|
|
|
|
|
|
|
|
int ladd ( LISTID lid, void * p );
|
|
|
|
int laddo ( LISTID lid, void *p,
|
|
|
|
int (*compare)(const void *p1,const void *p2),
|
|
|
|
LNODEID * firstdup );
|
|
|
|
int laddu ( LISTID lid, void * p,
|
|
|
|
int (*compare)(const void *p1,const void *p2));
|
|
|
|
int lins_n ( LISTID lid, void * d, unsigned int n );
|
|
|
|
int lins_ln ( LISTID lid, LNODEID lnid, void * data_ptr );
|
|
|
|
|
|
|
|
void * lget ( LISTID lid );
|
|
|
|
void * lget_n ( LISTID lid, unsigned int n );
|
|
|
|
LNODEID lget_ln ( LISTID lid, unsigned int n );
|
|
|
|
|
|
|
|
void * lrmv ( LISTID lid );
|
|
|
|
void * lrmv_n ( LISTID lid, unsigned int n );
|
|
|
|
void * lrmv_ln ( LISTID lid, LNODEID lnid );
|
|
|
|
void * lrmv_d ( LISTID lid, void * data_ptr );
|
|
|
|
|
|
|
|
LISTID lcat ( LISTID lid1, LISTID lid2 );
|
|
|
|
|
|
|
|
void lsort ( LISTID lid, int (*compare)(void * p1, void * p2));
|
|
|
|
|
|
|
|
void * lsrch ( LISTID lid, void * p, int (*compare)(void *p1,void *p2));
|
|
|
|
|
|
|
|
int lprint ( FILE * f, LISTID lid );
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* formerly avrpart.h */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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_LOAD_EXT_ADDR,
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ctl_stack_t {
|
|
|
|
CTL_STACK_NONE, /* no control stack defined */
|
|
|
|
CTL_STACK_PP, /* parallel programming control stack */
|
|
|
|
CTL_STACK_HVSP /* high voltage serial programming control stack */
|
|
|
|
};
|
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
|
2014-05-19 10:01:59 +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;
|
|
|
|
|
|
|
|
|
2022-08-30 15:33:42 +00:00
|
|
|
// Any changes here, please also reflect in dev_part_strct() of developer_opts.c
|
|
|
|
#define AVRPART_SERIALOK 1 // Part supports serial programming
|
|
|
|
#define AVRPART_PARALLELOK 2 // Part supports parallel programming
|
|
|
|
#define AVRPART_PSEUDOPARALLEL 4 // Part has pseudo parallel support
|
|
|
|
#define AVRPART_ALLOWFULLPAGEBITSTREAM 8 // JTAG ICE mkII param
|
|
|
|
#define AVRPART_ENABLEPAGEPROGRAMMING 16 // JTAG ICE mkII param
|
|
|
|
#define AVRPART_IS_AT90S1200 32 // Part is an AT90S1200, needs special treatment
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
// Programming modes for parts and programmers: reflect changes in lexer.l, developer_opts.c and config.c
|
|
|
|
#define PM_SPM 1 // Bootloaders, self-programming with SPM opcodes or NVM Controllers
|
|
|
|
#define PM_TPI 2 // Tiny Programming Interface (t4, t5, t9, t10, t20, t40, t102, t104)
|
|
|
|
#define PM_ISP 4 // SPI programming for In-System Programming (almost all classic parts)
|
|
|
|
#define PM_PDI 8 // Program and Debug Interface (xmega parts)
|
|
|
|
#define PM_UPDI 16 // Unified Program and Debug Interface
|
|
|
|
#define PM_HVSP 32 // High Voltage Serial Programming (some classic parts)
|
|
|
|
#define PM_HVPP 64 // High Voltage Parallel Programming (most non-HVSP classic parts)
|
|
|
|
#define PM_debugWIRE 128 // Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
|
2022-09-20 17:36:46 +00:00
|
|
|
#define PM_JTAG 256 // Joint Test Action Group standard (some classic parts)
|
|
|
|
#define PM_JTAGmkI 512 // Subset of PM_JTAG, older parts, Atmel ICE mkI
|
|
|
|
#define PM_XMEGAJTAG 1024 // JTAG, some XMEGA parts
|
|
|
|
#define PM_AVR32JTAG 2048 // JTAG for 32-bit AVRs
|
|
|
|
#define PM_aWire 4096 // For 32-bit AVRs
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
|
2022-06-26 17:54:40 +00:00
|
|
|
#define HV_UPDI_VARIANT_0 0 /* Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)*/
|
|
|
|
#define HV_UPDI_VARIANT_1 1 /* Dedicated UPDI pin, no HV (megaAVR0/AVR-Dx) */
|
|
|
|
#define HV_UPDI_VARIANT_2 2 /* Shared UPDI pin, HV on _RESET (AVR-Ex) */
|
|
|
|
|
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
patch #9507: Fix UPDI chip erase
* lexer.l (family_id): New keyword.
* config_gram.y: (Ditto)
* doc/avrdude.texi: Document new keyword
* avrdude.conf.in: Add family_id for avr8x devices
* avr.c: Pass error code up.
* jtag3.c: Pass error code from memory read up; implement
jtag3_read_sib()
* libavrdude.h: Add new items.
* main.c: Implement different chip erase handling required
for UPDI devices.
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
patch #9506: Script to create device configuration stub from Atmel ATDF files
* avrdude.conf.in (ATtiny202, ATtiny204, ATtiny402, ATtiny404)
(ATtiny406, ATtiny804, ATtiny806, ATtiny807, ATtiny1604)
(ATtiny1606, ATtiny1607, ATtiny212, ATtiny214, ATtiny412)
(ATTiny414, ATtiny416, ATtiny417, ATtiny814, ATtiny816)
(ATtiny1614, ATtiny1616, ATtiny3214, ATtiny3216, ATtiny3217)
(ATmega3208, ATmega3209, ATmega4808, ATmega4809): New devices
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1405 81a1dc3b-b13d-400b-aceb-764788c761c2
2018-01-09 23:29:31 +00:00
|
|
|
#define AVR_FAMILYIDLEN 7
|
|
|
|
#define AVR_SIBLEN 16
|
2014-05-19 10:01:59 +00:00
|
|
|
#define CTL_STACK_SIZE 32
|
|
|
|
#define FLASH_INSTR_SIZE 3
|
|
|
|
#define EEPROM_INSTR_SIZE 20
|
|
|
|
|
|
|
|
#define TAG_ALLOCATED 1 /* memory byte is allocated */
|
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
/*
|
|
|
|
* Any changes in AVRPART or AVRMEM, please also ensure changes are made in
|
|
|
|
* - lexer.l
|
|
|
|
* - Either Component_t avr_comp[] of config.c or in config_gram.y
|
|
|
|
* - dev_part_strct() in developer_opts.c
|
|
|
|
* - avr_new_part() and/or avr_new_memtype() in avrpart.c for
|
|
|
|
* initialisation; note that all const char * must be initialised with ""
|
|
|
|
*/
|
2014-05-19 10:01:59 +00:00
|
|
|
typedef struct avrpart {
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
const char * desc; /* long part name */
|
|
|
|
const char * id; /* short part name */
|
2022-08-11 23:28:54 +00:00
|
|
|
LISTID comments; // Used by developer options -p*/[ASsr...]
|
|
|
|
const char * parent_id; /* Used by developer options */
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
const char * family_id; /* family id in the SIB (avr8x) */
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
int prog_modes; /* Programming interfaces, see #define PM_... */
|
|
|
|
int mcuid; /* Unique id in 0..2039 for urclock programmer */
|
|
|
|
int n_interrupts; /* Number of interrupts, used for vector bootloaders */
|
|
|
|
int n_page_erase; /* If set, number of pages erased during NVM erase */
|
2022-07-07 10:23:05 +00:00
|
|
|
int hvupdi_variant; /* HV pulse on UPDI pin, no pin or RESET pin */
|
2014-05-19 10:01:59 +00:00
|
|
|
int stk500_devcode; /* stk500 device code */
|
|
|
|
int avr910_devcode; /* avr910 device code */
|
|
|
|
int chip_erase_delay; /* microseconds */
|
|
|
|
unsigned char pagel; /* for parallel programming */
|
|
|
|
unsigned char bs2; /* for parallel programming */
|
|
|
|
unsigned char signature[3]; /* expected value of signature bytes */
|
|
|
|
unsigned short usbpid; /* USB DFU product ID (0 = none) */
|
|
|
|
int reset_disposition; /* see RESET_ enums */
|
|
|
|
int retry_pulse; /* retry program enable by pulsing
|
|
|
|
this pin (PIN_AVR_*) */
|
|
|
|
unsigned flags; /* see AVRPART_ masks */
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
enum ctl_stack_t ctl_stack_type; /* what to use the ctl stack for */
|
|
|
|
unsigned char controlstack[CTL_STACK_SIZE]; /* stk500v2 PP/HVSP ctl stack */
|
|
|
|
unsigned char flash_instr[FLASH_INSTR_SIZE]; /* flash instructions (debugWire, JTAG) */
|
|
|
|
unsigned char eeprom_instr[EEPROM_INSTR_SIZE]; /* EEPROM instructions (debugWire, JTAG) */
|
|
|
|
|
|
|
|
int hventerstabdelay; /* stk500 v2 hv mode parameter */
|
|
|
|
int progmodedelay; /* stk500 v2 hv mode parameter */
|
|
|
|
int latchcycles; /* stk500 v2 hv mode parameter */
|
|
|
|
int togglevtg; /* stk500 v2 hv mode parameter */
|
|
|
|
int poweroffdelay; /* stk500 v2 hv mode parameter */
|
|
|
|
int resetdelayms; /* stk500 v2 hv mode parameter */
|
|
|
|
int resetdelayus; /* stk500 v2 hv mode parameter */
|
|
|
|
int hvleavestabdelay; /* stk500 v2 hv mode parameter */
|
|
|
|
int resetdelay; /* stk500 v2 hv mode parameter */
|
|
|
|
int chiperasepulsewidth; /* stk500 v2 hv mode parameter */
|
|
|
|
int chiperasepolltimeout; /* stk500 v2 hv mode parameter */
|
|
|
|
int chiperasetime; /* stk500 v2 hv mode parameter */
|
|
|
|
int programfusepulsewidth; /* stk500 v2 hv mode parameter */
|
|
|
|
int programfusepolltimeout; /* stk500 v2 hv mode parameter */
|
|
|
|
int programlockpulsewidth; /* stk500 v2 hv mode parameter */
|
|
|
|
int programlockpolltimeout; /* stk500 v2 hv mode parameter */
|
|
|
|
int synchcycles; /* stk500 v2 hv mode parameter */
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
int hvspcmdexedelay; /* stk500 v2 hv mode file parameter */
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
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 */
|
2022-08-09 12:19:40 +00:00
|
|
|
unsigned char eecr; /* JTAC ICE mkII XML file parameter */
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned int mcu_base; /* Base address of MCU control block in ATxmega devices */
|
|
|
|
unsigned int nvm_base; /* Base address of NVM controller in ATxmega devices */
|
2017-11-29 23:09:51 +00:00
|
|
|
unsigned int ocd_base; /* Base address of OCD module in AVR8X/UPDI devices */
|
2014-05-19 10:01:59 +00:00
|
|
|
int ocdrev; /* OCD revision (JTAGICE3 parameter, from AS6 XML files) */
|
|
|
|
|
|
|
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
|
|
|
|
|
|
|
LISTID mem; /* avr memory definitions */
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
LISTID mem_alias; /* memory alias definitions */
|
2022-08-07 13:05:54 +00:00
|
|
|
const char * config_file; /* config file where defined */
|
2022-07-18 17:10:09 +00:00
|
|
|
int lineno; /* config file line number */
|
2014-05-19 10:01:59 +00:00
|
|
|
} AVRPART;
|
|
|
|
|
|
|
|
typedef struct avrmem {
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
const char *desc; /* memory description ("flash", "eeprom", etc) */
|
2022-08-11 23:28:54 +00:00
|
|
|
LISTID comments; // Used by developer options -p*/[ASsr...]
|
2014-05-19 10:01:59 +00:00
|
|
|
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) */
|
|
|
|
unsigned int offset; /* offset in IO memory (ATxmega) */
|
|
|
|
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/dyn/resources/prod_documents/doc1280.pdf */
|
|
|
|
unsigned char readback[2]; /* polled read-back values */
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
unsigned char * buf; /* pointer to memory buffer */
|
|
|
|
unsigned char * tags; /* allocation tags */
|
|
|
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
|
|
|
} AVRMEM;
|
|
|
|
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
typedef struct avrmem_alias {
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
const char *desc; /* alias name ("syscfg0" etc.) */
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
AVRMEM *aliased_mem;
|
|
|
|
} AVRMEM_ALIAS;
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 22:55:42 +00:00
|
|
|
|
|
|
|
int intlog2(unsigned int n);
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
/* Functions for OPCODE structures */
|
|
|
|
OPCODE * avr_new_opcode(void);
|
|
|
|
void avr_free_opcode(OPCODE * op);
|
2022-08-23 15:57:09 +00:00
|
|
|
int avr_set_bits(const OPCODE *op, unsigned char *cmd);
|
|
|
|
int avr_set_addr(const OPCODE *op, unsigned char *cmd, unsigned long addr);
|
|
|
|
int avr_set_addr_mem(const AVRMEM *mem, int opnum, unsigned char *cmd, unsigned long addr);
|
|
|
|
int avr_set_input(const OPCODE *op, unsigned char *cmd, unsigned char data);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
int avr_get_output(const OPCODE *op, const unsigned char *res, unsigned char *data);
|
|
|
|
int avr_get_output_index(const OPCODE *op);
|
2022-07-26 22:55:42 +00:00
|
|
|
char cmdbitchar(CMDBIT cb);
|
|
|
|
char *cmdbitstr(CMDBIT cb);
|
|
|
|
const char *opcodename(int opnum);
|
2022-08-23 15:57:09 +00:00
|
|
|
char *opcode2str(const OPCODE *op, int opnum, int detailed);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
/* Functions for AVRMEM structures */
|
|
|
|
AVRMEM * avr_new_memtype(void);
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
AVRMEM_ALIAS * avr_new_memalias(void);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
int avr_initmem(const AVRPART *p);
|
|
|
|
AVRMEM * avr_dup_mem(const AVRMEM *m);
|
2014-05-19 10:01:59 +00:00
|
|
|
void avr_free_mem(AVRMEM * m);
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
void avr_free_memalias(AVRMEM_ALIAS * m);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
AVRMEM * avr_locate_mem(const AVRPART *p, const char *desc);
|
|
|
|
AVRMEM * avr_locate_mem_noalias(const AVRPART *p, const char *desc);
|
|
|
|
AVRMEM_ALIAS * avr_locate_memalias(const AVRPART *p, const char *desc);
|
|
|
|
AVRMEM_ALIAS * avr_find_memalias(const AVRPART *p, const AVRMEM *m_orig);
|
|
|
|
void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
|
|
|
|
const AVRPART *p, int verbose);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
/* Functions for AVRPART structures */
|
|
|
|
AVRPART * avr_new_part(void);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
AVRPART * avr_dup_part(const AVRPART *d);
|
2014-05-19 10:01:59 +00:00
|
|
|
void avr_free_part(AVRPART * d);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
AVRPART * locate_part(const LISTID parts, const char *partdesc);
|
|
|
|
AVRPART * locate_part_by_avr910_devcode(const LISTID parts, int devcode);
|
|
|
|
AVRPART * locate_part_by_signature(const LISTID parts, unsigned char *sig,
|
2014-08-18 21:43:08 +00:00
|
|
|
int sigsize);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
void avr_display(FILE *f, const AVRPART *p, const char *prefix, int verbose);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
typedef void (*walk_avrparts_cb)(const char *name, const char *desc,
|
|
|
|
const char *cfgname, int cfglineno,
|
|
|
|
void *cookie);
|
|
|
|
void walk_avrparts(LISTID avrparts, walk_avrparts_cb cb, void *cookie);
|
|
|
|
void sort_avrparts(LISTID avrparts);
|
2021-11-12 22:02:29 +00:00
|
|
|
|
2022-07-26 22:55:42 +00:00
|
|
|
int part_match(const char *pattern, const char *string);
|
|
|
|
|
2021-11-12 22:02:29 +00:00
|
|
|
int compare_memory_masked(AVRMEM * m, uint8_t buf1, uint8_t buf2);
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* formerly pindefs.h */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PPI_AVR_VCC = 1,
|
|
|
|
PPI_AVR_BUFF,
|
|
|
|
PIN_AVR_RESET,
|
|
|
|
PIN_AVR_SCK,
|
|
|
|
PIN_AVR_MOSI,
|
|
|
|
PIN_AVR_MISO,
|
|
|
|
PIN_LED_ERR,
|
|
|
|
PIN_LED_RDY,
|
|
|
|
PIN_LED_PGM,
|
|
|
|
PIN_LED_VFY,
|
|
|
|
N_PINS
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PIN_MASK (UINT_MAX>>1)
|
|
|
|
#define PIN_INVERSE (~(PIN_MASK)) /* flag for inverted pin in serbb */
|
|
|
|
#define PIN_MIN 0 /* smallest allowed pin number */
|
|
|
|
#define PIN_MAX 31 /* largest allowed pin number */
|
|
|
|
|
|
|
|
#ifdef HAVE_LINUXGPIO
|
|
|
|
/* Embedded systems might have a lot more gpio than only 0-31 */
|
|
|
|
#undef PIN_MAX
|
2021-11-27 21:54:56 +00:00
|
|
|
#define PIN_MAX 400 /* largest allowed pin number */
|
2014-05-19 10:01:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Number of pins in each element of the bitfield */
|
|
|
|
#define PIN_FIELD_ELEMENT_SIZE (sizeof(pinmask_t) * 8)
|
|
|
|
/** Numer of elements to store the complete bitfield of all pins */
|
|
|
|
#define PIN_FIELD_SIZE ((PIN_MAX + PIN_FIELD_ELEMENT_SIZE)/PIN_FIELD_ELEMENT_SIZE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This sets the corresponding bits to 1 or 0, the inverse mask is used to invert the value in necessary.
|
|
|
|
* It uses only the lowest element (index=0) of the bitfield, which should be enough for most
|
|
|
|
* programmers.
|
|
|
|
*
|
|
|
|
* @param[in] x input value
|
|
|
|
* @param[in] pgm the programmer whose pin definitions to use
|
|
|
|
* @param[in] pinname the logical name of the pin (PIN_AVR_*, ...)
|
|
|
|
* @param[in] level the logical level (level != 0 => 1, level == 0 => 0),
|
|
|
|
* if the pin is defined as inverted the resulting bit is also inverted
|
|
|
|
* @returns the input value with the relevant bits modified
|
|
|
|
*/
|
|
|
|
#define SET_BITS_0(x,pgm,pinname,level) (((x) & ~(pgm)->pin[pinname].mask[0]) \
|
|
|
|
| (\
|
|
|
|
(pgm)->pin[pinname].mask[0] & ( \
|
|
|
|
(level) \
|
|
|
|
?~((pgm)->pin[pinname].inverse[0]) \
|
|
|
|
: ((pgm)->pin[pinname].inverse[0]) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the corresponding bit is set (returns != 0) or cleared.
|
|
|
|
* The inverse mask is used, to invert the relevant bits.
|
|
|
|
* If the pin definition contains multiple pins, then a single set pin leads to return value != 0.
|
|
|
|
* Then you have to check the relevant bits of the returned value, if you need more information.
|
|
|
|
* It uses only the lowest element (index=0) of the bitfield, which should be enough for most
|
|
|
|
* programmers.
|
|
|
|
*
|
|
|
|
* @param[in] x input value
|
|
|
|
* @param[in] pgm the programmer whose pin definitions to use
|
|
|
|
* @param[in] pinname the logical name of the pin (PIN_AVR_*, ...)
|
|
|
|
* @returns the input value with only the relevant bits (which are already inverted,
|
|
|
|
* so you get always the logical level)
|
|
|
|
*/
|
|
|
|
#define GET_BITS_0(x,pgm,pinname) (((x) ^ (pgm)->pin[pinname].inverse[0]) & (pgm)->pin[pinname].mask[0])
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data structure to hold used pins by logical function (PIN_AVR_*, ...)
|
|
|
|
*/
|
|
|
|
struct pindef_t {
|
|
|
|
pinmask_t mask[PIN_FIELD_SIZE]; ///< bitfield of used pins
|
|
|
|
pinmask_t inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data structure to define a checklist of valid pins for each function.
|
|
|
|
*/
|
|
|
|
struct pin_checklist_t {
|
|
|
|
int pinname; ///< logical pinname eg. PIN_AVR_SCK
|
|
|
|
int mandatory; ///< is this a mandatory pin
|
|
|
|
const struct pindef_t* valid_pins; ///< mask defines allowed pins, inverse define is they might be used inverted
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a pin in the pin definition as normal or inverse pin.
|
|
|
|
*
|
|
|
|
* @param[out] pindef pin definition to update
|
|
|
|
* @param[in] pin number of pin [0..PIN_MAX]
|
|
|
|
* @param[in] inverse inverse (true) or normal (false) pin
|
|
|
|
*/
|
|
|
|
void pin_set_value(struct pindef_t * const pindef, const int pin, const bool inverse);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear all defined pins in pindef.
|
|
|
|
*
|
|
|
|
* @param[out] pindef pin definition to clear
|
|
|
|
*/
|
|
|
|
void pin_clear_all(struct pindef_t * const pindef);
|
|
|
|
|
|
|
|
struct programmer_t; /* forward declaration */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert for given programmer new pin definitions to old pin definitions.
|
|
|
|
*
|
|
|
|
* @param[inout] pgm programmer whose pins shall be converted.
|
|
|
|
*/
|
|
|
|
int pgm_fill_old_pins(struct programmer_t * const pgm);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function checks all pin of pgm against the constraints given in the checklist.
|
|
|
|
* It checks if
|
|
|
|
* @li any invalid pins are used
|
|
|
|
* @li valid pins are used inverted when not allowed
|
|
|
|
* @li any pins are used by more than one function
|
|
|
|
* @li any mandatory pin is not set all.
|
|
|
|
*
|
|
|
|
* In case of any error it report the wrong function and the pin numbers.
|
|
|
|
* For verbose >= 2 it also reports the possible correct values.
|
|
|
|
* For verbose >=3 it shows also which pins were ok.
|
|
|
|
*
|
|
|
|
* @param[in] pgm the programmer to check
|
|
|
|
* @param[in] checklist the constraint for the pins
|
|
|
|
* @param[in] size the number of entries in checklist
|
|
|
|
* @param[in] output false suppresses error messages to the user
|
|
|
|
* @returns 0 if all pin definitions are valid, -1 otherwise
|
|
|
|
*/
|
|
|
|
int pins_check(const struct programmer_t * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the pin as string.
|
|
|
|
*
|
|
|
|
* @param pinname the pinname which we want as string.
|
|
|
|
* @returns a string with the pinname, or <unknown> if pinname is invalid.
|
|
|
|
*/
|
|
|
|
const char * avr_pin_name(int pinname);
|
|
|
|
|
|
|
|
/**
|
2022-08-08 15:52:09 +00:00
|
|
|
* Returns the name of the pin as lowercase string.
|
|
|
|
*
|
|
|
|
* @param pinname the pinname which we want as string.
|
|
|
|
* @returns a lowercase string with the pinname, or <unknown> if pinname is invalid.
|
|
|
|
*/
|
|
|
|
const char * avr_pin_lcname(int pinname);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function returns a string of defined pins, eg, ~1,2,~4,~5,7 or " (not used)"
|
2014-05-19 10:01:59 +00:00
|
|
|
* Another execution of this function will overwrite the previous result in the static buffer.
|
|
|
|
*
|
|
|
|
* @param[in] pindef the pin definition for which we want the string representation
|
|
|
|
* @returns pointer to a static string.
|
|
|
|
*/
|
|
|
|
const char * pins_to_str(const struct pindef_t * const pindef);
|
|
|
|
|
|
|
|
/**
|
2022-08-08 15:52:09 +00:00
|
|
|
* This function returns a string of defined pins, eg, ~1, 2, ~4, ~5, 7 or ""
|
|
|
|
*
|
|
|
|
* @param[in] pindef the pin definition for which we want the string representation
|
2022-08-09 20:20:44 +00:00
|
|
|
* @returns a pointer to a string, which was created by strdup
|
2022-08-08 15:52:09 +00:00
|
|
|
*/
|
|
|
|
char *pins_to_strdup(const struct pindef_t * const pindef);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function returns a string representation of pins in the mask, eg, 1,3,5-7,9,12
|
2014-05-19 10:01:59 +00:00
|
|
|
* Another execution of this function will overwrite the previous result in the static buffer.
|
2022-08-08 15:52:09 +00:00
|
|
|
* Consecutive pin number are represented as start-end.
|
2014-05-19 10:01:59 +00:00
|
|
|
*
|
|
|
|
* @param[in] pinmask the pin mask for which we want the string representation
|
|
|
|
* @returns pointer to a static string.
|
|
|
|
*/
|
|
|
|
const char * pinmask_to_str(const pinmask_t * const pinmask);
|
|
|
|
|
|
|
|
/* formerly serial.h */
|
|
|
|
|
|
|
|
/* This is the API for the generic serial interface. The implementations are
|
|
|
|
actually provided by the target dependant files:
|
|
|
|
|
|
|
|
ser_posix.c : posix serial interface.
|
|
|
|
ser_win32.c : native win32 serial interface.
|
|
|
|
|
|
|
|
The target file will be selected at configure time. */
|
|
|
|
|
|
|
|
extern long serial_recv_timeout;
|
|
|
|
union filedescriptor
|
|
|
|
{
|
|
|
|
int ifd;
|
|
|
|
void *pfd;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
void *handle;
|
|
|
|
int rep; /* bulk read endpoint */
|
|
|
|
int wep; /* bulk write endpoint */
|
|
|
|
int eep; /* event read endpoint */
|
|
|
|
int max_xfer; /* max transfer size */
|
|
|
|
int use_interrupt_xfer; /* device uses interrupt transfers */
|
|
|
|
} usb;
|
|
|
|
};
|
|
|
|
|
2021-12-08 10:09:52 +00:00
|
|
|
#define SERIAL_CS5 0x0000
|
|
|
|
#define SERIAL_CS6 0x0001
|
|
|
|
#define SERIAL_CS7 0x0002
|
|
|
|
#define SERIAL_CS8 0x0004
|
|
|
|
|
|
|
|
#define SERIAL_NO_CSTOPB 0x0000
|
|
|
|
#define SERIAL_CSTOPB 0x0008
|
|
|
|
|
|
|
|
#define SERIAL_NO_CREAD 0x0000
|
|
|
|
#define SERIAL_CREAD 0x0010
|
|
|
|
|
|
|
|
#define SERIAL_NO_PARITY 0x0000
|
|
|
|
#define SERIAL_PARENB 0x0020
|
|
|
|
#define SERIAL_PARODD 0x0040
|
|
|
|
|
|
|
|
#define SERIAL_NO_CLOCAL 0x0000
|
|
|
|
#define SERIAL_CLOCAL 0x0080
|
|
|
|
|
|
|
|
#define SERIAL_8N1 (SERIAL_CS8 | SERIAL_NO_CSTOPB | SERIAL_CREAD | SERIAL_NO_PARITY | SERIAL_CLOCAL)
|
|
|
|
#define SERIAL_8E1 (SERIAL_CS8 | SERIAL_NO_CSTOPB | SERIAL_CREAD | SERIAL_PARENB | SERIAL_CLOCAL)
|
|
|
|
#define SERIAL_8E2 (SERIAL_CS8 | SERIAL_CSTOPB | SERIAL_CREAD | SERIAL_PARENB | SERIAL_CLOCAL)
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
union pinfo
|
|
|
|
{
|
2021-12-08 10:09:52 +00:00
|
|
|
struct {
|
|
|
|
long baud;
|
|
|
|
unsigned long cflags;
|
|
|
|
} serialinfo;
|
2014-05-19 10:01:59 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned short vid;
|
|
|
|
unsigned short pid;
|
|
|
|
unsigned short flags;
|
|
|
|
#define PINFO_FL_USEHID 0x0001
|
|
|
|
#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */
|
|
|
|
} usbinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
struct serial_device {
|
2014-05-19 10:01:59 +00:00
|
|
|
// open should return -1 on error, other values on success
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*open)(const char *port, union pinfo pinfo, union filedescriptor *fd);
|
|
|
|
int (*setparams)(const union filedescriptor *fd, long baud, unsigned long cflags);
|
2014-05-19 10:01:59 +00:00
|
|
|
void (*close)(union filedescriptor *fd);
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*send)(const union filedescriptor *fd, const unsigned char * buf, size_t buflen);
|
|
|
|
int (*recv)(const union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
|
|
|
int (*drain)(const union filedescriptor *fd, int display);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*set_dtr_rts)(const union filedescriptor *fd, int is_on);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
int flags;
|
|
|
|
#define SERDEV_FL_NONE 0x0000 /* no flags */
|
|
|
|
#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct serial_device *serdev;
|
|
|
|
extern struct serial_device serial_serdev;
|
|
|
|
extern struct serial_device usb_serdev;
|
|
|
|
extern struct serial_device usb_serdev_frame;
|
|
|
|
extern struct serial_device avrdoper_serdev;
|
2016-02-20 22:50:13 +00:00
|
|
|
extern struct serial_device usbhid_serdev;
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
#define serial_open (serdev->open)
|
2021-12-08 10:09:52 +00:00
|
|
|
#define serial_setparams (serdev->setparams)
|
2014-05-19 10:01:59 +00:00
|
|
|
#define serial_close (serdev->close)
|
|
|
|
#define serial_send (serdev->send)
|
|
|
|
#define serial_recv (serdev->recv)
|
|
|
|
#define serial_drain (serdev->drain)
|
|
|
|
#define serial_set_dtr_rts (serdev->set_dtr_rts)
|
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
// See avrcache.c
|
|
|
|
typedef struct { // Memory cache for a subset of cached pages
|
|
|
|
int size, page_size; // Size of cache (flash or eeprom size) and page size
|
|
|
|
unsigned int offset; // Offset of flash/eeprom memory
|
|
|
|
unsigned char *cont, *copy; // current memory contens and device copy of it
|
|
|
|
unsigned char *iscached; // iscached[i] set when page i has been loaded
|
|
|
|
} AVR_Cache;
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
/* formerly pgm.h */
|
|
|
|
|
|
|
|
#define ON 1
|
|
|
|
#define OFF 0
|
|
|
|
|
|
|
|
#define PGM_PORTLEN PATH_MAX
|
|
|
|
#define PGM_TYPELEN 32
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EXIT_VCC_UNSPEC,
|
|
|
|
EXIT_VCC_ENABLED,
|
|
|
|
EXIT_VCC_DISABLED
|
|
|
|
} exit_vcc_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EXIT_RESET_UNSPEC,
|
|
|
|
EXIT_RESET_ENABLED,
|
|
|
|
EXIT_RESET_DISABLED
|
|
|
|
} exit_reset_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EXIT_DATAHIGH_UNSPEC,
|
|
|
|
EXIT_DATAHIGH_ENABLED,
|
|
|
|
EXIT_DATAHIGH_DISABLED
|
|
|
|
} exit_datahigh_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CONNTYPE_PARALLEL,
|
|
|
|
CONNTYPE_SERIAL,
|
2022-04-10 21:36:53 +00:00
|
|
|
CONNTYPE_USB,
|
|
|
|
CONNTYPE_SPI
|
2014-05-19 10:01:59 +00:00
|
|
|
} conntype_t;
|
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
/*
|
|
|
|
* Any changes in PROGRAMMER, please also ensure changes are made in
|
|
|
|
* - lexer.l
|
|
|
|
* - Either Component_t avr_comp[] of config.c or config_gram.y
|
|
|
|
* - dev_pgm_strct() in developer_opts.c
|
|
|
|
* - pgm_new() in pgm.c for initialisation; note that all const char * must
|
|
|
|
* be initialised with ""
|
|
|
|
*/
|
2014-05-19 10:01:59 +00:00
|
|
|
typedef struct programmer_t {
|
|
|
|
LISTID id;
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
const char *desc;
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
void (*initpgm)(struct programmer_t *pgm); // Sets up the AVRDUDE programmer
|
|
|
|
LISTID comments; // Used by developer options -c*/[ASsr...]
|
2022-08-11 23:28:54 +00:00
|
|
|
const char *parent_id; // Used by developer options
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
int prog_modes; // Programming interfaces, see #define PM_...
|
2014-05-19 10:01:59 +00:00
|
|
|
struct pindef_t pin[N_PINS];
|
|
|
|
conntype_t conntype;
|
|
|
|
int baudrate;
|
|
|
|
int usbvid;
|
|
|
|
LISTID usbpid;
|
2022-08-08 15:52:09 +00:00
|
|
|
const char *usbdev;
|
|
|
|
const char *usbsn;
|
|
|
|
const char *usbvendor;
|
|
|
|
const char *usbproduct;
|
|
|
|
LISTID hvupdi_support; // List of UPDI HV variants the tool supports, see HV_UPDI_VARIANT_x
|
2022-08-07 16:52:17 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
// Values below are not set by config_gram.y; ensure fd is first for dev_pgm_raw()
|
2014-05-19 10:01:59 +00:00
|
|
|
union filedescriptor fd;
|
2022-08-08 15:52:09 +00:00
|
|
|
char type[PGM_TYPELEN];
|
|
|
|
char port[PGM_PORTLEN];
|
|
|
|
unsigned int pinno[N_PINS]; // TODO to be removed if old pin data no longer needed
|
|
|
|
exit_vcc_t exit_vcc; // Should these be set in avrdude.conf?
|
|
|
|
exit_reset_t exit_reset;
|
|
|
|
exit_datahigh_t exit_datahigh;
|
|
|
|
int ppidata;
|
|
|
|
int ppictrl;
|
|
|
|
int ispdelay; // ISP clock delay
|
|
|
|
int page_size; // Page size if the programmer supports paged write/load
|
|
|
|
double bitclock; // JTAG ICE clock period in microseconds
|
2022-08-07 16:52:17 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*rdy_led) (const struct programmer_t *pgm, int value);
|
|
|
|
int (*err_led) (const struct programmer_t *pgm, int value);
|
|
|
|
int (*pgm_led) (const struct programmer_t *pgm, int value);
|
|
|
|
int (*vfy_led) (const struct programmer_t *pgm, int value);
|
|
|
|
int (*initialize) (const struct programmer_t *pgm, const AVRPART *p); // Sets up the physical programmer
|
|
|
|
void (*display) (const struct programmer_t *pgm, const char *p);
|
|
|
|
void (*enable) (struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
void (*disable) (const struct programmer_t *pgm);
|
|
|
|
void (*powerup) (const struct programmer_t *pgm);
|
|
|
|
void (*powerdown) (const struct programmer_t *pgm);
|
|
|
|
int (*program_enable) (const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
int (*chip_erase) (const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
int (*unlock) (const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
int (*cmd) (const struct programmer_t *pgm, const unsigned char *cmd,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned char *res);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*cmd_tpi) (const struct programmer_t *pgm, const unsigned char *cmd,
|
2014-05-19 10:01:59 +00:00
|
|
|
int cmd_len, unsigned char res[], int res_len);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*spi) (const struct programmer_t *pgm, const unsigned char *cmd,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned char *res, int count);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*open) (struct programmer_t *pgm, const char *port);
|
|
|
|
void (*close) (struct programmer_t *pgm);
|
|
|
|
int (*paged_write) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned int page_size, unsigned int baseaddr,
|
|
|
|
unsigned int n_bytes);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*paged_load) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned int page_size, unsigned int baseaddr,
|
|
|
|
unsigned int n_bytes);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*page_erase) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned int baseaddr);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
void (*write_setup) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m);
|
|
|
|
int (*write_byte) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned long addr, unsigned char value);
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int (*read_byte) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
|
|
|
unsigned long addr, unsigned char *value);
|
|
|
|
int (*read_sig_bytes) (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m);
|
|
|
|
int (*read_sib) (const struct programmer_t *pgm, const AVRPART *p, char *sib);
|
|
|
|
void (*print_parms) (const struct programmer_t *pgm);
|
|
|
|
int (*set_vtarget) (const struct programmer_t *pgm, double v);
|
|
|
|
int (*set_varef) (const struct programmer_t *pgm, unsigned int chan, double v);
|
|
|
|
int (*set_fosc) (const struct programmer_t *pgm, double v);
|
|
|
|
int (*set_sck_period) (const struct programmer_t *pgm, double v);
|
|
|
|
int (*setpin) (const struct programmer_t *pgm, int pinfunc, int value);
|
|
|
|
int (*getpin) (const struct programmer_t *pgm, int pinfunc);
|
|
|
|
int (*highpulsepin) (const struct programmer_t *pgm, int pinfunc);
|
|
|
|
int (*parseexitspecs) (struct programmer_t *pgm, const char *s);
|
|
|
|
int (*perform_osccal) (const struct programmer_t *pgm);
|
|
|
|
int (*parseextparams) (const struct programmer_t *pgm, const LISTID xparams);
|
|
|
|
void (*setup) (struct programmer_t *pgm);
|
|
|
|
void (*teardown) (struct programmer_t *pgm);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
// Cached r/w API for terminal reads/writes
|
|
|
|
int (*write_byte_cached)(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
|
|
|
unsigned long addr, unsigned char value);
|
|
|
|
int (*read_byte_cached)(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
|
|
|
|
unsigned long addr, unsigned char *value);
|
|
|
|
int (*chip_erase_cached)(const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
int (*flush_cache) (const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
int (*reset_cache) (const struct programmer_t *pgm, const AVRPART *p);
|
|
|
|
AVR_Cache *cp_flash, *cp_eeprom;
|
|
|
|
|
2022-08-07 16:52:17 +00:00
|
|
|
const char *config_file; // Config file where defined
|
|
|
|
int lineno; // Config file line number
|
|
|
|
void *cookie; // For private use by the programmer
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
char flag; // For use by pgm->initpgm()
|
2014-05-19 10:01:59 +00:00
|
|
|
} PROGRAMMER;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PROGRAMMER * pgm_new(void);
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
PROGRAMMER * pgm_dup(const PROGRAMMER *src);
|
|
|
|
void pgm_free(PROGRAMMER *p);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
void programmer_display(PROGRAMMER * pgm, const char * p);
|
|
|
|
|
|
|
|
/* show is a mask like this (1<<PIN_AVR_SCK)|(1<<PIN_AVR_MOSI)| ... */
|
|
|
|
#define SHOW_ALL_PINS (~0u)
|
|
|
|
#define SHOW_PPI_PINS ((1<<PPI_AVR_VCC)|(1<<PPI_AVR_BUFF))
|
|
|
|
#define SHOW_AVR_PINS ((1<<PIN_AVR_RESET)|(1<<PIN_AVR_SCK)|(1<<PIN_AVR_MOSI)|(1<<PIN_AVR_MISO))
|
|
|
|
#define SHOW_LED_PINS ((1<<PIN_LED_ERR)|(1<<PIN_LED_RDY)|(1<<PIN_LED_PGM)|(1<<PIN_LED_VFY))
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
void pgm_display_generic_mask(const PROGRAMMER *pgm, const char *p, unsigned int show);
|
|
|
|
void pgm_display_generic(const PROGRAMMER *pgm, const char *p);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.
config_gram.y now only needs to consider one type of string assignment.
This commit also
- Replaces the simple linear-search cache_string() function with faster
hashed cache_string(). Either way, the returned value is likely to be
shared, so should never be free()'d.
- Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()
- Adds const qualifier to some function args in avrpart.c and pgm.c
- Hardens some functions against being called with NULL pointers
- Ensures _new() and _dup() functions for parts, programmers and memory
return a suitable memory. Out of memory triggers exit in one of three
functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
rarely anything useful that AVRDUDE or, for that matter, any
application compiled against libavrdude can do once you run out of
memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 15:14:56 +00:00
|
|
|
PROGRAMMER *locate_programmer(const LISTID programmers, const char *configid);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
typedef void (*walk_programmers_cb)(const char *name, const char *desc,
|
|
|
|
const char *cfgname, int cfglineno,
|
|
|
|
void *cookie);
|
|
|
|
void walk_programmers(LISTID programmers, walk_programmers_cb cb, void *cookie);
|
|
|
|
|
|
|
|
void sort_programmers(LISTID programmers);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* formerly avr.h */
|
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
typedef void (*FP_UpdateProgress)(int percent, double etime, const char *hdr, int finish);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
extern struct avrpart parts[];
|
2022-08-02 22:53:00 +00:00
|
|
|
extern const char *avr_mem_order[100];
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
extern FP_UpdateProgress update_progress;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_tpi_poll_nvmbsy(const PROGRAMMER *pgm);
|
|
|
|
int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p);
|
|
|
|
int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned char guard_time);
|
|
|
|
int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned long addr, unsigned char * value);
|
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
int avr_read_mem(const PROGRAMMER * pgm, const AVRPART *p, const AVRMEM *mem, const AVRPART *v);
|
|
|
|
|
|
|
|
int avr_read(const PROGRAMMER * pgm, const AVRPART *p, const char *memtype, const AVRPART *v);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_write_page(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned long addr);
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned long addr, unsigned char data);
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
2014-05-19 10:01:59 +00:00
|
|
|
unsigned long addr, unsigned char data);
|
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int size, int auto_erase);
|
|
|
|
|
|
|
|
int avr_write(const PROGRAMMER *pgm, const AVRPART *p, const char *memtype, int size, int auto_erase);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_signature(const PROGRAMMER *pgm, const AVRPART *p);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_verify(const AVRPART * p, const AVRPART * v, const char * memtype, int size);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_get_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int *cycles);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
2022-08-02 22:53:00 +00:00
|
|
|
void avr_add_mem_order(const char *str);
|
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_mem_is_flash_type(const AVRMEM *mem);
|
2022-08-15 13:57:04 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_mem_is_eeprom_type(const AVRMEM *mem);
|
2022-08-15 13:57:04 +00:00
|
|
|
|
2022-08-02 23:04:14 +00:00
|
|
|
int avr_mem_is_known(const char *str);
|
2022-08-15 13:57:04 +00:00
|
|
|
|
2022-08-03 23:14:19 +00:00
|
|
|
int avr_mem_might_be_known(const char *str);
|
2022-08-02 22:53:00 +00:00
|
|
|
|
2022-04-28 16:26:09 +00:00
|
|
|
#define disable_trailing_ff_removal() avr_mem_hiaddr(NULL)
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_mem_hiaddr(const AVRMEM * mem);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_chip_erase(const PROGRAMMER *pgm, const AVRPART *p);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
int avr_unlock(const PROGRAMMER *pgm, const AVRPART *p);
|
2018-01-16 21:17:04 +00:00
|
|
|
|
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char *value);
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
AVRMEM *mem, unsigned long addr, unsigned char data);
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.
avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.
avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase.
For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.
Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 21:16:15 +00:00
|
|
|
void report_progress(int completed, int total, const char *hdr);
|
|
|
|
|
|
|
|
int avr_has_paged_access(const PROGRAMMER *pgm, const AVRMEM *m);
|
|
|
|
|
|
|
|
int avr_read_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int addr, unsigned char *buf);
|
|
|
|
|
|
|
|
int avr_write_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int addr, unsigned char *data);
|
|
|
|
|
|
|
|
int avr_is_and(const unsigned char *s1, const unsigned char *s2, const unsigned char *s3, size_t n);
|
|
|
|
|
|
|
|
// byte-wise cached read/write API
|
|
|
|
int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char *value);
|
|
|
|
int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char data);
|
|
|
|
int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
|
|
|
|
int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);
|
|
|
|
int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* formerly fileio.h */
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FMT_AUTO,
|
|
|
|
FMT_SREC,
|
|
|
|
FMT_IHEX,
|
|
|
|
FMT_RBIN,
|
|
|
|
FMT_IMM,
|
|
|
|
FMT_HEX,
|
|
|
|
FMT_DEC,
|
|
|
|
FMT_OCT,
|
|
|
|
FMT_BIN,
|
2022-07-16 22:40:36 +00:00
|
|
|
FMT_ELF,
|
|
|
|
FMT_IHXC,
|
2014-05-19 10:01:59 +00:00
|
|
|
} FILEFMT;
|
|
|
|
|
|
|
|
struct fioparms {
|
|
|
|
int op;
|
|
|
|
char * mode;
|
|
|
|
char * iodesc;
|
|
|
|
char * dir;
|
|
|
|
char * rw;
|
|
|
|
unsigned int fileoffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
FIO_READ,
|
2022-04-28 16:53:10 +00:00
|
|
|
FIO_WRITE,
|
|
|
|
FIO_READ_FOR_VERIFY,
|
2014-05-19 10:01:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-08-05 16:38:59 +00:00
|
|
|
char * fileio_fmtstr(FILEFMT format);
|
|
|
|
|
|
|
|
int fileio_fmt_autodetect(const char * fname);
|
2014-05-19 10:01:59 +00:00
|
|
|
|
2022-04-28 16:53:10 +00:00
|
|
|
int fileio(int oprwv, char * filename, FILEFMT format,
|
2014-05-19 10:01:59 +00:00
|
|
|
struct avrpart * p, char * memtype, int size);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* formerly update.h */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
DEVICE_READ,
|
|
|
|
DEVICE_WRITE,
|
|
|
|
DEVICE_VERIFY
|
|
|
|
};
|
|
|
|
|
|
|
|
enum updateflags {
|
|
|
|
UF_NONE = 0,
|
|
|
|
UF_NOWRITE = 1,
|
|
|
|
UF_AUTO_ERASE = 2,
|
Enable stdin verification and display correct number of bytes written/verified
Counting the number of bytes written to a memory and/or verified is not
trivial owing to potential holes in the input file and to potential trailing
0xff bytes in flash memory that are not written per default (but see -A). The
new function memstats(), which is best called just after an input file has
been read into mem->buf/mem->tags, computes the right number of bytes written
and allows easy computation of the number of bytes verified.
This commit also changes the strategy for the default verification after
writing to a chip memory, so that the input file only needs reading once thus
enabling successful verification of stdin input files.
Other, minor changes:
- Improving the grammar of AVRDUDE output, eg, 1 byte written instead of
1 bytes written
- Better description of the input file structure in terms of its sections,
the interval it spans, the number of pages, the number of padding bytes
in pages, and the number of actually cut off trailing 0xff bytes for flash
- Printing <stdin> or <stdout> instead of - in the -U routines
- Option -V no longer needs to be specified before option -U in order to work
As an aside this commit also provides useful helper functions for printing
plural(), inname(), outname() and interval() all of which return strings fit
for printing.
$ avrdude -qp ATmega2560 -c usbtiny -U blink-mega2560+lext-test.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file blink-mega2560+lext-test.hex auto detected as Intel Hex
avrdude: reading input file blink-mega2560+lext-test.hex for flash
with 1346 bytes in 4 sections within [0, 0x3106d]
using 7 pages and 446 pad bytes
avrdude: writing 1346 bytes flash ...
avrdude: 1346 bytes of flash written
avrdude: verifying flash memory against blink-mega2560+lext-test.hex
avrdude: 1346 bytes of flash verified
avrdude done. Thank you.
$ avrdude -qp ATmega328P -c usb-bub-ii -U sketch-ending-in-ff.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file sketch-ending-in-ff.hex auto detected as Intel Hex
avrdude: reading input file sketch-ending-in-ff.hex for flash
with 2160 bytes in 1 section within [0, 0x888]
using 17 pages and 16 pad bytes, cutting off 25 trailing 0xff bytes
avrdude: writing 2160 bytes flash ...
avrdude: 2160 bytes of flash written
avrdude: verifying flash memory against sketch-ending-in-ff.hex
avrdude: 2185 bytes of flash verified
avrdude done. Thank you.
$ echo "Hello, world..." | avrdude -qp ATmega328P -c ... -U eeprom:w:-:r
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file <stdin> for eeprom
avrdude: writing 16 bytes eeprom ...
avrdude: 16 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
avrdude: 16 bytes of eeprom verified
avrdude done. Thank you.
2022-08-02 22:26:01 +00:00
|
|
|
UF_VERIFY = 4,
|
2014-05-19 10:01:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct update_t {
|
|
|
|
char * memtype;
|
|
|
|
int op;
|
|
|
|
char * filename;
|
|
|
|
int format;
|
|
|
|
} UPDATE;
|
|
|
|
|
Enable stdin verification and display correct number of bytes written/verified
Counting the number of bytes written to a memory and/or verified is not
trivial owing to potential holes in the input file and to potential trailing
0xff bytes in flash memory that are not written per default (but see -A). The
new function memstats(), which is best called just after an input file has
been read into mem->buf/mem->tags, computes the right number of bytes written
and allows easy computation of the number of bytes verified.
This commit also changes the strategy for the default verification after
writing to a chip memory, so that the input file only needs reading once thus
enabling successful verification of stdin input files.
Other, minor changes:
- Improving the grammar of AVRDUDE output, eg, 1 byte written instead of
1 bytes written
- Better description of the input file structure in terms of its sections,
the interval it spans, the number of pages, the number of padding bytes
in pages, and the number of actually cut off trailing 0xff bytes for flash
- Printing <stdin> or <stdout> instead of - in the -U routines
- Option -V no longer needs to be specified before option -U in order to work
As an aside this commit also provides useful helper functions for printing
plural(), inname(), outname() and interval() all of which return strings fit
for printing.
$ avrdude -qp ATmega2560 -c usbtiny -U blink-mega2560+lext-test.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file blink-mega2560+lext-test.hex auto detected as Intel Hex
avrdude: reading input file blink-mega2560+lext-test.hex for flash
with 1346 bytes in 4 sections within [0, 0x3106d]
using 7 pages and 446 pad bytes
avrdude: writing 1346 bytes flash ...
avrdude: 1346 bytes of flash written
avrdude: verifying flash memory against blink-mega2560+lext-test.hex
avrdude: 1346 bytes of flash verified
avrdude done. Thank you.
$ avrdude -qp ATmega328P -c usb-bub-ii -U sketch-ending-in-ff.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file sketch-ending-in-ff.hex auto detected as Intel Hex
avrdude: reading input file sketch-ending-in-ff.hex for flash
with 2160 bytes in 1 section within [0, 0x888]
using 17 pages and 16 pad bytes, cutting off 25 trailing 0xff bytes
avrdude: writing 2160 bytes flash ...
avrdude: 2160 bytes of flash written
avrdude: verifying flash memory against sketch-ending-in-ff.hex
avrdude: 2185 bytes of flash verified
avrdude done. Thank you.
$ echo "Hello, world..." | avrdude -qp ATmega328P -c ... -U eeprom:w:-:r
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file <stdin> for eeprom
avrdude: writing 16 bytes eeprom ...
avrdude: 16 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
avrdude: 16 bytes of eeprom verified
avrdude done. Thank you.
2022-08-02 22:26:01 +00:00
|
|
|
typedef struct { // File reads for flash can exclude trailing 0xff, which are cut off
|
|
|
|
int nbytes, // Number of bytes set including 0xff but excluding cut off, trailing 0xff
|
|
|
|
nsections, // Number of consecutive sections in source excluding cut off, trailing 0xff
|
|
|
|
npages, // Number of memory pages needed excluding pages solely with trailing 0xff
|
|
|
|
nfill, // Number of fill bytes to make up full pages that are needed
|
|
|
|
ntrailing, // Number of trailing 0xff in source
|
|
|
|
firstaddr, // First address set in [0, mem->size-1]
|
|
|
|
lastaddr; // Highest address set by input file
|
|
|
|
} Filestats;
|
|
|
|
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern UPDATE * parse_op(char * s);
|
|
|
|
extern UPDATE * dup_update(UPDATE * upd);
|
|
|
|
extern UPDATE * new_update(int op, char * memtype, int filefmt,
|
|
|
|
char * filename);
|
|
|
|
extern void free_update(UPDATE * upd);
|
|
|
|
extern int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd,
|
|
|
|
enum updateflags flags);
|
|
|
|
|
Enable stdin verification and display correct number of bytes written/verified
Counting the number of bytes written to a memory and/or verified is not
trivial owing to potential holes in the input file and to potential trailing
0xff bytes in flash memory that are not written per default (but see -A). The
new function memstats(), which is best called just after an input file has
been read into mem->buf/mem->tags, computes the right number of bytes written
and allows easy computation of the number of bytes verified.
This commit also changes the strategy for the default verification after
writing to a chip memory, so that the input file only needs reading once thus
enabling successful verification of stdin input files.
Other, minor changes:
- Improving the grammar of AVRDUDE output, eg, 1 byte written instead of
1 bytes written
- Better description of the input file structure in terms of its sections,
the interval it spans, the number of pages, the number of padding bytes
in pages, and the number of actually cut off trailing 0xff bytes for flash
- Printing <stdin> or <stdout> instead of - in the -U routines
- Option -V no longer needs to be specified before option -U in order to work
As an aside this commit also provides useful helper functions for printing
plural(), inname(), outname() and interval() all of which return strings fit
for printing.
$ avrdude -qp ATmega2560 -c usbtiny -U blink-mega2560+lext-test.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file blink-mega2560+lext-test.hex auto detected as Intel Hex
avrdude: reading input file blink-mega2560+lext-test.hex for flash
with 1346 bytes in 4 sections within [0, 0x3106d]
using 7 pages and 446 pad bytes
avrdude: writing 1346 bytes flash ...
avrdude: 1346 bytes of flash written
avrdude: verifying flash memory against blink-mega2560+lext-test.hex
avrdude: 1346 bytes of flash verified
avrdude done. Thank you.
$ avrdude -qp ATmega328P -c usb-bub-ii -U sketch-ending-in-ff.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file sketch-ending-in-ff.hex auto detected as Intel Hex
avrdude: reading input file sketch-ending-in-ff.hex for flash
with 2160 bytes in 1 section within [0, 0x888]
using 17 pages and 16 pad bytes, cutting off 25 trailing 0xff bytes
avrdude: writing 2160 bytes flash ...
avrdude: 2160 bytes of flash written
avrdude: verifying flash memory against sketch-ending-in-ff.hex
avrdude: 2185 bytes of flash verified
avrdude done. Thank you.
$ echo "Hello, world..." | avrdude -qp ATmega328P -c ... -U eeprom:w:-:r
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file <stdin> for eeprom
avrdude: writing 16 bytes eeprom ...
avrdude: 16 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
avrdude: 16 bytes of eeprom verified
avrdude done. Thank you.
2022-08-02 22:26:01 +00:00
|
|
|
extern int memstats(struct avrpart *p, char *memtype, int size, Filestats *fsp);
|
|
|
|
|
|
|
|
// Convenience functions for printing
|
2022-08-04 17:25:14 +00:00
|
|
|
const char *update_plural(int x);
|
|
|
|
const char *update_inname(const char *fn);
|
|
|
|
const char *update_outname(const char *fn);
|
|
|
|
const char *update_interval(int a, int b);
|
Enable stdin verification and display correct number of bytes written/verified
Counting the number of bytes written to a memory and/or verified is not
trivial owing to potential holes in the input file and to potential trailing
0xff bytes in flash memory that are not written per default (but see -A). The
new function memstats(), which is best called just after an input file has
been read into mem->buf/mem->tags, computes the right number of bytes written
and allows easy computation of the number of bytes verified.
This commit also changes the strategy for the default verification after
writing to a chip memory, so that the input file only needs reading once thus
enabling successful verification of stdin input files.
Other, minor changes:
- Improving the grammar of AVRDUDE output, eg, 1 byte written instead of
1 bytes written
- Better description of the input file structure in terms of its sections,
the interval it spans, the number of pages, the number of padding bytes
in pages, and the number of actually cut off trailing 0xff bytes for flash
- Printing <stdin> or <stdout> instead of - in the -U routines
- Option -V no longer needs to be specified before option -U in order to work
As an aside this commit also provides useful helper functions for printing
plural(), inname(), outname() and interval() all of which return strings fit
for printing.
$ avrdude -qp ATmega2560 -c usbtiny -U blink-mega2560+lext-test.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file blink-mega2560+lext-test.hex auto detected as Intel Hex
avrdude: reading input file blink-mega2560+lext-test.hex for flash
with 1346 bytes in 4 sections within [0, 0x3106d]
using 7 pages and 446 pad bytes
avrdude: writing 1346 bytes flash ...
avrdude: 1346 bytes of flash written
avrdude: verifying flash memory against blink-mega2560+lext-test.hex
avrdude: 1346 bytes of flash verified
avrdude done. Thank you.
$ avrdude -qp ATmega328P -c usb-bub-ii -U sketch-ending-in-ff.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file sketch-ending-in-ff.hex auto detected as Intel Hex
avrdude: reading input file sketch-ending-in-ff.hex for flash
with 2160 bytes in 1 section within [0, 0x888]
using 17 pages and 16 pad bytes, cutting off 25 trailing 0xff bytes
avrdude: writing 2160 bytes flash ...
avrdude: 2160 bytes of flash written
avrdude: verifying flash memory against sketch-ending-in-ff.hex
avrdude: 2185 bytes of flash verified
avrdude done. Thank you.
$ echo "Hello, world..." | avrdude -qp ATmega328P -c ... -U eeprom:w:-:r
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file <stdin> for eeprom
avrdude: writing 16 bytes eeprom ...
avrdude: 16 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
avrdude: 16 bytes of eeprom verified
avrdude done. Thank you.
2022-08-02 22:26:01 +00:00
|
|
|
|
2022-08-05 16:38:59 +00:00
|
|
|
// Helper functions for dry run to determine file access
|
|
|
|
int update_is_okfile(const char *fn);
|
|
|
|
int update_is_writeable(const char *fn);
|
|
|
|
int update_is_readable(const char *fn);
|
|
|
|
|
|
|
|
int update_dryrun(struct avrpart *p, UPDATE *upd);
|
|
|
|
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* formerly pgm_type.h */
|
|
|
|
|
|
|
|
/*LISTID programmer_types;*/
|
|
|
|
|
|
|
|
typedef struct programmer_type_t {
|
|
|
|
const char * const id;
|
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:
- Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
const AVRPART *p); this allows changes in the PROGRAMMER structure after
the part is known. For example, use TPI, UPDI, PDI functions in that
programmer appropriate to the part. This used to be done later in the
process, eg, in the initialize() function, which "taints" all other
programmer functions wrt const and sometimes requires other finessing with
flags etc. Much clearer with the modified enable() interface.
- Move TPI initpgm-type code from initialize() to enable() --- note that
initpgm() does not have the info at the time when it is called whether or
not TPI is required
- buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
modification of the flag does not change PROGRAMMER structure)
- Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
FLAGS32_WRITE bits
- Move the xbeeResetPin component to private data in stk500.c as this is
needed by xbee when it saddles on the stk500 code (previously, the flags
component of the part was re-dedicated to this)
- Change the way the "chained" private data are used in jtag3.c whilst
keeping the PROGRAMMER structure read-only otherwise
- In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
(for const assertion).
- In usbasp change the code from changing PROGRAMMER functions late to
dispatching to TPI or regular SPI protocol functions at runtime; reason
being the decision whether to use TPI protocol is done at run-time
depending on the capability of the attached programmer
Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
|
|
|
void (*initpgm)(struct programmer_t *pgm);
|
2014-05-19 10:01:59 +00:00
|
|
|
const char * const desc;
|
|
|
|
} PROGRAMMER_TYPE;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-08-08 15:52:09 +00:00
|
|
|
const PROGRAMMER_TYPE *locate_programmer_type(const char *id);
|
|
|
|
|
2022-08-08 16:21:21 +00:00
|
|
|
const char *locate_programmer_type_id(void (*initpgm)(struct programmer_t *pgm));
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
typedef void (*walk_programmer_types_cb)(const char *id, const char *desc,
|
|
|
|
void *cookie);
|
|
|
|
void walk_programmer_types(/*LISTID programmer_types,*/ walk_programmer_types_cb cb, void *cookie);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* formerly config.h */
|
|
|
|
|
|
|
|
extern LISTID part_list;
|
|
|
|
extern LISTID programmers;
|
2022-08-09 20:45:04 +00:00
|
|
|
extern const char *default_programmer;
|
|
|
|
extern const char *default_parallel;
|
|
|
|
extern const char *default_serial;
|
|
|
|
extern const char *default_spi;
|
2014-05-19 10:01:59 +00:00
|
|
|
extern double default_bitclock;
|
|
|
|
|
|
|
|
/* This name is fixed, it's only here for symmetry with
|
|
|
|
* default_parallel and default_serial. */
|
|
|
|
#define DEFAULT_USB "usb"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
void *cfg_malloc(const char *funcname, size_t n);
|
|
|
|
|
|
|
|
char *cfg_strdup(const char *funcname, const char *s);
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
int init_config(void);
|
|
|
|
|
|
|
|
void cleanup_config(void);
|
|
|
|
|
|
|
|
int read_config(const char * file);
|
|
|
|
|
2022-08-08 15:52:09 +00:00
|
|
|
const char *cache_string(const char *file);
|
2022-08-07 13:05:54 +00:00
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
unsigned char *cfg_unescapeu(unsigned char *d, const unsigned char *s);
|
|
|
|
|
|
|
|
char *cfg_unescape(char *d, const char *s);
|
|
|
|
|
|
|
|
char *cfg_escape(const char *s);
|
|
|
|
|
2014-05-19 10:01:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* formerly confwin.h */
|
|
|
|
|
2022-01-07 12:15:55 +00:00
|
|
|
#if defined(WIN32)
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void win_sys_config_set(char sys_config[PATH_MAX]);
|
|
|
|
void win_usr_config_set(char usr_config[PATH_MAX]);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-07 12:15:55 +00:00
|
|
|
#endif /* WIN32 */
|
2014-05-19 10:01:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* libavrdude_h */
|