* 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 80dd0439a8
commit 0dd5684041
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> 2012-04-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* fileio.c: Rework the way ELF file sections are considered: while * 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 the appropriate section contents that matches the requested memory
region. 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 * Programmers and parts lists
They are now sorted at output with '-c ?'/'-p ?'. (patch #7671: 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); 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 * open the programmer
*/ */

View File

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