summaryrefslogtreecommitdiff
path: root/packages/openslug-init/openslug-init-0.10/update-kernel
blob: 796d45e95398dbaab04b3a0f9bfd2afdb95084d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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