3 COLOR_RED_BG=$(tput setab 1)
4 COLOR_RED_BOLD=$(tput bold)$(tput setaf 1)
5 COLOR_RESET=$(tput sgr0)
7 NCPUS=`cat /proc/cpuinfo | grep processor | wc -l`
11 echo "Usage : $0 <architecture> [rt]"
12 echo " architecture : arm or arm64"
14 echo " e.g) $0 arm64 rt"
18 # Check this system has ccache
22 if [ "$?" -eq "0" ]; then
29 cleanup_localversion()
34 DEFCONFIG=tizen_bcm2711_defconfig
36 touch .kernel_buildenv
37 if [ "$2" = "rt" ]; then
38 echo "Build RT-Kernel"
39 BUILD_VERSION=`cat .kernel_buildenv`
40 if [ "$BUILD_VERSION" != "RT" ]; then
41 echo "Previous .config is for Normal Kernel, so remove"
44 DEFCONFIG=tizen_bcm2711_rt_defconfig
45 cp _localversion-rt localversion-rt
46 trap cleanup_localversion EXIT
47 echo "RT" > ./.kernel_buildenv
48 elif [ "$2" = "pgo" ]; then
49 echo "Build PGO-kernel"
50 BUILD_VERSION=`cat .kernel_buildenv`
51 if [ "$BUILD_VERSION" == "RT" ]; then
52 echo "Previous .config is for RT Kernel, so remove"
54 elif [ "$BUILD_VERSION" == "GCOV" ]; then
55 echo "Previous .config is for GCOV Kernel, so remove and clean"
58 elif [ "$BUILD_VERSION" == "NORMAL" ]; then
59 echo "Previous .config is for Normal Kernel, so remove"
62 echo "PGO" > ./.kernel_buildenv
63 KCFLAGS="-fprofile-use=$3 -Wno-coverage-mismatch -Wno-error=coverage-mismatch"
64 echo "set KCFLAGS=$KCFLAGS"
65 DEFCONFIG=tizen_bcm2711_defconfig
66 elif [ "$2" = "gcov" ]; then
67 echo "Build GCOV-kernel"
68 BUILD_VERSION=`cat .kernel_buildenv`
69 if [ "$BUILD_VERSION" == "RT" ]; then
70 echo "Previous .config is for RT Kernel, so remove"
72 elif [ "$BUILD_VERSION" == "PGO" ]; then
73 echo "Previous, .config is for PGO kernel, so remove"
75 elif [ "$BUILD_VERSION" == "NORMAL" ]; then
76 echo "Previous .config is for Normal Kernel, so remove"
79 echo "GCOV" > ./.kernel_buildenv
80 DEFCONFIG=tizen_bcm2711_gcov_defconfig
82 echo "Build Normal-Kernel"
83 BUILD_VERSION=`cat .kernel_buildenv`
84 if [ "$BUILD_VERSION" == "RT" ]; then
85 echo "Previous .config is for RT Kernel, so remove"
88 echo "NORMAL" > ./.kernel_buildenv
92 if [ $1 = "arm" ]; then
94 cross_compile="${CCACHE} arm-linux-gnueabi-"
96 elif [ $1 = "arm64" ]; then
98 cross_compile="${CCACHE} aarch64-linux-gnu-"
102 if ! [ -e .config ] ; then
103 make ARCH="${arch}" CROSS_COMPILE="${cross_compile}" ${DEFCONFIG}
106 make ARCH="${arch}" CROSS_COMPILE="${cross_compile}" KCFLAGS="${KCFLAGS}" -j ${NCPUS} 2>&1 | \
107 sed -e "/error:.*/{s/^.*error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
108 -e "/Error.*/{s/^.*Error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
109 -e "/ERROR.*/{s/^.*ERROR/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}"
110 if [ $? -ne 0 ]; then
111 echo -e "${COLOR_RED_BOLD}Failed to build${COLOR_RESET}"
115 scripts/mkbootimg_rpi4.sh