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
The checks used to be in update.c, but as they are related to
the intended file operation, they are better placed in fileio.c.
The checks affected are to refuse 'm' on output (file write),
and 'd', 'h', 'o', and 'b' formats on input (file read).
The new file type I is essentially Intel HEX that, on download, inserts
comments next to data records with the resolved effective address and an
ASCII dump of that same record. On upload the `I` format is permissive
with respect to check sum errors, eg, after manipulated an Intel HEX file
for debugging.