Commit 5b7b245e authored by Benoit Rat's avatar Benoit Rat

Adding a first set of scripts for APTS

parent ab1bb422
Alpha PTS scripts
Benoit RAT @ Sevensols (2012)
============================================
1. First you need to setup the a tftp server on your PC
* 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
* Create a link from this git directory into tftpboot
ln -s ~/WR/wr-switch-testing/sw/alpha-pts /tftpboot
*. 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}
chmod +x loading.sh
./loading.sh
#!/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 cpu-fpga bus (EBI0)
# in memory range 0x10000000-0x10004000
# using the devmem application
nTot=512
addr=0x10000000
end=0x10004000
step=32
nOK=0
let addr10=$addr
let end10=$end
printf "======: $0\n"
printf "Testing CPU-FPGA bus (EBI0 @ $addr > $end): "
while [ $addr10 -lt $end10 ]; do
rand=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "`
val=`printf "0x%08X" $rand`
devmem $addr 32 $val
ret=`devmem $addr`
if [ $val != $ret ]; then
echo "ERROR @ $addr W:$val, R:$ret"
else
nOK=`expr ${nOK} + 1`
fi
if [ `expr $addr10 % 1024` -eq 0 ]; then
printf "."
fi
addr10=`expr $addr10 + $step`
addr=`printf "0x%X" $addr10`
done
echo ""
echo "Result CPU-FPGA bus: OK=${nOK}/${nTot}W"
#!/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
## Parameters
export APTS_LOCAL_DIR="/alpha-pts"
export APTS_SERVER_DIR="alpha-pts"
export APTS_SERVER_IP="192.168.7.1"
load_ask2run()
{
sh=$1
echo ""
read -t 5 -p "# Execute $sh? (timeout in 5s) [Y/n]: " valid;
if [ "${valid}" != "n" ]; then
# 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
else
echo -e "Skip the script $sh"
fi
}
#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
# 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
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