mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-24 01:56:25 +03:00
Inspect memory lists to decide whether initial chip erase is needed
This commit is contained in:
@@ -1318,6 +1318,8 @@ int update_is_readable(const char *fn);
|
||||
|
||||
int update_dryrun(const AVRPART *p, UPDATE *upd);
|
||||
|
||||
AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry);
|
||||
int memlist_contains_flash(const char *mstr, const AVRPART *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
19
src/main.c
19
src/main.c
@@ -242,7 +242,7 @@ static void usage(void)
|
||||
" -r Reconnect to -P port after \"touching\" it; wait\n"
|
||||
" 400 ms for each -r; needed for some USB boards\n"
|
||||
" -F Override invalid signature or initial checks\n"
|
||||
" -e Perform a chip erase\n"
|
||||
" -e Perform a chip erase at the beginning\n"
|
||||
" -O Perform RC oscillator calibration (see AVR053)\n"
|
||||
" -t Run an interactive terminal when it is its turn\n"
|
||||
" -T <terminal cmd line> Run terminal line when it is its turn\n"
|
||||
@@ -1686,22 +1686,13 @@ skipopen:
|
||||
imsg_info("Each page will be erased before programming it, but no chip erase is performed.\n");
|
||||
imsg_info("To disable page erases, specify the -D option; for a chip-erase, use the -e option.\n");
|
||||
} else {
|
||||
AVRMEM * m;
|
||||
const char *memname = p->prog_modes & PM_PDI? "application": "flash";
|
||||
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
||||
for(ln=lfirst(updates); !erase && ln; ln=lnext(ln)) {
|
||||
upd = ldata(ln);
|
||||
if(!upd->memstr)
|
||||
continue;
|
||||
m = avr_locate_mem(p, upd->memstr);
|
||||
if (m == NULL)
|
||||
continue;
|
||||
if(str_eq(m->desc, memname) && upd->op == DEVICE_WRITE) {
|
||||
if(upd->memstr && upd->op == DEVICE_WRITE && memlist_contains_flash(upd->memstr, p)) {
|
||||
erase = 1;
|
||||
pmsg_info("Note: %s memory has been specified, an erase cycle will be performed.\n", memname);
|
||||
imsg_info("To disable this feature, specify the -D option.\n");
|
||||
break;
|
||||
pmsg_info("Note: carrying out an erase cycle as flash memory needs programming (-U %s:w:...)\n", upd->memstr);
|
||||
imsg_info("specify the -D option to disable this feature\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/update.c
17
src/update.c
@@ -38,7 +38,7 @@
|
||||
|
||||
// Is s a multi-memory string (comma-separates list, all, ALL, etc or list subtraction)?
|
||||
static int is_multimem(const char *s) {
|
||||
return str_eq(s, "ALL") || str_eq(s, "all") || str_eq(s, "etc") || strpbrk(s, ",\\");
|
||||
return str_eq(s, "ALL") || str_eq(s, "all") || str_eq(s, "etc") || strpbrk(s, "-,\\");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -304,7 +304,7 @@ static int memadd(AVRMEM **mlist, int nm, int not, AVRMEM *m) {
|
||||
* to *np and *rwvsoftfail indicating unknown memories for this part. If dry is
|
||||
* set then -1 will be written to *dry when a generally unknown memory is used.
|
||||
*/
|
||||
static AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) {
|
||||
AVRMEM **memory_list(const char *mstr, const AVRPART *p, int *np, int *rwvsoftp, int *dry) {
|
||||
int not, nm = (lsize(p->mem) + 1) * ((int) str_numc(mstr, ',') + 1); // Upper limit
|
||||
AVRMEM *m, **umemlist = mmt_malloc(nm*sizeof*umemlist);
|
||||
char *dstr = mmt_strdup(mstr), *s = dstr, *e;
|
||||
@@ -363,6 +363,19 @@ done:
|
||||
return umemlist;
|
||||
}
|
||||
|
||||
|
||||
// Returns whether or not the memory list contains a flash memory
|
||||
int memlist_contains_flash(const char *mstr, const AVRPART *p) {
|
||||
int ret = 0, nm = 0;
|
||||
AVRMEM **mlist = memory_list(mstr, p, &nm, NULL, NULL);
|
||||
for(int i=0; i<nm; i++)
|
||||
if(mem_is_in_flash(mlist[i]))
|
||||
ret = 1;
|
||||
|
||||
mmt_free(mlist);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Basic checks to reveal serious failure before programming (and on autodetect set format)
|
||||
int update_dryrun(const AVRPART *p, UPDATE *upd) {
|
||||
int known, format_detect, ret = LIBAVRDUDE_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user