* update.c (parse_op): do not assume default memtype here

* main.c: after locating the part information, determine default
memtype for all update options that didn't have a memtype
specified; this is "application" for Xmega parts, and "flash" for
everything else.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1086 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2012-04-25 16:32:23 +00:00
parent 0bda6f26d1
commit c4bcc20e07
4 changed files with 46 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2012-04-25 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* update.c (parse_op): do not assume default memtype here
* main.c: after locating the part information, determine default
memtype for all update options that didn't have a memtype
specified; this is "application" for Xmega parts, and "flash" for
everything else.
2012-04-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* fileio.c: Rework the way ELF file sections are considered: while

5
NEWS
View File

@ -81,6 +81,11 @@ Current:
the appropriate section contents that matches the requested memory
region.
* Specifying a -U option without a memory type (short form of
option argument list) now defaults to "application" memory for
Xmega devices, and "flash" for everything else. This ensures
the bootloader is not touched.
* Programmers and parts lists
They are now sorted at output with '-c ?'/'-p ?'. (patch #7671:

24
main.c
View File

@ -859,6 +859,30 @@ int main(int argc, char * argv [])
exit(1);
}
/*
* Now that we know which part we are going to program, locate any
* -U options using the default memory region, and fill in the
* device-dependent default region name, either "application" (for
* Xmega devices), or "flash" (everything else).
*/
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
upd = ldata(ln);
if (upd->memtype == NULL) {
const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
if (verbose >= 2) {
fprintf(stderr,
"%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
progname,
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
upd->filename, mtype);
}
if ((upd->memtype = strdup(mtype)) == NULL) {
fprintf(stderr, "%s: out of memory\n", progname);
exit(1);
}
}
}
/*
* open the programmer
*/

View File

@ -54,17 +54,13 @@ UPDATE * parse_op(char * s)
buf[i] = 0;
if (*p != ':') {
upd->memtype = (char *)malloc(strlen("flash")+1);
if (upd->memtype == NULL) {
outofmem:
fprintf(stderr, "%s: out of memory\n", progname);
exit(1);
}
strcpy(upd->memtype, "flash");
upd->memtype = NULL; /* default memtype, "flash", or "application" */
upd->op = DEVICE_WRITE;
upd->filename = (char *)malloc(strlen(buf) + 1);
if (upd->filename == NULL)
goto outofmem;
if (upd->filename == NULL) {
fprintf(stderr, "%s: out of memory\n", progname);
exit(1);
}
strcpy(upd->filename, buf);
upd->format = FMT_AUTO;
return upd;
@ -177,7 +173,10 @@ UPDATE * dup_update(UPDATE * upd)
memcpy(u, upd, sizeof(UPDATE));
u->memtype = strdup(upd->memtype);
if (upd->memtype != NULL)
u->memtype = strdup(upd->memtype);
else
u->memtype = NULL;
u->filename = strdup(upd->filename);
return u;