From e2a28d845d28f045ea59f8b5d53ff2c8bd21bb16 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 21 Feb 2024 15:43:02 +0800
Subject: [PATCH] Build:IGKBoard-All: Update setup_tools.sh
---
tools/setup_tools.sh | 104 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 74 insertions(+), 30 deletions(-)
diff --git a/tools/setup_tools.sh b/tools/setup_tools.sh
index 5e4314c..09a6fab 100755
--- a/tools/setup_tools.sh
+++ b/tools/setup_tools.sh
@@ -1,21 +1,37 @@
#!/bin/bash
# This shell script used to install system tools
-# display in red
+# this project absolute path
+PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
+
+# top project absolute path
+TOP_PATH=$(realpath $PRJ_PATH/..)
+
+# config file path
+CONF_FILE=$TOP_PATH/config.json
+
+# NXP document suggest cross compiler from ARM Developer:
+# https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
+ARMTOOL_VER=10.3-2021.07
+
+# shell script will exit once get command error
+set -e
+
+#+-------------------------+
+#| Shell script functions |
+#+-------------------------+
+
function pr_error() {
- echo -e "\033[40;31m --E-- $1 \033[0m\n"
+ echo -e "\033[40;31m $1 \033[0m"
}
-# display in green
+function pr_warn() {
+ echo -e "\033[40;33m $1 \033[0m"
+}
+
function pr_info() {
- echo -e "\033[40;32m --I-- $1 \033[0m\n"
+ echo -e "\033[40;32m $1 \033[0m"
}
-
-if [ `id -u` != 0 ] ; then
- echo ""
- pr_error "This shell script must be excuted as root privilege"
- exit;
-fi
function install_systools()
{
@@ -53,19 +69,40 @@
apt install -y $devtools
}
-
-# NXP document suggest cross compiler from ARM Developer:
-# https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
-function install_crosstool()
+function install_crosstool_imx6()
{
- ARMTOOL_VER=10.3-2021.07
+ # Crosstool for Cortex-A download from ARM Developer
+ ARMTOOL_NAME=arm-none-linux-gnueabihf
+ CortexA_PACK=gcc-arm-$ARMTOOL_VER-`uname -p`-$ARMTOOL_NAME
+ CortexA_TAR=$CortexA_PACK.tar.xz
+ CortexA_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/$ARMTOOL_VER/binrel/
+ CortexA_NAME=gcc-aarch32-$ARMTOOL_VER
- CortexM_PACK=gcc-arm-none-eabi-$ARMTOOL_VER-`uname -p`-linux
+ if [ -d /opt/$CortexA_NAME ] ; then
+ pr_info "Cortex-A crosstool /opt/$CortexA_NAME installed already, skip it"
+ else
+ if [ ! -s $CortexA_TAR ] ; then
+ pr_info "start download cross compiler from ARM Developer for Cortex-A core"
+ wget $CortexA_URL/$CortexA_TAR
+ fi
+
+ pr_info "start decompress cross compiler for Cortex-A core"
+ tar -xJf $CortexA_TAR -C /opt
+ mv /opt/$CortexA_PACK /opt/$CortexA_NAME
+ /opt/$CortexA_NAME/bin/${ARMTOOL_NAME}-gcc -v
+ pr_info "cross compiler for Cortex-A installed to \"/opt/$CortexA_NAME\" successfully"
+ rm -f $CortexA_TAR
+ fi
+}
+
+function install_crosstool_imx8()
+{
+ # Crosstool for Cortex-M download from ARM Developer
+ ARMTOOL_NAME=arm-none-eabi
+ CortexM_PACK=gcc-$ARMTOOL_NAME-$ARMTOOL_VER-`uname -p`-linux
CortexM_TAR=$CortexM_PACK.tar.bz2
CortexM_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$ARMTOOL_VER/
CortexM_NAME=gcc-cortexM-$ARMTOOL_VER
-
- # Crosstool for Cortex-M download from ARM Developer
if [ -d /opt/$CortexM_NAME ] ; then
pr_info "Cortex-M crosstool /opt/$CortexM_NAME installed already, skip it"
@@ -77,16 +114,15 @@
pr_info "start decompress cross compiler for Cortex-M core"
tar -xjf $CortexM_TAR -C /opt
- mv /opt/gcc-arm-none-eabi-$ARMTOOL_VER /opt/$CortexM_NAME
- rm -f $CortexM_TAR
-
- /opt/$CortexM_NAME/bin/arm-none-eabi-gcc -v
+ mv /opt/gcc-$ARMTOOL_NAME-$ARMTOOL_VER /opt/$CortexM_NAME
+ /opt/$CortexM_NAME/bin/$ARMTOOL_NAME-gcc -v
pr_info "cross compiler for Cortex-M installed to \"/opt/$CortexM_NAME\" successfully"
+ rm -f $CortexM_TAR
fi
# Crosstool for Cortex-A download from ARM Developer
-
- CortexA_PACK=gcc-arm-$ARMTOOL_VER-`uname -p`-aarch64-none-linux-gnu
+ ARMTOOL_NAME=aarch64-none-linux-gnu
+ CortexA_PACK=gcc-arm-$ARMTOOL_VER-`uname -p`-$ARMTOOL_NAME
CortexA_TAR=$CortexA_PACK.tar.xz
CortexA_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/$ARMTOOL_VER/binrel/
CortexA_NAME=gcc-aarch64-$ARMTOOL_VER
@@ -102,19 +138,27 @@
pr_info "start decompress cross compiler for Cortex-A core"
tar -xJf $CortexA_TAR -C /opt
mv /opt/$CortexA_PACK /opt/$CortexA_NAME
- rm -f $CortexA_TAR
-
- /opt/$CortexA_NAME/bin/aarch64-none-linux-gnu-gcc -v
+ /opt/$CortexA_NAME/bin/$ARMTOOL_NAME-gcc -v
pr_info "cross compiler for Cortex-A installed to \"/opt/$CortexA_NAME\" successfully"
+ rm -f $CortexA_TAR
fi
}
-echo ""
-set -e
+if [ `id -u` != 0 ] ; then
+ echo ""
+ pr_error "This shell script must be excuted as root privilege"
+ exit;
+fi
install_systools
install_devtools
-install_crosstool
+BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
+
+if [[ $BOARD =~ mx6ull ]] ; then
+ install_crosstool_imx6
+else
+ install_crosstool_imx8
+fi
--
Gitblit v1.9.1