From: Jaehoon Chung Date: Mon, 8 Jan 2024 02:57:12 +0000 (+0900) Subject: build: Add local build script for VisionFive2 X-Git-Tag: accepted/tizen/unified/x/20240220.145856~78 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b03352ef9a424e5900405a6c6b1c8877079b161f;p=platform%2Fkernel%2Flinux-starfive.git build: Add local build script for VisionFive2 Add local build script for VisionFive2. This change is squash of below commits: commit 7c34e2ea4586 ("build: Change module image size from 32M to 20M") commit 9956753185f6 ("Build packages for different platforms") commit e876165aca8f ("build: add the separated device tree file") commit 34a3215f6226 ("build: Add local build script for VisionFive2") Change-Id: I0ca80fd1e383b9ce62797944fba1755e315fa9c7 Signed-off-by: Jaehoon Chung Signed-off-by: Seung-Woo Kim --- diff --git a/build.sh b/build.sh new file mode 100755 index 000000000000..3239bece90f9 --- /dev/null +++ b/build.sh @@ -0,0 +1,83 @@ +#!/bin/bash +MOD_DIR="usr/tmp_mod" +MOD_IMG="usr/modules.img" +MOD_SIZE=20 +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_visionfive2_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-starfive-visionfive-2-v1.2a.dtb jh7110-starfive-visionfive-2-v1.3b.dtb modules.img +mv linux-visionfive2.tar ./output/