#!/bin/sh if [ ! -f /boot/zImage ] ; then echo "Cannot find kernel to flash in /boot/zImage" exit 1 fi /bin/rm -f /boot/zImage-partition if [ -f /boot/zImage-partition ] ; then echo "Unable to remove kernel partition file" exit 1 fi echo "Creating kernel partition header" /usr/sbin/kern_header /boot/zImage /boot/zImage-partition if [ ! -f /boot/zImage-partition ] ; then echo "Unable to create kernel partition header" exit 1 fi echo "Creating kernel partition file" /bin/cat /boot/zImage >> /boot/zImage-partition /bin/rm -f /boot/zImage-partition.old if [ -f /boot/zImage-partition.old ] ; then echo "Unable to remove old kernel partition file" exit 1 fi echo "Saving old kernel partition" cat /dev/mtdblock2 > /boot/zImage-partition.old if [ ! -f /boot/zImage-partition.old ] ; then echo "Unable to create old kernel partition file" exit 1 fi /bin/ls -l /boot/zImage /boot/zImage-partition /boot/zImage-partition.old echo "Flashing new kernel partition" cat /boot/zImage-partition > /dev/mtdblock2 /bin/rm -f /boot/zImage-partition.verify if [ -f /boot/zImage-partition.verify ] ; then echo "Unable to remove kernel partition verify file" exit 1 fi echo "Verifing new kernel partition" /bin/dd if=/dev/mtd2 of=/boot/zImage-partition.verify bs=1 \ count=`/bin/dd if=/dev/mtd2 bs=4 count=1 2>/dev/null | \ /usr/bin/hexdump -n 6 -e '"%02d"'` 2>/dev/null if [ ! -f /boot/zImage-partition.verify ] ; then echo "Unable to create kernel partition verify file" exit 1 fi if cmp /boot/zImage-partition /boot/zImage-partition.verify ; then echo "Verification successful" /bin/rm -f /boot/zImage-partition.verify /bin/rm -f /boot/zImage-partition /bin/rm -f /boot/zImage-partition.old exit 0 fi echo "VERIFICATION FAILED - DANGER DANGER DANGER" echo "You must now manually reflash the new kernel," echo "or reflash the old kernel back again." echo "The kernel partition is /dev/mtdblock2" echo "The old kernel partition is in /boot/zImage-partition.old" echo "The present partition contents are in /boot/zImage-partition.verify" echo "The new kernel partition is in /boot/zImage-partition" exit 1