mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-12-27 13:41:09 +02:00
d7874e306c
- series, low-addr.patch: record the lowest address touched (only for ihex, all others default to 0) - series, skip-low-addr.patch: skip untouched addresses in avr_read and avr_write
143 lines
4.1 KiB
Diff
143 lines
4.1 KiB
Diff
Index: avrdude/avrdude-5.10/avrpart.h
|
|
===================================================================
|
|
--- avrdude.orig/avrdude-5.10/avrpart.h 2011-03-08 23:40:10.000000000 -0300
|
|
+++ avrdude/avrdude-5.10/avrpart.h 2011-03-08 23:40:13.000000000 -0300
|
|
@@ -185,6 +185,8 @@
|
|
|
|
unsigned char * buf; /* pointer to memory buffer */
|
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
|
+
|
|
+ int low_addr; /* lowest address used, in bytes */
|
|
} AVRMEM;
|
|
|
|
#ifdef __cplusplus
|
|
Index: avrdude/avrdude-5.10/config_gram.y
|
|
===================================================================
|
|
--- avrdude.orig/avrdude-5.10/config_gram.y 2011-03-08 23:40:10.000000000 -0300
|
|
+++ avrdude/avrdude-5.10/config_gram.y 2011-03-08 23:40:13.000000000 -0300
|
|
@@ -1209,6 +1209,7 @@
|
|
}
|
|
mem_specs
|
|
{
|
|
+ current_mem->low_addr = current_mem->size;
|
|
ladd(current_part->mem, current_mem);
|
|
current_mem = NULL;
|
|
} |
|
|
Index: avrdude/avrdude-5.10/fileio.c
|
|
===================================================================
|
|
--- avrdude.orig/avrdude-5.10/fileio.c 2011-03-08 23:40:10.000000000 -0300
|
|
+++ avrdude/avrdude-5.10/fileio.c 2011-03-08 23:40:13.000000000 -0300
|
|
@@ -52,7 +52,7 @@
|
|
char * outfile, FILE * outf);
|
|
|
|
static int ihex2b(char * infile, FILE * inf,
|
|
- unsigned char * outbuf, int bufsize);
|
|
+ unsigned char * outbuf, int bufsize, int *low_addr);
|
|
|
|
static int b2srec(unsigned char * inbuf, int bufsize,
|
|
int recsize, int startaddr,
|
|
@@ -69,7 +69,8 @@
|
|
char * filename, FILE * f, unsigned char * buf, int size);
|
|
|
|
static int fileio_ihex(struct fioparms * fio,
|
|
- char * filename, FILE * f, unsigned char * buf, int size);
|
|
+ char * filename, FILE * f, unsigned char * buf, int size,
|
|
+ int *low_addr);
|
|
|
|
static int fileio_srec(struct fioparms * fio,
|
|
char * filename, FILE * f, unsigned char * buf, int size);
|
|
@@ -262,7 +263,7 @@
|
|
*
|
|
* */
|
|
static int ihex2b(char * infile, FILE * inf,
|
|
- unsigned char * outbuf, int bufsize)
|
|
+ unsigned char * outbuf, int bufsize, int *low_addr)
|
|
{
|
|
char buffer [ MAX_LINE_LEN ];
|
|
unsigned char * buf;
|
|
@@ -271,7 +272,7 @@
|
|
int lineno;
|
|
int len;
|
|
struct ihexrec ihex;
|
|
- int rc;
|
|
+ int rc, lowest;
|
|
|
|
lineno = 0;
|
|
buf = outbuf;
|
|
@@ -279,6 +280,7 @@
|
|
maxaddr = 0;
|
|
offsetaddr = 0;
|
|
nextaddr = 0;
|
|
+ lowest = bufsize;
|
|
|
|
while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) {
|
|
lineno++;
|
|
@@ -313,11 +315,14 @@
|
|
for (i=0; i<ihex.reclen; i++) {
|
|
buf[nextaddr+i-offsetaddr] = ihex.data[i];
|
|
}
|
|
+ if (nextaddr-offsetaddr < lowest)
|
|
+ lowest = nextaddr-offsetaddr;
|
|
if (nextaddr+ihex.reclen > maxaddr)
|
|
maxaddr = nextaddr+ihex.reclen;
|
|
break;
|
|
|
|
case 1: /* end of file record */
|
|
+ *low_addr = lowest;
|
|
return maxaddr-offsetaddr;
|
|
break;
|
|
|
|
@@ -354,6 +359,7 @@
|
|
"file \"%s\"\n",
|
|
progname, infile);
|
|
|
|
+ *low_addr = lowest;
|
|
return maxaddr-offsetaddr;
|
|
}
|
|
|
|
@@ -777,7 +783,8 @@
|
|
|
|
|
|
static int fileio_ihex(struct fioparms * fio,
|
|
- char * filename, FILE * f, unsigned char * buf, int size)
|
|
+ char * filename, FILE * f, unsigned char * buf, int size,
|
|
+ int *low_addr)
|
|
{
|
|
int rc;
|
|
|
|
@@ -790,7 +797,7 @@
|
|
break;
|
|
|
|
case FIO_READ:
|
|
- rc = ihex2b(filename, f, buf, size);
|
|
+ rc = ihex2b(filename, f, buf, size, low_addr);
|
|
if (rc < 0)
|
|
return -1;
|
|
break;
|
|
@@ -1021,6 +1028,7 @@
|
|
struct fioparms fio;
|
|
AVRMEM * mem;
|
|
int using_stdio;
|
|
+ int low_addr = 0;
|
|
|
|
mem = avr_locate_mem(p, memtype);
|
|
if (mem == NULL) {
|
|
@@ -1113,7 +1121,7 @@
|
|
|
|
switch (format) {
|
|
case FMT_IHEX:
|
|
- rc = fileio_ihex(&fio, fname, f, buf, size);
|
|
+ rc = fileio_ihex(&fio, fname, f, buf, size, &low_addr);
|
|
break;
|
|
|
|
case FMT_SREC:
|
|
@@ -1149,6 +1157,8 @@
|
|
*/
|
|
rc = avr_mem_hiaddr(mem);
|
|
}
|
|
+ if (op == FIO_READ && low_addr < mem->low_addr)
|
|
+ mem->low_addr = low_addr;
|
|
}
|
|
if (format != FMT_IMM && !using_stdio) {
|
|
fclose(f);
|