blob: 2f5b7db58d41f20cab39aabec835d00414ef0a68 [file] [log] [blame]
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +02001#! /bin/bash
Stephen Warren7ad67e52014-06-10 16:28:10 -06002
Lukasz Majewski4c984c82014-08-18 12:12:27 +02003# Copyright (C) 2014 Samsung Electronics
4# Lukasz Majewski <l.majewski@samsung.com>
5#
6# Script fixes, enhancements and testing:
7# Stephen Warren <swarren@nvidia.com>
8#
9# DFU operation test script
10#
11# SPDX-License-Identifier: GPL-2.0+
12
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020013set -e # any command return if not equal to zero
14clear
15
16COLOUR_RED="\33[31m"
17COLOUR_GREEN="\33[32m"
18COLOUR_DEFAULT="\33[0m"
19
20DIR=./
21SUFFIX=img
22RCV_DIR=rcv/
23LOG_FILE=./log/log-`date +%d-%m-%Y_%H-%M-%S`
24
Stephen Warren7ad67e52014-06-10 16:28:10 -060025cd `dirname $0`
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020026./dfu_gadget_test_init.sh
27
28cleanup () {
Stephen Warren7ad67e52014-06-10 16:28:10 -060029 rm -rf $DIR$RCV_DIR
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020030}
31
32die () {
33 printf " $COLOUR_RED FAILED $COLOUR_DEFAULT \n"
34 cleanup
35 exit 1
36}
37
38calculate_md5sum () {
39 MD5SUM=`md5sum $1`
40 MD5SUM=`echo $MD5SUM | cut -d ' ' -f1`
41 echo "md5sum:"$MD5SUM
42}
43
44dfu_test_file () {
45 printf "$COLOUR_GREEN ========================================================================================= $COLOUR_DEFAULT\n"
46 printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1
47
48 dfu-util -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
49
50 echo -n "TX: "
51 calculate_md5sum $1
52
53 MD5_TX=$MD5SUM
54
Stephen Warren7ad67e52014-06-10 16:28:10 -060055 dfu-util -D ${DIR}/dfudummy.bin -a $TARGET_ALT_SETTING_B >> $LOG_FILE 2>&1 || die $?
56
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020057 N_FILE=$DIR$RCV_DIR${1:2}"_rcv"
58
59 dfu-util -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $?
60
61 echo -n "RX: "
62 calculate_md5sum $N_FILE
63 MD5_RX=$MD5SUM
64
65 if [ "$MD5_TX" == "$MD5_RX" ]; then
66 printf " $COLOUR_GREEN -------> OK $COLOUR_DEFAULT \n"
67 else
68 printf " $COLOUR_RED -------> FAILED $COLOUR_DEFAULT \n"
69 cleanup
70 exit 1
71 fi
72
73}
74
75printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n"
76echo "DFU EP0 transmission test program"
77echo "Trouble shoot -> disable DBG (even the KERN_DEBUG) in the UDC driver"
78echo "@ -> TRATS2 # dfu 0 mmc 0"
Stephen Warrenc0e66632014-07-01 12:16:55 -060079cleanup
Stephen Warren7ad67e52014-06-10 16:28:10 -060080mkdir -p $DIR$RCV_DIR
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020081touch $LOG_FILE
82
83if [ $# -eq 0 ]
84then
85 printf " $COLOUR_RED Please pass alt setting number!! $COLOUR_DEFAULT \n"
86 exit 0
87fi
88
89TARGET_ALT_SETTING=$1
Stephen Warren7ad67e52014-06-10 16:28:10 -060090TARGET_ALT_SETTING_B=$2
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020091
Stephen Warren7ad67e52014-06-10 16:28:10 -060092if [ -n "$3" ]
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020093then
Stephen Warren7ad67e52014-06-10 16:28:10 -060094 dfu_test_file $3
Lukasz Majewskia4c86bb2014-06-18 11:38:56 +020095else
96 for file in $DIR*.$SUFFIX
97 do
98 dfu_test_file $file
99 done
100fi
101
102cleanup
103
104exit 0