summaryrefslogtreecommitdiff
path: root/packages/slugos-init/files/update-kernel
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2006-01-07 08:58:44 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-01-07 08:58:44 +0000
commit8fb6b2d3d410ad2badf0c99ed7a66b698aafaa17 (patch)
tree8a700d795bdf33061b8bccc353fe0aaffa044036 /packages/slugos-init/files/update-kernel
parent0b67482ddc4fe571d16fa094627abb447b9a8edb (diff)
slugos: Major rename of common SlugOS files and directories from openslug to slugos.
Diffstat (limited to 'packages/slugos-init/files/update-kernel')
-rw-r--r--packages/slugos-init/files/update-kernel82
1 files changed, 82 insertions, 0 deletions
diff --git a/packages/slugos-init/files/update-kernel b/packages/slugos-init/files/update-kernel
new file mode 100644
index 0000000000..796d45e953
--- /dev/null
+++ b/packages/slugos-init/files/update-kernel
@@ -0,0 +1,82 @@
+#!/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
+
+