From 0e5790ecce7c991f3b8e0efb2900e958e0e7baba Mon Sep 17 00:00:00 2001
From: lin <lin@kickpi.com>
Date: Tue, 15 Apr 2025 03:52:51 +0000
Subject: [PATCH] feat(uart): add uart7 support

---
 build.sh |  125 ++++++++++++++++++++++++++++++-----------
 1 files changed, 92 insertions(+), 33 deletions(-)

diff --git a/build.sh b/build.sh
index 051fc41..8a2e427 100755
--- a/build.sh
+++ b/build.sh
@@ -1,39 +1,98 @@
 #!/bin/bash
 
-if [ x"$1" == "xu" ] ;then
-	cd longan/brandy/brandy-2.0
-	./build.sh -p sun50iw10p1
-	cd -
-fi
+BOARD_CONFIG_DIR=longan/device/config/chips/
+BOARD_CONFIG_FILE=longan/device/.BoardConfig.mk
 
-if [ x"$1" == "xk" ] ;then
-	cd longan
-	./build.sh
-	cd -
-	
-	#cd android
-	#. ./build/envsetup.sh
-	#lunch ceres_c3-userdebug
-	#extract-bsp && pack
-	#cd -
-fi
+function build_lunch() {
+    TARGET_BOARD_PATH_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sort))
+    TARGET_BOARD_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sed 's#.*/##' | sort))
+    echo "======you are building a133 android======"
+    echo "${TARGET_BOARD_ARRAY[@]}" | xargs -n 1 | sed "=" | sed "N;s/\n/. /"
 
-if [ x"$1" == "xa" ] ;then	
-	cd android
-	. ./build/envsetup.sh
-	lunch ceres_c3-userdebug
-	extract-bsp
-	make installclean
-	make BUILD_NUMBER=ido-a133 -j10 && pack
-#	make -j10 && pack -v
-	cd -
-fi
+    while true; do
+        read -p "which board would you like (1-${#TARGET_BOARD_ARRAY[@]}): " INDEX
+        if [[ "$INDEX" =~ ^[0-9]+$ ]] && ((INDEX >= 1 && INDEX <= ${#TARGET_BOARD_ARRAY[@]})); then
+            INDEX=$(($INDEX - 1))
+            BUILD_TARGET_BOARD="${TARGET_BOARD_PATH_ARRAY[$INDEX]}"
 
-if [ x"$1" == "xp" ] ;then
-	cd android
-	. ./build/envsetup.sh
-	lunch ceres_c3-userdebug
-	extract-bsp && pack
-	cd -
-fi
+            break
+        else
+            echo "Invalid input. Please enter a number between 1 and ${#TARGET_BOARD_ARRAY[@]}."
+        fi
+    done
 
+    cp -f $BUILD_TARGET_BOARD $BOARD_CONFIG_FILE
+
+    echo -e "build target board configuration: $BUILD_TARGET_BOARD\n"
+    #select partition table
+    source $BOARD_CONFIG_FILE
+    echo "you board is ${DTS_NAME}"
+
+    echo "Start clean kerenl"
+    cd longan/kernel/linux-4.9 && make clean -j32 && cd -
+    source $BOARD_CONFIG_FILE
+    longan/build/mkcommon.sh autoconfig -i a133 -o android -b c3
+}
+
+if [ "x$1" == "xlunch" ]; then
+    build_lunch && exit 0
+else
+    source $BOARD_CONFIG_FILE
+    if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ]; then
+        echo "Start build uboot"
+        cd longan/brandy/brandy-2.0
+        ./build.sh -p sun50iw10p1
+        if [ $? -eq 0 ]; then
+            echo "Build uboot ok!"
+        else
+            echo "Build uboot failed!"
+            cd -
+            exit 1
+        fi
+        cd -
+    fi
+
+    if [ x"$1" == "xkernel" ] || [ x"$1" == "xk" ] || [ x"$1" == "x" ]; then
+        echo "Start build kernel"
+        cd longan
+        ./build.sh autoconfig -o android -i a133 -b c3
+        ./build.sh
+        if [ $? -eq 0 ]; then
+            echo "Build kernel ok!"
+        else
+            echo "Build kernel failed!"
+            cd -
+            exit 1
+        fi
+        cd -
+    fi
+
+    # android envsetup
+    cd android
+    . ./build/envsetup.sh
+    lunch ceres_c3-userdebug
+    extract-bsp
+    cd -
+
+    if [ x"$1" == "xandroid" ] || [ x"$1" == "xa" ] || [ x"$1" == "x" ]; then
+        echo "Start build Android"
+        cd android
+        make installclean
+        make BUILD_NUMBER=ido-a133 -j32
+        if [ $? -eq 0 ]; then
+            echo "Build android ok!"
+        else
+            echo "Build android failed!"
+            cd -
+            exit 1
+        fi
+        cd -
+    fi
+
+    # pack image
+    echo "Start pack image"
+    cd android
+    pack
+    cd -
+
+fi

--
Gitblit v1.6.2