2014-06-18 09:38:56 +00:00
|
|
|
#! /bin/bash
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
|
2014-08-18 10:12:27 +00:00
|
|
|
# Copyright (C) 2014 Samsung Electronics
|
|
|
|
# Lukasz Majewski <l.majewski@samsung.com>
|
|
|
|
#
|
|
|
|
# Script fixes, enhancements and testing:
|
|
|
|
# Stephen Warren <swarren@nvidia.com>
|
|
|
|
#
|
|
|
|
# DFU operation test script
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
2014-06-18 09:38:56 +00:00
|
|
|
set -e # any command return if not equal to zero
|
|
|
|
clear
|
|
|
|
|
|
|
|
COLOUR_RED="\33[31m"
|
|
|
|
COLOUR_GREEN="\33[32m"
|
|
|
|
COLOUR_DEFAULT="\33[0m"
|
|
|
|
|
|
|
|
DIR=./
|
|
|
|
SUFFIX=img
|
|
|
|
RCV_DIR=rcv/
|
|
|
|
LOG_FILE=./log/log-`date +%d-%m-%Y_%H-%M-%S`
|
|
|
|
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
cd `dirname $0`
|
2014-06-18 09:38:56 +00:00
|
|
|
./dfu_gadget_test_init.sh
|
|
|
|
|
|
|
|
cleanup () {
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
rm -rf $DIR$RCV_DIR
|
2014-06-18 09:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
die () {
|
|
|
|
printf " $COLOUR_RED FAILED $COLOUR_DEFAULT \n"
|
|
|
|
cleanup
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
calculate_md5sum () {
|
|
|
|
MD5SUM=`md5sum $1`
|
|
|
|
MD5SUM=`echo $MD5SUM | cut -d ' ' -f1`
|
|
|
|
echo "md5sum:"$MD5SUM
|
|
|
|
}
|
|
|
|
|
|
|
|
dfu_test_file () {
|
|
|
|
printf "$COLOUR_GREEN ========================================================================================= $COLOUR_DEFAULT\n"
|
|
|
|
printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1
|
|
|
|
|
2015-08-15 09:23:45 +00:00
|
|
|
dfu-util $USB_DEV -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
|
2014-06-18 09:38:56 +00:00
|
|
|
|
|
|
|
echo -n "TX: "
|
|
|
|
calculate_md5sum $1
|
|
|
|
|
|
|
|
MD5_TX=$MD5SUM
|
|
|
|
|
2015-08-15 09:23:45 +00:00
|
|
|
dfu-util $USB_DEV -D ${DIR}/dfudummy.bin -a $TARGET_ALT_SETTING_B >> $LOG_FILE 2>&1 || die $?
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
|
2014-06-18 09:38:56 +00:00
|
|
|
N_FILE=$DIR$RCV_DIR${1:2}"_rcv"
|
|
|
|
|
2015-08-15 09:23:45 +00:00
|
|
|
dfu-util $USB_DEV -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
|
2014-06-18 09:38:56 +00:00
|
|
|
|
|
|
|
echo -n "RX: "
|
|
|
|
calculate_md5sum $N_FILE
|
|
|
|
MD5_RX=$MD5SUM
|
|
|
|
|
|
|
|
if [ "$MD5_TX" == "$MD5_RX" ]; then
|
|
|
|
printf " $COLOUR_GREEN -------> OK $COLOUR_DEFAULT \n"
|
|
|
|
else
|
|
|
|
printf " $COLOUR_RED -------> FAILED $COLOUR_DEFAULT \n"
|
|
|
|
cleanup
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n"
|
|
|
|
echo "DFU EP0 transmission test program"
|
|
|
|
echo "Trouble shoot -> disable DBG (even the KERN_DEBUG) in the UDC driver"
|
|
|
|
echo "@ -> TRATS2 # dfu 0 mmc 0"
|
2014-07-01 18:16:55 +00:00
|
|
|
cleanup
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
mkdir -p $DIR$RCV_DIR
|
2014-06-18 09:38:56 +00:00
|
|
|
touch $LOG_FILE
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
TARGET_ALT_SETTING=$1
|
test: dfu: script enhancements
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file
with different data. This ensures that the DFU buffer's content is
replaced, so that if the read (upload) succeeds, we know that the
correct data was actually read from the storage device, rather than
simply being left over in the DFU buffer. This requires two alt
setting names to be passed to the script, and a dummy data file to
be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory
that contains it, by cd'ing to that directory before invoking
./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in
some places.
* Add 959, 961 test file sizes, to be consistent with having one
more than and one less than all the other "round" sizes 64, 128, and
4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it
isn't used.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-06-10 22:28:10 +00:00
|
|
|
TARGET_ALT_SETTING_B=$2
|
2014-06-18 09:38:56 +00:00
|
|
|
|
2015-08-15 09:23:45 +00:00
|
|
|
file=$3
|
|
|
|
[[ $3 == *':'* ]] && USB_DEV="-d $3" && file=""
|
|
|
|
[ $# -eq 4 ] && USB_DEV="-d $4"
|
|
|
|
|
|
|
|
if [ -n "$file" ]
|
2014-06-18 09:38:56 +00:00
|
|
|
then
|
2015-08-15 09:23:45 +00:00
|
|
|
dfu_test_file $file
|
2014-06-18 09:38:56 +00:00
|
|
|
else
|
2015-08-15 09:23:45 +00:00
|
|
|
for f in $DIR*.$SUFFIX
|
2014-06-18 09:38:56 +00:00
|
|
|
do
|
2015-08-15 09:23:45 +00:00
|
|
|
dfu_test_file $f
|
2014-06-18 09:38:56 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
exit 0
|