3 COLOR_RED_BG=$(tput setab 1)
4 COLOR_RED_BOLD=$(tput bold)$(tput setaf 1)
5 COLOR_RESET=$(tput sgr0)
8 MOD_IMG="usr/modules.img"
10 NCPUS=`cat /proc/cpuinfo | grep processor | wc -l`
14 KERNEL_PATH=`basename ${BUILD_ROOT}`
17 echo "Usage : $0 <architecture> [rt] [bootimg]"
18 echo " architecture : arm or arm64"
20 echo " e.g) $0 arm64 rt"
21 echo " e.g) $0 arm64 bootimg"
22 echo " e.g) $0 arm rt bootimg"
26 # Check this system has ccache
30 if [ "$?" -eq "0" ]; then
37 [ -e /usr/bin/make_ext4fs ] && USE_MAKE_EXT4FS=1
38 if [ "$USE_MAKE_EXT4FS" != "1" ] || [ "$IS_BOOTIMG" = "1" ]; then
46 TMP_PATH=./tmp_bootimg
47 TMP_UBOOT_PATH=./tmp_uboot
57 mkfs.vfat -F 16 -C -n BOOT boot.img 65536
58 sudo mount -o loop,uid=$USER_ID,gid=$GROUP_ID,showexec boot.img ${TMP_PATH}
60 cp -a $BOOT_PATH/LICENCE.broadcom ${TMP_PATH}
61 cp -a $BOOT_PATH/start*.elf ${TMP_PATH}
62 cp -a $BOOT_PATH/fixup*.dat ${TMP_PATH}
63 if [ "$ARM_ARCH" = "arm64" ]; then
64 echo "Create 64bit boot image"
65 cp -a $BOOT_PATH/config_64bit.txt ${TMP_PATH}/config.txt
66 cp -a arch/arm64/boot/Image ${TMP_PATH}
67 cp -a arch/arm64/boot/dts/broadcom/bcm*.dtb ${TMP_PATH}
69 echo "Create 32bit boot image"
70 cp -a $BOOT_PATH/config.txt ${TMP_PATH}
71 cp -a arch/arm/boot/zImage ${TMP_PATH}
72 cp -a arch/arm/boot/dts/broadcom/bcm*.dtb ${TMP_PATH}
74 mkdir -p ${TMP_PATH}/overlays
75 cp -a arch/arm/boot/dts/overlays/*.dtbo ${TMP_PATH}/overlays
77 # install u-boot files extracted from u-boot-rpi4 rpm package in download.tizen.org.
78 rm -rf ${TMP_UBOOT_PATH}
79 mkdir -p ${TMP_UBOOT_PATH}
80 pushd ${TMP_UBOOT_PATH}
81 if [ "$ARM_ARCH" = "arm64" ]; then
82 REPO_URL=http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest/repos/standard/packages/aarch64/
84 REPO_URL=http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest/repos/standard/packages/armv7l/
88 UBOOT=`awk -F\" '{ print $2 }' index.html | grep u-boot-rpi4`
89 wget ${REPO_URL}${UBOOT}
93 cp -a ${TMP_UBOOT_PATH}/boot/* ${TMP_PATH}
95 sudo umount ${TMP_PATH}
97 rm -rf ${TMP_UBOOT_PATH}
101 function mk_tizen_modules()
103 if [ -e ${BUILD_ROOT}/../linux-tizen-modules-source ]; then
104 pushd ${BUILD_ROOT}/../linux-tizen-modules-source
106 ln -s ${PWD}/include kernel
108 export BUILD_logger=m
109 export LOGGER_MAIN_BUFFER_SIZE=256
110 export LOGGER_EVENTS_BUFFER_SIZE=256
111 export LOGGER_RADIO_BUFFER_SIZE=256
112 export LOGGER_SYSTEM_BUFFER_SIZE=256
114 export BUILD_proc_tsm=m
116 export BUILD_zlogger=m
118 ARCH="${ARM_ARCH}" CROSS_COMPILE="${CROSS_COMPILER}" make -C kernel KERNELDIR=${BUILD_ROOT}
122 ARCH="${ARM_ARCH}" CROSS_COMPILE="${CROSS_COMPILER}" make -C kernel modules_install KERNELDIR=${BUILD_ROOT} INSTALL_MOD_PATH=../${KERNEL_PATH}/${MOD_DIR} INSTALL_MOD_STRIP=1 INSTALL_MOD_DIR=extra
126 if [ -e ${BUILD_ROOT}/../linux-tizen-modules ]; then
127 mkdir -p ${MOD_DIR}/lib/modules/modprobe.d
128 mkdir -p ${MOD_DIR}/lib/modules/modules-load.d
129 cp ${BUILD_ROOT}/../linux-tizen-modules/conf/tizen-modprobe-rpi4.conf ${MOD_DIR}/lib/modules/modprobe.d
130 cp ${BUILD_ROOT}/../linux-tizen-modules/conf/tizen-modules-rpi4.conf ${MOD_DIR}/lib/modules/modules-load.d
133 echo "linux-tizen-modules-source/linux-tizen-modules are not cloned in parent path, so skip building linux-tizen-modules."
134 echo "To build linux-tizen-modules, please use below command:"
135 echo " git clone git://git.tizen.org/platform/kernel/linux-tizen-modules-source -b tizen ../linux-tizen-modules-source"
136 echo " git clone git://git.tizen.org/platform/kernel/linux-tizen-modules -b tizen ../linux-tizen-modules"
140 function mk_modules() {
141 make ARCH=${ARM_ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules_prepare
142 make ARCH=${ARM_ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules -j ${NCPUS}
144 if [ "$?" != "0" ]; then
145 echo "Failed to make modules"
149 [ -d ${MOD_DIR} ] || mkdir ${MOD_DIR}
151 make ARCH=${ARM_ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules_install INSTALL_MOD_PATH=${MOD_DIR} INSTALL_MOD_STRIP=1
153 # build and install linux-tizen-modules if cloned in parent path
156 if [ "$USE_MAKE_EXT4FS" == "1" ]; then
157 /usr/bin/make_ext4fs -b 4096 -L modules -l ${MOD_SIZE}M $MOD_IMG ${MOD_DIR}/lib/modules/
159 dd if=/dev/zero of=${MOD_IMG} bs=1M count=${MOD_SIZE}
160 mkfs.ext4 -F -b 4096 -L modules ${MOD_IMG}
161 [ -d ${MOD_DIR}/mnt ] || mkdir ${MOD_DIR}/mnt
162 sudo mount -o loop ${MOD_IMG} ${MOD_DIR}/mnt
163 sudo cp -rf ${MOD_DIR}/lib/modules/* ${MOD_DIR}/mnt
165 sudo umount ${MOD_DIR}/mnt
173 function cleanup_localversion()
175 rm -f localversion-rt
178 function create_tar()
181 if [ ! -d output ] ; then
187 cp $BOOTFILES ./output
188 cp usr/modules.img ./output
191 DATE=`date +%Y%m%d%H%M`
192 if [ $ARM_ARCH = "arm" ]; then
193 tar cvf tizen-local-${DATE}-boot-armv7l-rpi4.tar -C output $FILES
194 mv tizen-local-${DATE}-boot-armv7l-rpi4.tar ./output/
195 elif [ $ARM_ARCH = "arm64" ]; then
196 tar cvf tizen-local-${DATE}-boot-arm64-rpi4.tar -C output $FILES
197 mv tizen-local-${DATE}-boot-arm64-rpi4.tar ./output/
199 echo "There is no proper architecture agrument!"
204 DEFCONFIG=tizen_bcm2711_defconfig
205 touch .kernel_buildenv
208 if [ "$2" = "rt" ] || [ "$3" = "rt" ]; then
213 if [ "$2" = "bootimg" ] || [ "$3" = "bootimg" ]; then
217 if [ "$IS_RT" = "1" ]; then
218 echo "Build RT-Kernel"
219 BUILD_VERSION=`cat .kernel_buildenv`
220 if [ "$BUILD_VERSION" != "RT" ]; then
221 echo "Previous .config is for Normal Kernel, so remove"
224 DEFCONFIG=tizen_bcm2711_rt_defconfig
225 cp _localversion-rt localversion-rt
226 trap cleanup_localversion EXIT
227 echo "RT" > ./.kernel_buildenv
229 echo "Build Normal-Kernel"
230 BUILD_VERSION=`cat .kernel_buildenv`
231 if [ "$BUILD_VERSION" == "RT" ]; then
232 echo "Previous .config is for RT Kernel, so remove"
235 echo "NORMAL" > ./.kernel_buildenv
240 if [ $1 = "arm" ]; then
242 CROSS_COMPILER="${CCACHE} arm-linux-gnueabi-"
244 elif [ $1 = "arm64" ]; then
246 CROSS_COMPILER="${CCACHE} aarch64-linux-gnu-"
249 echo "There is no arcitecture type..."
253 if ! [ -e .config ] ; then
254 make ARCH="${ARM_ARCH}" CROSS_COMPILE="${CROSS_COMPILER}" ${DEFCONFIG}
257 make ARCH="${ARM_ARCH}" CROSS_COMPILE="${CROSS_COMPILER}" -j ${NCPUS} 2>&1 | \
258 sed -e "/error:.*/{s/^.*error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
259 -e "/Error.*/{s/^.*Error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
260 -e "/ERROR.*/{s/^.*ERROR/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}"
261 if [ $? -ne 0 ]; then
262 echo -e "${COLOR_RED_BOLD}Failed to build${COLOR_RESET}"
266 if [ "$IS_BOOTIMG" = "1" ]; then
270 if [ $ARM_ARCH = "arm" ]; then
271 BOOTFILES="./arch/arm/boot/zImage ./arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dtb"
273 BOOTFILES="./arch/arm64/boot/Image ./arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb"
277 # Make module.img file