-
Notifications
You must be signed in to change notification settings - Fork 1
/
boot.sh
executable file
·99 lines (78 loc) · 2.12 KB
/
boot.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z `command -v dtc` ]
then
echo "device tree compiler (dtc) not found"
echo "on ubuntu, apt install device-tree-compiler"
fi
if [ ! -f ./c/morello ]
then
echo "cannot find C emulator; please build it by running \`make gen_c\`"
exit 1
fi
BOOT="https://github.com/Alasdair/sail-arm-boot/archive/master.zip"
while true; do
read -p "Download boot files from $BOOT (y/n)? " yn
case $yn in
[Yy]* )
curl -L $BOOT 1> boot.zip;
break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
if [ ! -f boot.zip ]
then
echo "existing boot.zip could not be found, exiting"
exit 1
fi
unzip -u boot.zip
mkdir -p sail-arm-boot-master/initramfs
echo "Building bootloader"
make -C sail-arm-boot-master bootloader.bin
echo "Building initramfs"
make -C sail-arm-boot-master initramfs
echo "Building device tree blob"
make -C sail-arm-boot-master sail.dtb
LINUX="https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.92.tar.xz"
while true; do
read -p "Download Linux from $LINUX (y/n)? " yn
case $yn in
[Yy]* )
wget $LINUX;
break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
if [ ! -f linux-4.14.92.tar.xz ]
then
echo "existing linux-4.14.92 could not be found, exiting"
exit 1
fi
echo "Unpacking Linux"
tar -xf linux-4.14.92.tar.xz
echo "Copying config file"
cp sail-arm-boot-master/.config linux-4.14.92/
echo "Building Linux"
make -C linux-4.14.92 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -k -j 8
cp linux-4.14.92/arch/arm64/boot/Image .
cp sail-arm-boot-master/bootloader.bin .
cp sail-arm-boot-master/sail.dtb .
while true; do
read -p "Rebuild C emulator with device support (y/n)? " yn
case $yn in
[Yy]* )
rm -f c/morello.c c/morello;
make DEVICES=devices.sail gen_c;
break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
./c/morello -b 0x80000000,bootloader.bin -b 0x81000000,sail.dtb -b 0x82080000,Image -C cpu.cpu0.RVBAR=0x80000000 2> /dev/null || true
rm -f bootloader.bin
rm -f sail.dtb
rm -f Image
exit 0