diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dfu/README | 37 | ||||
-rwxr-xr-x | test/dfu/dfu_gadget_test.sh | 104 | ||||
-rwxr-xr-x | test/dfu/dfu_gadget_test_init.sh | 45 | ||||
-rwxr-xr-x | test/image/test-fit.py | 8 | ||||
-rw-r--r-- | test/ums/README | 30 | ||||
-rwxr-xr-x | test/ums/ums_gadget_test.sh | 175 | ||||
-rwxr-xr-x | test/vboot/vboot_test.sh | 10 |
7 files changed, 404 insertions, 5 deletions
diff --git a/test/dfu/README b/test/dfu/README new file mode 100644 index 00000000000..5176aba632c --- /dev/null +++ b/test/dfu/README @@ -0,0 +1,37 @@ +DFU TEST CASE DESCRIPTION: + +The prerequisites for running this script are assured by +dfu_gadget_test_init.sh, which is automatically invoked by dfu_gadget_test.sh. +In this file user is able to generate their own set of test files by altering +the default set of TEST_FILES_SIZES variable. +The dfu_gadget_test_init.sh would generate test images only if they are not +already generated. + +On the target device, environment variable "dfu_alt_info" must contain at +least: + + dfu_test.bin fat 0 6;dfudummy.bin fat 0 6 + +Depending on your device, you may need to replace "fat" with +"ext4", and "6" with the relevant partition number. For reference please +consult the config file for TRATS/TRATS2 devices +(../../include/configs/trats{2}.h) + +One can use fat, ext4 or any other supported file system supported by U-Boot. +These can be created by exporting storage devices via UMS (ums 0 mmc 0) and +using standard tools on host (like mkfs.ext4). + +Example usage: +1. On the target: + setenv dfu_alt_info dfu_test.bin fat 0 6\;dfudummy.bin fat 0 6 + dfu 0 mmc 0 +2. On the host: + test/dfu/dfu_gadget_test.sh X Y [test file name] + e.g. test/dfu/dfu_gadget_test.sh 0 1 + or + e.g. test/dfu/dfu_gadget_test.sh 0 1 ./dat_960.img + +... where X and Y are dfu_test.bin's and dfudummy.bin's alt setting numbers. +They can be obtained from dfu-util -l or $dfu_alt_info. +It is also possible to pass optional [test file name] to force the script to +test one particular file. diff --git a/test/dfu/dfu_gadget_test.sh b/test/dfu/dfu_gadget_test.sh new file mode 100755 index 00000000000..2f5b7db58d4 --- /dev/null +++ b/test/dfu/dfu_gadget_test.sh @@ -0,0 +1,104 @@ +#! /bin/bash + +# 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+ + +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` + +cd `dirname $0` +./dfu_gadget_test_init.sh + +cleanup () { + rm -rf $DIR$RCV_DIR +} + +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 + + dfu-util -D $1 -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $? + + echo -n "TX: " + calculate_md5sum $1 + + MD5_TX=$MD5SUM + + dfu-util -D ${DIR}/dfudummy.bin -a $TARGET_ALT_SETTING_B >> $LOG_FILE 2>&1 || die $? + + N_FILE=$DIR$RCV_DIR${1:2}"_rcv" + + dfu-util -U $N_FILE -a $TARGET_ALT_SETTING >> $LOG_FILE 2>&1 || die $? + + 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" +cleanup +mkdir -p $DIR$RCV_DIR +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 +TARGET_ALT_SETTING_B=$2 + +if [ -n "$3" ] +then + dfu_test_file $3 +else + for file in $DIR*.$SUFFIX + do + dfu_test_file $file + done +fi + +cleanup + +exit 0 diff --git a/test/dfu/dfu_gadget_test_init.sh b/test/dfu/dfu_gadget_test_init.sh new file mode 100755 index 00000000000..640628eecb7 --- /dev/null +++ b/test/dfu/dfu_gadget_test_init.sh @@ -0,0 +1,45 @@ +#! /bin/bash + +# Copyright (C) 2014 Samsung Electronics +# Lukasz Majewski <l.majewski@samsung.com> +# +# Script fixes, enhancements and testing: +# Stephen Warren <swarren@nvidia.com> +# +# Script for test files generation +# +# SPDX-License-Identifier: GPL-2.0+ + +set -e # any command return if not equal to zero +clear + +COLOUR_RED="\33[31m" +COLOUR_GREEN="\33[32m" +COLOUR_DEFAULT="\33[0m" + +LOG_DIR="./log" + +if [ $# -eq 0 ]; then + TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 1048575 1048576 8M" +else + TEST_FILES_SIZES=$@ +fi + +printf "Init script for generating data necessary for DFU test script" + +if [ ! -d $LOG_DIR ]; then + `mkdir $LOG_DIR` +fi + +for size in $TEST_FILES_SIZES +do + FILE="./dat_$size.img" + if [ ! -f $FILE ]; then + dd if=/dev/urandom of="./dat_$size.img" bs=$size count=1 > /dev/null 2>&1 || exit $? + fi +done +dd if=/dev/urandom of="./dfudummy.bin" bs=1024 count=1 > /dev/null 2>&1 || exit $? + +printf "$COLOUR_GREEN OK $COLOUR_DEFAULT \n" + +exit 0 diff --git a/test/image/test-fit.py b/test/image/test-fit.py index 7394df740af..b065fcb130c 100755 --- a/test/image/test-fit.py +++ b/test/image/test-fit.py @@ -93,13 +93,13 @@ base_fdt = ''' # then do the 'bootm' command, then save out memory from the places where # we expect 'bootm' to write things. Then quit. base_script = ''' -sb load host 0 %(fit_addr)x %(fit)s +sb load hostfs 0 %(fit_addr)x %(fit)s fdt addr %(fit_addr)x bootm start %(fit_addr)x bootm loados -sb save host 0 %(kernel_out)s %(kernel_addr)x %(kernel_size)x -sb save host 0 %(fdt_out)s %(fdt_addr)x %(fdt_size)x -sb save host 0 %(ramdisk_out)s %(ramdisk_addr)x %(ramdisk_size)x +sb save hostfs 0 %(kernel_out)s %(kernel_addr)x %(kernel_size)x +sb save hostfs 0 %(fdt_out)s %(fdt_addr)x %(fdt_size)x +sb save hostfs 0 %(ramdisk_out)s %(ramdisk_addr)x %(ramdisk_size)x reset ''' diff --git a/test/ums/README b/test/ums/README new file mode 100644 index 00000000000..c80fbfefbf5 --- /dev/null +++ b/test/ums/README @@ -0,0 +1,30 @@ +UMS test script. + +ums_gadget_test.sh +================== + +Example usage: +1. On the target: + create UMS exportable partitions (with e.g. gpt write), or specify a + partition number (PART_NUM) as "-" to use the entire device + ums 0 mmc 0 +2. On the host: + sudo test/ums/ums_gadget_test.sh VID PID PART_NUM [-f FILE_SYSTEM] [test_file] + e.g. sudo test/ums/ums_gadget_test.sh 0525 a4a5 6 -f vfat ./dat_14M.img + +... where: + VID - UMS device USB Vendor ID + PID - UMS device USB Product ID + PART_NUM - is the partition number on which UMS operates or "-" to use the + whole device + +Information about available partitions on the target one can read with using +the 'mmc part' or 'part list' commands. + +The partition num (PART_NUM) can be specified as '-' for using the whole device. + +The [-f FILE_SYSTEM] optional switch allows for formatting target partition to +FILE_SYSTEM. + +The last, optional [test_file] parameter is for specifying the exact test file +to use. diff --git a/test/ums/ums_gadget_test.sh b/test/ums/ums_gadget_test.sh new file mode 100755 index 00000000000..56d46163760 --- /dev/null +++ b/test/ums/ums_gadget_test.sh @@ -0,0 +1,175 @@ +#! /bin/bash + +# Copyright (C) 2014 Samsung Electronics +# Lukasz Majewski <l.majewski@samsung.com> +# +# UMS operation test script +# +# SPDX-License-Identifier: GPL-2.0+ + +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` + +cd `dirname $0` +../dfu/dfu_gadget_test_init.sh 33M 97M + +cleanup () { + rm -rf $RCV_DIR $MNT_DIR +} + +control_c() +# run if user hits control-c +{ + echo -en "\n*** CTRL+C ***\n" + umount $MNT_DIR + cleanup + exit 0 +} + +# trap keyboard interrupt (control-c) +trap control_c SIGINT + +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 +} + +ums_test_file () { + printf "$COLOUR_GREEN========================================================================================= $COLOUR_DEFAULT\n" + printf "File:$COLOUR_GREEN %s $COLOUR_DEFAULT\n" $1 + + mount /dev/$MEM_DEV $MNT_DIR + if [ -f $MNT_DIR/dat_* ]; then + rm $MNT_DIR/dat_* + fi + + cp ./$1 $MNT_DIR + umount $MNT_DIR + + + echo -n "TX: " + calculate_md5sum $1 + + MD5_TX=$MD5SUM + sleep 1 + N_FILE=$DIR$RCV_DIR${1:2}"_rcv" + + mount /dev/$MEM_DEV $MNT_DIR + cp $MNT_DIR/$1 $N_FILE || die $? + rm $MNT_DIR/$1 + umount $MNT_DIR + + 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 "U-boot UMS test program" + +if [ $EUID -ne 0 ]; then + echo "You must be root to do this." 1>&2 + exit 100 +fi + +if [ $# -lt 3 ]; then + echo "Wrong number of arguments" + echo "Example:" + echo "sudo ./ums_gadget_test.sh VID PID PART_NUM [-f ext4] [test_file]" + die +fi + +MNT_DIR="/mnt/tmp-ums-test" + +VID=$1; shift +PID=$1; shift +PART_NUM=$1; shift + +if [ "$1" == "-f" ]; then + shift + FS_TO_FORMAT=$1; shift +fi + +TEST_FILE=$1 + +for f in `find /sys -type f -name idProduct`; do + d=`dirname ${f}` + if [ `cat ${d}/idVendor` != "${VID}" ]; then + continue + fi + if [ `cat ${d}/idProduct` != "${PID}" ]; then + continue + fi + USB_DEV=${d} + break +done + +if [ -z "${USB_DEV}" ]; then + echo "Connect target" + echo "e.g. ums 0 mmc 0" + exit 1 +fi + +MEM_DEV=`find $USB_DEV -type d -name "sd[a-z]" | awk -F/ '{print $(NF)}' -` + +mkdir -p $RCV_DIR +if [ ! -d $MNT_DIR ]; then + mkdir -p $MNT_DIR +fi + +if [ "$PART_NUM" == "-" ]; then + PART_NUM="" +fi +MEM_DEV=$MEM_DEV$PART_NUM + +if [ -n "$FS_TO_FORMAT" ]; then + echo -n "Formatting partition /dev/$MEM_DEV to $FS_TO_FORMAT" + mkfs -t $FS_TO_FORMAT /dev/$MEM_DEV > /dev/null 2>&1 + if [ $? -eq 0 ]; then + printf " $COLOUR_GREEN DONE $COLOUR_DEFAULT \n" + else + die + fi +fi + +printf "Mount: /dev/$MEM_DEV \n" + +if [ -n "$TEST_FILE" ]; then + if [ ! -e $TEST_FILE ]; then + echo "No file: $TEST_FILE" + die + fi + ums_test_file $TEST_FILE +else + for file in $DIR*.$SUFFIX + do + ums_test_file $file + done +fi + +cleanup + +exit 0 diff --git a/test/vboot/vboot_test.sh b/test/vboot/vboot_test.sh index 8074fc6adc0..6d7abb82bd7 100755 --- a/test/vboot/vboot_test.sh +++ b/test/vboot/vboot_test.sh @@ -54,8 +54,16 @@ echo ${mkimage} -D "${dtc}" echo "Build keys" mkdir -p ${keys} +PUBLIC_EXPONENT=${1} + +if [ -z "${PUBLIC_EXPONENT}" ]; then + PUBLIC_EXPONENT=65537 +fi + # Create an RSA key pair -openssl genrsa -F4 -out ${keys}/dev.key 2048 2>/dev/null +openssl genpkey -algorithm RSA -out ${keys}/dev.key \ + -pkeyopt rsa_keygen_bits:2048 \ + -pkeyopt rsa_keygen_pubexp:${PUBLIC_EXPONENT} 2>/dev/null # Create a certificate containing the public key openssl req -batch -new -x509 -key ${keys}/dev.key -out ${keys}/dev.crt |