]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/openslug-init/openslug-init-0.10/update-kernel
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / openslug-init / openslug-init-0.10 / update-kernel
1 #!/bin/sh
2
3 if [ ! -f /boot/zImage ] ; then
4     echo "Cannot find kernel to flash in /boot/zImage"
5     exit 1
6 fi
7
8 /bin/rm -f /boot/zImage-partition
9
10 if [ -f /boot/zImage-partition ] ; then
11     echo "Unable to remove kernel partition file"
12     exit 1
13 fi
14
15 echo "Creating kernel partition header"
16 /usr/sbin/kern_header /boot/zImage /boot/zImage-partition
17
18 if [ ! -f /boot/zImage-partition ] ; then
19     echo "Unable to create kernel partition header"
20     exit 1
21 fi
22
23 echo "Creating kernel partition file"
24 /bin/cat /boot/zImage >> /boot/zImage-partition
25
26 /bin/rm -f /boot/zImage-partition.old
27
28 if [ -f /boot/zImage-partition.old ] ; then
29     echo "Unable to remove old kernel partition file"
30     exit 1
31 fi
32
33 echo "Saving old kernel partition"
34 cat /dev/mtdblock2 > /boot/zImage-partition.old
35
36 if [ ! -f /boot/zImage-partition.old ] ; then
37     echo "Unable to create old kernel partition file"
38     exit 1
39 fi
40
41 /bin/ls -l /boot/zImage /boot/zImage-partition /boot/zImage-partition.old
42
43 echo "Flashing new kernel partition"
44 cat /boot/zImage-partition > /dev/mtdblock2
45
46 /bin/rm -f /boot/zImage-partition.verify
47
48 if [ -f /boot/zImage-partition.verify ] ; then
49     echo "Unable to remove kernel partition verify file"
50     exit 1
51 fi
52
53 echo "Verifing new kernel partition"
54 /bin/dd if=/dev/mtd2 of=/boot/zImage-partition.verify bs=1 \
55     count=`/bin/dd if=/dev/mtd2 bs=4 count=1 2>/dev/null | \
56         /usr/bin/hexdump -n 6 -e '"%02d"'` 2>/dev/null 
57
58 if [ ! -f /boot/zImage-partition.verify ] ; then
59     echo "Unable to create kernel partition verify file"
60     exit 1
61 fi
62
63 if cmp /boot/zImage-partition /boot/zImage-partition.verify ; then
64     echo "Verification successful"
65     /bin/rm -f /boot/zImage-partition.verify
66     /bin/rm -f /boot/zImage-partition
67     /bin/rm -f /boot/zImage-partition.old
68     exit 0
69 fi
70
71 echo "VERIFICATION FAILED - DANGER DANGER DANGER"
72
73 echo "You must now manually reflash the new kernel,"
74 echo "or reflash the old kernel back again."
75 echo "The kernel partition is /dev/mtdblock2"
76 echo "The old kernel partition is in /boot/zImage-partition.old"
77 echo "The present partition contents are in /boot/zImage-partition.verify"
78 echo "The new kernel partition is in /boot/zImage-partition"
79
80 exit 1
81
82