forked from bennhuang/build
-
Notifications
You must be signed in to change notification settings - Fork 41
/
mk-kernel.sh
executable file
·64 lines (47 loc) · 1.41 KB
/
mk-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
#!/bin/bash -e
LOCALPATH=$(pwd)
OUT=${LOCALPATH}/out
EXTLINUXPATH=${LOCALPATH}/build/extlinux
BOARD=$1
version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
finish() {
echo -e "\e[31m MAKE KERNEL IMAGE FAILED.\e[0m"
exit -1
}
trap finish ERR
if [ $# != 1 ]; then
BOARD=rk3288-evb
fi
[ ! -d ${OUT} ] && mkdir ${OUT}
[ ! -d ${OUT}/kernel ] && mkdir ${OUT}/kernel
source $LOCALPATH/build/board_configs.sh $BOARD
if [ $? -ne 0 ]; then
exit
fi
echo -e "\e[36m Building kernel for ${BOARD} board! \e[0m"
KERNEL_VERSION=$(cd ${LOCALPATH}/kernel && make kernelversion)
echo $KERNEL_VERSION
if version_gt "${KERNEL_VERSION}" "5.11"; then
if [ "${DTB_MAINLINE}" ]; then
DTB=${DTB_MAINLINE}
fi
if [ "${DEFCONFIG_MAINLINE}" ]; then
DEFCONFIG=${DEFCONFIG_MAINLINE}
fi
fi
cd ${LOCALPATH}/kernel
[ ! -e .config ] && echo -e "\e[36m Using ${DEFCONFIG} \e[0m" && make ${DEFCONFIG}
make -j8
cd ${LOCALPATH}
if [ "${ARCH}" == "arm" ]; then
cp ${LOCALPATH}/kernel/arch/arm/boot/zImage ${OUT}/kernel/
cp ${LOCALPATH}/kernel/arch/arm/boot/dts/${DTB} ${OUT}/kernel/
else
cp ${LOCALPATH}/kernel/arch/arm64/boot/Image ${OUT}/kernel/
cp ${LOCALPATH}/kernel/arch/arm64/boot/dts/rockchip/${DTB} ${OUT}/kernel/
fi
# Change extlinux.conf according board
sed -e "s,fdt .*,fdt /$DTB,g" \
-i ${EXTLINUXPATH}/${CHIP}.conf
./build/mk-image.sh -c ${CHIP} -t boot -b ${BOARD}
echo -e "\e[36m Kernel build success! \e[0m"