From 2161762ebc50914fe51a7923945c64e6ce4ee25f Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Tue, 28 Dec 2021 21:46:06 +0800
Subject: [PATCH] update build shell script, add system and distro
---
bsp/images/build.sh | 73 ++++++++++++++++++++++--------------
1 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/bsp/images/build.sh b/bsp/images/build.sh
index b66b133..2e8e592 100755
--- a/bsp/images/build.sh
+++ b/bsp/images/build.sh
@@ -20,20 +20,31 @@
PRJ_PATH=`pwd`
PRJ_NAME=`basename ${PRJ_PATH}`
-IMAGE_PATH=${PRJ_PATH}/boot/
+BOARD=igkboard
+BSP_BRANCH=lf-5.10.52-2.1.0
-BOARD=imx6ull
+# $SYSTEM should be buildroot, yocto or debian
+# Buildroot distro should be: buildroot-2021.02
+# Yocto distro should be : hardknott
+# Debian distro should be : buster or bullseye
+SYSTEM=buildroot
+DISTRO=v2021.02
-# rootfs should be buildroot or stretch/buster/bullseye for debian system
-ROOTFS=buildroot
+SYSTYPE=`echo $SYSTEM | tr 'A-Z' 'a-z'`
+if [ $SYSTYPE == "debian" ] ; then
+ SYSNAME=${DISTRO}
+else
+ SYSNAME=${SYSTYPE}
+fi
+ROOTFS_DIR=rootfs_${SYSNAME}
-# linux kernel tarball path and branch
TAR_PATH=${PRJ_PATH}/../tarball
+IMAGE_PATH=${PRJ_PATH}/boot/
BOOT=emmc
-IMAGE_NAME=linuxsys_${BOARD}_${ROOTFS}.img
-if [ $ROOTFS == buildroot ] ; then
+IMAGE_NAME=linuxsys_${BOARD}_${SYSNAME}.img
+if [ $SYSTEM == buildroot ] ; then
IMAGE_SIZE=512
else
IMAGE_SIZE=2048
@@ -50,10 +61,10 @@
BOOT_SIZE=100
-IMG_UBOOT=${PRJ_PATH}/u-boot-imx6ull-emmc.imx
+IMG_UBOOT=${PRJ_PATH}/u-boot-${BOARD}.imx
IMG_KERNEL=${IMAGE_PATH}/zImage
-IMG_DTB=${IMAGE_PATH}/imx6ull-emmc.dtb
-ROOTFS_TAR=${TAR_PATH}/rootfs_${ROOTFS}.tar.bz2
+IMG_DTB=${IMAGE_PATH}/${BOARD}-emmc.dtb
+ROOTFS_TAR=${PRJ_PATH}/../rootfs/${ROOTFS_DIR}.tar.bz2
MNT_POINT=./mnt
LOOP_DEV=`losetup -f | cut -d/ -f3`
@@ -66,19 +77,24 @@
echo "Shell script exit now, do some clean work"
echo ""
+ set +e
+
mountpoint $MNT_POINT > /dev/null 2>&1
if [ $? == 0 ] ; then
+ echo "umount ${MNT_POINT}"
umount ${MNT_POINT}
fi
rm -rf ${MNT_POINT}
if [ -L /dev/mapper/${LOOP_DEV}p1 ] ; then
+ echo "kpartx -dv /dev/${LOOP_DEV}"
kpartx -dv /dev/${LOOP_DEV}
fi
losetup -a | grep "${LOOP_DEV}" > /dev/null 2>&1
if [ $? == 0 ] ; then
+ echo "losetup -d /dev/${LOOP_DEV}"
losetup -d /dev/${LOOP_DEV}
fi
}
@@ -160,6 +176,7 @@
mount -t ext4 /dev/mapper/${LOOP_DEV}p2 ${MNT_POINT}
tar -xjf ${ROOTFS_TAR} -C ${MNT_POINT} && sync
+ chown -R root.root ${MNT_POINT} && sync
umount ${MNT_POINT}
}
@@ -176,18 +193,19 @@
}
function do_image()
-{
- mkdir -p ${MNT_POINT}
+{
+ mkdir -p ${MNT_POINT}
- generate_image
+ generate_image
- format_partition
+ format_partition
- install_sysimg
+ install_sysimg
- install_rootfs
+ install_rootfs
msg_banner " bzip2 compress system image "
+ rm -f ${IMAGE_NAME}*.bz2
bzip2 ${IMAGE_NAME}
rm -rf ${MNT_POINT}
@@ -195,19 +213,18 @@
printf "\n\n -- generate system image done --\n\n"
}
-
function do_root()
{
echo ""
- if [[ $1 == "yes" ]] && [ `id -u` != 0 ] ; then
+ if [[ $1 == "yes" ]] && [ `id -u` != 0 ] ; then
echo "ERROR: This action must run as root!"
echo ""
exit;
- elif [[ $1 != "yes" ]] && [ `id -u` == 0 ] ; then
+ elif [[ $1 != "yes" ]] && [ `id -u` == 0 ] ; then
echo "ERROR: This action cannot run as root!"
echo ""
exit;
- fi
+ fi
}
function do_usage()
@@ -228,22 +245,22 @@
while getopts "bch" OPTNAME
do
- case "${OPTNAME}" in
- "b")
+ case "${OPTNAME}" in
+ "b")
break;
- ;;
+ ;;
- "c")
+ "c")
do_root "yes"
do_distclean
- ;;
+ ;;
"*")
do_usage
- ;;
+ ;;
esac
done
-do_root "yes"
+do_root "yes"
do_image
-
+exit;
--
Gitblit v1.9.1