From 435024a55a8a3f64af6ebeff596332aebd15b7e9 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 06 May 2024 17:52:06 +0800
Subject: [PATCH] Build:GauGuin-Board: Add GauGuin Board based on i.MX8MP build support

---
 kernel/build.sh |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/kernel/build.sh b/kernel/build.sh
index dbf6078..04545ee 100755
--- a/kernel/build.sh
+++ b/kernel/build.sh
@@ -93,6 +93,7 @@
     export BRANCH=$BSP_VER
     export KER_SRC=linux-imx
     export KER_PATH=$PRJ_PATH/$KER_SRC
+    export DRV_PATH=$TOP_PATH/drivers/${BOARD}
 
     export JOBS=`cat /proc/cpuinfo | grep processor | wc -l`
 
@@ -122,7 +123,7 @@
 
             # Download source code packet
             if [ ! -s $TARBALL_PATH/$KER_SRC.tar.xz ] ; then
-                wget $BSP_URL/bsp/$BSP_VER/$KER_SRC.tar.xz -P $TARBALL_PATH
+                wget $BSP_URL/imx/bsp/$BSP_VER/$KER_SRC.tar.xz -P $TARBALL_PATH
             fi
 
             # decompress source code packet
@@ -130,14 +131,14 @@
         fi
     fi
 
-    pr_info "Start build linux kernel source code"
-
     cd $KER_PATH
 
     if [ ! -s arch/$ARCH/configs/$defconfig -a -s $patch_file ] ; then
-        pr_warn "do patch for $KER_PATH now..."
+        pr_warn "do patch for $KER_SRC now..."
         patch -p1 < $patch_file
     fi
+
+    pr_warn "start build $KER_SRC"
 
     if [ ! -s .config ] ; then
         make ${defconfig}
@@ -164,13 +165,17 @@
         set -x
         cp -f arch/${ARCH}/boot/zImage $PRFX_PATH
         cp -f arch/${ARCH}/boot/dts/${BOARD}.dtb $PRFX_PATH
-        cp -f arch/${ARCH}/boot/dts/${BOARD}/*.dtbo $PRFX_PATH/overlays
+        if [ -d arch/${ARCH}/boot/dts/${BOARD} ] ; then
+            cp -f arch/${ARCH}/boot/dts/${BOARD}/*.dtbo $PRFX_PATH/overlays
+        fi
         set +x
     else
         set -x
         cp -f arch/${ARCH}/boot/Image $PRFX_PATH
         cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}.dtb $PRFX_PATH
-        #cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}/*.dtbo $PRFX_PATH/overlays
+        if [ -d arch/${ARCH}/boot/dts/${BOARD} ] ; then
+            cp -f arch/${ARCH}/boot/dts/${BOARD}/*.dtbo $PRFX_PATH/overlays
+        fi
         set +x
     fi
 
@@ -188,6 +193,21 @@
     fi
 }
 
+function build_driver()
+{
+    if [ ! -d $DRV_PATH ] ; then
+        return 0;
+    fi
+
+    pr_info "start ${BOARD} linux drivers"
+
+    if [ -d $DRV_PATH ] ; then
+        cd $DRV_PATH && ./build.sh
+    fi
+
+    cd $PRJ_PATH
+}
+
 function do_build()
 {
     cd $PRJ_PATH
@@ -195,6 +215,8 @@
     build_kernel
 
     do_install
+
+    build_driver
 }
 
 function do_clean()
@@ -204,6 +226,12 @@
     rm -rf $PRJ_PATH/$KER_SRC
     rm -rf $PRJ_PATH/tarballs
     rm -rf $PRFX_PATH
+
+    if [ -d $DRV_PATH ] ; then
+        cd $DRV_PATH && ./build.sh -c
+    fi
+
+    cd
 }
 
 #+-------------------------+

--
Gitblit v1.9.1