test: dfu: script enhancements
PATCH 1/1 test: dfu: script enhancements
From: Stephen Warren <[email protected]>
Various misc enhancements to dfu_gadget_test.sh:
* After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by dfu_gadget_test_init.sh.
* Fix the assumption that dfu_gadget_test.sh is run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh.
* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places.
* Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096.
* Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it isn't used.
--- test/dfu/README | 31 +++++++++++++++++-------------- test/dfu/dfu_gadget_test.sh | 13 +++++++++---- test/dfu/dfu_gadget_test_init.sh | 9 +++------ 3 files changed, 29 insertions(+), 24 deletions(-)
test/dfu/README +17 -14
@@ -1,27 +1,30 @@ DFU TEST CASE DESCRIPTION: The prerequisites for running this script are assured by -dfu_gadget_test_init.sh script. +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 -Moreover, on a target device the "dfu_alt_info" env variable should be extended -to have "dfu_test.bin fat 0 6;" \ entry ([1]). For reference please consult the -config file for TRATS/TRATS2 devices (./include/configs/trats{2}.h) +On the target device, environment variable "dfu_alt_info" must contain at +least: -One can use fat, ext4 or any other supported file system, which can be -created in a convenient way with exporting partitions via UMS (ums 0 mmc 0) -and using standard tools on host (like mkfs.ext4). + 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: - env default -a + setenv dfu_alt_info dfu_test.bin fat 0 6\;dfudummy.bin fat 0 6 dfu 0 mmc 0 2. On the host: - ./dfu_gadget_test.sh 11 - -where 11 is the mumber of alt setting corresponding to entry [1]. + test/dfu/dfu_gadget_test.sh dfu_test.bin dfudummy.bin -The number of the alt setting entry can be obtained with dfu-util -l command. -In its output one should look for the 'name="dfu_test1.bin"' and corresponding -alt=11. +... where dfu_test.bin and dfudummy.bin are the names of the alt settings from +$dfu_alt_info.
test/dfu/dfu_gadget_test.sh +9 -4
@@ -1,4 +1,5 @@ #! /bin/bash + set -e # any command return if not equal to zero clear
@@ -11,10 +12,11 @@ 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 $RCV_DIR + rm -rf $DIR$RCV_DIR } die () {
@@ -40,6 +42,8 @@ dfu_test_file () { 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 $?
@@ -62,7 +66,7 @@ printf "$COLOR_GREEN============================================================ 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" -mkdir -p $RCV_DIR +mkdir -p $DIR$RCV_DIR touch $LOG_FILE if [ $# -eq 0 ]
@@ -72,10 +76,11 @@ then fi TARGET_ALT_SETTING=$1 +TARGET_ALT_SETTING_B=$2 -if [ -n "$2" ] +if [ -n "$3" ] then - dfu_test_file $2 + dfu_test_file $3 else for file in $DIR*.$SUFFIX do
test/dfu/dfu_gadget_test_init.sh +3 -6
@@ -1,4 +1,5 @@ #! /bin/bash + set -e # any command return if not equal to zero clear
@@ -7,9 +8,8 @@ COLOR_GREEN="\33[32m" COLOR_DEFAULT="\33[0m" LOG_DIR="./log" -BKP_DIR="./bkp" -TEST_FILES_SIZES="127 128 129 8M 4095 4096 4097 63 64 65 960" +TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 8M" printf "Init script for generating data necessary for DFU test script"
@@ -17,10 +17,6 @@ if [ ! -d $LOG_DIR ]; then `mkdir $LOG_DIR` fi -if [ ! -d $BKP_DIR ]; then - `mkdir $BKP_DIR` -fi - for size in $TEST_FILES_SIZES do FILE="./dat_$size.img"
@@ -28,6 +24,7 @@ do 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 "$COLOR_GREEN OK $COLOR_DEFAULT \n"
Signature · 1 line
1.8.1.5
PATCH 1/1 test: dfu: script enhancements
Hi Stephen,
Quoted 19 lines
From: Stephen Warren <[email protected]>
Various misc enhancements to
dfu_gadget_test.sh:* After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by
dfu_gadget_test_init.sh.* Fix the assumption that
dfu_gadget_test.shis run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh.* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places.
Quoted 7 lines
* Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096.
* Remove references to $BKP_DIR from
dfu_gadget_test_init.sh, since it isn't used.
Thanks for enhancements Stephen - a lot of issues addressed.
However, I'm a bit puzzled, since this patch applies on top of patch which wasn't accepted (yet) to mainline.
If Simon who had a minor comments agrees, I would opt for adding the initial commit with this script to ML:
http://patchwork.ozlabs.org/patch/355283/
And on top apply this one.
Afterwards other comments would be addressed as well.
I would like to avoid sending many patches for base code which is still floating on the ML.
Quoted 151 lines
Signed-off-by Stephen Warren <[email protected]>--- test/dfu/README | 31 +++++++++++++++++-------------- test/dfu/dfu_gadget_test.sh | 13 +++++++++---- test/dfu/dfu_gadget_test_init.sh | 9 +++------ 3 files changed, 29 insertions(+), 24 deletions(-)test/dfu/README +1
-1@@ -1,27 +1,30 @@ DFU TEST CASE DESCRIPTION: The prerequisites for running this script are assured by -dfu_gadget_test_init.sh script. +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 ofTEST_FILES_SIZESvariable
-Moreover, on a target device the "dfu_alt_info" env variable should be extended -to have "dfu_test.bin fat 0 6;" \ entry ([1]). For reference please consult the -config file for TRATS/TRATS2 devices (./include/configs/trats{2}.h) +On the target device, environment variable "dfu_alt_info" must contain at +least:-One can use fat, ext4 or any other supported file system, which can be -created in a convenient way with exporting partitions via UMS (ums 0 mmc 0) -and using standard tools on host (like mkfs.ext4).
test/dfu/README +4
-0+ 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 referenceplease +consult the config file for TRATS/TRATS2 devices
test/dfu/README +3
-0+(../../include/configs/trats{2}.h) + +One can use fat, ext4 or any other supported file system supportedby 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:test/dfu/README +2
-5- env default -a + setenv dfu_alt_info dfu_test.bin fat 0 6\;dfudummy.bin fat 0 6 dfu 0 mmc 0 2. On the host: - ./dfu_gadget_test.sh 11 - -where 11 is the mumber of alt setting corresponding to entry [1]. + test/dfu/dfu_gadget_test.sh dfu_test.bin dfudummy.bin -The number of the alt setting entry can be obtained with dfu-util -lcommand. -In its output one should look for the 'name="dfu_test1.bin"' and corresponding -alt=11.
+... where dfu_test.bin and dfudummy.bin are the names of the alt settings from +$dfu_alt_info.test/dfu/dfu_gadget_test.sh +4
-1@@ -1,4 +1,5 @@ #! /bin/bash + set -e # any command return if not equal to zero clear@@ -11,10 +12,11 @@ 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 $RCV_DIR + rm -rf $DIR$RCV_DIR } die () {@@ -40,6 +42,8 @@ dfu_test_file () { 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 $? @@ -62,7 +66,7 @@ printf "$COLOR_GREEN============================================================ 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" -mkdir -p $RCV_DIRtest/dfu/dfu_gadget_test.sh +4
-2+mkdir -p $DIR$RCV_DIR touch $LOG_FILE if [ $# -eq 0 ]@@ -72,10 +76,11 @@ then fi TARGET_ALT_SETTING=$1 +TARGET_ALT_SETTING_B=$2 -if [ -n "$2" ] +if [ -n "$3" ] then - dfu_test_file $2 + dfu_test_file $3 else for file in $DIR*.$SUFFIX do(quoted diff) +0
-0
b/test/dfu/dfu_gadget_test_init.shindexea2f715b8834..1f3634f065f5100755 ---a/test/dfu/dfu_gadget_test_init.sh
+++b/test/dfu/dfu_gadget_test_init.shtest/dfu/dfu_gadget_test.sh +2
-2@@ -1,4 +1,5 @@ #! /bin/bash + set -e # any command return if not equal to zero clear@@ -7,9 +8,8 @@ COLOR_GREEN="\33[32m" COLOR_DEFAULT="\33[0m" LOG_DIR="./log" -BKP_DIR="./bkp" -TEST_FILES_SIZES="127 128 129 8M 4095 4096 4097 63 64 65 960" +TEST_FILES_SIZES="63 64 65 127 128 129 4095 4096 4097 959 960 961 8M" printf "Init script for generating data necessary for DFU testscript"
test/dfu/dfu_gadget_test_init.sh +0
-4@@ -17,10 +17,6 @@ if [ ! -d $LOG_DIR ]; then `mkdir $LOG_DIR` fi -if [ ! -d $BKP_DIR ]; then - `mkdir $BKP_DIR` -fi - for size in $TEST_FILES_SIZES do FILE="./dat_$size.img"@@ -28,6 +24,7 @@ do dd if=/dev/urandom of="./dat_$size.img" bs=$size count=1Quoted 1 line
/dev/null2>&1 || exit $? fidone
+dd if=/dev/urandom of="./dfudummy.bin" bs=1024 count=1 >/dev/null2>&1 || exit $?
printf "$COLOR_GREEN OK $COLOR_DEFAULT \n"
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 1/1 test: dfu: script enhancements
Quoted 25 lines · Lukasz Majewski
Hi Stephen,
Quoted 23 lines
From: Stephen Warren <[email protected]>
Various misc enhancements to
dfu_gadget_test.sh:* After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by
dfu_gadget_test_init.sh.* Fix the assumption that
dfu_gadget_test.shis run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh.* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places.
* Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096.
Quoted 7 lines
Quoted 2 lines
* Remove references to $BKP_DIR from
dfu_gadget_test_init.sh, since it isn't used.Thanks for enhancements Stephen - a lot of issues addressed.
However, I'm a bit puzzled, since this patch applies on top of patch which wasn't accepted (yet) to mainline.
Yes, I applied your patch locally and worked on top of that.
Quoted 10 lines
If Simon who had a minor comments agrees, I would opt for adding the initial commit with this script to ML:
http://patchwork.ozlabs.org/patch/355283/
And on top apply this one.
Afterwards other comments would be addressed as well.I would like to avoid sending many patches for base code which is still floating on the ML.
Unfortunately, code takes so long to get applied that approach isn't very practical. There's no issue working on top of unapplied patches; I'm quite happy to rebase and resend my patch if you need to resend yours and mine no longer applies.
PATCH 1/1 test: dfu: script enhancements
In reply to Stephen WarrenHi Stephen,
Quoted 19 lines
From: Stephen Warren <[email protected]>
Various misc enhancements to
dfu_gadget_test.sh:* After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by
dfu_gadget_test_init.sh.* Fix the assumption that
dfu_gadget_test.shis run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh.* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places.
Quoted 8 lines
* Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096.
* Remove references to $BKP_DIR from
dfu_gadget_test_init.sh, since it isn't used.Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot-dfu
[Although, I've also added an incremental patch with some README clarification]
Stephen, thanks for enhancements.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 1/1 test: dfu: script enhancements
Quoted 28 lines · Lukasz Majewski
Hi Stephen,
Quoted 26 lines
From: Stephen Warren <[email protected]>
Various misc enhancements to
dfu_gadget_test.sh:* After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by
dfu_gadget_test_init.sh.* Fix the assumption that
dfu_gadget_test.shis run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh.* Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places.
* Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096.
* Remove references to $BKP_DIR from
dfu_gadget_test_init.sh, since it isn't used.
Quoted 8 lines
Quoted 1 line
Signed-off-by Stephen Warren <[email protected]>Applied to u-boot-dfu
[Although, I've also added an incremental patch with some README clarification]
Stephen, thanks for enhancements.
Oh, thanks! I'd just applied your updated base patch yesterday and was going to send an updated version of this. Still, the conflicts were trivial enough you evidently managed to work through them:-)