blob: c5c5f1d957f148ea341459c520f4efee5dbfdcd8 [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 Warren7ad67e52014-06-10 16:28:10 -060069mkdir -p $DIR$RCV_DIR
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020070touch $LOG_FILE
71
72if [ $# -eq 0 ]
73then
74 printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n"
75 exit 0
76fi
77
78TARGET_ALT_SETTING=$1
Stephen Warren7ad67e52014-06-10 16:28:10 -060079TARGET_ALT_SETTING_B=$2
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020080
Stephen Warren7ad67e52014-06-10 16:28:10 -060081if [ -n "$3" ]
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020082then
Stephen Warren7ad67e52014-06-10 16:28:10 -060083 dfu_test_file $3
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020084else
85 for file in $DIR*.$SUFFIX
86 do
87 dfu_test_file $file
88 done
89fi
90
91cleanup
92
93exit 0