4 Install Toolchain

V0.0.2

4.1 Histroy

  • 2014-10-08, rayoslee, release V0.0.2
  • 2014-03-19, rayoslee, release V0.0.1

4.2 FAQ

  1. How to install tool chain for S605-32(skyeye) demo kit?
    • sudo ./arm_linux_4.2_install.sh as the below.
    • Installing folder is /usr/local/arm_linux_4.2
#!/bin/bash
# Copyright (c) Nuvoton Tech. Corp. All rights reserved.
# Description:  Nuvoton Linux platform toolchain install script
# Version:  2010-09-28  first release version
# Author:   C.C. Chang  ccchang12@nuvoton.com.tw

#2014-03-19, rayoslee@acsip, add some ref. files for skyeye.

ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]; then
    echo 'Sorry !! You are not root !!'
    exit 1
fi

ARM_TOOL_ROOT="/usr/local"
ARM_TOOL_NANE="arm_linux_4.2"
ARM_TOOL_PATH="$ARM_TOOL_ROOT/$ARM_TOOL_NANE"

if [ -d $ARM_TOOL_PATH ]; then
    echo "The folder \"$ARM_TOOL_PATH\" is already existed, continue the installation?[y/n]"
    INSTALL=1
    while [ $INSTALL == 1 ]
    do
        read install
        case "$install" in
        [yY]|[yY][eE][sS] ) 
            INSTALL=0
            ;;
        [nN]|[nN][oO] ) 
            echo "Give up the installation. Bye!"
            exit 1
            ;;
        * )
            echo "Please type yes or no!"
            ;;
        esac
    done

    echo "Do you want to remove this folder first?[y/n]"
    REMOVE=1
    while [ $REMOVE == 1 ]
    do
    read remove
    case "$remove" in
        [yY]|[yY][eE][sS] ) 
            echo "Now deleteing the folder \"$ARM_TOOL_PATH\"..."
            rm -rf $ARM_TOOL_PATH
            REMOVE=0
            ;;
        [nN]|[nN][oO] ) 
            echo "This installation will overwirte folder \"$ARM_TOOL_PATH\"!"
            REMOVE=0
            ;;
        * )
            echo "Please type yes or no!"
            ;;
        esac
    done
fi

echo "Now installing $ARM_TOOL_NANE toolchain to $ARM_TOOL_ROOT"
echo 'Please wait for a while... '
mkdir -p $ARM_TOOL_ROOT
tar --directory=$ARM_TOOL_ROOT -zxf $ARM_TOOL_NANE.tar.gz&
pid=`echo $!`
str="| / - \\"
count=1
while [ -d /proc/$pid ]
do
    if [ $count == 5 ]; then
        count=1
    fi
    echo -e -n "\r"`echo $str | awk '{print $'$count'}'`
    count=`expr $count + 1`
    sleep 1
done
chown -R root:root $ARM_TOOL_PATH
echo -e -n '\r'

echo "Now setting toolchain environment"
PROFILE=/etc/profile
NVTFILE=/etc/profile.d/nvt_arm_linux.sh
TMPFILE=`mktemp -q /tmp/$0.XXXXXX`
if [ $? -ne 0 ]; then
    echo "$0: Can't create temp file, exiting..."
    exit 1
fi

# Check toolchain environment setting in PROFILE
REC=$(cat $PROFILE|tr -d '\r'|tr -t '\n' '\r'|sed '1,$s/\\
//g' |tr -t '\r' '\n'|grep "PATH="|sed '1,$s/PATH=//g'|tr -t '\n' ':')
NUM=$(echo $REC|awk -F: 'END {print NF}')
i=1
RES=0
while (test $i -le $NUM)
do
    TMP=$(echo $REC | awk -F: "{print \$$i}")
    if [ "$TMP" = "$ARM_TOOL_PATH/bin" ]; then
        RES=1
    elif [ "$TMP" = "$ARM_TOOL_PATH/bin/" ]; then
        RES=1
    fi
    i=`expr $i + 1`
done

# Check toolchain environment setting in NVTFILE
if [ $RES == 0 ]; then
    if [ -f $NVTFILE ]; then
        cat $NVTFILE | grep "^[ ]*export PATH=$ARM_TOOL_PATH/bin" > /dev/null
        if [ $? == 0 ]; then
            RES=1
        fi
    fi
fi

if [ $RES == 1 ]; then
    echo > /dev/null
else
    if [ -f $NVTFILE ]; then
        cat $NVTFILE | grep  "^[ ]*export " > /dev/null
        if [ $? == 0 ]; then
            ARM_TOOL_PATH_TMP=`echo $ARM_TOOL_PATH | sed -e 's/\//\\\\\//g'`
            #echo 'ARM_TOOL_PATH_TMP='$ARM_TOOL_PATH_TMP''
            cat $NVTFILE | grep  "^[ ]*export " | grep "$ARM_TOOL_PATH/bin" > /dev/null
            if [ $? == 0 ]; then
                sed -e 's/'$ARM_TOOL_PATH_TMP'\/bin[/]*://' $NVTFILE > $TMPFILE
                cp -f $TMPFILE $NVTFILE
            fi
            sed -e 's/PATH=/PATH='$ARM_TOOL_PATH_TMP'\/bin:/' $NVTFILE > $TMPFILE
            cp -f $TMPFILE $NVTFILE
            rm -f $TMPFILE
        else
            echo 'export PATH='$ARM_TOOL_PATH'/bin:$PATH' >> $NVTFILE
        fi 
    else
        echo '## Nuvoton toolchain environment export' >> $NVTFILE
        echo 'export PATH='$ARM_TOOL_PATH'/bin:$PATH' >> $NVTFILE
        chmod +x $NVTFILE
    fi
fi

echo "Installing $ARM_TOOL_NANE toolchain successfully"

#20140319, rayoslee@acsip
#Copy 'mkimage' to toolchain bin folder (default is /usr/local/arm_linux_4.2/bin/)
sudo cp mkimage $ARM_TOOL_PATH/bin

#Copy mtd header files from kernel header folder to toolchain include folder
sudo cp -af mtd/ $ARM_TOOL_PATH/include/ 
#rayoslee