From 895d1bcb91189eae2070e7d353294ce6cece986c Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Fri, 05 Apr 2024 14:38:55 +0800 Subject: [PATCH] Driver:IGKBoard-All: Update default board to igkboard-imx6ull --- images/build.sh | 95 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 64 insertions(+), 31 deletions(-) diff --git a/images/build.sh b/images/build.sh index 2045cb8..11e5c3a 100755 --- a/images/build.sh +++ b/images/build.sh @@ -10,14 +10,19 @@ PRFX_PATH=$PRJ_PATH/install # binaries finally install path if needed -INST_PATH=/tftp +#INST_PATH=/tftp + +# compress system image or not +COMPRESS=yes + +# download taballs path +TARBALL_PATH=$PRJ_PATH/tarballs # config file path CONF_FILE=$TOP_PATH/config.json # shell script will exit once get command error set -e -set -u #+-------------------------+ #| Shell script functions | @@ -85,6 +90,8 @@ { export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'` export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'` + export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE` + export DIS_TYPE=`jq -r ".system.distro" $CONF_FILE | tr 'A-Z' 'a-z'` export DIS_VER=`jq -r ".system.version" $CONF_FILE | tr 'A-Z' 'a-z'` export IMAGE_SIZE=`jq -r ".system.imgsize" $CONF_FILE | tr 'A-Z' 'a-z'` export BOOT_SIZE=`jq -r ".system.bootsize" $CONF_FILE | tr 'A-Z' 'a-z'` @@ -95,8 +102,9 @@ export ROOTFS=rootfs-${DIS_VER} export UBOOT_BINPATH=$TOP_PATH/bootloader/install/ export KERNEL_BINPATH=$TOP_PATH/kernel/install/ - export ROOTFS_TARPATH=$TOP_PATH/images/tarballs/ export ROOTFS_YCTPATH=$TOP_PATH/yocto/install/ + export IMAGE_NAME=${DIS_TYPE}-${DIS_VER}-${BOARD}.img + export KERNEL_IMAGE=Image if [[ $BOARD =~ mx8ulp ]] || [[ $BOARD =~ mx8mq ]] || [[ $BOARD =~ mx8mm ]] ; then export UBOOT_OFFSET_SECTOR=66 @@ -104,6 +112,7 @@ export UBOOT_OFFSET_SECTOR=64 elif [[ $BOARD =~ mx6 ]] || [[ $BOARD =~ mx7 ]] ; then export UBOOT_OFFSET_SECTOR=2 + export KERNEL_IMAGE=zImage fi } @@ -111,38 +120,53 @@ { cd $PRJ_PATH - SRCS=$ROOTFS + if [ -d $ROOTFS/bin ] ; then + pr_info "$ROOTFS fetched already" + return ; + fi - for src in $SRCS - do - if [ -d $ROOTFS/bin ] ; then - pr_info "$src fetched already" - continue - fi + if [[ $DIS_TYPE == yocto ]] ; then + TAR_TYPE=tar.zst + else + TAR_TYPE=tar.xz + fi - for tarball in $ROOTFS_TARPATH/rootfs*${DIS_VER}.tar.* - do - if [ -s $tarball ] ; then - pr_warn "Decompress $ROOTFS from tarballs" - mkdir -p $ROOTFS - do_unpack $tarball $ROOTFS - break; - fi - done + # Decompress the rootfs form Yocto build install path + if [[ $DIS_TYPE == yocto ]] ; then - for tarball in $ROOTFS_YCTPATH/rootfs.tar.* + for tarball in $ROOTFS_YCTPATH/*.${TAR_TYPE} do if [ -s $tarball ] ; then pr_warn "Decompress $ROOTFS from yocto install path" mkdir -p $ROOTFS do_unpack $tarball $ROOTFS - break; + return ; fi done + fi - done + tarball=rootfs-${DIS_TYPE}-${DIS_VER}.${TAR_TYPE} - if [ ! -d $ROOTFS ] ; then + if [[ $BSP_URL =~ github.com ]] ; then + + pr_error "INFO: Please download $tarball and decompress it to folder '$PRJ_PATH/$ROOTFS'" + + else + + pr_info "INFO: download $tarball form $BSP_URL" + + mkdir -p $TARBALL_PATH + + # Download source code packet + if [ ! -s $TARBALL_PATH/$tarball ] ; then + wget $BSP_URL/imx/${BOARD}/rootfs/$tarball -P $TARBALL_PATH + fi + + # decompress source code packet + do_unpack $TARBALL_PATH/$tarball $ROOTFS + fi + + if [ ! -d $ROOTFS/bin ] ; then pr_error "Fetch rootfs $ROOTFS failed" exit ; fi @@ -157,8 +181,6 @@ function build_image() { - export IMAGE_NAME=$BOARD-$DIS_VER.img - # Uboot size set be 10MB and deployed in 64th sector on eMMC/TFCard UBOOT_SIZE=10 @@ -190,8 +212,12 @@ pr_info "start install linux kernel images" mount -t vfat /dev/mapper/${LOOP_DEV}p1 ${MNT_POINT} - cp -rf $KERNEL_BINPATH/Image ${MNT_POINT}/ + cp -rf $PRJ_PATH/patches/config-${BOARD}.txt ${MNT_POINT}/config.txt + cp -rf $KERNEL_BINPATH/$KERNEL_IMAGE ${MNT_POINT}/ cp -rf $KERNEL_BINPATH/${BOARD}.dtb ${MNT_POINT}/ + if [ -d $KERNEL_BINPATH/overlays ] ; then + cp -rf $KERNEL_BINPATH/overlays ${MNT_POINT}/ + fi sync && umount ${MNT_POINT} @@ -199,13 +225,14 @@ rm -rf $ROOTFS/lib/modules/ mkdir -p $ROOTFS/lib/modules/ cp -rf $KERNEL_BINPATH/lib/modules/[0-9]*\.[0-9]*\.[0-9]* $ROOTFS/lib/modules/ + cp -rf $KERNEL_BINPATH/lib/firmware/* $ROOTFS/lib/firmware/ pr_info "start install root filesystem" mount -t ext4 /dev/mapper/${LOOP_DEV}p2 ${MNT_POINT} cp -af $ROOTFS/* ${MNT_POINT} sync && umount ${MNT_POINT} - pr_warn "Build $BOARD-$BSP_VER-$DIS_VER system image done" + pr_warn "Build system image $IMAGE_NAME done" } function exit_handler() @@ -243,17 +270,22 @@ { cd $PRJ_PATH + if [[ `echo $COMPRESS | tr 'A-Z' 'a-z'` == "yes" ]] ; then + pr_info "Start bzip2 compress $IMAGE_NAME" + rm -f $IMAGE_NAME.bz2 + bzip2 $IMAGE_NAME + fi + mkdir -p $PRFX_PATH + mv $IMAGE_NAME* $PRFX_PATH cp $UBOOT_BINPATH/u-boot-${BOARD}.imx $PRFX_PATH - mv $IMAGE_NAME $PRFX_PATH if [[ -n "$INST_PATH" && -w $INST_PATH ]] ; then pr_info "install bootloader and system image to '$INST_PATH'" cp $PRFX_PATH/u-boot-${BOARD}.imx $INST_PATH - cp $PRFX_PATH/$IMAGE_NAME $INST_PATH + cp $PRFX_PATH/$IMAGE_NAME* $INST_PATH fi } - function do_clean() { @@ -262,6 +294,7 @@ rm -rf $PRJ_PATH/$d done + rm -rf $PRJ_PATH/tarballs rm -rf $PRFX_PATH rm -f *.img } @@ -285,7 +318,7 @@ exit; fi -pr_warn "Build $BOARD-$BSP_VER-$DIS_VER system image" +pr_warn "Build system image $IMAGE_NAME" trap 'exit_handler' EXIT -- Gitblit v1.9.1