mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-06-02 09:46:34 +03:00
Lowercase variable names in test-avrdude
Uppercase names are typically used for environment variables in bash
This commit is contained in:
@@ -192,7 +192,7 @@ result () {
|
||||
else
|
||||
echo ❌ "$(printf '%7.3f s' $elapsed): $specify (failed command below)"
|
||||
echo "\$ ${command[@]}" | sed "s/ -l [^ ]* / /" | tr -s " "
|
||||
FAIL=true
|
||||
fail=true
|
||||
bench_char="❌"
|
||||
exitstate=1
|
||||
[[ $emulated -eq 0 ]] && sleep 4 # Let the hw settle down before next test
|
||||
@@ -235,22 +235,22 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
bench_char="✅"; bench_t_flwr=0; bench_t_flrd=0; bench_t_eewr=0; bench_t_eerd=0; bench_t_ce=0
|
||||
|
||||
if [ "$key" == '' ]; then
|
||||
FAIL=false
|
||||
fail=false
|
||||
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}')
|
||||
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}')
|
||||
bench_eewr_size=$((EEPROM_SIZE/6)) # Approximate(!) size of file holes_pack_my_box_${EE_SIZE}B.hex
|
||||
flash_size=$(${avrdude[@]} -cdryrun -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}')
|
||||
bench_eewr_size=$((ee_size/6)) # Approximate(!) size of file holes_pack_my_box_${ee_size}B.hex
|
||||
|
||||
if [[ -z "$FLASH_SIZE" ]]; then
|
||||
if [[ -z "$flash_size" ]]; then
|
||||
echo "Cannot detect flash; check that \"${pgm_and_target[$p]}\" are valid avrdude options; skipping this test"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Memories that may or may not be present
|
||||
USERSIG_SIZE=$(${avrdude[@]} -cdryrun -T 'part -m' 2>/dev/null | grep usersig | awk '{print $2}') # R/W
|
||||
usersig_size=$(${avrdude[@]} -cdryrun -T 'part -m' 2>/dev/null | grep usersig | awk '{print $2}') # R/W
|
||||
|
||||
# Is the to be tested programmer for a bootloader?
|
||||
is_bootloader=0
|
||||
@@ -264,13 +264,13 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
|
||||
# Should EEPROM test be carried out?
|
||||
check_eeprom=1
|
||||
[[ -z "$EE_SIZE" ]] && check_eeprom=0
|
||||
[[ -z "$ee_size" ]] && check_eeprom=0
|
||||
[[ $is_bootloader -eq 1 && $skip_eeprom -eq 1 ]] && check_eeprom=0
|
||||
|
||||
#####
|
||||
# Dryrun tests for high-level progrmmer-independent tests (only for -m2560 or similar)
|
||||
#
|
||||
if [[ "$programmer" == -cdryrun && $FLASH_SIZE -eq 262144 && $benchmark -eq 0 ]]; then
|
||||
if [[ "$programmer" == -cdryrun && $flash_size -eq 262144 && $benchmark -eq 0 ]]; then
|
||||
# Raw test
|
||||
specify="flash raw format -T/-U write/verify cola-vending-machine.raw"
|
||||
command=(${avrdude[@]}
|
||||
@@ -328,7 +328,7 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
# Fuse test (bootloaders usually cannot set fuses)
|
||||
#
|
||||
if [[ $is_bootloader -ne 1 && $fusetest -eq 1 && $benchmark -eq 0 ]]; then
|
||||
if [ -n "$EE_SIZE" ]; then
|
||||
if [ -n "$ee_size" ]; then
|
||||
specify="fuse access: clear, set and read eesave fuse bit"
|
||||
command=(${avrdude[@]} -T '"config eesave=0; config eesave=1; config eesave"')
|
||||
else
|
||||
@@ -341,7 +341,7 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
mv ${outfile}-2 $outfile
|
||||
result [[ '"$fusebit"' == 1 '&&' ! -s $outfile '&&' ! -s $logfile ]]
|
||||
|
||||
if [ -n "$EE_SIZE" ]; then
|
||||
if [ -n "$ee_size" ]; then
|
||||
specify="fuse access: set eesave fusebit to delete EEPROM on chip erase"
|
||||
command=(${avrdude[@]} -T '"config eesave=ee*erased"')
|
||||
execute "${command[@]}" > $outfile
|
||||
@@ -364,13 +364,13 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
#####
|
||||
# Flash test: a relatively difficult file with two code blocks and one data block with holes
|
||||
#
|
||||
specify="flash -U write/verify holes_rjmp_loops_${FLASH_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -Uflash:w:$tfiles/holes_rjmp_loops_${FLASH_SIZE}B.hex)
|
||||
specify="flash -U write/verify holes_rjmp_loops_${flash_size}B.hex"
|
||||
command=(${avrdude[@]} -Uflash:w:$tfiles/holes_rjmp_loops_${flash_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
if [[ $? != 0 && $benchmark -eq 0 ]]; then # Not working? try a file without holes
|
||||
specify="flash -U write/verify rjmp_loops_for_bootloaders_${FLASH_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -Uflash:w:$tfiles/rjmp_loops_for_bootloaders_${FLASH_SIZE}B.hex)
|
||||
specify="flash -U write/verify rjmp_loops_for_bootloaders_${flash_size}B.hex"
|
||||
command=(${avrdude[@]} -Uflash:w:$tfiles/rjmp_loops_for_bootloaders_${flash_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
fi
|
||||
@@ -385,13 +385,13 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
fi
|
||||
|
||||
if [[ $benchmark -eq 0 ]]; then
|
||||
specify="flash -T write/verify holes_rjmp_loops_${FLASH_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -T '"write flash '$tfiles/holes_rjmp_loops_${FLASH_SIZE}B.hex:a'"')
|
||||
specify="flash -T write/verify holes_rjmp_loops_${flash_size}B.hex"
|
||||
command=(${avrdude[@]} -T '"write flash '$tfiles/holes_rjmp_loops_${flash_size}B.hex:a'"')
|
||||
execute "${command[@]}" > $outfile
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]]
|
||||
if [ $? != 0 ]; then # Not working? try a file without holes
|
||||
specify="flash -T write/verify rjmp_loops_for_bootloaders_${FLASH_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -T '"write flash '$tfiles/rjmp_loops_for_bootloaders_${FLASH_SIZE}B.hex:a'"')
|
||||
specify="flash -T write/verify rjmp_loops_for_bootloaders_${flash_size}B.hex"
|
||||
command=(${avrdude[@]} -T '"write flash '$tfiles/rjmp_loops_for_bootloaders_${flash_size}B.hex:a'"')
|
||||
execute "${command[@]}" > $outfile
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]]
|
||||
fi
|
||||
@@ -402,8 +402,8 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
#
|
||||
if [ $check_eeprom -eq 1 ]; then
|
||||
if [ $benchmark -eq 1 ]; then
|
||||
specify="eeprom -U write/verify holes_pack_my_box_${EE_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/holes_pack_my_box_${EE_SIZE}B.hex)
|
||||
specify="eeprom -U write/verify holes_pack_my_box_${ee_size}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/holes_pack_my_box_${ee_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
bench_t_eewr=$bench_t
|
||||
@@ -421,13 +421,13 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
if [ $? == 0 ]; then # OK, try a file with holes
|
||||
specify="eeprom -U write/verify holes_pack_my_box_${EE_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/holes_pack_my_box_${EE_SIZE}B.hex)
|
||||
specify="eeprom -U write/verify holes_pack_my_box_${ee_size}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/holes_pack_my_box_${ee_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
if [ $? != 0 ]; then # Not working? try a file without holes
|
||||
specify="eeprom -U write/verify the_quick_brown_fox_${EE_SIZE}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/the_quick_brown_fox_${EE_SIZE}B.hex)
|
||||
specify="eeprom -U write/verify the_quick_brown_fox_${ee_size}B.hex"
|
||||
command=(${avrdude[@]} -Ueeprom:w:$tfiles/the_quick_brown_fox_${ee_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
fi
|
||||
@@ -435,16 +435,16 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
echo "# ... the next test may therefore take longer"
|
||||
fi
|
||||
|
||||
specify="eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_${EE_SIZE}B.hex"
|
||||
specify="eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_${ee_size}B.hex"
|
||||
command=(${avrdude[@]}
|
||||
-T '"write eeprom '$tfiles/holes_the_five_boxing_wizards_${EE_SIZE}B.hex:a'"'
|
||||
-T '"write eeprom '$tfiles/holes_the_five_boxing_wizards_${ee_size}B.hex:a'"'
|
||||
-T flush
|
||||
-T '"write eeprom '$tfiles/holes_pack_my_box_${EE_SIZE}B.hex:a'"')
|
||||
-T '"write eeprom '$tfiles/holes_pack_my_box_${ee_size}B.hex:a'"')
|
||||
execute "${command[@]}" > $outfile
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]]
|
||||
if [ $? != 0 ]; then # Not working? try a file without holes
|
||||
specify="eeprom -T write/verify lorem_ipsum_${EE_SIZE}B.srec"
|
||||
command=(${avrdude[@]} -T '"write eeprom '$tfiles/lorem_ipsum_${EE_SIZE}B.srec:a'"')
|
||||
specify="eeprom -T write/verify lorem_ipsum_${ee_size}B.srec"
|
||||
command=(${avrdude[@]} -T '"write eeprom '$tfiles/lorem_ipsum_${ee_size}B.srec:a'"')
|
||||
execute "${command[@]}" > $outfile
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]]
|
||||
fi
|
||||
@@ -455,12 +455,12 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
# Chip erase and verify
|
||||
#
|
||||
specify="chip erase and spot check flash is actually erased"
|
||||
command=(${avrdude[@]} -e -Uflash:v:$tfiles/holes_flash_0xff_${FLASH_SIZE}B.hex)
|
||||
command=(${avrdude[@]} -e -Uflash:v:$tfiles/holes_flash_0xff_${flash_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
if [[ $? == 0 && $check_eeprom -eq 1 && $is_bootloader -eq 0 && $benchmark -eq 0 ]]; then
|
||||
specify="spot check eeprom is erased, too"
|
||||
command=(${avrdude[@]} -Ueeprom:v:$tfiles/holes_eeprom_0xff_${EE_SIZE}B.hex)
|
||||
command=(${avrdude[@]} -Ueeprom:v:$tfiles/holes_eeprom_0xff_${ee_size}B.hex)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
fi
|
||||
@@ -469,18 +469,18 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
######
|
||||
# Write and verify random data to usersig if present
|
||||
#
|
||||
if [[ -n "$USERSIG_SIZE" && $is_bootloader -ne 1 && $benchmark -eq 0 ]]; then
|
||||
specify="usersig -T/-U write/read random_data_${USERSIG_SIZE}B.bin"
|
||||
if [[ -n "$usersig_size" && $is_bootloader -ne 1 && $benchmark -eq 0 ]]; then
|
||||
specify="usersig -T/-U write/read random_data_${usersig_size}B.bin"
|
||||
command=(${avrdude[@]}
|
||||
-T '"erase usersig; write usersig '$tfiles/random_data_${USERSIG_SIZE}B.bin'"'
|
||||
-T '"erase usersig; write usersig '$tfiles/random_data_${usersig_size}B.bin'"'
|
||||
-T flush
|
||||
-U usersig:r:$tmpfile:r
|
||||
-U usersig:v:$tmpfile:r
|
||||
-T '"erase usersig"'
|
||||
-T flush
|
||||
-U usersig:v:$tfiles/0xff_${USERSIG_SIZE}B.hex:i)
|
||||
-U usersig:v:$tfiles/0xff_${usersig_size}B.hex:i)
|
||||
execute "${command[@]}" >$outfile
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]] '&&' cmp -s "$tfiles/random_data_${USERSIG_SIZE}B.bin" "$tmpfile"
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]] '&&' cmp -s "$tfiles/random_data_${usersig_size}B.bin" "$tmpfile"
|
||||
cp /dev/null $tmpfile
|
||||
fi
|
||||
|
||||
@@ -489,7 +489,7 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
echo $bench_char "$(printf '%7.3f s' $bench_sum): benchmark for ${pgm_and_target[$p]}"
|
||||
fi
|
||||
|
||||
if [ $FAIL == true ]; then
|
||||
if [ $fail == true ]; then
|
||||
echo ''
|
||||
read -rep "One or more AVRDUDE \"${pgm_and_target[$p]}\" tests failed. Do you want to retry this particular test? (y/n): " choice
|
||||
case "$choice" in
|
||||
|
||||
Reference in New Issue
Block a user