blob: 4133155ae97dc7657e96b6a4d96f826a5da4e668 [file] [log] [blame]
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +02001#! /bin/bash
Stephen Warren7ad67e52014-06-10 16:28:10 -06002
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +02003set -e # any command return if not equal to zero
4clear
5
6COLOUR_RED="\33[31m"
7COLOUR_GREEN="\33[32m"
8COLOUR_DEFAULT="\33[0m"
9
10DIR=./
11SUFFIX=img
12RCV_DIR=rcv/
13LOG_FILE=./log/log-`date +%d-%m-%Y_%H-%M-%S`
14
Stephen Warren7ad67e52014-06-10 16:28:10 -060015cd `dirname $0`
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020016./dfu_gadget_test_init.sh
17
18cleanup () {
Stephen Warren7ad67e52014-06-10 16:28:10 -060019 rm -rf $DIR$RCV_DIR
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020020}
21
22die () {
23 printf " $COLOUR_RED FAILED $COLOUR_DEFAULT \n"
24 cleanup
25 exit 1
26}
27
28calculate_md5sum () {
29 MD5SUM=`md5sum $1`
30 MD5SUM=`echo $MD5SUM | cut -d ' ' -f1`
31 echo "md5sum:"$MD5SUM
32}
33
34dfu_test_file () {
35 printf "$COLOUR_GREEN ========================================================================================= $COLOUR_DEFAULT\n"
36 printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1
37
38 dfu-util -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
39
40 echo -n "TX: "
41 calculate_md5sum $1
42
43 MD5_TX=$MD5SUM
44
Stephen Warren7ad67e52014-06-10 16:28:10 -060045 dfu-util -D ${DIR}/dfudummy.bin -a $TARGET_ALT_SETTING_B >> $LOG_FILE 2>&1 || die $?
46
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020047 N_FILE=$DIR$RCV_DIR${1:2}"_rcv"
48
49 dfu-util -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
50
51 echo -n "RX: "
52 calculate_md5sum $N_FILE
53 MD5_RX=$MD5SUM
54
55 if [ "$MD5_TX" == "$MD5_RX" ]; then
56 printf " $COLOUR_GREEN -------> OK $COLOUR_DEFAULT \n"
57 else
58 printf " $COLOUR_RED -------> FAILED $COLOUR_DEFAULT \n"
59 cleanup
60 exit 1
61 fi
62
63}
64
65printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n"
66echo "DFU EP0 transmission test program"
67echo "Trouble shoot -> disable DBG (even the KERN_DEBUG) in the UDC driver"
68echo "@ -> TRATS2 # dfu 0 mmc 0"
Stephen Warrenc0e66632014-07-01 12:16:55 -060069cleanup
Stephen Warren7ad67e52014-06-10 16:28:10 -060070mkdir -p $DIR$RCV_DIR
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020071touch $LOG_FILE
72
73if [ $# -eq 0 ]
74then
75 printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n"
76 exit 0
77fi
78
79TARGET_ALT_SETTING=$1
Stephen Warren7ad67e52014-06-10 16:28:10 -060080TARGET_ALT_SETTING_B=$2
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020081
Stephen Warren7ad67e52014-06-10 16:28:10 -060082if [ -n "$3" ]
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020083then
Stephen Warren7ad67e52014-06-10 16:28:10 -060084 dfu_test_file $3
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020085else
86 for file in $DIR*.$SUFFIX
87 do
88 dfu_test_file $file
89 done
90fi
91
92cleanup
93
94exit 0