#!/bin/sh

handle_checkflash()
{
	ERRMSG="Check Flash Sections Error !!"
	RETRY=5

	counter=1;
	while [ $counter -le $RETRY ] ; do

		CHK_RESULT=`rdcsman 0x8002F005 str`
		
		if [ "$CHK_RESULT" == "" ] ; then
			# CSID value does not exist, check again.
			checkflashsection
		else
			# Check flash sections finished.
			break;	
		fi
	
		counter=`expr $counter + 1`
	done

	if [ $counter -ge $RETRY ] ; then
		wrcsman "0x8002F005 \"$ERRMSG"
	fi
	
	return 0;
}

usage () {
        echo "$0 [start]"
        exit 1
}

# main ##########################################################

[ -z "$1" ] && usage

case "$1" in

	start)
		
		handle_checkflash
		
		;;
	
	*)
		exit 1
esac

exit 0		
