mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-14 01:44:58 +00:00
Implement a dry run for -U updates before opening the programmer
This commit checks -U update requests for
- Typos in memory names
- Whether the files can be written or read
- Automatic format detection if necessary
before opening the programmer. This to reduce the chances of the
programming failing midway through.
Minor additional changes:
- Give strerror() system info when files are not read/writeable
- Lift the auto detection message from MSG_INFO to MSG_NOTICE
- Provide fileio_fmt_autodetect() in the AVRDUDE library
- Rename fmtstr() in the AVRDUDE library to fileio_fmtstr() to
avoid name clashes when an application links with it
Example:
$ avrdude -U - -U typo:r:.:h -U eeprom:w:testin:r -p ... -c ...
avrdude: can't auto detect file format for stdin/out, specify explicitly
avrdude: unknown memory type typo
avrdude: file . is not writeable (not a regular or character file?)
avrdude: file testin is not readable. No such file or directory
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -901,11 +901,13 @@ int main(int argc, char * argv [])
|
||||
}
|
||||
|
||||
/*
|
||||
* 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).
|
||||
* Now that we know which part we are going to program, locate any -U
|
||||
* options using the default memory region, fill in the device-dependent
|
||||
* default region name ("application" for Xmega parts or "flash" otherwise)
|
||||
* and check for basic problems with memory names or file access with a
|
||||
* view to exit before programming.
|
||||
*/
|
||||
int doexit = 0;
|
||||
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
||||
upd = ldata(ln);
|
||||
if (upd->memtype == NULL) {
|
||||
@@ -920,12 +922,12 @@ int main(int argc, char * argv [])
|
||||
}
|
||||
}
|
||||
|
||||
if (!avr_mem_might_be_known(upd->memtype)) {
|
||||
avrdude_message(MSG_INFO, "%s: unknown memory type %s\n", progname, upd->memtype);
|
||||
exit(1);
|
||||
}
|
||||
// TODO: check whether filename other than "-" is readable/writable
|
||||
rc = update_dryrun(p, upd);
|
||||
if (rc && rc != LIBAVRDUDE_SOFTFAIL)
|
||||
doexit = 1;
|
||||
}
|
||||
if(doexit)
|
||||
exit(1);
|
||||
|
||||
/*
|
||||
* open the programmer
|
||||
|
||||
Reference in New Issue
Block a user