I'm stomped on how to accomplish this task. I need to run this script that fills up the nand flash on an embedded (linux-Busybox v1) device with random data, then continually repeats this process until the user stops it or the flash drive fails. The problem I'm having is that my testing involves power-cycling the device several times. But, the script stops running, which calls for me to start it again manually. Can someone recommend a resolution? Thanks!
Script:
#!/bin/sh
mkdir -p /mytest/storage/testnand
idx=0
while true
do
#./script.sh >/mytest/storage/testnand/test.raw
dd if=/dev/urandom of=/mytest/storage/testnand/test.raw bs=100000 count=50 2> /dev/null
if [ ! $? = 0 ]
then
echo "ERROR: ${idx}"
echo "ERROR: ${idx}" >> /mytest/storage/testnand/error.log
continue
fi
cp /mytest/storage/testnand/test.raw /mytest/storage/testnand/test_copied.raw
if [ ! $? = 0 ]
then
echo "ERROR 1: ${idx}"
echo "ERROR 1: ${idx}" >> /mytest/storage/testnand/error.log
continue
fi
cmp /mytest/storage/testnand/test.raw /mytest/storage/testnand/test_copied.raw 2> /dev/null
if [ ! $? = 0 ]
then
echo "ERROR 2: ${idx}"
echo "ERROR 2: ${idx}" >> /mytest/storage/testnand/error.log
continue
fi
echo "OK ${idx}"
echo "OK ${idx}" >> /mytest/storage/testnand/ok.log
idx=`expr $idx + 1`
done
Update:
I failed to mention, as I didn't have this information at the time, the embedded os is patched: there are many files that are read-only; /etc/rc is one of those files. Is there some kind of work-around that will allow me to run my script at start-up?