From ffa59a8bddb4f2da26a03b1e09743c1bdd9cbb8c Mon Sep 17 00:00:00 2001
From: Guo Wenxue <“guowenxue@gmail.com”>
Date: Mon, 11 Oct 2021 20:15:17 +0800
Subject: [PATCH] Add setup_tools.sh

---
 tools/lintools/setup_tools.sh |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/tools/lintools/setup_tools.sh b/tools/lintools/setup_tools.sh
new file mode 100755
index 0000000..7cc45eb
--- /dev/null
+++ b/tools/lintools/setup_tools.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+# This shell script used to setup fl2440 build envrionment and test on Ubuntu-20.04
+#
+# U-boot, Linux kernel and root file system all compiled or generated by this crosstool.ha
+
+
+LYFTP_ADDR=ftp://master.iot-yun.club/fl2440/lintools/
+
+function sudo_banner()
+{
+    if [ `id -u` != 0 ] ; then
+       echo "WARRNING: Follow linux command maybe need input sudo passwd here:"
+       echo ""
+    fi
+}
+
+function msg_banner()
+{
+    echo "" 
+    echo "+-----------------------------------------------------------------------" 
+    echo "|  $1 " 
+    echo "+-----------------------------------------------------------------------" 
+    echo ""
+}
+
+function prepare_instpath()
+{
+    if [ -w /apps -a -w /opt ] ; then
+        msg_banner "Install path [/apps and /opt] already setup, skip it"
+        return ;
+    fi
+
+    msg_banner "/apps and /opt not writable, use chmod to give writable permissions"
+
+    sudo_banner
+
+    #QT build will installed to this path
+    sudo mkdir -p /apps && sudo chmod 777 /apps
+
+    #crosstool will installed to this path
+    sudo chmod 777 /opt/
+}
+
+function install_systools()
+{
+    mkimage -V > /dev/null 2>&1
+    if [ $? == 0 ] ;  then
+        msg_banner "All development system tools already installed, skip it"
+        return 0;
+    fi
+
+    msg_banner "start apt-get install system devlopment tools(commands)" 
+
+    systools="gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libncurses-dev \
+        libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 tree \
+        help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf \
+        automake groff curl lzop asciidoc lib32z1 lib32ncurses5 libssl-dev autoconf-archive bison flex lzop"
+
+    devtools="u-boot-tools mtd-utils device-tree-compiler"
+
+    sudo_banner
+
+    sudo apt-get update > /dev/null 2>&1
+    sudo apt-get install -y $systools $devtools
+}
+
+function install_crosstool()
+{
+    INST_PATH=/opt/xtools/
+    CROSSTOOL_PATH=$INST_PATH/arm920t
+
+    CROSSTOOL_TAR=crosstool-gcc4.4.6-arm920t.tar.xz
+
+    if [ -d $CROSSTOOL_PATH ] ; then
+        msg_banner "crosstool already installed to $CROSSTOOL_PATH"
+        return 0;
+    fi
+
+    mkdir -p ${INST_PATH} 
+
+    if [ ! -f $CROSSTOOL_TAR ] ; then 
+        msg_banner "download $CROSSTOOL_TAR now..."
+        wget -c ${LYFTP_ADDR}/$CROSSTOOL_TAR
+    fi 
+
+    msg_banner "install crosstool to $CROSSTOOL_PATH now..."
+    tar -xJf ${CROSSTOOL_TAR} -C ${INST_PATH} 
+
+    $CROSSTOOL_PATH/bin/arm-linux-gcc -v
+
+    msg_banner "Cross compiler: $CROSSTOOL_PATH/bin/arm-linux-"
+}
+
+
+prepare_instpath
+
+install_systools
+
+install_crosstool
+
+exit;
+
+
+
+

--
Gitblit v1.9.1