#!/bin/sh
KRN_PROC_MTD=`cat /proc/mtd | grep '"kernel2"' | cut -d ':' -f 1`
KRN_MTD=6
KRN_IMG=/boot/uImage

if [ x${KRN_PROC_MTD} = xmtd${KRN_MTD} -a -e ${KRN_IMG} -a -e /sbin/flash_erase -a -e /sbin/nandwrite ]; then
  echo "***  Erasing ****"
  /sbin/flash_erase /dev/mtd${KRN_MTD} 0 0
  echo "*** Writing ***"
  #/sbin/flashcp ${KRN_IMG} /dev/mtd${KRN_MTD}
  /sbin/nandwrite -a -p /dev/mtd${KRN_MTD} ${KRN_IMG}
  echo "*** Set next_bootfrom ***"
  /firmware/sbin/info_setenv next_bootfrom 2
fi

