39 Commits

Author SHA1 Message Date
stefanrueger
fce210c341 Use bash printf with C locale 2025-06-18 16:13:39 +02:00
stefanrueger
5c7d1674b5 Zap outfile before starting test runs 2025-06-09 19:02:28 +02:00
Hans Ulrich Niedermann
8f64d849a5 test-avrdude: Determine mem sizes without the full command
Determine the flash and ee memory sizes without invoking the full
${avrdude[@]} command with logging etc.

Slight adaptation of code by Stefan Rueger from
https://github.com/avrdudes/avrdude/pull/1891#issuecomment-2293314322
2024-08-16 16:27:05 +02:00
Hans Ulrich Niedermann
cef23e252e test-avrdude: Condense two info lines into one
Condense the information about the avrdude binary executable
and its version from two output lines into a single output line.

Slight adaptation of code by Stefan Rueger from
https://github.com/avrdudes/avrdude/pull/1891#issuecomment-2293314322
2024-08-16 16:17:19 +02:00
Hans Ulrich Niedermann
b8718e6b5d test-avrdude: Replace associative array with function call
Macos ships a quite old version of bash (3.x) which does not have
associative arrays (declare -A) yet.

As the test-avrdude script only uses one associative array
for a static mapping of one character strings to one word
strings, this can be easily replaced by a shell function
containing a "case" statement.

Before this fix:

2024-08-15T15:39:59.9596380Z Prepare "-cdryrun -pm2560" and press 'enter' or 'space' to continue. Press any other key to skip
2024-08-15T15:40:00.5796130Z    0.155 s: flash raw format -T/-U write/verify cola-vending-machine.raw
2024-08-15T15:40:00.7006170Z    0.111 s: flash extended address and hole test
2024-08-15T15:40:00.7057180Z ./tools/test-avrdude: line 322: declare: -A: invalid option
2024-08-15T15:40:00.7057750Z declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
2024-08-15T15:40:00.9218810Z    0.212 s: flash writing R numbers
2024-08-15T15:40:01.1793950Z    0.240 s: flash reading and verifying R numbers
2024-08-15T15:40:01.3661060Z    0.173 s: flash writing R numbers
2024-08-15T15:40:01.6317540Z    0.254 s: flash reading and verifying R numbers
2024-08-15T15:40:01.8235780Z    0.182 s: flash writing R numbers
2024-08-15T15:40:02.0724260Z    0.239 s: flash reading and verifying R numbers
2024-08-15T15:40:02.2713120Z    0.188 s: flash writing R numbers
2024-08-15T15:40:02.4497490Z    0.162 s: flash reading and verifying R numbers
2024-08-15T15:40:02.5897960Z    0.128 s: flash writing R numbers
2024-08-15T15:40:02.8667350Z    0.263 s: flash reading and verifying R numbers
2024-08-15T15:40:03.0635260Z    0.181 s: flash writing srec format
2024-08-15T15:40:03.2152560Z    0.142 s: flash reading and verifying srec format file

After this fix:

2024-08-15T17:23:24.5161820Z Prepare "-cdryrun -pm2560" and press 'enter' or 'space' to continue. Press any other key to skip
2024-08-15T17:23:25.1088990Z    0.162 s: flash raw format -T/-U write/verify cola-vending-machine.raw
2024-08-15T17:23:25.2742090Z    0.157 s: flash extended address and hole test
2024-08-15T17:23:25.4795650Z    0.196 s: flash writing binary numbers
2024-08-15T17:23:25.6721130Z    0.180 s: flash reading and verifying binary numbers
2024-08-15T17:23:25.8423490Z    0.161 s: flash writing octal numbers
2024-08-15T17:23:26.0901770Z    0.235 s: flash reading and verifying octal numbers
2024-08-15T17:23:26.2308860Z    0.127 s: flash writing decimal numbers
2024-08-15T17:23:26.4667010Z    0.228 s: flash reading and verifying decimal numbers
2024-08-15T17:23:26.6574670Z    0.180 s: flash writing hexadecimal numbers
2024-08-15T17:23:26.8651240Z    0.200 s: flash reading and verifying hexadecimal numbers
2024-08-15T17:23:27.0446640Z    0.168 s: flash writing R numbers
2024-08-15T17:23:27.3074230Z    0.250 s: flash reading and verifying R numbers
2024-08-15T17:23:27.4962750Z    0.179 s: flash writing srec format
2024-08-15T17:23:27.6594570Z    0.150 s: flash reading and verifying srec format file
2024-08-16 16:13:28 +02:00
Hans Ulrich Niedermann
4323a43519 test-avrdude: Print the type of the avrdude_bin executable 2024-08-16 16:13:28 +02:00
Hans Ulrich Niedermann
a8a8711b34 test-avrdude: Abort if running "avrdude -v" fails 2024-08-16 16:13:28 +02:00
Hans Ulrich Niedermann
a2906da411 test-avrdude: Adapt version check to new version format
The output of the version information in "avrdude -v" has changed between
avrdude 7.3 and now (commit cf0822bb71):

avrdude: Version 7.3

Avrdude version 7.3-20240814 (250a663a)

This means that the old grep call looking for "Version" cannot
find anything any more, and therefore needs to be changed.

This was not discovered as the test-avrdude script neglected to
abort if no version information is found.
2024-08-16 16:13:28 +02:00
stefanrueger
34366a6b9d Update test-avrdude help message 2024-02-29 20:26:57 +13:00
stefanrueger
71a9cb47b3 Keep case of part in test-avrdude -b -p "-p part ..." 2024-02-28 23:27:38 +13:00
stefanrueger
e35714b1ce Change 1-byte file upload for emulated chip erase 2024-02-28 22:14:28 +13:00
stefanrueger
64c5d1da0b Remove avrbench and generate 4-number benchmark table with legend 2024-02-28 22:07:18 +13:00
stefanrueger
61ed3dd18f Mention avrbench legend in test-avrdude -b summary 2024-02-27 23:14:31 +13:00
stefanrueger
82c001bab4 Drop chip erase and checking test for test-avrdude -b 2024-02-27 23:10:01 +13:00
stefanrueger
efd6bab19c Widen chip erase tests to also capture -c urclock emulation 2024-02-27 22:51:36 +13:00
stefanrueger
cd41d2b4e2 Change /dev/null to temp file to be Windows compatible 2024-02-27 15:00:22 +13:00
stefanrueger
f088a9bc3f Clarify -b option 2024-02-27 14:46:37 +13:00
stefanrueger
df3c67f2d0 Add normalised avrbench number suitable for markdown tables
The cumulative time for typical user tasks depends on the flash and EEPROM
size of the part. This commit computes a size-normalised time. Lower is
better. This avrbench number still depends on the part, but less so than
the cumulative time of the tasks.

The summary line is put in vertical bars to make creation of markdown
tables easier.
2024-02-27 14:09:52 +13:00
stefanrueger
3b567687a7 Lowercase variable names in test-avrdude
Uppercase names are typically used for environment variables in bash
2024-02-27 13:44:52 +13:00
stefanrueger
6e6404cbb4 Use alternative for /dev/null when not available 2024-02-27 11:54:40 +13:00
stefanrueger
274ac34b6c Add benchmark option -b to test-avrdude
This executes five tests for typical programming tasks:
  - Write/verify a "difficult" sketch to flash: two code sections and one
    data section separated by "holes" of different sizes
  - Dump all flash, eg, to make a backup
  - Write/verify a "difficult" eeprom data file with holes
  - Dump all eeprom, eg, to make a backup
  - Chip erase (bootloaders are expected to page erase flash apart from
    the bootloader itself) and spot check whether flash was erased

The reported times are realistic times with overhead of starting avrdude,
resetting the board via DTR/RTS, establishing comms, including erasing the
flash before writing/verifying the sketch and disengaging the chip.

$ test-avrdude -b -d 0 \
  -p "u7.7/weu-jPrac -c urclock -P ch340 -p m328p -b 1000000" \
  -p "u7.7/-eu-jPrac -c urclock -P ch340 -p m328p -b 1000000"

Testing avrdude version 7.3-20240225 (20788712)
Prepare "u7.7/weu-jPrac -c urclock -P ch340 -p m328p -b 1000000" and press 'enter' or 'space' to continue. Press any other key to skip
   2.174 s: flash -U write/verify holes_rjmp_loops_32768B.hex
   1.339 s: flash -U read all flash
   1.415 s: eeprom -U write/verify holes_pack_my_box_1024B.hex
   1.034 s: eeprom -U read all
   1.604 s: chip erase and spot check flash is actually erased
   7.566 s: benchmark for u7.7/weu-jPrac -c urclock -P ch340 -p m328p -b 1000000
Prepare "u7.7/-eu-jPrac -c urclock -P ch340 -p m328p -b 1000000" and press 'enter' or 'space' to continue. Press any other key to skip
   2.001 s: flash -U write/verify holes_rjmp_loops_32768B.hex
   1.333 s: flash -U read all flash
   1.405 s: eeprom -U write/verify holes_pack_my_box_1024B.hex
   1.029 s: eeprom -U read all
   1.618 s: chip erase and spot check flash is actually erased
   7.386 s: benchmark for u7.7/-eu-jPrac -c urclock -P ch340 -p m328p -b 1000000

Note the benchmark line with the cumulative time for all five tasks
2024-02-26 23:19:43 +13:00
stefanrueger
83571e3310 Remove -l $logfile when echoing a failed avrdude command 2024-02-06 12:32:22 +13:00
stefanrueger
cf2b362532 Remove -l $logfile when listing avrdude commands 2024-02-05 15:13:43 +13:00
stefanrueger
7bf69aad43 Check $avrdude_bin is executable 2024-02-05 14:51:18 +13:00
stefanrueger
f9246b81c4 Remove wildcard string matches in test script 2024-02-05 14:33:02 +13:00
stefanrueger
8f8316f08b Change integer test to string test to allow non-integer $elapsed 2024-02-05 14:11:41 +13:00
stefanrueger
e6c1229b71 Remove config eesave output from test-avrdude -v runs
-v is meant to only show AVRDUDE errors and warnings

Before this commit:

$ tools/test-avrdude -v -p "-c dryrun -p m328p"
Testing avrdude version 7.2-20240201 (571a8063)
Prepare "-c dryrun -p m328p" and press 'enter' or 'space' to continue. Press any other key to skip
   0.064 s: fuse access: clear, set and read eesave fuse bit
config eesave=ee_erased # 1
   0.068 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
   0.068 s: chip erase
   0.068 s: flash -U write/verify holes_rjmp_loops_32768B.hex
   0.068 s: flash -T write/verify holes_rjmp_loops_32768B.hex
   0.068 s: eeprom check whether programmer can flip 0s to 1s
   0.069 s: eeprom -U write/verify holes_pack_my_box_1024B.hex
   0.067 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_1024B.hex
   0.068 s: chip erase and spot check flash is actually erased
   0.068 s: spot check eeprom is erased, too

After:

$ tools/test-avrdude -v -p "-c dryrun -p m328p"
Testing avrdude version 7.2-20240201 (571a8063)
Prepare "-c dryrun -p m328p" and press 'enter' or 'space' to continue. Press any other key to skip
   0.065 s: fuse access: clear, set and read eesave fuse bit
   0.068 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
   0.067 s: chip erase
   0.068 s: flash -U write/verify holes_rjmp_loops_32768B.hex
   0.068 s: flash -T write/verify holes_rjmp_loops_32768B.hex
   0.066 s: eeprom check whether programmer can flip 0s to 1s
   0.069 s: eeprom -U write/verify holes_pack_my_box_1024B.hex
   0.068 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_1024B.hex
   0.067 s: chip erase and spot check flash is actually erased
2024-02-05 14:04:38 +13:00
stefanrueger
571a8063b9 Update test-avrdude usage 2024-02-01 18:29:00 +13:00
stefanrueger
acd5584c62 Provide -T option for test-avrdude to add dryrun/dryboot tests 2024-02-01 15:21:34 +13:00
stefanrueger
2c677693f8 Exit test-avrdude with 1 if any failure occurred 2024-02-01 15:09:00 +13:00
stefanrueger
213fe7561f Create test-avrdude's temporary files in the script itself 2024-02-01 15:02:48 +13:00
stefanrueger
370a15d032 Reduce default delay between avrdude test runs
- From 4 s to 0.75 s
 - Do not delay at all for -c dryrun/dryboot
 - Do not delay before first avrdude call in a series
2024-01-31 14:49:46 +13:00
stefanrueger
86af6b6d01 Add option test-avrdude -t <dir> for tmp directory 2024-01-31 11:44:16 +13:00
stefanrueger
8f46c531f1 Avoid sed -i in test-avrdude script 2024-01-31 11:38:53 +13:00
stefanrueger
3d3a387d1a Check test-avrdude can write to /dev/shm 2024-01-30 23:15:06 +13:00
stefanrueger
742cb9dd77 Update test-avrdude script
- Simplify command to make eesave fusebit delete EEPROM on chip erase
 - Replace ${var,,} construct with tr A-Z a-z so older bash shells work
 - Make -l work for fuse access tests
2024-01-30 14:31:25 +13:00
stefanrueger
5e2409b9fc Remove EEPROM spot check after chip erase from bootloaders
Bootloaders emulate chip erase (if at all) so EEPROM is unlikely erased
2024-01-29 18:31:32 +13:00
stefanrueger
73adee82e2 Update test-avrdude error message 2024-01-29 10:26:11 +13:00
stefanrueger
be9c2a507d Add tools/test-avrdude
$ tools/test-avrdude -h
Syntax: test-avrdude {<opts>}
Function: test AVRDUDE for certain programmer and part combinations
Options:
    -c <configuration spec>     additional configuration options used for all runs
    -d <sec>                    delay between test commands (default 4 seconds)
    -e <avrdude path>           set path of AVRDUDE executable (default avrdude)
    -l                          list test commands but do not execute them
    -p <programmer/part specs>  can be used multiple times, overrides default tests
    -s                          skip EEPROM tests for bootloaders
    -v                          verbose: show AVRDUDE error and warning messages
    -? or -h                    show this help text
Example:
    $ test-avrdude -d 0 -p "-c dryrun -p t13" -p "-c dryrun -p m4809"

$ echo | tools/test-avrdude -p"-cdryrun -pm328p" -d0
Testing avrdude version 7.2-20240128 (09345002)
Prepare "-cdryrun -pm328p" and press 'enter' or 'space' to continue. Press any other key to skip
   0.064 s: fuse access: clear, set and read eesave fuse bit
   0.083 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
   0.066 s: chip erase
   0.068 s: flash -U write/verify holes_rjmp_loops_32768B.hex
   0.067 s: flash -T write/verify holes_rjmp_loops_32768B.hex
   0.067 s: eeprom check whether programmer can flip 0s to 1s
   0.067 s: eeprom -U write/verify holes_pack_my_box_1024B.hex
   0.066 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_1024B.hex
   0.069 s: chip erase and spot check flash is actually erased
   0.067 s: spot check eeprom is erased, too
2024-01-29 01:39:08 +13:00