-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_msm8976_kernel.sh
175 lines (138 loc) · 5.31 KB
/
build_msm8976_kernel.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
175
#!/bin/bash
BUILD_COMMAND=$1
PRODUCT_OUT=$2
PRODUCT_NAME=$3
if [ "${SEC_BUILD_CONF_USE_DMVERITY}" == "true" ] ; then
DMVERITY_DEFCONFIG=dmverity_defconfig
fi
if [ "${SEC_BUILD_CONF_KERNEL_KASLR}" == "true" ] ; then
KASLR_DEFCONFIG=kaslr_defconfig
fi
MODEL=${BUILD_COMMAND%%_*}
echo PRODUCT_NAME=$PRODUCT_NAME
echo MODEL=$MODEL
echo DMVERITY_DEFCONFIG=$DMVERITY_DEFCONFIG
echo KASLR_DEFCONFIG=$KASLR_DEFCONFIG
BUILD_WHERE=$(pwd)
BUILD_KERNEL_DIR=$BUILD_WHERE
BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/../..
BUILD_KERNEL_OUT_DIR=$PRODUCT_OUT/obj/KERNEL_OBJ
SECURE_SCRIPT=$BUILD_ROOT_DIR/buildscript/tools/signclient.jar
BUILD_CROSS_COMPILE=$BUILD_ROOT_DIR/android/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
KERNEL_DEFCONFIG=msm8976_sec_defconfig
DEBUG_DEFCONFIG=msm8976_sec_eng_defconfig
SELINUX_DEFCONFIG=selinux_defconfig
SELINUX_LOG_DEFCONFIG=selinux_log_defconfig
MODEL=${BUILD_COMMAND%%_*}
TEMP=${BUILD_COMMAND#*_}
REGION=${TEMP%%_*}
CARRIER=${TEMP##*_}
VARIANT=${CARRIER}
PROJECT_NAME=${VARIANT}
if [ "${REGION}" == "${CARRIER}" ]; then
VARIANT_DEFCONFIG=msm8976_sec_${MODEL}_${CARRIER}_defconfig
else
VARIANT_DEFCONFIG=msm8976_sec_${MODEL}_${REGION}_${CARRIER}_defconfig
fi
BUILD_CONF_PATH=$BUILD_ROOT_DIR/buildscript/build_conf/${MODEL}
BUILD_CONF=${BUILD_CONF_PATH}/common_build_conf.${MODEL}
BOARD_KERNEL_PAGESIZE=2048
mkdir -p $BUILD_KERNEL_OUT_DIR
KERNEL_ZIMG=$BUILD_KERNEL_OUT_DIR/arch/arm64/boot/Image.gz
DTC=$BUILD_KERNEL_OUT_DIR/scripts/dtc/dtc
INSTALLED_DTIMAGE_TARGET=${PRODUCT_OUT}/dt.img
DTBTOOL=$BUILD_KERNEL_DIR/tools/dtbTool
FUNC_BUILD_DTIMAGE_TARGET()
{
echo ""
echo "================================="
echo "START : FUNC_BUILD_DTIMAGE_TARGET"
echo "================================="
echo ""
echo "DT image target : $INSTALLED_DTIMAGE_TARGET"
if ! [ -e $DTBTOOL ] ; then
if ! [ -d $BUILD_ROOT_DIR/android/out/host/linux-x86/bin ] ; then
mkdir -p $BUILD_ROOT_DIR/android/out/host/linux-x86/bin
fi
cp $BUILD_ROOT_DIR/kernel/tools/dtbTool $DTBTOOL
fi
echo "$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \
-p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/"
$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \
-p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm64/boot/dts/
chmod a+r $INSTALLED_DTIMAGE_TARGET
echo ""
echo "================================="
echo "END : FUNC_BUILD_DTIMAGE_TARGET"
echo "================================="
echo ""
}
FUNC_BUILD_KERNEL()
{
echo ""
echo "=============================================="
echo "START : FUNC_BUILD_KERNEL"
echo "=============================================="
echo ""
echo "build project="$PROJECT_NAME""
echo "build common config="$KERNEL_DEFCONFIG ""
echo "build variant config="$VARIANT_DEFCONFIG ""
echo "build secure option="$SECURE_OPTION ""
echo "build SEANDROID option="$SEANDROID_OPTION ""
echo "build selinux defconfig="$SELINUX_DEFCONFIG ""
echo "build selinux log defconfig="$SELINUX_LOG_DEFCONFIG ""
echo "build dmverity defconfig="$DMVERITY_DEFCONFIG""
echo "build kaslr defconfig="$KASLR_DEFCONFIG""
echo "build PRODUCT_OUT="$PRODUCT_OUT ""
if [ "$BUILD_COMMAND" == "" ]; then
SECFUNC_PRINT_HELP;
exit -1;
fi
chmod u+w $PRODUCT_OUT/mkbootimg_ver_args.txt
echo '--base 0x80000000 --cmdline "console=null androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk" --pagesize 2048 --tags_offset 0x01E00000 --ramdisk_offset 0x02000000 --os_version 8.0.0 --os_patch_level 2018-04-01' > $PRODUCT_OUT/mkbootimg_ver_args.txt
echo ----------------------------------------------
echo info $PRODUCT_OUT/mkbootimg_ver_args.txt
echo ----------------------------------------------
cat $PRODUCT_OUT/mkbootimg_ver_args.txt
echo ----------------------------------------------
if [[ "${SEC_BUILD_OPTION_EXTRA_BUILD_CONFIG}" != *"kasan"* ]] && \
[[ "${SEC_BUILD_OPTION_EXTRA_BUILD_CONFIG}" != *"ubsan"* ]];
then
KCFLAGS=-mno-android
fi
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE KCFLAGS=$KCFLAGS \
VARIANT_DEFCONFIG=$VARIANT_DEFCONFIG \
DEBUG_DEFCONFIG=$DEBUG_DEFCONFIG $KERNEL_DEFCONFIG \
SELINUX_DEFCONFIG=$SELINUX_DEFCONFIG \
SELINUX_LOG_DEFCONFIG=$SELINUX_LOG_DEFCONFIG \
DMVERITY_DEFCONFIG=$DMVERITY_DEFCONFIG \
KASLR_DEFCONFIG=$KASLR_DEFCONFIG || exit -1
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm64 \
CROSS_COMPILE=$BUILD_CROSS_COMPILE KCFLAGS=$KCFLAGS || exit -1
FUNC_BUILD_DTIMAGE_TARGET
rsync -cv $KERNEL_ZIMG $PRODUCT_OUT/kernel
ls -al $PRODUCT_OUT/kernel
echo ""
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
SECFUNC_PRINT_HELP()
{
echo -e '\E[33m'
echo "Help"
echo "$0 \$1"
echo " \$1 : "
for model in `ls -1 ../../model/build_conf | sed -e "s/.\+\///"`; do
for build_conf in `find ../../model/build_conf/$model/ -name build_conf.${model}_* | sed -e "s/.\+build_conf\.//"`; do
echo " $build_conf"
done
done
echo -e '\E[0m'
}
(
FUNC_BUILD_KERNEL
)