script: build: add local build script for v5.15
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 6 Apr 2023 05:42:30 +0000 (14:42 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 6 Apr 2023 05:42:30 +0000 (14:42 +0900)
Add local build ssript for v5.15.

Change-Id: I0f54869889fd787eeff8acf650e270b21fd8929f
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
build.sh [new file with mode: 0755]

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..a678f2d
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+MOD_DIR="usr/tmp_mod"
+MOD_IMG="usr/modules.img"
+MOD_SIZE=32
+NCPUS=`grep ^processor /proc/cpuinfo | wc -l`
+NCPUS=$(($NCPUS * 2))
+
+# Check this system has ccache
+check_ccache()
+{
+       type ccache
+       if [ "$?" -eq "0" ]; then
+               CCACHE=ccache
+       fi
+}
+
+function mk_modules() {
+       [ -e /usr/bin/make_ext4fs ] && USE_MAKE_EXT4FS=1
+       if [ "$USE_MAKE_EXT4FS" != "1" ]; then
+               sudo ls > /dev/null
+       fi
+
+       make ARCH=${ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules_prepare
+       make ARCH=${ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules -j ${NCPUS}
+
+       if [ "$?" != "0" ]; then
+               echo "Failed to make modules"
+               exit 1
+       fi
+
+       [ -d ${MOD_DIR} ] || mkdir ${MOD_DIR}
+
+       make ARCH=${ARCH} CROSS_COMPILE="$CROSS_COMPILER" modules_install INSTALL_MOD_PATH=${MOD_DIR} INSTALL_MOD_STRIP=1
+
+       if [ "$USE_MAKE_EXT4FS" == "1" ]; then
+               /usr/bin/make_ext4fs -b 4096 -L modules -l ${MOD_SIZE}M $MOD_IMG ${MOD_DIR}/lib/modules/
+       else
+               dd if=/dev/zero of=${MOD_IMG} bs=1M count=${MOD_SIZE}
+               mkfs.ext4 -F -b 4096 -L modules ${MOD_IMG}
+               [ -d ${MOD_DIR}/mnt ] || mkdir ${MOD_DIR}/mnt
+               sudo mount -o loop ${MOD_IMG} ${MOD_DIR}/mnt
+               sudo cp -rf ${MOD_DIR}/lib/modules/* ${MOD_DIR}/mnt
+               sync
+               sudo umount ${MOD_DIR}/mnt
+       fi
+       rm -rf ${MOD_DIR}
+       ls -al ${MOD_IMG}
+}
+
+check_ccache
+
+echo "riscv64"
+rm -f arch/riscv/boot/Image
+rm -f arch/riscv/boot/dts/starfive/*.dtb
+rm -f output/Image
+rm -f output/*.dtb
+rm -f output/modules.img
+rm -f output/*.tar
+
+CROSS_COMPILER=riscv64-linux-gnu-
+ARCH=riscv
+if ! [ -e .config ] ; then
+       make ARCH=${ARCH} CROSS_COMPILE="$CROSS_COMPILER" tizen_vf2_defconfig
+fi
+make ARCH=${ARCH} CROSS_COMPILE="$CROSS_COMPILER" -j8
+if [ ! -f "./arch/riscv/boot/Image" ]; then
+       echo "Build fail"
+       exit 1
+fi
+
+# Make module.img file
+mk_modules
+
+if [ ! -d output ] ; then
+       mkdir ./output
+fi
+
+cp usr/modules.img ./output
+
+cp ./arch/riscv/boot/Image ./output
+cp ./arch/riscv/boot/dts/starfive/*.dtb ./output
+tar cvf linux-visionfive2.tar -C output Image jh7110-visionfive-v2.dtb modules.img
+mv linux-visionfive2.tar ./output/