Skip to content

Commit

Permalink
Add options -a and -m to test8
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Aug 9, 2024
1 parent c833d9f commit 526ffe1
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tools/test8
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Author Stefan Rueger, 2024

progname=$(basename "$0")
adopts=()
mem=ALL
init=-1
rand=-1

Expand All @@ -13,8 +15,10 @@ Syntax: $progname [<opts>] <programmer> <part>
Function: test AVRDUDE for v 8.0 release with -c programmer -p part;
also leaves a file bak-<programmer>-<part.hex for inspection
Options:
-i <n> use avrdude -c dryrun -xinit=<n> to initialiase part and exit
-r <n> use avrdude -c dryrun -xrandom=<n> to initialiase part and exit
-i <n> use avrdude -c dryrun -xinit=<n> to initialiase part and exit
-r <n> use avrdude -c dryrun -xrandom=<n> to initialiase part and exit
-a <opt> pass avrdude option <opt> through to avrdude test commands
-m <mlist> use memory list <mlist> instead of ALL
Examples:
- Prepare a part with non-trivial random content
Expand All @@ -26,12 +30,16 @@ Examples:
END
}

while getopts ":i:r:" opt; do
while getopts ":i:r:a:m:" opt; do
case ${opt} in
i) init=0; [[ ! -z "$OPTARG" ]] && init="$OPTARG"
;;
r) rand=0; [[ ! -z "$OPTARG" ]] && rand="$OPTARG"
;;
a) if [[ ! -z "$OPTARG" ]]; then adopts+=("$OPTARG"); fi
;;
m) if [[ ! -z "$OPTARG" ]]; then mem="$OPTARG"; fi
;;
--) shift;
break
;;
Expand Down Expand Up @@ -63,17 +71,17 @@ f="bak-$1-$2.hex:I"

if [[ $init -gt -1 || $rand -gt -1 ]]; then
how="init=$init"; [ $rand -gt -1 ] && how="random=$rand"
avrdude -qqc dryrun -p $2 -U ALL:r:$f -x $how
avrdude -c $1 -p $2 -U ALL:w:$f
avrdude -qqc dryrun -p $2 -U $mem:r:$f -x $how
avrdude -c $1 -p $2 -U $mem:w:$f
echo $progname: $2 initialsed
exit 0
fi

######
# Actual test

if ! avrdude -c $1 -p $2 -D -UALL:r:$f -T "fact reset" -UALL:w:$f -UALL:v:$f; then
if ! avrdude "${adopts[@]}" -c $1 -p $2 -D -U$mem:r:$f -T "fact reset" -U$mem:w:$f -U$mem:v:$f; then
echo -------------------------------
echo Re-running to create error logs
avrdude -vvv -c $1 -p $2 -D -UALL:r:$f -T "fact reset" -UALL:w:$f -UALL:v:$f -llog-$1-$2.txt
avrdude "${adopts[@]}" -vvv -c $1 -p $2 -D -U$mem:r:$f -T "fact reset" -U$mem:w:$f -U$mem:v:$f -llog-$1-$2.txt
fi

0 comments on commit 526ffe1

Please sign in to comment.