From e144371582ce39f4dda26058f2b4b794796fb2f2 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 15 Jan 2024 21:45:33 +0800
Subject: [PATCH] Update u-boot patch to add random MAC address and reduce env in igkboard-imx8mp.h

---
 kernel/build.sh |   50 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/kernel/build.sh b/kernel/build.sh
index d7a5023..e4a2093 100755
--- a/kernel/build.sh
+++ b/kernel/build.sh
@@ -42,17 +42,23 @@
     export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'`
     export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'`
 
+    export SRCS="linux-imx"
     export BRANCH=$BSP_VER
     export KER_PATH=$PRJ_PATH/linux-imx
 
     export JOBS=`cat /proc/cpuinfo | grep processor | wc -l`
-    export ARCH=arm64
-    export SRCS="linux-imx"
+
+    if [[ $BOARD =~ mx6ull ]] ; then
+        export ARCH=arm
+    else
+        export ARCH=arm64
+    fi
 }
 
 function build_kernel()
 {
-    PATCH_FILE=$PRJ_PATH/patches/$BOARD/linux-imx-$BSP_VER.patch
+    defconfig=${BOARD}_defconfig
+    patch_file=$PRJ_PATH/patches/$BOARD/linux-imx-$BSP_VER.patch
 
     cd $PRJ_PATH
 
@@ -61,19 +67,17 @@
     else
         pr_info "start fetch linux kernel source code"
         git clone $GIT_URL/linux-imx.git -b $BRANCH --depth=1
-
-        if [ -s $PATCH_FILE ] ; then
-            pr_warn "do patch for $KER_PATH now..."
-            cd $KER_PATH
-            patch -p1 < $PATCH_FILE
-        fi
     fi
 
     pr_info "Start build linux kernel source code"
 
     cd $KER_PATH
 
-    defconfig=${BOARD}_defconfig
+    if [ ! -s arch/$ARCH/configs/$defconfig -a -s $patch_file ] ; then
+        pr_warn "do patch for $KER_PATH now..."
+        patch -p1 < $patch_file
+    fi
+
     if [ ! -s .config ] ; then
         make ${defconfig}
     fi
@@ -89,13 +93,25 @@
 
     if [ -d $PRFX_PATH ] ; then
         rm -rf $PRFX_PATH/*
-    else
-        mkdir -p $PRFX_PATH
     fi
 
-    # Install image
-    cp arch/arm64/boot/Image $PRFX_PATH
-    cp arch/arm64/boot/dts/freescale/${BOARD}.dtb $PRFX_PATH
+    mkdir -p $PRFX_PATH/overlays
+
+    # Install system image and device tree binaries
+
+    if [[ $BOARD =~ 6ull ]] ; then
+        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
+        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
+        set +x
+    fi
 
     # Install kernel modules
     make modules_install INSTALL_MOD_PATH=$PRFX_PATH INSTALL_MOD_STRIP=1
@@ -106,8 +122,8 @@
 
     if [[ -n "$INST_PATH" && -w $INST_PATH ]] ; then
         pr_info "install linux kernel to '$INST_PATH'"
-        cp $PRFX_PATH/Image $INST_PATH
-        cp $PRFX_PATH/${BOARD}.dtb $INST_PATH
+        cp -f $PRFX_PATH/*Image $INST_PATH
+        cp -f $PRFX_PATH/${BOARD}.dtb $INST_PATH
     fi
 }
 

--
Gitblit v1.9.1