From 256f9500617fc2374cbb07cfb73cc2a428bdb607 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Fri, 05 Apr 2024 14:30:04 +0800
Subject: [PATCH] Driver:IGKBoard-IMX6ULL: Add igkboard-imx6ull linux driver

---
 yocto/build.sh |   95 +++++++++++++++++++++++++++++++----------------
 1 files changed, 62 insertions(+), 33 deletions(-)

diff --git a/yocto/build.sh b/yocto/build.sh
index aec649e..b526d16 100755
--- a/yocto/build.sh
+++ b/yocto/build.sh
@@ -7,7 +7,7 @@
 PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
 
 # top project absolute path
-TOP_PATH=$(realpath $PRJ_PATH/..)
+TOP_PATH=$PRJ_PATH/..
 
 # prefix install path
 PRFX_PATH=$PRJ_PATH/install
@@ -16,7 +16,7 @@
 #INST_PATH=/srv/ftp/
 
 # compress system image or not
-#COMPRESS=yes
+COMPRESS=yes
 
 # download taballs path
 TARBALL_PATH=$PRJ_PATH/tarballs
@@ -25,7 +25,7 @@
 CONF_FILE=$TOP_PATH/config.json
 
 # Download path
-#DL_PATH="/srv/yocto_packets/"
+#DL_PATH="/srv/yocto/"
 
 # shell script will exit once get command error
 set -e
@@ -97,31 +97,52 @@
     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 YCT_VER=`jq -r ".system.version" $CONF_FILE | tr 'A-Z' 'a-z'`
+    export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
 
     export YCT_BOARD=`echo $BOARD| cut -d- -f1`
     export YCT_META=meta-$YCT_BOARD
-    export YCT_PATH=$PRJ_PATH/$YCT_VER-$BSP_VER
+    export YCT_SRC=$YCT_VER-$BSP_VER
+    export YCT_PATH=$PRJ_PATH/$YCT_SRC
     export BUILD_DIR=${BOARD}
 }
 
 function do_fetch()
 {
+    cd $PRJ_PATH
 
-    mkdir -p $YCT_PATH && cd $YCT_PATH
+    if [ ! -d $YCT_SRC/sources ] ; then
 
-    if [ ! -d sources ] ; then
+        if [[ $BSP_URL =~ github.com ]] ; then
 
-        pr_info "start repo fetch Yocto $YCT_VER source code"
+            pr_info "start repo fetch Yocto $YCT_VER source code"
 
-        if ! command -v repo > /dev/null 2>&1 ; then
-            curl https://storage.googleapis.com/git-repo-downloads/repo > repo
-            chmod a+x repo
-            export PATH=$YCT_PATH:$PATH
+            mkdir -p $YCT_PATH && cd $YCT_PATH
+
+            if ! command -v repo > /dev/null 2>&1 ; then
+                curl https://storage.googleapis.com/git-repo-downloads/repo > repo
+                chmod a+x repo
+                export PATH=$YCT_PATH:$PATH
+            fi
+
+            BSP_VER=`echo $BSP_VER | sed 's/lf/imx/'`
+            repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-$YCT_VER -m $BSP_VER.xml
+            repo sync && rm -f repo
+
+        else
+
+            pr_info "start download fetch Yocto $YCT_VER source code"
+
+            mkdir -p $TARBALL_PATH
+
+            # Download source code packet
+            if [ ! -s $TARBALL_PATH/$YCT_SRC.tar.xz ] ; then
+                wget $BSP_URL/imx/bsp/$BSP_VER/$YCT_SRC.tar.xz -P $TARBALL_PATH
+            fi
+
+            # decompress source code packet
+            do_unpack $TARBALL_PATH/$YCT_SRC.tar.xz
+
         fi
-
-        BSP_VER=`echo $BSP_VER | sed 's/lf/imx/'`
-        repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-$YCT_VER -m $BSP_VER.xml
-        repo sync && rm -f repo
 
     else
         pr_warn "Yocto $YCT_VER source code fetched already"
@@ -135,8 +156,8 @@
     pr_warn "start update BSP patches for $YCT_META"
     BSP_VER=`echo $BSP_VER | sed 's/imx/lf/'`
     cp $TOP_PATH/bootloader/patches/${BOARD}/uboot-imx-${BSP_VER}.patch $PRJ_PATH/$YCT_META/recipes-bsp/u-boot/files/
-    cp $TOP_PATH/bootloader/patches/${BOARD}/imx-atf-${BSP_VER}.patch $PRJ_PATH/$YCT_META/recipes-bsp/imx-atf/files/
     cp $TOP_PATH/kernel/patches/${BOARD}/linux-imx-${BSP_VER}.patch $PRJ_PATH/$YCT_META/recipes-kernel/linux/files/
+    cp $TOP_PATH/images/patches/config-*.txt $PRJ_PATH/$YCT_META/recipes-bsp/u-boot/files/
 
     if [ ! -e $YCT_PATH/sources/$YCT_META ] ; then
         ln -s $PRJ_PATH/$YCT_META $YCT_PATH/sources/$YCT_META
@@ -165,33 +186,41 @@
 
 function do_install()
 {
+    IMAGE_NAME=yocto-${YCT_VER}-${BOARD}.img
+    ROOTFS_TAR=rootfs-yocto-${YCT_VER}.tar.zst
+
     cd $YCT_PATH
 
     echo ""
     pr_info "Yocto($YCT_VER) installed to '$PRFX_PATH'"
 
     mkdir -p ${PRFX_PATH}
-    cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/$BB_TARGET-$BOARD.wic ${PRFX_PATH}/
-    cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/$BB_TARGET-$BOARD.tar.zst ${PRFX_PATH}/
-    cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/imx-boot ${PRFX_PATH}/u-boot-${BOARD}.imx
-    chmod a+x ${PRFX_PATH}/u-boot-${BOARD}.imx
-    ls ${PRFX_PATH} && echo ""
+    cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/$BB_TARGET-$BOARD.wic ${PRFX_PATH}/$IMAGE_NAME
+    cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/$BB_TARGET-$BOARD.tar.zst ${PRFX_PATH}/$ROOTFS_TAR
+
+    if [[ $BOARD =~ mx6ull ]] ; then
+        cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/u-boot-${BOARD}.imx ${PRFX_PATH}/u-boot-${BOARD}.imx
+    else
+        cp $YCT_PATH/$BUILD_DIR/tmp/deploy/images/$BOARD/imx-boot ${PRFX_PATH}/u-boot-${BOARD}.imx
+    fi
+
+    cd ${PRFX_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
+    chmod a+x u-boot-${BOARD}.imx
+
+    ls && echo ""
 
     if [ -n "$INST_PATH" -a -w $INST_PATH ] ; then
 
-        cd ${PRFX_PATH}/
-
-        rm -f $BB_TARGET-$BOARD.wic.bz2
-
-        if [[ `echo $COMPRESS | tr 'A-Z' 'a-z'` == "yes" ]] ; then
-            pr_info "Start bzip2 compress $BB_TARGET-$BOARD.wic"
-            bzip2 $BB_TARGET-$BOARD.wic
-        fi
-
         pr_info "Start copy Yocto system images to $INST_PATH"
-        cp u-boot-${BOARD}.imx       $INST_PATH
-        cp $BB_TARGET-$BOARD.wic*    $INST_PATH
-        cp $BB_TARGET-$BOARD.tar.zst $INST_PATH
+        cp u-boot-${BOARD}.imx $INST_PATH
+        cp $IMAGE_NAME*        $INST_PATH
+        cp $ROOTFS_TAR         $INST_PATH
 
         ls ${INST_PATH} && echo ""
     fi

--
Gitblit v1.9.1