avrdude/src
Stefan Rueger 02027ab766 Enable stdin verification and display correct number of bytes written/verified
Counting the number of bytes written to a memory and/or verified is not
trivial owing to potential holes in the input file and to potential trailing
0xff bytes in flash memory that are not written per default (but see -A). The
new function memstats(), which is best called just after an input file has
been read into mem->buf/mem->tags, computes the right number of bytes written
and allows easy computation of the number of bytes verified.

This commit also changes the strategy for the default verification after
writing to a chip memory, so that the input file only needs reading once thus
enabling successful verification of stdin input files.

Other, minor changes:
 - Improving the grammar of AVRDUDE output, eg, 1 byte written instead of
   1 bytes written
 - Better description of the input file structure in terms of its sections,
   the interval it spans, the number  of pages, the number of padding bytes
   in pages, and the number of actually cut off trailing 0xff bytes for flash
 - Printing <stdin> or <stdout> instead of - in the -U routines
 - Option -V no longer needs to be specified before option -U in order to work

As an aside this commit also provides useful helper functions for printing
plural(), inname(), outname() and interval() all of which return strings fit
for printing.

$ avrdude -qp ATmega2560 -c usbtiny -U blink-mega2560+lext-test.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file blink-mega2560+lext-test.hex auto detected as Intel Hex
avrdude: reading input file blink-mega2560+lext-test.hex for flash
         with 1346 bytes in 4 sections within [0, 0x3106d]
         using 7 pages and 446 pad bytes
avrdude: writing 1346 bytes flash ...
avrdude: 1346 bytes of flash written
avrdude: verifying flash memory against blink-mega2560+lext-test.hex
avrdude: 1346 bytes of flash verified

avrdude done.  Thank you.

$ avrdude -qp ATmega328P -c usb-bub-ii -U sketch-ending-in-ff.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: input file sketch-ending-in-ff.hex auto detected as Intel Hex
avrdude: reading input file sketch-ending-in-ff.hex for flash
         with 2160 bytes in 1 section within [0, 0x888]
         using 17 pages and 16 pad bytes, cutting off 25 trailing 0xff bytes
avrdude: writing 2160 bytes flash ...
avrdude: 2160 bytes of flash written
avrdude: verifying flash memory against sketch-ending-in-ff.hex
avrdude: 2185 bytes of flash verified

avrdude done.  Thank you.

$ echo "Hello, world..." | avrdude -qp ATmega328P -c ... -U eeprom:w:-:r

avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file <stdin> for eeprom
avrdude: writing 16 bytes eeprom ...
avrdude: 16 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
avrdude: 16 bytes of eeprom verified

avrdude done.  Thank you.
2022-08-02 23:26:01 +01:00
..
doc Merge pull request #1033 from MCUdude/ignore-safemode-flag 2022-08-02 18:26:58 +01:00
msvc Add C code alternative to __builtin_popcount. 2022-01-08 16:13:32 +01:00
CMakeLists.txt Merge pull request #1040 from stefanrueger/partdesc 2022-08-02 18:27:42 +01:00
Makefile.am Move developer_opts* file names from library section to main section for c/make 2022-07-27 00:18:06 +01:00
arduino.c Provide self-documenting API for disabling trailing-0xff removal 2022-04-28 17:26:09 +01:00
arduino.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
avr.c Merge branch 'main' into issue918 2022-07-12 15:05:45 +01:00
avr910.c Merged AVRDUDES/main into SerialUPDI branch 2021-12-21 21:38:51 +01:00
avr910.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
avrdude.1 Merge pull request #1033 from MCUdude/ignore-safemode-flag 2022-08-02 18:26:58 +01:00
avrdude.conf.in Merge pull request #1048 from MCUdude/jtagmkii-updi 2022-08-02 18:32:12 +01:00
avrdude.h Merge pull request #798 from mariusgreuel/pr-msvc 2022-01-07 18:30:19 +01:00
avrdude.spec.in Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
avrftdi.c Adapt whitespace to existing style in avrftdi.c 2022-07-04 23:54:02 +01:00
avrftdi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
avrftdi_private.h Fix avrftdi support for ATmega2560 et al (load extended address) 2022-07-04 12:30:25 +01:00
avrftdi_tpi.c Add C code alternative to __builtin_popcount. 2022-01-08 16:13:32 +01:00
avrftdi_tpi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
avrpart.c Move useful CMDBIT/part functions from developer_opts.c to avrpart.c 2022-07-27 00:12:57 +01:00
bitbang.c Clean up legacy code 2022-01-07 17:57:02 +01:00
bitbang.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
bootstrap Make `bootstrap' executable 2021-12-19 00:35:52 +01:00
buspirate.c buspirate: fix invalidScanfArgType_int warning 2022-01-07 19:22:57 +01:00
buspirate.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
butterfly.c Merged AVRDUDES/main into SerialUPDI branch 2021-12-21 21:38:51 +01:00
butterfly.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
cmake_config.h.in Clean up legacy code 2022-01-07 17:57:02 +01:00
config.c Cache config_file components in AVRPART and PROGRAMMER structures 2022-07-18 18:10:09 +01:00
config.h Move realpath() compatibility definition from config_gram.y to config.h 2022-07-19 08:05:42 +01:00
config_gram.y Add parent id output for developer options -p*/s for parts 2022-07-26 23:43:56 +01:00
configure.ac Post-7.0 changes 2022-05-07 22:57:49 +02:00
confwin.c Remove ac_cfg.h from libavrdude.h 2022-01-10 15:12:33 +01:00
crc16.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
crc16.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
developer_opts.c Move useful CMDBIT/part functions from developer_opts.c to avrpart.c 2022-07-27 00:12:57 +01:00
developer_opts.h Declare useful CMDBIT/part functions of developer_opts.c in libavrdude.h 2022-07-26 23:55:42 +01:00
developer_opts_private.h Make developer opts portable: change statement exprs and index(); use size_t 2022-07-22 23:50:22 +01:00
dfu.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
dfu.h Add compatibility shim for MSVC 2022-01-07 17:54:36 +01:00
fileio.c Provide file format I: Intel HEX with comments that ignores checksum errors 2022-07-16 23:40:36 +01:00
flip1.c Clean up legacy code 2022-01-07 17:57:02 +01:00
flip1.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
flip2.c Merge pull request #798 from mariusgreuel/pr-msvc 2022-01-07 18:30:19 +01:00
flip2.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
freebsd_ppi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
ft245r.c Fix paged read for ATmega2560 et al for ft245r.c 2022-07-04 23:11:32 +01:00
ft245r.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
jtag3.c Merge pull request #1015 from MCUdude/hv-updi 2022-07-18 14:28:39 +01:00
jtag3.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
jtag3_private.h Merge pull request #1015 from MCUdude/hv-updi 2022-07-18 14:28:39 +01:00
jtagmkI.c Add EEPROM dummy read 2022-07-19 23:44:22 +02:00
jtagmkI.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
jtagmkII.c Improve error detection logic 2022-07-29 12:48:53 +02:00
jtagmkII.h Add new jtagmkii_updi programmer type option 2022-07-26 11:36:50 +02:00
jtagmkII_private.h Add more jtagmkii baud rates 2022-01-02 12:13:13 +01:00
jtagmkI_private.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
lexer.l Add avrdude.conf syntax opcode = NULL; for SPI programming 2022-07-19 15:38:54 +01:00
libavrdude.h Enable stdin verification and display correct number of bytes written/verified 2022-08-02 23:26:01 +01:00
linux_ppdev.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
linuxgpio.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
linuxgpio.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
linuxspi.c Fix linuxspi baud to clock period calculation 2022-04-10 23:36:53 +02:00
linuxspi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
lists.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
main.c Enable stdin verification and display correct number of bytes written/verified 2022-08-02 23:26:01 +01:00
micronucleus.c Fix typo in micronucleus message 2022-05-05 22:08:46 +02:00
micronucleus.h Add support for Micronucleus bootloader 2022-01-04 18:37:57 +01:00
par.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
par.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
pgm.c Add parent id output for developer options -p*/s for parts 2022-07-26 23:43:56 +01:00
pgm_type.c Add new jtagmkii_updi programmer type option 2022-07-26 11:36:50 +02:00
pickit2.c Fix PICKit2 ATmega2560 flash paged flash read 2022-07-10 23:41:44 +01:00
pickit2.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
pindefs.c Merge pull request #820 from dl8dtl/libavrdude-remove-ac_cfg_h 2022-01-11 12:44:26 +01:00
ppi.c Clean up legacy code 2022-01-07 17:57:02 +01:00
ppi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
ppiwin.c Clean up legacy code 2022-01-07 17:57:02 +01:00
ser_avrdoper.c Remove libhid support in ser_avrdoper.c in favor of libhidapi 2022-02-18 20:05:52 +01:00
ser_posix.c adding support for all Linux baud rates v.2 2022-07-04 12:30:37 +01:00
ser_win32.c Clean up legacy code 2022-01-07 17:57:02 +01:00
serbb.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
serbb_posix.c Clean up legacy code 2022-01-07 17:57:02 +01:00
serbb_win32.c Clean up legacy code 2022-01-07 17:57:02 +01:00
serialupdi.c Replaced tabs by spaces 2022-01-13 10:01:01 +01:00
serialupdi.h Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
solaris_ecpp.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500.c Deprecate original STK500 v1 protocol in favour of optiboot and Arduino as ISP 2022-07-24 20:39:14 +01:00
stk500.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500_private.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500generic.c Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500generic.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500v2.c Resolve signed/unsigned comparisons in stk500.c and stk500v2.c 2022-07-24 19:41:42 +01:00
stk500v2.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
stk500v2_private.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
teensy.c Add support for Teensy bootloader 2022-01-06 23:39:17 +01:00
teensy.h Add support for Teensy bootloader 2022-01-06 23:39:17 +01:00
term.c Fix terminal line parsing for strings (to some extent) 2022-07-15 18:50:20 +01:00
term.h Flush stderr and stdout with all terminal error messages 2022-07-13 11:48:29 +01:00
tpi.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
update.c Enable stdin verification and display correct number of bytes written/verified 2022-08-02 23:26:01 +01:00
updi_constants.h Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
updi_link.c Fixed warning with unsigned char 2022-02-19 21:18:03 +01:00
updi_link.h Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
updi_nvm.c Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
updi_nvm.h Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
updi_readwrite.c Fix typos all over the code 2022-01-07 11:31:16 +01:00
updi_readwrite.h Moved SerialUPDI sources to correct location 2021-12-21 21:45:36 +01:00
updi_state.c Implemented extended parameter for RTS/DTR lines management 2022-01-08 10:04:25 +01:00
updi_state.h Implemented extended parameter for RTS/DTR lines management 2022-01-08 10:04:25 +01:00
usb_hidapi.c Increased timeout passed to hid_read_timeout() - set to 10000 for consistency (#901) 2022-03-31 23:26:53 +02:00
usb_libusb.c Clean up legacy code 2022-01-07 17:57:02 +01:00
usbasp.c Assign proper type to msg[] in errstr() 2022-01-29 23:32:39 +01:00
usbasp.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
usbdevs.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
usbtiny.c Fix usbtiny read/verify for parts with more than 64 kB flash 2022-07-16 11:06:18 +01:00
usbtiny.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
whereami.c Find 'avrdude.conf' based on absolute path to executable (#780) 2022-01-03 23:20:31 +01:00
whereami.h Find 'avrdude.conf' based on absolute path to executable (#780) 2022-01-03 23:20:31 +01:00
windows.rc.in Derive program version from last commit 2022-01-03 15:04:25 +01:00
wiring.c Merged AVRDUDES/main into SerialUPDI branch 2021-12-21 21:38:51 +01:00
wiring.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00
xbee.c Merged AVRDUDES/main into SerialUPDI branch 2021-12-21 21:38:51 +01:00
xbee.h Move source files to 'src' folder 2021-12-17 09:17:42 +01:00