-
Notifications
You must be signed in to change notification settings - Fork 1
/
hikey-kernel-builder-newclang.sh
executable file
·174 lines (146 loc) · 5.52 KB
/
hikey-kernel-builder-newclang.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
usage()
{
echo "usage: -i [-s] -v=[4.4|4.9|4.14]"
echo "-i = interactive mode"
echo "-s = skip download"
echo "-v = kernel version"
}
set -ex
# export TOOLCHAIN="clang-r328903"
# export TOOLCHAIN="clang-r339409"
# export TOOLCHAIN="clang-4679922"
export TOOLCHAIN="clang-r339409b"
export nproc=9
export ANDROID_VERSION="O-MR1"
export REFERENCE_BUILD_URL="http://testdata.linaro.org/lkft/aosp-stable/android-8.1.0_r29/"
export KERNEL_DIR="hikey-linaro"
while [ "$1" != "" ]; do
case $1 in
-v | --version ) shift
VERSION=$1
;;
-i | --interactive ) interactive=1
;;
-t | --toolchain ) shift
toolchain=$1
;;
-s | --skipdownloads ) skipdownloads=1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
if [ "$VERSION" = "4.9" ]; then
export KERNEL_BRANCH=android-hikey-linaro-4.9
export ANDROID_KERNEL_CONFIG_DIR="android-4.9"
fi
if [ "$VERSION" = "4.14" ]; then
export KERNEL_BRANCH=android-hikey-linaro-4.14
export ANDROID_KERNEL_CONFIG_DIR="android-4.14"
fi
if [ "$VERSION" = "4.19" ]; then
export KERNEL_BRANCH=android-hikey-linaro-4.19
export ANDROID_KERNEL_CONFIG_DIR="android-4.19"
fi
if [ "$VERSION" = "4.4" ]; then
export KERNEL_BRANCH=android-hikey-linaro-4.4
export ANDROID_KERNEL_CONFIG_DIR="android-4.4"
fi
# android-4.14 android-4.4 android-4.9 o o-mr1 p
if [ "$ANDROID_VERSION" = "O-MR1" ]; then
export CONFIG_FRAGMENTS_PATH="o-mr1"
fi
if [ "$ANDROID_VERSION" = "P" ]; then
export CONFIG_FRAGMENTS_PATH="p"
fi
if [ "$skipdownloads" != "1" ]; then
git clone --depth=1 https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
wget https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
fi
export PATH=${PWD}/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:${PWD}/linux-x86/${TOOLCHAIN}/bin/:${PATH}
if echo "${JOB_NAME}" | grep premerge; then
git merge --no-edit remotes/origin/${UPSTREAM_KERNEL_BRANCH}
fi
if [ "$skipdownloads" != "1" ]; then
mkdir patches
cd patches
wget -r -np -nH -R index.html --cut-dirs=2 http://people.linaro.org/~tom.gall/patches/
cd ..
fi
if [ "$skipdownloads" = "1" ]; then
cd configs
git pull
cd ..
else
git clone --depth=1 https://android.googlesource.com/kernel/configs
if [ "$ANDROID_VERSION" = "O-MR1" ]; then
cd configs
patch -p1 < ../patches/ConfigsTurnOnQTA.patch
cd ..
fi
fi
if [ "$interactive" = "1" ]; then
echo "interactive mode"
else
export ANDROID_VERSION=$(echo $REFERENCE_BUILD_URL | awk -F"/" '{print$(NF-1)}')
fi
if echo "$ANDROID_VERSION" | grep -i aosp ; then
CMD="androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab video=HDMI-A-1:1280x720@60"
else
CMD="androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on buildvariant=userdebug video=HDMI-A-1:1280x720@60"
fi
if [ "$skipdownloads" = "1" ]; then
cd "$KERNEL_DIR"
make mrproper
git checkout master
git clean -fd
git pull
git checkout "$KERNEL_BRANCH"
git pull
else
git clone https://android.googlesource.com/kernel/hikey-linaro
cd "$KERNEL_DIR"
git checkout -b "$KERNEL_BRANCH" origin/"$KERNEL_BRANCH"
if [ "$VERSION" = "4.9" ]; then
git revert --no-edit bbab5cb8a5bd598af247d9eaf5a3033e7d12104e
fi
if [ "$VERSION" = "4.14" ]; then
git revert --no-edit 20ebc74d51a1542e4290abf5ac9e32b524f891d1
git revert --no-edit d0455063e17c07841eb40b8e755f4c9241506de5
fi
fi
cd ..
mkdir -p out
export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE=aarch64-linux-gnu-
cd "$KERNEL_DIR"
if [ "$ANDROID_VERSION" = "O-MR1" ]; then
if [ "$VERSION" = "4.14" ]; then
ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/hikey_defconfig ../configs/${ANDROID_KERNEL_CONFIG_DIR}/android-base.config ../configs/${ANDROID_KERNEL_CONFIG_DIR}/android-recommended-arm64.config
else
ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/hikey_defconfig ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base.config ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base-arm64.config
fi
else
ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/hikey_defconfig ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base.config ../configs/${CONFIG_FRAGMENTS_PATH}/${ANDROID_KERNEL_CONFIG_DIR}/android-base-arm64.config
fi
cp .config ../defconfig
# make ARCH=arm64 CC=clang HOSTCC=clang -j$(nproc) -s Image.gz-dtb
make ARCH=arm64 CC=clang HOSTCC=clang -j$(nproc) Image-dtb
cd ..
wget -q https://android-git.linaro.org/platform/system/core.git/plain/mkbootimg/mkbootimg.py -O mkbootimg
wget -q ${REFERENCE_BUILD_URL}/ramdisk.img -O ramdisk.img
# --kernel ${PWD}/"$KERNEL_DIR"/arch/arm64/boot/Image.gz-dtb
python mkbootimg \
--kernel ${PWD}/"$KERNEL_DIR"/arch/arm64/boot/Image-dtb \
--cmdline console="${CMD}" \
--os_version O \
--os_patch_level 2016-11-05 \
--ramdisk ./ramdisk.img \
--output boot.img
#