#!/bin/sh
#

FILE=`ls /rootfs/*.jff|head -1`

if [ "${FILE}" = "" ];then
#try for a fs with sane extensions
FILE=`ls /rootfs/*.jffs2|head -1`
fi

if [ "${FILE}" = "" ];then
echo no file found - emergency shell sort it out yourself
/bin/sh
exit 0
fi

echo programming ${FILE}

for loop in 5 4 3 2 1;do
echo write will commence in ${loop} Seconds
sleep 1
done

echo erasing main flash
/bin/flash_eraseall -j /dev/mtdblock0
if [ $? -ne 0 ]; then
panic "flash erase failed"
fi

echo writing main flash
/bin/nandwrite --blockalign=2 /dev/mtdblock0 ${FILE}
if [ $? -ne 0 ]; then
panic "nandwrite failed"
fi

echo completed - remove card
 
