#!/bin/sh
#
# mb5120_flash_chk.sh
#
if [ x$1 = x ];then
	DEBUG=0
else
	DEBUG=$1
fi
CMD_MTDCHKSUM=/usr/local/bin/chksum


test ${DEBUG} -eq 1 && echo "linecnt=${linecnt}"

MTD0SUM=`${CMD_MTDCHKSUM} /tmp/testdev/mtd0 -s 0x1ffc0,0x40 `
echo "IPL sum    = ${MTD0SUM}"
MTD1SUM=`${CMD_MTDCHKSUM} /tmp/testdev/mtd1`
echo "Kernel sum = ${MTD1SUM}"
MTD2SUM=`${CMD_MTDCHKSUM} /tmp/testdev/mtd2`
echo "Files sum  = ${MTD2SUM}"

#MTD3SUM=`${CMD_MTDCHKSUM} /tmp/testdev/mtd3`
#if [ x${MTD3SUM} != x01FE0000 ];then
#	echo -n "Data sum   = ${MTD3SUM}"
#	echo  "  Error : data area not initialize"
#	exit 1
#fi 

while true ; do
	echo -n "Checksum Ok ? (y/n) "
	read YesNo 
	if [ x${YesNo} = xy ] ; then
		RETCODE=0
		break
	elif [ x${YesNo} = xn ] ; then
		RETCODE=1
		break
	fi
	echo "IPL sum    = ${MTD0SUM}"
	echo "Kernel sum = ${MTD1SUM}"
	echo "Files sum  = ${MTD2SUM}"
done

exit ${RETCODE}
