-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·73 lines (59 loc) · 1.62 KB
/
run.sh
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
#!/bin/sh
#set -x
# Bash script to build a bootable kernel for the ASUS C101PA Chromebook
# Set defaults
CMDLINE=./cmdline
ITS=./kernel.its
# Args
if [ "$#" -lt 1 ]
then echo "Usage: run partition [path to its file] [path to text file containing cmdline]"
exit 1
fi
# Set partition
PART=$1
# Set its file path if provided
if [ "$#" -gt 1 ]
then ITS=$2
fi
# Set cmdline file path if provided
if [ "$#" -gt 1 ]
then CMDLINE=$3
fi
echo "---> Partition to flashed kernel to: $PART"
echo "---> Path to .its file: $ITS"
echo "---> Kernel command line:\n `cat $CMDLINE`"
# Run mkimage to build a kernel image. Input: its file Output: image in uimg format
mkimage "-D -I dts -O dtb -p 2048" -f $ITS vmlinux.uimg
if [ "$?" -ne 0 ];
then echo "mkimage failed with $?"
exit 1
fi
echo "---> mkimage: SUCCESS"
# Check if bootloader.bin available before running vbutil, otherwise create it
if ! [ -f bootloader.bin ]; then
echo "---> Generating empty booloader.bin..."
dd if=/dev/zero of=bootloader.bin bs=512 count=1
fi
# Run vbutil_kernel to get a bootable image for the chromebook
vbutil_kernel \
--pack vmlinux.kpart \
--version 1 \
--vmlinuz vmlinux.uimg \
--arch aarch64 \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config cmdline \
--bootloader bootloader.bin
if [ "$?" -ne 0 ];
then echo "vbutil failed."
exit 1
fi
echo "---> vbutil_kernel: SUCCESS"
# Flash kernel image to partition
if [ -b $PART ]; then
sudo dd if=vmlinux.kpart of=$PART
echo "---> Successfully flashed to $PART"
sudo sync
else
echo "---> Partition $PART does not exist"
fi