forked from DoctorStrange96/android_kernel_samsung_msm8916
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_msm8916_kernel.sh
executable file
·367 lines (314 loc) · 10.6 KB
/
build_msm8916_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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/bin/bash
# MSM8916 KK kernel build script v0.5
SELINUX_DEFCONFIG=selinux_defconfig
SELINUX_LOG_DEFCONFIG=selinux_log_defconfig
BUILD_COMMAND=$1
if [ "$BUILD_COMMAND" == "kleos_eur" ]; then
PRODUCT_NAME=kleoslte;
elif [ "$BUILD_COMMAND" == "rossa_cmcc" ]; then
PRODUCT_NAME=rossalte;
elif [ "$BUILD_COMMAND" == "rossa_ctc" ]; then
PRODUCT_NAME=rossaltectc;
elif [ "$BUILD_COMMAND" == "rossa_aus" ]; then
PRODUCT_NAME=rossaltedv;
elif [ "$BUILD_COMMAND" == "fortuna_cmcc" ]; then
PRODUCT_NAME=fortunalte;
elif [ "$BUILD_COMMAND" == "fortuna_ctc" ]; then
PRODUCT_NAME=fortunaltectc;
elif [ "$BUILD_COMMAND" == "fortuna_cu" ]; then
PRODUCT_NAME=fortunalte;
elif [ "$BUILD_COMMAND" == "fortuna3g_eur" ]; then
PRODUCT_NAME=fortuna3g;
elif [ "$BUILD_COMMAND" == "fortuna_sea" ]; then
PRODUCT_NAME=fortunalte;
elif [ "$BUILD_COMMAND" == "gpen_eur" ]; then
PRODUCT_NAME=gpenlte;
elif [ "$BUILD_COMMAND" == "heat_eur" ]; then
PRODUCT_NAME=heatlte;
elif [ "$BUILD_COMMAND" == "a3_chnopen" ]; then
PRODUCT_NAME=a3ltechn;
elif [ "$BUILD_COMMAND" == "a3_chntw" ]; then
PRODUCT_NAME=a3ltezt;
elif [ "$BUILD_COMMAND" == "a3_chnctc" ]; then
PRODUCT_NAME=a3ltectc;
elif [ "$BUILD_COMMAND" == "a3_eur" ]; then
PRODUCT_NAME=a3ltexx;
elif [ "$BUILD_COMMAND" == "a3_ltn" ]; then
PRODUCT_NAME=a3lteub;
elif [ "$BUILD_COMMAND" == "a33g_eur" ]; then
PRODUCT_NAME=a33gxx;
elif [ "$BUILD_COMMAND" == "vivalto_aus" ]; then
PRODUCT_NAME=vivaltolte;
elif [ "$BUILD_COMMAND" == "vivalto_mea" ]; then
PRODUCT_NAME=vivaltolte;
else
#default product
PRODUCT_NAME=$BUILD_COMMAND;
fi
BUILD_WHERE=$(pwd)
BUILD_KERNEL_DIR=$BUILD_WHERE
BUILD_ROOT_DIR=$BUILD_KERNEL_DIR/../..
BUILD_KERNEL_OUT_DIR=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME/obj/KERNEL_OBJ
PRODUCT_OUT=$BUILD_ROOT_DIR/android/out/target/product/$PRODUCT_NAME
SECURE_SCRIPT=$BUILD_ROOT_DIR/buildscript/tools/signclient.jar
BUILD_CROSS_COMPILE=$BUILD_ROOT_DIR/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/arm-eabi-
BUILD_JOB_NUMBER=`grep processor /proc/cpuinfo|wc -l`
# Default Python version is 2.7
mkdir -p bin
ln -sf /usr/bin/python2.7 ./bin/python
export PATH=$(pwd)/bin:$PATH
KERNEL_DEFCONFIG=msm8916_sec_defconfig
DEBUG_DEFCONFIG=msm8916_sec_eng_defconfig
while getopts "w:t:" flag; do
case $flag in
w)
BUILD_OPTION_HW_REVISION=$OPTARG
echo "-w : "$BUILD_OPTION_HW_REVISION""
;;
t)
TARGET_BUILD_VARIANT=$OPTARG
echo "-t : "$TARGET_BUILD_VARIANT""
;;
*)
echo "wrong 2nd param : "$OPTARG""
exit -1
;;
esac
done
shift $((OPTIND-1))
BUILD_COMMAND=$1
SEANDROID_OPTION=
SECURE_OPTION=
if [ "$2" == "-B" ]; then
SECURE_OPTION=$2
elif [ "$2" == "-E" ]; then
SEANDROID_OPTION=$2
else
NO_JOB=
fi
if [ "$3" == "-B" ]; then
SECURE_OPTION=$3
elif [ "$3" == "-E" ]; then
SEANDROID_OPTION=$3
else
NO_JOB=
fi
if [ "$BUILD_COMMAND" == "kleos_eur" ]; then
SIGN_MODEL=SM-G510F_EUR_XX_ROOT0
elif [ "$BUILD_COMMAND" == "fortuna_cmcc" ]; then
SIGN_MODEL=SM-G5308W_CHN_ZM_ROOT0
elif [ "$BUILD_COMMAND" == "fortuna_ctc" ]; then
SIGN_MODEL=SM-G5309W_CHN_CTC_ROOT0
elif [ "$BUILD_COMMAND" == "fortuna_sea" ]; then
SIGN_MODEL=SM-G530F_SEA_DX_ROOT0
elif [ "$BUILD_COMMAND" == "heat_eur" ]; then
SIGN_MODEL=SM-G357FZ_EUR_XX_ROOT0
else
SIGN_MODEL=
fi
MODEL=${BUILD_COMMAND%%_*}
TEMP=${BUILD_COMMAND#*_}
REGION=${TEMP%%_*}
CARRIER=${TEMP##*_}
VARIANT=k${CARRIER}
PROJECT_NAME=${VARIANT}
VARIANT_DEFCONFIG=msm8916_sec_${MODEL}_${CARRIER}_defconfig
CERTIFICATION=NONCERT
case $1 in
clean)
echo "Not support... remove kernel out directory by yourself"
exit 1
;;
*)
BOARD_KERNEL_BASE=0x80000000
BOARD_KERNEL_PAGESIZE=2048
BOARD_KERNEL_TAGS_OFFSET=0x01E00000
BOARD_RAMDISK_OFFSET=0x02000000
#BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3"
BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci"
# BOARD_KERNEL_CMDLINE="console=ttyHSL0,115200,n8 androidboot.hardware=qcom androidboot.bootdevice=soc.0/7824900.sdhci user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 video=vfb:640x400,bpp=32,memsize=3072000 earlyprintk"
mkdir -p $BUILD_KERNEL_OUT_DIR
;;
esac
KERNEL_ZIMG=$BUILD_KERNEL_OUT_DIR/arch/arm/boot/zImage
DTC=$BUILD_KERNEL_OUT_DIR/scripts/dtc/dtc
FUNC_CLEAN_DTB()
{
if ! [ -d $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts ] ; then
echo "no directory : "$BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts""
else
echo "rm files in : "$BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/*.dtb""
rm $BUILD_KERNEL_OUT_DIR/arch/arm/boot/dts/*.dtb
fi
}
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/arm/boot/dts/"
$DTBTOOL -o $INSTALLED_DTIMAGE_TARGET -s $BOARD_KERNEL_PAGESIZE \
-p $BUILD_KERNEL_OUT_DIR/scripts/dtc/ $BUILD_KERNEL_OUT_DIR/arch/arm/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 ""
if [ "$BUILD_COMMAND" == "" ]; then
SECFUNC_PRINT_HELP;
exit -1;
fi
FUNC_CLEAN_DTB
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm \
CROSS_COMPILE=$BUILD_CROSS_COMPILE \
VARIANT_DEFCONFIG=$VARIANT_DEFCONFIG \
DEBUG_DEFCONFIG=$DEBUG_DEFCONFIG $KERNEL_DEFCONFIG\
SELINUX_DEFCONFIG=$SELINUX_DEFCONFIG \
SELINUX_LOG_DEFCONFIG=$SELINUX_LOG_DEFCONFIG || exit -1
make -C $BUILD_KERNEL_DIR O=$BUILD_KERNEL_OUT_DIR -j$BUILD_JOB_NUMBER ARCH=arm \
CROSS_COMPILE=$BUILD_CROSS_COMPILE || exit -1
FUNC_BUILD_DTIMAGE_TARGET
echo ""
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
FUNC_MKBOOTIMG()
{
echo ""
echo "==================================="
echo "START : FUNC_MKBOOTIMG"
echo "==================================="
echo ""
MKBOOTIMGTOOL=$BUILD_ROOT_DIR/android/kernel/tools/mkbootimg
if ! [ -e $MKBOOTIMGTOOL ] ; 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/anroid/kernel/tools/mkbootimg $MKBOOTIMGTOOL
fi
echo "Making boot.img ..."
echo " $MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \
--ramdisk $PRODUCT_OUT/ramdisk.img \
--output $PRODUCT_OUT/boot.img \
--cmdline "$BOARD_KERNEL_CMDLINE" \
--base $BOARD_KERNEL_BASE \
--pagesize $BOARD_KERNEL_PAGESIZE \
--ramdisk_offset $BOARD_RAMDISK_OFFSET \
--tags_offset $BOARD_KERNEL_TAGS_OFFSET \
--dt $INSTALLED_DTIMAGE_TARGET"
$MKBOOTIMGTOOL --kernel $KERNEL_ZIMG \
--ramdisk $PRODUCT_OUT/ramdisk.img \
--output $PRODUCT_OUT/boot.img \
--cmdline "$BOARD_KERNEL_CMDLINE" \
--base $BOARD_KERNEL_BASE \
--pagesize $BOARD_KERNEL_PAGESIZE \
--ramdisk_offset $BOARD_RAMDISK_OFFSET \
--tags_offset $BOARD_KERNEL_TAGS_OFFSET \
--dt $INSTALLED_DTIMAGE_TARGET
if [ "$SEANDROID_OPTION" == "-E" ] ; then
FUNC_SEANDROID
fi
if [ "$SECURE_OPTION" == "-B" ]; then
FUNC_SECURE_SIGNING
fi
cd $PRODUCT_OUT
tar cvf boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar boot.img
cd $BUILD_ROOT_DIR
if ! [ -d output ] ; then
mkdir -p output
fi
echo ""
echo "================================================="
echo "-->Note, copy to $BUILD_TOP_DIR/../output/ directory"
echo "================================================="
cp $PRODUCT_OUT/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar $BUILD_ROOT_DIR/output/boot_${MODEL}_${CARRIER}_${CERTIFICATION}.tar || exit -1
cd ~
echo ""
echo "==================================="
echo "END : FUNC_MKBOOTIMG"
echo "==================================="
echo ""
}
FUNC_SEANDROID()
{
echo -n "SEANDROIDENFORCE" >> $PRODUCT_OUT/boot.img
}
FUNC_SECURE_SIGNING()
{
echo "java -jar $SECURE_SCRIPT -model $SIGN_MODEL -runtype ss_openssl_sha -input $PRODUCT_OUT/boot.img -output $PRODUCT_OUT/signed_boot.img"
openssl dgst -sha256 -binary $PRODUCT_OUT/boot.img > sig_32
java -jar $SECURE_SCRIPT -runtype ss_openssl_sha -model $SIGN_MODEL -input sig_32 -output sig_256
cat $PRODUCT_OUT/boot.img sig_256 > $PRODUCT_OUT/signed_boot.img
mv -f $PRODUCT_OUT/boot.img $PRODUCT_OUT/unsigned_boot.img
mv -f $PRODUCT_OUT/signed_boot.img $PRODUCT_OUT/boot.img
CERTIFICATION=CERT
}
SECFUNC_PRINT_HELP()
{
echo -e '\E[33m'
echo "Help"
echo "$0 \$1 \$2 \$3"
echo " \$1 : "
echo " for KLEOS EUR OPEN use kleos_eur"
echo " for ROSSA CHN CMCC use rossa_cmcc"
echo " for ROSSA CHN CTC use rossa_ctc"
echo " for ROSSA AUS XSA use rossa_aus"
echo " for FORTUNA CHN CMCC use fortuna_cmcc"
echo " for FORTUNA CHN CTC use fortuna_ctc"
echo " for FORTUNA CHN CU use fortuna_cu"
echo " for FORTUNA SEA OPEN use fortuna_sea"
echo " for FORTUNA3G EUR OPEN use fortuna3g_eur"
echo " for GPEN_EUR_OPEN use gpen_eur"
echo " for HEAT EUR OPEN use heat_eur"
echo " for A3 CHN OPEN use a3_chnopen"
echo " for A3 CHN CTC use a3_chntw"
echo " for A3 CHN CTC use a3_chnctc"
echo " for A3 EUR OPEN use a3lte_eur"
echo " for A33G EUR OPEN use a33g_eur"
echo " for VIVALTO_AUS_XSA use vivalto_aus"
echo " for VIVALTO_MEA use vivalto_mea"
echo " \$2 : "
echo " -B or Nothing (-B : Secure Binary)"
echo " \$3 : "
echo " -E or Nothing (-E : SEANDROID Binary)"
echo -e '\E[0m'
}
# MAIN FUNCTION
rm -rf ./build.log
(
START_TIME=`date +%s`
FUNC_BUILD_KERNEL
#FUNC_RAMDISK_EXTRACT_N_COPY
FUNC_MKBOOTIMG
END_TIME=`date +%s`
let "ELAPSED_TIME=$END_TIME-$START_TIME"
echo "Total compile time is $ELAPSED_TIME seconds"
) 2>&1 | tee -a ./build.log