From a2906da411e6326a248eaa84e622148fb439ac99 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Aug 2024 15:39:01 +0200 Subject: [PATCH 1/7] 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 cf0822bb71086bf633c3166b21beb3201ad202dd): 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. --- tools/test-avrdude | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index 2ecacadc..a1f2fb46 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -149,8 +149,8 @@ fi arraylength=${#pgm_and_target[@]} type "$avrdude_bin" >/dev/null 2>&1 || { echo "$progname: cannot execute $avrdude_bin"; exit 1; } -echo -n "Testing $avrdude_bin" -$avrdude_bin -v 2>&1 | grep Version | cut -f2- -d: | sed s/Version/version/ +echo -n "Testing $avrdude_bin " +$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion/version/' | head -n1 [[ -d $tmp && -w $tmp ]] || tmp=/tmp # Fall back to /tmp if tmp directory unusable status=$(mktemp "$tmp/$progname.status.XXXXXX") From a8a8711b34b1ae7107e56c68b6bda3d2df26111a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Aug 2024 14:07:41 +0200 Subject: [PATCH 2/7] test-avrdude: Abort if running "avrdude -v" fails --- tools/test-avrdude | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index a1f2fb46..43d7ca97 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -149,8 +149,6 @@ fi arraylength=${#pgm_and_target[@]} type "$avrdude_bin" >/dev/null 2>&1 || { echo "$progname: cannot execute $avrdude_bin"; exit 1; } -echo -n "Testing $avrdude_bin " -$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion/version/' | head -n1 [[ -d $tmp && -w $tmp ]] || tmp=/tmp # Fall back to /tmp if tmp directory unusable status=$(mktemp "$tmp/$progname.status.XXXXXX") @@ -160,6 +158,17 @@ tmpfile=$(mktemp "$tmp/$progname.tmp.XXXXXX") resfile=$(mktemp "$tmp/$progname.res.XXXXXX") trap "rm -f $status $logfile $outfile $tmpfile $resfile" EXIT +echo -n "Testing $avrdude_bin version..." +$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion //' | head -n1 > "$outfile" +if test -s "$outfile"; then + echo -n " " + cat "$outfile" +else + echo " error" + $avrdude_bin -v + exit 1 +fi + devnull=$tmpfile # Cannot use /dev/null as file in Windows avrdude TIMEFORMAT=%R # time built-in only returns elapsed wall-clock time From f3e8524cb37126f0b1c3d3c8fe1f9e92bdd7eb95 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 15 Aug 2024 21:11:54 +0200 Subject: [PATCH 3/7] ci: linux-autotools use uninstalled avrdude for test-avrdude Use the uninstalled avrdude executable and the avrdude.conf config file which have just been built for the dry-run test with tools/test-avrdude. Note that the parameter for the config file is a bit unexpected: -c "-C path/to/avrdude.conf" --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68917971..211de948 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: - name: Install run: sudo make -C _ambuild install - name: Dryrun_test - run: printf "\n\n" | ./tools/test-avrdude -d0 -p"-cdryrun -pm2560" -p"-cdryrun -pavr64du28" + run: printf "\n\n" | ./tools/test-avrdude -e _ambuild/avrdude -c '-C _ambuild/avrdude.conf' -d0 -p"-cdryrun -pm2560" -p"-cdryrun -pavr64du28" - name: distcheck run: make -C _ambuild -j$(nproc) distcheck From 4323a435197967d0be25e97eabc0cefecad1e160 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Aug 2024 14:28:49 +0200 Subject: [PATCH 4/7] test-avrdude: Print the type of the avrdude_bin executable --- tools/test-avrdude | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index 43d7ca97..5f9bf377 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -148,7 +148,16 @@ if [[ ${#pgm_and_target[@]} -eq 0 ]]; then fi arraylength=${#pgm_and_target[@]} -type "$avrdude_bin" >/dev/null 2>&1 || { echo "$progname: cannot execute $avrdude_bin"; exit 1; } + +echo -n "Testing executable type for '$avrdude_bin'..." +if type "$avrdude_bin" >/dev/null 2>&1; then + echo -n " " + type "$avrdude_bin" +else + echo + echo "$progname: cannot execute $avrdude_bin" + exit 1 +fi [[ -d $tmp && -w $tmp ]] || tmp=/tmp # Fall back to /tmp if tmp directory unusable status=$(mktemp "$tmp/$progname.status.XXXXXX") From b8718e6b5d6b7d94ea2cf3aec645de2256bd8807 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 15 Aug 2024 19:21:59 +0200 Subject: [PATCH 5/7] test-avrdude: Replace associative array with function call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tools/test-avrdude | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index 5f9bf377..192bee63 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -320,9 +320,19 @@ for (( p=0; p<$arraylength; p++ )); do result [ $? == 0 ] # Test binary, octal, decimal, hexadecimal and R number lists for I/O - declare -A numsys=([b]=binary [o]=octal [d]=decimal [h]=hexadecimal [R]=R) + numsys() { + # this function replaces constant associative array, as + # macos bash does not support associative arrays. + case "$1" in + b) echo "binary" ;; + o) echo "octal" ;; + d) echo "decimal" ;; + h) echo "hexadecimal" ;; + R) echo "R" ;; + esac + } for fmt in b o d h R; do - specify="flash writing ${numsys[$fmt]} numbers" + specify="flash writing $(numsys "$fmt") numbers" command=(${avrdude[@]} -U $tfiles/urboot_m2560_1s_x16m0_115k2_uart0_rxe0_txe1_led+b7_pr_ee_ce.hex -T '"write flash 0x3fd00 0xc0cac01a 0xcafe \"secret Coca Cola recipe\""' @@ -331,7 +341,7 @@ for (( p=0; p<$arraylength; p++ )); do execute "${command[@]}" result [ $? == 0 ] - specify="flash reading and verifying ${numsys[$fmt]} numbers" + specify="flash reading and verifying $(numsys "$fmt") numbers" command=(${avrdude[@]} -U flash:w:$tmpfile:$fmt -U flash:r:$resfile:r) From cef23e252e283d5d4bb30ea4b4d00954c55733e2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 16 Aug 2024 15:50:58 +0200 Subject: [PATCH 6/7] 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 --- tools/test-avrdude | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index 192bee63..a3112c6f 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -149,13 +149,9 @@ fi arraylength=${#pgm_and_target[@]} -echo -n "Testing executable type for '$avrdude_bin'..." -if type "$avrdude_bin" >/dev/null 2>&1; then - echo -n " " - type "$avrdude_bin" -else - echo +if ! type "$avrdude_bin" >/dev/null 2>&1; then echo "$progname: cannot execute $avrdude_bin" + type "$avrdude_bin" exit 1 fi @@ -167,13 +163,12 @@ tmpfile=$(mktemp "$tmp/$progname.tmp.XXXXXX") resfile=$(mktemp "$tmp/$progname.res.XXXXXX") trap "rm -f $status $logfile $outfile $tmpfile $resfile" EXIT -echo -n "Testing $avrdude_bin version..." -$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion //' | head -n1 > "$outfile" +echo -n "Testing $(type -p "$avrdude_bin")" +$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion//' | head -n1 > "$outfile" if test -s "$outfile"; then - echo -n " " cat "$outfile" else - echo " error" + echo ": error obtaining version from '$avrdude_bin -v'" $avrdude_bin -v exit 1 fi From 8f64d849a5f7306168d6045bab00f35766148b32 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 16 Aug 2024 15:58:23 +0200 Subject: [PATCH 7/7] 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 --- tools/test-avrdude | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test-avrdude b/tools/test-avrdude index a3112c6f..0206326c 100755 --- a/tools/test-avrdude +++ b/tools/test-avrdude @@ -268,9 +268,9 @@ for (( p=0; p<$arraylength; p++ )); do avrdude=($avrdude_bin -l $logfile $avrdude_conf -qq ${pgm_and_target[$p]}) # Get flash and EEPROM size in bytes and make sure the numbers are in dec form - flash_size=$(${avrdude[@]} -cdryrun -T 'part -m' 2>/dev/null | grep flash | awk '{print $2}') + flash_size=$($avrdude_bin $avrdude_conf -c dryrun -p $part -T 'part -m' 2>/dev/null | grep flash | awk '{print $2}') bench_flwr_size=$((flash_size/6)) # Approximate(!) size of file holes_rjmp_loops_${flash_size}B.hex - ee_size=$(${avrdude[@]} -cdryrun -T 'part -m' 2>/dev/null | grep eeprom | awk '{print $2}') + ee_size=$($avrdude_bin $avrdude_conf -c dryrun -p $part -T 'part -m' 2>/dev/null | grep eeprom | awk '{print $2}') bench_eewr_size=$((ee_size/6)) # Approximate(!) size of file holes_pack_my_box_${ee_size}B.hex if [[ -z "$flash_size" ]]; then