You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.5 KiB

###
###
# @ : Copyright (c) 2020 Phytium Information Technology, Inc. 
#  
# SPDX-License-Identifier: Apache-2.0.
#
# @Date: 2021-06-30 17:24:45
# @LastEditTime: 2021-07-06 15:37:55
# @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
# setup u git
git config core.ignorecase false
# make sure all src file ends with LF
#find . -type f -exec dos2unix {} \;
# update
##################SET ROOT PATH##############
# profile to save environment variables
PROFILE_PATH=~/.profile
# get absoulte path of sdk
export SDK_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# delete SDK_ROOT if exists
sed -i '/export SDK_ROOT=/d' $PROFILE_PATH
# append SDK_ROOT environment
echo "export SDK_ROOT=$SDK_ROOT" >> $PROFILE_PATH
###################CHANGE FILE MODE##############
# make sure sdk scripts are executable
chmod +x $SDK_ROOT/*.sh --silent
chmod +x $SDK_ROOT/scripts/*.sh --silent
chmod +x $SDK_ROOT/make/*.mk --silent
chmod +x $SDK_ROOT/tools/Kconfiglib/*.py --silent
# install gcc compiler
if [ ! -d $SDK_ROOT ]; then
echo "Please set the SDK Root Path first !!!"
exit 1
fi
# if define offline install, put aarch32 & aarch64 compiler package under dir tools
AARCH32_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz
AARCH32_CC_PACK=gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz
AARCH64_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
AARCH64_CC_PACK=gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
INSTALL_PATH=$SDK_ROOT/tools
export AARCH32_CROSS_PATH=$INSTALL_PATH/gcc-arm-none-eabi-10-2020-q4-major
export AARCH64_CROSS_PATH=$INSTALL_PATH/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf
if [ $OFFLINE_INSTALL -ne 1 ]; then
# do not download if package exists
[ ! -d $AARCH32_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH32_CC_PACK ] && wget -P $INSTALL_PATH/ $AARCH32_URL
[ ! -d $AARCH64_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH64_CC_PACK ] && wget -P $INSTALL_PATH/ $AARCH64_URL
fi
##################SET COMPILER PATH##############
## AARCH32 CC
[ ! -d $AARCH32_CROSS_PATH ] && sudo tar -C $INSTALL_PATH/ -jxvf $INSTALL_PATH/$AARCH32_CC_PACK
sed -i '/export AARCH32_CROSS_PATH=/d' $PROFILE_PATH
sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' $PROFILE_PATH
echo "export AARCH32_CROSS_PATH=$AARCH32_CROSS_PATH" >> $PROFILE_PATH
echo "export PATH=\$PATH:\$AARCH32_CROSS_PATH/bin">> $PROFILE_PATH
## AARCH64 CC
[ ! -d $AARCH64_CROSS_PATH ] && sudo tar -C $INSTALL_PATH/ -vxf $INSTALL_PATH/$AARCH64_CC_PACK
sed -i '/export AARCH64_CROSS_PATH=/d' $PROFILE_PATH
sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' $PROFILE_PATH
echo "export AARCH64_CROSS_PATH=$AARCH64_CROSS_PATH" >> $PROFILE_PATH
echo "export PATH=\$PATH:\$AARCH64_CROSS_PATH/bin">> $PROFILE_PATH
##################Show msg, Make Environment Variables works#######
source $PROFILE_PATH
echo "Please type in 'source ./export.sh'"
echo "Phytium Embedded SDK Setup Done!!"
echo "Install AARCH32 Compiler at " $AARCH32_CROSS_PATH
echo "Install AARCH64 Compiler at " $AARCH64_CROSS_PATH
echo "Install AARCH32 Linux Compiler at " $AARCH32_LINUX_CROSS_PATH
echo "SDK Path is set as "$SDK_ROOT