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