forked from yank555-lu/N3-KK-faux123-yank555.lu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_kernel.sh
executable file
·57 lines (48 loc) · 2.43 KB
/
build_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
#!/bin/sh
export KERNELDIR=`readlink -f .`
export RAMFS_SOURCE=`readlink -f $KERNELDIR/ramfs/9005-unpacked`
#export USE_SEC_FIPS_MODE=true
export TOOLBASE="/home/yank555-lu/android/git/FauxToolz"
if [ "${1}" != "" ];then
export KERNELDIR=`readlink -f ${1}`
fi
RAMFS_TMP="/home/yank555-lu/temp/tmp/ramfs-source-sgn3"
# make defconfig
# JB : make VARIANT_DEFCONFIG=yank555-lu_msm8974_sec_hlteeur_defconfig faux_msm8974_sec_defconfig
cp arch/arm/configs/yank555-lu_msm8974_sec_defconfig .config
. $KERNELDIR/.config
echo ".............................................................Building new ramdisk............................................................."
#remove previous ramfs files
rm -rf $RAMFS_TMP
rm -rf $RAMFS_TMP.cpio
rm -rf $RAMFS_TMP.cpio.gz
#copy ramfs files to tmp directory
cp -ax $RAMFS_SOURCE $RAMFS_TMP
#clear git repositories in ramfs
find $RAMFS_TMP -name .git -exec rm -rf {} \;
#remove empty directory placeholders
find $RAMFS_TMP -name EMPTY_DIRECTORY -exec rm -rf {} \;
rm -rf $RAMFS_TMP/tmp/*
#remove mercurial repository
rm -rf $RAMFS_TMP/.hg
cd $RAMFS_TMP
find | fakeroot cpio -H newc -o > $RAMFS_TMP.cpio 2>/dev/null
ls -lh $RAMFS_TMP.cpio
gzip -9 $RAMFS_TMP.cpio
echo "...............................................................Compiling kernel..............................................................."
#remove previous out files
rm $KERNELDIR/dt.img
rm $KERNELDIR/boot.img
rm $KERNELDIR/*.ko
#compile kernel
cd $KERNELDIR
make -j6 || exit 1
echo "..............................................................Making new dt image............................................................."
$TOOLBASE/dtbtool -o $KERNELDIR/dt.img -s 2048 -p $KERNELDIR/scripts/dtc/ $KERNELDIR/arch/arm/boot/
echo ".............................................................Making new boot image............................................................"
$TOOLBASE/dt-mkbootimg --base 0x0 --kernel $KERNELDIR/arch/arm/boot/zImage --ramdisk_offset 0x2000000 --tags_offset 0x1e00000 --pagesize 2048 --cmdline 'console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3' --ramdisk $RAMFS_TMP.cpio.gz --dt $KERNELDIR/dt.img -o $KERNELDIR/boot.img
echo ".....................................................................done....................................................................."
find . -name "boot.img"
find . -name "*.ko" -exec mv {} . \;
${CROSS_COMPILE}strip --strip-unneeded ./*.ko
find . -name "*.ko"