Commit 0380235e authored by Benoit Rat's avatar Benoit Rat

Improve testing (checked with v3.2)

parent bf40a253
# Binary files used #
######################
.project
.cproject
*.bit
*.bin
lm32-loader
......
#!/bin/ash
# setupGlobalVar exportname value
setupGlobalVar()
{
export | grep $1 &> /dev/null
if [ $? -gt "0" ]; then
export $1="$2"
echo $1=$2
else
echo "Already set"
fi
}
# checkLoadTFTP filename updateflag
checkLoadTFTP()
{
fname=$1
upflag=$2
dest=$3
if [[ -f $fname ]]; then
upflag="1"
fi
if [[ -z $dest ]]; then
dest=${APTS_HOST_IP}/bin/
fi
if [[ $upflag ]]; then
tftp -g -r ${APTS_HOST_DIR}/$fname ${APTS_HOST_IP}
ret=$(( $ret + $? ))
mv $fname $dest
fi
}
load_ask2run()
{
sh=$1
ask=$2
update=$3
inlog=$4
valid="Y"
itest=$( echo $sh | sed 's/\([0-9]*\)-.*/\1/' )
if [ ${ask} = "1" ]; then
read -t 5 -p "# Execute $sh? (timeout in 5s) [Y/n/c]: " valid;
fi
if [ "${valid}" == "c" ]; then
echo -e "Cancel the test"
exit 0;
elif [ "${valid}" == "n" ]; then
echo -e "Skip the script $sh"
else
echo ""
ts=$(date +%s)
# Load script
chmod +x ${APTS_SWITCH_DIR}/$sh
printf "\n\n" > ${logfname}_${itest}.log
# Run it into the log
if [ $inlog -eq "1" ]; then
echo "inlog"
${APTS_SWITCH_DIR}/$sh $update ${logfname}_${itest}.log
else
${APTS_SWITCH_DIR}/$sh $update 2>&1 | tee -a ${logfname}_${itest}.log
fi
ret=$(cat /tmp/func_ret)
ts=$(( $(date +%s) - $ts))
min=$(($ts / 60 ))
sec=$(($ts % 60 ))
printf "Running time: %d'%d\"\n\n" $min $sec
printf "\t%s > %s (%02d'%02d)\n" ${itest} "${ret}" ${min} ${sec} >> ${logfname}.log
fi
}
#user_echoasking type question answer
user_echoasking()
{
type=$1
question=$2
answer=$3
ret="";
loop="1"
while [ $loop == "1" ]; do
read -p "$question [$type]: " ret
case $ret in
y|Y) if [ $type != "num" ]; then ret="y"; loop="0"; fi;;
n|N) if [ $type != "num" ]; then ret="n"; loop="0"; fi;;
[0-1]*) if [ $type == "bin" -o $type == "num" ]; then loop=0; fi;;
[0-9]*) if [ $type == "num" ]; then loop=0; fi;;
*) if [ $type == "Y/n" ]; then
ret="y"
loop=0
elif [ $type == "y/N" ]; then
ret="n"
loop=0
fi;;
esac
done
echo "$answer=$ret"
}
errpercent()
{
if [ $# -eq "0" ]; then
return 0
elif [ $# -eq "1" ]; then
return $1
else
nOK=$1
nTotal=$2
if [ ${nOK} -eq ${nTotal} ]; then
return 0
else
##Return the %of fault
tmp=$(($(($((${nTotal} - ${nOK})) \*100 )) / ${nTotal} ))
if [ $tmp -eq "0"]; then
tmp=1; ##Transform 0.x% to 1%
fi
fi
fi
}
exit_errpercent()
{
errpercent $1 $2
ret=$?
if [ $ret -eq "0" ]; then
ret="OK"
else
ret="ERROR $ret%"
fi
echo "$ret" > /tmp/func_ret
exit 0
}
exit_multierr()
{
retmsg=""
oneERR="0"
for i in $(seq 1 $# ); do
ret=$(eval echo "\$${i}")
if [ $ret -eq "0" ]; then
ret="OK"
else
ret="$ret%"
oneERR="1"
fi
retmsg="$retmsg Sub$(($i-1)):$ret"
done
if [ $oneERR -ne "0" ]; then
retmsg="ERROR ($retmsg)"
else
retmsg="OK"
fi
echo "$retmsg" > /tmp/func_ret
exit 0
}
#!/bin/sh
echo ${APTS_LOCAL_DIR}
## Read the MD5 of the different binaries used by the test
##
## This is intended to know which version of the test and its files we are using
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
printf "Testing FPGA loading (TK0, TD0, FPGA_INIT_B+FPGA_INIT_A)\n"
printf "printing md5sum of the files to load:\n"
md5sum ${APTS_LOCAL_DIR}/load-virtex
md5sum ${APTS_LOCAL_DIR}/lm32-loader
md5sum ${APTS_LOCAL_DIR}/test_scb.bin
md5sum ${APTS_LOCAL_DIR}/rt_cpu.bin
chmod +x ${APTS_LOCAL_DIR}/load-virtex
. 000-functions.sh
uname -a
ret0=$?
printf "MAC="$(ifconfig | grep 'eth0' | tr -s ' ' | cut -d ' ' -f5)"\n"
ret1=$?
printf "printing md5sum the loading file:\n"
md5sum "$(which load-fpga)"
ret2=$?
md5sum "$(which lm32-loader)"
ret3=$?
printf "printing md5sum of the binaries:\n"
md5sum bin/*
ret4=$?
exit_multierr $ret0 $ret1 $ret2 $ret3 $ret4
#!/bin/ash
## LED checking
##
## Load the standard bitstream to active the GPIOs of the LEDs.
## then it use HAL to run a LED moving pattern.
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
exit_multierr 0
#First loading the correct firmwares:
load-fpga ${APTS_SWITCH_DIR}/bin/8ports_mb.bin
lm32-loader ${APTS_SWITCH_DIR}/bin/rt_cpu.bin
ret=0
user_echoasking "y/n" "Did you see the LEDs moving" "LEDS"
exit_multierr 0
#!/bin/sh
## Testing the NAND flash: MT29F4G16 (x16)
##
## Page = 1056 words = (1K + 32) words
## Block = 64 x pages = (64K + 2K) words => (0x0002.0000 + 0x0000.1000) bytes
## Total = 4096 blocks = 262144 pages = 512 MBytes = 4.224Mbits
## = (0x2000.0000 + 0x0100.0000) bytes
##
## Layout:
## mtd0 -------------- (barebox & kernel)
## 0x0000.0000 - 0x0004.0000 //Empty (two first blocks)
## 0x0004.0000 - 0x0008.0000 //Barebox env
## 0x0008.0000 - 0x0010.0000 //Empty (up to 1MB position)
## 0x0010.0000 - 0x0090.0000 //Kernel (size of 8MB)
## 0x0090.0000 - 0x0400.0000 //Empty (up to the end of /dev/mtd0)
## mtd1 -------------- (filesystem)
## 0x0400.0000 - 0x2000.0000 //Filesystem space, jffs2
##
## dev: size erasesize name
## mtd0 : 04000000 00020000 "Partition 1"
## mtd1 : 1c000000 00020000 "Partition 2"
displayErr() {
if [ "$md5w" != "$md5r" ]; then
echo "ERROR @ $testdev W:$md5w, R:$md5r"
cmp -l /testing/at91bootstrap.bin /tmp/nand-at91 > /tmp/cmprw
head -n 1 /tmp/cmprw
tail -n 1 /tmp/cmprw
hexdump -n 500 -v /tmp/nand-at91
else
echo "OK @ $testnand R/W"
fi
}
flashAllSkip()
{
echo "execute $1?"
read -t 5 -p "Press any key to skip it (5s): " ret;
}
printf "======: $0\n"
npages=8192
ipage=0
dfdev=/dev/mtd0
f2w=/tmp/w1k.bin
f2r=/tmp/r1k.bin
nOK=0
nKO=0
ddopt="bs=1k count=1"
flashAllSkip "flash_eraseall ${dfdev}";
if [ -z ${ret} ]; then
flash_eraseall ${dfdev}
fi
printf "Testing NAND memory\n"
okTxt=""
while [ $ipage -lt $npages ]; do
if [ $(expr $ipage % 256) -eq 0 ]; then
printf "${okTxt}\n\nSector %02d:" $(expr $ipage / 256)
okTxt=""
fi
if [ $(expr $ipage % 32) -eq 0 ]; then
printf "${okTxt}\nB%04d:" $(expr $ipage / 32)
okTxt=" OK"
fi
startaddr=$(expr $ipage \* 1056)
dd $ddopt if=/dev/urandom of=${f2w} 2> /dev/null
# dd $ddopt if=${f2w} of=${dfdev} seek=${startaddr} 2> /dev/null
# dd $ddopt if=${dfdev} of=${f2r} skip=${startaddr} 2> /dev/null
# md5w=`md5sum ${f2w} | cut -f1 -d" "`
# md5r=`md5sum ${f2r} | cut -f1 -d" "`
md5w="0215"
md5r="0215"
if [ "$md5w" != "$md5r" ]; then
nKO=$(expr ${nKO} + 1)
echo "ERROR @ $startaddr"
else
nOK=$(expr ${nOK} + 1)
printf ".."
fi
ipage=$(expr $ipage + 1)
done
echo ""
echo "Result DF testing: OK=${nOK}/${npages}"
#!/bin/ash
## FAN checking
##
## Test the different FANs of the switch at different speed before starting the temperature monitoring.
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
printf "To be implemented\n"
exit_multierr 0
ret=0
user_echoasking "y/n" "Did you see the LEDs moving" "LEDS"
#!/bin/sh
## Testing the dataflash: AT45DB642
##
## Page = 1056 bytes (1K + 32) => 0x420 (0x400+0x020)
## Block = 8448 bytes (8K + 256) => 8 x Pages
## Sector = 32 Blocks (Except Sector 0 = 1 x block (0); Sector [1-31] = 31 x blocks).
##
## Total: 32 sectors = 1024 blocks = 8192 pages = 8650752 bytes
## : 0x84'0000 bytes
displayErr() {
if [ "$md5w" != "$md5r" ]; then
echo "ERROR @ $testdev W:$md5w, R:$md5r"
cmp -l /testing/at91bootstrap.bin /tmp/nand-at91 > /tmp/cmprw
head -n 1 /tmp/cmprw
tail -n 1 /tmp/cmprw
hexdump -n 500 -v /tmp/nand-at91
else
echo "OK @ $testnand R/W"
fi
}
flashAllSkip()
{
echo "execute $1?"
read -t 5 -p "Press any key to skip it (5s): " ret;
}
printf "======: $0\n"
npages=8192
ipage=0
dfdev=/dev/mtd2
f2w=/tmp/w1k.bin
f2r=/tmp/r1k.bin
nOK=0
nKO=0
ddopt="bs=1k count=1"
flashAllSkip "flash_eraseall ${dfdev}";
if [ -z ${ret} ]; then
flash_eraseall ${dfdev}
fi
printf "Testing DF memory\n"
while [ $ipage -lt $npages ]; do
if [ $(expr $ipage % 8) -eq 0 ]; then
printf "B%04d:" $(expr $ipage / 8)
fi
if [ $(expr $ipage % 256) -eq 0 ]; then
printf "\n\nSector %02d:" $(expr $ipage / 256)
fi
startaddr=$(expr $ipage \* 1056)
dd $ddopt if=/dev/urandom of=${f2w} 2> /dev/null
dd $ddopt if=${f2w} of=${dfdev} seek=${startaddr} 2> /dev/null
dd $ddopt if=${dfdev} of=${f2r} skip=${startaddr} 2> /dev/null
md5w=`md5sum ${f2w} | cut -f1 -d" "`
md5r=`md5sum ${f2r} | cut -f1 -d" "`
if [ "$md5w" != "$md5r" ]; then
nKO=$(expr ${nKO} + 1)
echo "ERROR @ $startaddr"
else
nOK=$(expr ${nOK} + 1)
printf "."
fi
ipage=$(expr $ipage + 1)
done
echo ""
echo "Result DF testing: OK=${nOK}/${npages}"
#!/bin/sh
## Testing QDRII, PLL, and GPIOs
##
## This test stress the QDRII at maximum, and read the different temperature sensor to check
## that it is working correctly.
##
## Future Improvements:
## - There are no communications between the FPGA and CPU
## - The test should be divided in first a QDRII check, then a temperature stress
## - The temperature test should be run at the same time then the NAND & DF test (15min)
##
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
#First loading the correct firmwares:
load-fpga ${APTS_SWITCH_DIR}/bin/004-fpga_montemp.bit
timeout=60 #Timeout before reading
printf "Monitoring temperature and testing CPU (${timeout}s): "
i=0
while [ $i -lt $timeout ]; do
printf "."
sleep 1
i=`expr $i + 1`
done
echo ""
load-fpga ${APTS_SWITCH_DIR}/bin/005-scb_test.bit ## We force to reset
ret=0
user_echoasking "y/n" "Do you see the 3 last LEDs on the miniBP?" "LED QDRII"
if [ $ret == "n" ]; then
user_echoasking "bin" "LED pattern?" "LED patterm QDRII"
ret0="1"
else
ret0="0"
fi;
user_echoasking "y/n" "Do you see temperature message on UART?" "UART temp"
if [ $ret == "y" ]; then
user_echoasking "num" "System Monitor Temp. " "temp-sysmon"
user_echoasking "num" "Temp. Sensor FPGA:" "temp-fpga"
user_echoasking "num" "Temp. Sensor Power Supply:" "tmp-powsup"
ret1="1"
else
ret1="0"
fi
exit_multierr $ret0 $ret1
#!/bin/ash
## Check the USB connexion
##
## This should use USB gadget and the device that need to communicate
## are /dev/ttyACM0 on host and /dev/ttyGS0 on switch.
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
printf "To be implemented\n"
exit_multierr 0
#!/bin/sh
## Testing the cpu-fpga bus (EBI1)
##
##
## Using devmem we read/write in the memory range 0x10000000-0x10004000 (16KiB)
## The bridge used can be find here: http://www.ohwr.org/projects/general-cores/repository/revisions/master/show/modules/wishbone/wb_async_bridge
## And it is defined using PC16..31: periphA as EBI1_D16..31
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
# Testing the cpu-fpga bus (EBI0)
# in memory range 0x10000000-0x10004000
# using the devmem application
printf "======: $0\n"
. 000-functions.sh
#First loading the correct firmwares:
${APTS_LOCAL_DIR}/load-virtex ${APTS_LOCAL_DIR}/test_scb.bin
${APTS_LOCAL_DIR}/lm32-loader ${APTS_LOCAL_DIR}/rt_cpu.bin
load-fpga ${APTS_SWITCH_DIR}/bin/006-scb_test.bit
lm32-loader ${APTS_SWITCH_DIR}/bin/006-cpu_rt.bin
nTot=512
addr=0x10000000
end=0x10004000
step=32
nOK=0
nOK=0
let addr10=$addr
let end10=$end
printf "======: $0\n"
printf "Testing CPU-FPGA bus (EBI0 @ $addr > $end): "
while [ $addr10 -lt $end10 ]; do
......@@ -49,3 +65,4 @@ done
echo ""
echo "Result CPU-FPGA bus: OK=${nOK}/${nTot}W"
exit_errpercent ${nOK} ${nTot}
\ No newline at end of file
#!/bin/ash
## Testing the NAND flash: MT29F4G16 (x16)
##
## This test first try the different partitions by writing/reading random blocks
## Then it format & mount a JFFS2 partition to write/read random size files.
##
##
## Page = 1056 words = (1K + 32) words
## Block = 64 x pages = (64K + 2K) words => (0x0002.0000 + 0x0000.1000) bytes
## Total = 4096 blocks = 262144 pages = 512 MBytes = 4.224Mbits
## = (0x2000.0000 + 0x0100.0000) bytes
##
## Layout:
## mtd0 -------------- (barebox & kernel)
## 0x0000.0000 - 0x0004.0000 //Empty (two first blocks)
## 0x0004.0000 - 0x0008.0000 //Barebox env
## 0x0008.0000 - 0x0010.0000 //Empty (up to 1MB position)
## 0x0010.0000 - 0x0090.0000 //Kernel (size of 8MB)
## 0x0090.0000 - 0x0400.0000 //Empty (up to the end of /dev/mtd0)
## mtd1 -------------- (filesystem)
## 0x0400.0000 - 0x2000.0000 //Filesystem space, jffs2
##
## dev: size erasesize name
## mtd0 : 04000000 00020000 "Partition 1"
## mtd1 : 1c000000 00020000 "Partition 2"
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
displayErr() {
if [ "$md5w" != "$md5r" ]; then
echo "ERROR @ $testdev W:$md5w, R:$md5r"
cmp -l /testing/at91bootstrap.bin /tmp/nand-at91 > /tmp/cmprw
head -n 1 /tmp/cmprw
tail -n 1 /tmp/cmprw
hexdump -n 500 -v /tmp/nand-at91
else
echo "OK @ $testnand R/W"
fi
}
askToSkip()
{
ret="1"
echo "execute $1?"
read -t 5 -p "Press any key to skip it (5s): " ret;
}
testblocks()
{
## Parse the arguments
device=$1
ntest=$2
#Obtain the range in which we jump between two block addresses
if [ -n $ntest ] && [ $nblock -gt ${ntest} ]; then
range=$(expr $(expr $nblock / $ntest) \* 2 ) #((nblock/ntest) + 1)*2
echo "range $range"
else
ntest=$nblock
range=1
fi
## Erase the flash
flash_eraseall -j ${device} #It is better to clear the flash with -j option to avoid bad oob errors using nandump
##Init params
f2w=/tmp/w128k.bin
f2r=/tmp/r128k.bin
sizeblock=131072
okTxt=""
itest=0
iblock=0
nOK=0
nKO=0
ddopt="bs=128k count=1"
while [ $itest -lt $ntest ]; do
startaddr=$(expr $iblock \* ${sizeblock})
printf "> Checking Block: %04d @ 0x%08X " $iblock $startaddr
dd $ddopt if=/dev/urandom of=${f2w} 2> /dev/null
printf "..."
mtd_debug erase ${device} ${startaddr} ${sizeblock} &> /dev/null
printf "..."
mtd_debug write ${device} ${startaddr} ${sizeblock} ${f2w} &> /dev/null
printf "..."
mtd_debug read ${device} ${startaddr} ${sizeblock} ${f2r} &> /dev/null
printf "..."
md5w=`md5sum ${f2w} | cut -f1 -d" "`
md5r=`md5sum ${f2r} | cut -f1 -d" "`
if [ "$md5w" != "$md5r" ]; then
nKO=$(expr ${nKO} + 1)
printf "ERROR (%02d %%) \n" $(expr $(expr $iblock \* 100 ) / $nblock)
else
nOK=$(expr ${nOK} + 1)
printf " %02d %% \\r" $(expr $(expr $iblock \* 100 ) / $nblock)
fi
tmp=$RANDOM #Improve RANDOM generation
iblock=$(expr $(expr $iblock + $(expr $(expr $RANDOM % $range ) + 1 )) % $nblock)
itest=$(expr $itest + 1)
done
echo ""
echo "Result NAND testing ($device): OK=${nOK}/${ntest} (nblocks=$nblock)"
errpercent ${nOK} ${ntest}
}
testFiles()
{
## Parse the arguments
device=$1
mtdblock=$2
ntest=$3
##Try to umount /mnt
umount /mnt
#format as JFFS2
flash_eraseall -j ${device}
#mount as JFFS2
mount -t jffs2 ${mtdblock} /mnt
#Init value
tcount=0
ddopt="bs=1k"
nOK=0
nKO=0
itest=0
f2w=/tmp/w-rand.bin
while [ $itest -lt $ntest ]; do
tmp=$RANDOM
count=$(expr 128 + $(expr $RANDOM % 1920 )) #Mean file size is 1M
tcount=$(expr $tcount + $count )
f2r=/mnt/file-$itest.bin
printf "> Checking File: %04d (%04d KiB)" $itest $count
##generate random
dd $ddopt count=$count if=/dev/urandom of=${f2w} 2> /dev/null
printf "..."
## write
dd $ddopt count=$count if=${f2w} of=${f2r} 2> /dev/null
printf "..."
md5w=`md5sum ${f2w} | cut -f1 -d" "` 2> /dev/null
md5r=`md5sum ${f2r} | cut -f1 -d" "` 2> /dev/null
printf "..."
if [ "$md5w" != "$md5r" ]; then
nKO=$(expr ${nKO} + 1)
printf "ERROR (%02d %%) \\n" $(expr $(expr $itest \* 100 ) / $ntest)
else
nOK=$(expr ${nOK} + 1)
printf " %02d %% \\r" $(expr $(expr $itest \* 100 ) / $ntest)
fi
itest=$(expr $itest + 1)
done
echo ""
echo "Result NAND testing (${mtdblock}): OK=${nOK}/${ntest} (total $(expr $tcount / 1024 ) MB)"
#umount /mnt
errpercent ${nOK} ${ntest}
return $?
}
echo "This test will last about 8m"
ret=""
errmsg=""
## Partion mtd0 (Barebox + Kernel)
echo "testing NAND mtd0 (Barebox + Kernel)"
nblock=512 #0x04000000 / 0x20000
device=/dev/mtd0
askToSkip "erase and test ${device}";
echo "Random Checking of ${device} (64M)"
if [ x${ret} != "x" ]; then
testblocks ${device} 256
ret0=$?
fi
## Partion mtd1 (FileSystem)
echo "testing NAND mtd1 (FileSystem)"
nblock=3584 #0x1c000000 / 0x20000
device=/dev/mtd1
askToSkip "erase and test ${device}";
echo "Random Checking of ${device} (448M)"
if [ x${ret} != "x" ]; then
testblocks ${device} 256
ret1=$?
fi
## Finaly mount some files of different size and try read and write.
mtdbname=mtdblock0
echo "testing NAND ${mtdbname} (Files)"
askToSkip "erase and test ${mtdbname}";
if [ x${ret} != "x" ]; then
testFiles /dev/mtd0 /dev/${mtdbname} 10
ret2=$?
fi
mtdbname=mtdblock1
echo "testing NAND ${mtdbname} (Files)"
askToSkip "erase and test ${mtdbname}";
if [ x${ret} != "x" ]; then
testFiles /dev/mtd1 /dev/mtdblock1 20
ret3=$?
fi
### Produce output message
exit_multierr $ret0 $ret1 $ret2 $ret3
#!/bin/sh
## Testing the dataflash: AT45DB642
##
## This test use mtd-tools (mtd_debug) to check all the dataflash
## Then it format & mount a JFFS2 partition to write/read random size files.
##
##
## Page = 1056 bytes (1K + 32) => 0x420 (0x400+0x020)
## Block = 8448 bytes (8K + 256) => 8 x Pages
## Sector = 32 Blocks (Except Sector 0 = 1 x block (0); Sector [1-31] = 31 x blocks).
##
## Total: 32 sectors = 1024 blocks = 8192 pages = 8650752 bytes
## : 0x84'0000 bytes
##
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
nblock=1024
iblock=0
sizeblock=8192
device=/dev/mtd2
f2w=/tmp/w-df.bin
f2r=/tmp/r-df.bin
nOK=0
nKO=0
ddopt="bs=1k count=8"
printf "Testing DF memory\n"
while [ $iblock -lt $nblock ]; do
startaddr=$(expr $iblock \* ${sizeblock})
printf "> Checking Block: %04d @ 0x%08X " $iblock $startaddr
dd $ddopt if=/dev/urandom of=${f2w} 2> /dev/null
printf "..."
mtd_debug erase ${device} ${startaddr} ${sizeblock} &> /dev/null
printf "..."
mtd_debug write ${device} ${startaddr} ${sizeblock} ${f2w} &> /dev/null
printf "..."
mtd_debug read ${device} ${startaddr} ${sizeblock} ${f2r} &> /dev/null
printf "..."
md5w=`md5sum ${f2w} | cut -f1 -d" "`
md5r=`md5sum ${f2r} | cut -f1 -d" "`
if [ "$md5w" != "$md5r" ]; then
nKO=$(expr ${nKO} + 1)
printf "ERROR (%02d %%) \n" $(expr $(expr $iblock \* 100 ) / $nblock)
else
nOK=$(expr ${nOK} + 1)
printf " %02d %% \\r" $(expr $(expr $iblock \* 100 ) / $nblock)
fi
iblock=$(expr $iblock + 1)
done
echo ""
echo "Result DF testing: OK=${nOK}/${nblock}"
exit_errpercent ${nOK} ${nblock}
#!/bin/sh
## Finally test the TFTP connexion and flash the default firmwares
##
## The TFTP connexion might have been used previously but with
## this test we ensure that it correctly work
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
printf "======: $0\n"
. 000-functions.sh
bin_dir="/tmp"
printf "Flashing at91bootstrap and barebox on dataflash: "
ret=0
checkLoadTFTP at91bootstrap.bin 1 ${bin_dir}
checkLoadTFTP barebox.bin 1 ${bin_dir}
if [ $ret -eq "0" ]; then
cat ${bin_dir}/at91bootstrap.bin > /dev/mtd2
dd bs=33792 seek=1 if=${bin_dir}/barebox.bin of=/dev/mtd2
printf "OK\n"
else
printf "ERROR: While downloading\n"
fi
ret0=$ret
printf "Flashing kernel and filesystem on nandflash: "
ret=0
checkLoadTFTP zImage 1 ${bin_dir}
checkLoadTFTP wrs-image.jffs2.img 1 ${bin_dir}
if [ $ret -eq "0" ]; then
# Flashing kernel (without erasing barebox env)
flash_erase /dev/mtd0 0x100000 0x40
nandwrite --pad -s 0x00100000 /dev/mtd0 ${bin_dir}/zImage
# Flashing whole partiton for FS.
flash_eraseall /dev/mtd1
nandwrite --pad /dev/mtd1 ${bin_dir}/wrs-image.jffs2.img
printf "OK\n"
else
printf "ERROR: While downloading\n"
fi
ret1=$ret
exit_multierr $ret0 $ret1
\ No newline at end of file
......@@ -3,13 +3,20 @@ Alpha PTS scripts
#### Benoit RAT @ Sevensols (2012)
1. First you need to setup the a tftp server on your PC
1. First you need to setup a tftp server on your PC
>
You can use the package `dnsmasq` to ease the instalation
* Then you need to download all binaries files in your tftpboot directory.
>
fwver=20120412
wget https://dl.dropbox.com/shz/k2uwarm5eo6q4mg/kUbdkT3DZ0/${fwver}
unzip ${fwver}
mv ${fwver} /tftpboot
* Extract the filesystem on your /tftpboot directory
>
* Create a link from this git directory into tftpboot.
>
......@@ -17,11 +24,11 @@ Alpha PTS scripts
* And finally, you can run the script from the WRS console.
>
export APTS_SERVER_IP="192.168.7.1"
tftp -g -r alpha-pts/loading.sh ${APTS_SERVER_IP}
export APTS_HOST_IP="192.168.7.1"
tftp -g -r alpha-pts/loading.sh ${APTS_HOST_IP}
chmod +x loading.sh
./loading.sh
--------------------------------------------------------
*This document is written in markdown syntax*
\ No newline at end of file
*This document is written in markdown syntax*
#!/bin/sh
dd bs=28 count=1 if=/dev/mtd2 of=/tmp/b0
dd bs=28 count=1 if=${APTS_ROOT_DIR}/at91bootstrap.bin of=/tmp/b1
diff /tmp/b0 /tmp/b1 > /dev/null
if [ $? != "0" ]; then
read -p "# Did you flash firmware before $sh? [y/N]: " valid;
if [ "${valid}" == "y" ]; then
echo "ERROR: /dev/mtd2 does not contains valid data"
exit 1
else
echo "Skipping check previous flashing"
fi
fi
printf "======: $0\n"
printf "Checking flash\n"
fname="at91bootstrap.bin"
ddopt=""
size=`ls -l ${APTS_ROOT_DIR}/${fname} | awk '{print $5}'`
dd bs=1 count=${size} ${ddopt} if=/dev/mtd2 of=/tmp/${fname}
diff ${APTS_ROOT_DIR}/${fname} /tmp/${fname} > /dev/null
if [ $? == "0" ]; then
echo "VALID: ${fname} checked"
else
echo "ERROR: ${fname} is not correctly load on dataflash"
fi
fname="barebox.bin"
ddopt="skip=33792" #skip is in block size
size=`ls -l ${APTS_ROOT_DIR}/${fname} | awk '{print $5}'`
dd bs=1 count=${size} ${ddopt} if=/dev/mtd2 of=/tmp/${fname}
diff ${APTS_ROOT_DIR}/${fname} /tmp/${fname} > /dev/null
if [ $? == "0" ]; then
echo "VALID: ${fname} checked"
else
echo "ERROR: ${fname} is not correctly load on dataflash"
fi
#!/bin/sh
# Testing the data flash and NAND memory
# Dataflash is at /dev/mtd2
# NAND is at /dev/mtd0
## Function
# Write random image, read it and compare md5sum
#
# Inputs:
# testdev: the device to test
# size: size of the device to test
ddmd5diff() {
ls $testdev
printf " creating random data...\n"
dd bs=1k $ncount if=/dev/urandom > /tmp/w
printf " writing random data...\n"
cat /tmp/w > $testdev
printf " reading random data...\n"
dd bs=1k $ncount if=$testdev > /tmp/r
md5w=`md5sum /tmp/w | cut -f1 -d" "`
md5r=`md5sum /tmp/r | cut -f1 -d" "`
if [ "$md5w" != "$md5r" ]; then
echo "ERROR @ $testdev W:$md5w, R:$md5r"
cmp -l /tmp/r /tmp/w > /tmp/cmprw
#nErrs=`cat /tmp/cmprw | wc -l`
echo "nErrs=${nErrs}"
head -n 1 /tmp/cmprw
tail -n 1 /tmp/cmprw
else
echo "OK @ $testdev R/W"
fi
}
## obtain the brute size
brutesize()
{
size=$(expr $(cat $testdev | wc -c) / 1024)
echo $size
}
printf "======: $0\n"
printf "Testing Dataflash memory (This test may take some time)\n Be sure to flash the firmware after this step"
## Testing the DF memory (8.25 MB = 0x840000)
ncount="count=8192"
testdev=/dev/mtd2
ddmd5diff
printf "Testing Dataflash memory\n"
## Testing the NAND memory
testdev=/dev/mtd0
#ddmd5diffprintf "creating random data.../n"
#!/bin/sh
printf "======: $0\n"
printf "Flashing at91bootstrap and barebox on dataflash\n"
cat /proc/mtd
cat ${APTS_ROOT_DIR}/at91bootstrap.bin > /dev/mtd2
dd bs=33792 seek=1 if=${APTS_ROOT_DIR}/barebox.bin of=/dev/mtd2
#!/bin/sh
setupGlobalVar()
{
if [[ -z $1 ]]; then
export $1="$2"
fi
echo $1;
}
## setup default parameters
setupGlobalVar "APTS_LOCAL_DIR" "/alpha-pts"
setupGlobalVar "APTS_SERVER_DIR" "alpha-pts"
setupGlobalVar "APTS_SERVER_IP" "192.168.7.1"
## Starting scripts
mkdir ${APTS_LOCAL_DIR}
cd ${APTS_LOCAL_DIR}
## These binaries must be loaded to use the alpha pts scripts
tftp -g -r at91bootstrap.bin ${APTS_SERVER_IP}
tftp -g -r barebox.bin ${APTS_SERVER_IP}
tftp -g -r load-virtex ${APTS_SERVER_IP}
tftp -g -r lm32-loader ${APTS_SERVER_IP}
tftp -g -r rt_cpu.bin ${APTS_SERVER_IP}
tftp -g -r test_scb.bin ${APTS_SERVER_IP}
## Then load the main testing script
tftp -g -r ${APTS_SERVER_DIR}/testing.sh ${APTS_SERVER_IP}
chmod +x ${APTS_LOCAL_DIR}/testing.sh
${APTS_LOCAL_DIR}/testing.sh #Execute the main testing script
#!/bin/sh
printf "======: $0\n"
printf "Testing FPGA loading (TK0, TD0, FPGA_INIT_B+FPGA_INIT_A)\n"
dir=/testing
printf "printing md5sum of the files to load:\n"
md5sum ${dir}/load-virtex
md5sum ${dir}/lm32-loader
md5sum ${dir}/test_scb.bin
md5sum ${dir}/rt_cpu.bin
chmod +x ${dir}/load-virtex
${dir}/load-virtex ${dir}/test_scb.bin
${dir}/lm32-loader ${dir}/rt_cpu.bin
#!/bin/sh
## A page is about 4224 (0x1080) byte
## everything is FFFF except from 0 from 0x0800>0x840 & 0x1040>0x1080)
printf "======: $0\n"
printf "Testing NAND memory"
dd bs=1k count=1 if=/dev/urandom > /tmp/w1k.bin
nandwrite -p /dev/mtd0 at91bootstrap.bin
nanddump --length=3564 --file=/tmp/nand-at91 /dev/mtd0
md5w=`md5sum /testing/at91bootstrap.bin | cut -f1 -d" "`
md5r=`md5sum /tmp/nand-at91 | cut -f1 -d" "`
if [ "$md5w" != "$md5r" ]; then
echo "ERROR @ $testdev W:$md5w, R:$md5r"
cmp -l /testing/at91bootstrap.bin /tmp/nand-at91 > /tmp/cmprw
head -n 1 /tmp/cmprw
tail -n 1 /tmp/cmprw
hexdump -n 500 -v /tmp/nand-at91
else
echo "OK @ $testnand R/W"
fi
#!/bin/sh
#!/bin/ash
## Parameters
export APTS_LOCAL_DIR="/alpha-pts"
export APTS_SERVER_DIR="alpha-pts"
export APTS_SERVER_IP="192.168.7.1"
## Load generic function
. 000-functions.sh
## setup default parameters
setupGlobalVar "APTS_SWITCH_DIR" "/alpha-pts"
setupGlobalVar "APTS_HOST_DIR" "."
setupGlobalVar "APTS_HOST_IP" "192.168.7.7"
load_ask2run()
{
sh=$1
echo ""
read -t 5 -p "# Execute $sh? (timeout in 5s) [Y/n]: " valid;
if [ "${valid}" != "n" ]; then
## Creating directories structure
mkdir ${APTS_SWITCH_DIR} &> /dev/null
mkdir ${APTS_SWITCH_DIR}/bin &> /dev/null
mkdir ${APTS_SWITCH_DIR}/logs &> /dev/null
cd ${APTS_SWITCH_DIR}
# Load script
tftp -g -r ${APTS_SERVER_DIR}/$sh ${APTS_SERVER_IP}
chmod +x ${APTS_LOCAL_DIR}/$sh
# Run it into the log
${APTS_LOCAL_DIR}/$sh 2>&1 | tee -a $logfile
# Run the scritps
run()
{
if [ x"$1" != x ]; then
numseq="$1"
else
echo -e "Skip the script $sh"
numseq="01 02 04 06 07 08 09"
fi
}
for itest in $numseq; do
load_ask2run $(ls *${itest}-*.sh) $ask $update $inlog
done
#Go to test directory
cd ${APTS_LOCAL_DIR}
}
# Obtain mac address
MAC=$(ifconfig | grep 'eth0' | tr -s ' ' | cut -d ' ' -f5 | sed s/://g)
logfile="${APTS_LOCAL_DIR}/output-$MAC.log"
# Put timestamp in the log
echo "" >> $logfile
echo "-----------------------------------------------" >> $logfile
echo "$(date)" >> $logfile
echo "" >> $logfile
showhelp()
{
echo ""
echo "Usage: $0 [OPTION]... [TESTNUM]"
echo ""
echo "Testing script to check various components of the White Rabbit Switch"
echo ""
echo "if TESTNUM is not defined all tests will be executed in ascending order"
echo ""
echo "Options:"
echo " -h|--help Show this little message"
echo " -f|--force Don't ask to continue"
echo " -u|--update Update binary files"
echo " -i|--inlog Create an independant log file for each test"
echo " -l|--list List the different building steps"
echo " -s|--serial Serial number"
echo ""
exit 0;
}
# Run the scritps
load_ask2run loadingfpga.sh
load_ask2run cpuebi0fpga.sh
load_ask2run checkflash.sh
load_ask2run devmemtesting.sh
load_ask2run flashingimgs.sh
load_ask2run nandflashing.sh
update="0"
inlog="0"
ask="1"
SN="0"
while [ $# -gt 0 ]; do # Until you run out of parameters . . .
case "$1" in
-h|--help) showhelp;;
-f|--force) ask="0";;
-u|--update) update="1";;
-i|--inlog) inlog="1";;
-s|--serial) SN=$2; shift;;
-l|--list) cd ${APTS_SWITCH_DIR}; ls 0*-*.sh; exit 0;;
[0-9]*) num="$1";;
*) showhelp;;
esac
shift # Check next set of parameters.
done
# Obtain mac address
#MAC=$(ifconfig | grep 'eth0' | tr -s ' ' | cut -d ' ' -f5 | sed s/://g)
if [ ${SN} -eq "0" ]; then
ret=""
user_echoasking "num" "Type the serial number" "S/N"
SN=$ret;
fi
export logfname="${APTS_SWITCH_DIR}/logs/output-${SN}"
# Put timestamp in the log
echo "" > $logfname.log
echo "-----------------------------------------------" >> $logfname.log
echo "$(date)" >> $logfname.log
echo "" >> $logfname.log
run "$num";
## Append all log to an history
cat $logfname.log >> ${logfname}_history.log
echo "" >> ${logfname}_history.log
exit 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment