-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·217 lines (192 loc) · 5.54 KB
/
build.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
#!/bin/bash
# Inits
KERNEL_DIR=$PWD
ZIMAGE=$KERNEL_DIR/arch/arm/boot/zImage
# Exports
export ARCH=arm
export SUBARCH=arm
export KBUILD_BUILD_USER="ShankarWarang"
export KBUILD_BUILD_HOST="HighwayUltimatrix"
# Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
nocol='\033[0m' # Default
make q380_defconfig
# Default settings
verfile="android.ver"
curcfg=".config"
release="n"
rebuild="n"
clean="n"
makeflags="-w"
makedefs="V=0"
makejobs=${MAKEJOBS}
curdir=`pwd`
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ];then
outdir=../${MTK_ROOT_OUT}/KERNEL_OBJ
mkdir -p $outdir
mkdir -p mediatek/custom
ln -fns ../../../${MTK_ROOT_CUSTOM_OUT} mediatek/custom/out
fi
usage() {
echo "Usage: $0 {release|rebuild|clean|silent|verbose|single} [config-xxx]"
echo " config file will be generated if build with TARGET_PRODUCT"
exit 1
}
make_clean() {
echo "**** Cleaning ****"
nice make ${makeflags} ${makedefs} distclean
}
# Main starts here
while test -n "$1"; do
case "$1" in
release)
release="y"
;;
rebuild)
rebuild="y"
;;
clean)
clean="y"
;;
mrproper)
mrproper="y"
;;
silent)
makeflags="-ws"
makedefs="V=0"
;;
verbose)
makeflags="-w"
makedefs="V=1"
;;
single)
makejobs=""
;;
*)
export TARGET_PRODUCT=$1
;;
esac
shift
done
source ../mediatek/build/shell.sh ../ kernel
defcfg="${MTK_ROOT_GEN_CONFIG}/kconfig"
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
makeflags+=" O=$outdir"
fi
if [ ! -z $KMOD_PATH ]; then
if [ ! -e $KMOD_PATH ]; then
echo "Invalid KMOD_PATH:$KMOD_PATH"
echo "CURDIR=$curdir"
exit 1;
fi
fi
# clean if it is necessary
if [ "${clean}" == "y" ]; then
if [ ! -z $KMOD_PATH ]; then
echo "Clean kernel module PROJECT=$MTK_PROJECT PATH=$KMOD_PATH";
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
make M="$KMOD_PATH" O=$outdir clean
else
make M="$KMOD_PATH" clean
fi
exit $?
else
make_clean; exit $?;
fi
fi
if [ "${mrproper}" == "y" ]; then
make mrproper; exit $?;
fi
if [ "${rebuild}" == "y" ]; then make_clean; fi
echo "**** Configuring / $defcfg / ****"
# select correct configuration file
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
make mediatek-configs O=$outdir
else
make mediatek-configs
fi
# Config DRAM size according to central Project Configuration file setting
# Todo:
# Need a robust mechanism to control Kconfig content by central Config setting
# Move below segment to a configuration file for extension
if [ "$CUSTOM_DRAM_SIZE" == "3G" ]; then
# Config DRAM size as 3G (0x18000000).
sed --in-place=.orig \
-e 's/\(CONFIG_MAX_DRAM_SIZE_SUPPORT=\).*/\10x18000000/' \
$outdir/.config
else
if [ "$CUSTOM_DRAM_SIZE" == "2G" ]; then
# Config DRAM size as 2G (0x10000000).
sed --in-place=.orig \
-e 's/\(CONFIG_MAX_DRAM_SIZE_SUPPORT=\).*/\10x10000000/' \
-e 's/\(CONFIG_RESERVED_MEM_SIZE_FOR_PMEM=\).*/\10x1700000/' \
$outdir/.config
else
if [ "$CUSTOM_DRAM_SIZE" == "4G" ]; then
# Config DRAM size as 4G (0x20000000).
sed --in-place=.orig \
-e 's/\(CONFIG_MAX_DRAM_SIZE_SUPPORT=\).*/\10x20000000/' \
$outdir/.config
else
if [ "$CUSTOM_DRAM_SIZE" == "6G" ]; then
# Config DRAM size as 6G (0x30000000).
sed --in-place=.orig \
-e 's/\(CONFIG_MAX_DRAM_SIZE_SUPPORT=\).*/\10x30000000/' \
-e 's/\(CONFIG_CMDLINE=.*\)"/\1 vmalloc=280M"/' \
-e 's/.*\(CONFIG_HIGHMEM\).*/\1=y/' \
-e '$ a\# CONFIG_HIGHPTE is not set' \
-e '$ a\# CONFIG_DEBUG_HIGHMEM is not set' \
$outdir/.config
else
if [ "$CUSTOM_DRAM_SIZE" == "8G" ]; then
# Config DRAM size as 8G (0x40000000).
sed --in-place=.orig \
-e 's/\(CONFIG_MAX_DRAM_SIZE_SUPPORT=\).*/\10x40000000/' \
-e 's/\(CONFIG_CMDLINE=.*\)"/\1 vmalloc=280M"/' \
-e 's/.*\(CONFIG_HIGHMEM\).*/\1=y/' \
-e '$ a\# CONFIG_HIGHPTE is not set' \
-e '$ a\# CONFIG_DEBUG_HIGHMEM is not set' \
$outdir/.config
fi
fi
fi
fi
fi
# update configuration
nice make ${makeflags} ${makedefs} silentoldconfig
if [ ! -z $KMOD_PATH ]; then
echo "Build kernel module PROJECT=$MTK_PROJECT PATH=$KMOD_PATH";
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
make M="$KMOD_PATH" O=$outdir modules
else
make M="$KMOD_PATH" modules
fi
exit $?
fi
echo "**** Building ****"
make ${makeflags} ${makejobs} ${makedefs}
if [ $? -ne 0 ]; then exit 1; fi
echo "**** Successfully built kernel ****"
mkimg="${MTK_ROOT_BUILD}/tools/mkimage"
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
kernel_img="${outdir}/arch/arm/boot/Image"
kernel_zimg="${outdir}/arch/arm/boot/zImage"
else
kernel_img="${curdir}/arch/arm/boot/Image"
kernel_zimg="${curdir}/arch/arm/boot/zImage"
fi
echo "**** Generate download images ****"
if [ ! -x ${mkimg} ]; then chmod a+x ${mkimg}; fi
if [ "${KBUILD_OUTPUT_SUPPORT}" == "yes" ]; then
${mkimg} ${kernel_zimg} KERNEL > $outdir/kernel_${MTK_PROJECT}.bin
else
${mkimg} ${kernel_zimg} KERNEL > kernel_${MTK_PROJECT}.bin
fi
copy_to_legacy_download_flash_folder $outdir/kernel_${MTK_PROJECT}.bin rootfs_${MTK_PROJECT}.bin