### ### # @ : Copyright (c) 2020 Phytium Information Technology, Inc.  #   # SPDX-License-Identifier: Apache-2.0. # # @Date: 2021-06-30 17:24:45 # @LastEditTime: 2021-07-22 15:35:03 # @Description:  This files is for  # # @Modify History: #  Ver   Who        Date         Changes # ----- ------     --------    -------------------------------------- #!/bin/sh # online install would wget cc and install # offline install need put cc package under folder 'tools' if [ "$1" = "-online" ]; then OFFLINE_INSTALL=0 else OFFLINE_INSTALL=1 fi # profile to save environment variables PROFILE_PATH=~/.profile chmod +x $PROFILE_PATH if [ $(arch) != x86_64 ] && [$(arch) != aarch64]; then echo "[1]: Failed for Non Support Environment !!! " fi # get absoulte path of script SDK_ABS=$(readlink -f "$0") export STANDALONE_SDK_ROOT=$(dirname $SDK_ABS) echo "[1]: Standalone SDK at "$STANDALONE_SDK_ROOT INSTALL_PATH=$STANDALONE_SDK_ROOT/tools # make sure all src file ends with LF #find . -type f -exec dos2unix {} \; # make sure sdk scripts are executable chmod +x $STANDALONE_SDK_ROOT/*.sh --silent chmod +x $STANDALONE_SDK_ROOT/scripts/*.sh --silent chmod +x $STANDALONE_SDK_ROOT/make/*.mk --silent chmod +x $STANDALONE_SDK_ROOT/lib/Kconfiglib/*.py --silent if [ $? -ne 0 ]; then echo "[3]: Failed when assign file premission !!!" exit fi # remove environment variables sed -i '/export AARCH32_CROSS_PATH=/d' $PROFILE_PATH sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' $PROFILE_PATH sed -i '/export AARCH64_CROSS_PATH=/d' $PROFILE_PATH sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' $PROFILE_PATH sed -i '/export STANDALONE_SDK_ROOT=/d' $PROFILE_PATH echo "[2]: Reset Environment" #####################################Install GCC Tools############################################## # name of cc if [ $(arch) == x86_64 ]; then AARCH32_CC=gcc-arm-x86_64-none-eabi-10-2020-q4-major AARCH64_CC=gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11 fi if [ $(arch) == aarch64 ]; then AARCH32_CC=gcc-arm-aarch64-none-eabi-10-2020-q4-major AARCH64_CC=gcc-arm-10.2-2020.11-aarch64-aarch64-none-elf fi # url of cc package if [ $(arch) == x86_64 ]; then AARCH32_URL=https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz AARCH64_URL=https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz fi if [ $(arch) == aarch64 ]; then echo "[4]: Failed AARCH64 Environment do not Support Online Install!!!" exit fi # cc package name AARCH32_CC_PACK=$AARCH32_CC.tar.xz AARCH64_CC_PACK=$AARCH64_CC.tar.xz # cc package name during download AARCH32_CC_DL=$AARCH32_CC.tmp.tar.xz AARCH64_CC_DL=$AARCH64_CC.tmp.tar.xz echo "[4]: Install CC...." # cc install path export AARCH32_CROSS_PATH=$INSTALL_PATH/$AARCH32_CC export AARCH64_CROSS_PATH=$INSTALL_PATH/$AARCH64_CC # remove tmp load package [ -f $INSTALL_PATH/$AARCH32_CC_DL ] && rm $INSTALL_PATH/$AARCH32_CC_DL [ -f $INSTALL_PATH/$AARCH64_CC_DL ] && rm $INSTALL_PATH/$AARCH64_CC_DL # do not download if package exists # do not download if compiler already installed if [ $OFFLINE_INSTALL -ne 1 ]; then if [ ! -d $AARCH32_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH32_CC_PACK ]; then wget $AARCH32_URL -O $INSTALL_PATH/$AARCH32_CC_DL -c -t 0 # rename downlaod cc package in case download process is intrrupted if [ -f $INSTALL_PATH/$AARCH32_CC_DL ]; then mv $INSTALL_PATH/$AARCH32_CC_DL $INSTALL_PATH/$AARCH32_CC_PACK echo "[4]: Got CC "$INSTALL_PATH/$AARCH32_CC_PACK fi else echo "[4]: AARCH32 CC Already Exists" fi if [ ! -d $AARCH64_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH64_CC_PACK ]; then wget $AARCH64_URL -O $INSTALL_PATH/$AARCH64_CC_DL -c -t 0 if [ -f $INSTALL_PATH/$AARCH64_CC_DL ]; then mv $INSTALL_PATH/$AARCH64_CC_DL $INSTALL_PATH/$AARCH64_CC_PACK echo "[4]: Got CC "$INSTALL_PATH/$AARCH64_CC_PACK fi else echo "[4]: AARCH64 CC Already Exists" fi fi if [ ! -f $INSTALL_PATH/$AARCH32_CC_PACK ]; then echo "[4]: Failed, AARCH32 CC Package Non Found !!!" exit fi if [ ! -f $INSTALL_PATH/$AARCH64_CC_PACK ]; then echo "[4]: Failed, AARCH64 CC Package Non Found !!!" exit fi # untar aarch32 cc echo "[4]: Untar AARCH32 CC in process.." if [ ! -d $AARCH32_CROSS_PATH ]; then tar -C $INSTALL_PATH/ -xvf $INSTALL_PATH/$AARCH32_CC_PACK if [ $? -ne 0 ]; then echo "[4]: Failed when Untar AARCH32 CC !!!" exit fi fi # write aarch32 cc path echo "[4]: AARCH32 CC Install Success at "$AARCH32_CROSS_PATH # untar aarch64 cc echo "[4]: Untar AARCH64 CC in process.." if [ ! -d $AARCH64_CROSS_PATH ]; then tar -C $INSTALL_PATH/ -xvf $INSTALL_PATH/$AARCH64_CC_PACK if [ $? -ne 0 ]; then echo "[4]: Failed when Untar AARCH64 CC !!!" exit fi fi # write aarch64 cc path echo "[4]: AARCH64 CC Install Success at "$AARCH64_CROSS_PATH # write environment variables echo "export AARCH32_CROSS_PATH=$AARCH32_CROSS_PATH" >> $PROFILE_PATH echo "export PATH=\$PATH:\$AARCH32_CROSS_PATH/bin">> $PROFILE_PATH echo "export AARCH64_CROSS_PATH=$AARCH64_CROSS_PATH" >> $PROFILE_PATH echo "export PATH=\$PATH:\$AARCH64_CROSS_PATH/bin">> $PROFILE_PATH echo "export STANDALONE_SDK_ROOT=$STANDALONE_SDK_ROOT" >> $PROFILE_PATH if [ $? -ne 0 ]; then echo "[4]: Failed when Update Environment Variables !!!" exit fi # show success info echo "[5]: Success!!! Standalone SDK is Install at "$STANDALONE_SDK_ROOT echo "[5]: Phytium Standalone SDK Setup Done!!!"