#!/bin/bash
|
|
# exit shell script when command get error
|
set -e
|
|
# crosstool name
|
BUILDROOT_NAME=gcc-10.4-cortexA7-2023.02
|
|
# crosstool download server URL
|
LYFTP_PUB=http://master.iot-yun.club:2211/imx/crosstool
|
|
# install path defined in build shell script
|
INST_PATH=/opt/buildroot
|
|
# buildroot version
|
BR_VER=buildroot-2023.02
|
|
# set workspace to build buildroot
|
WORK_SPACE=${HOME}
|
|
if [ -d $INST_PATH/$BUILDROOT_NAME ] ; then
|
echo "crosstool $BUILDROOT_NAME already installed to \"$INST_PATH\""
|
exit
|
fi
|
|
# check install path is writable or not
|
if [ ! -w $INST_PATH ] ; then
|
CUR_USER=`whoami`
|
|
echo "ERROR: Crosstool install path \"$INST_PATH\" not writable, please solve it by follow command: "
|
echo " sudo sh -c 'mkdir -p $INST_PATH && chown $CUR_USER.$CUR_USER $INST_PATH' "
|
exit
|
fi
|
|
|
cd $WORK_SPACE
|
|
# Download source code pacakge, it's about 1.8GB
|
if [ ! -s ${BR_VER}-packets.tar.xz ] ; then
|
wget $LYFTP_PUB/${BR_VER}-packets.tar.xz
|
fi
|
|
if [ ! -d ${BR_VER} ] ; then
|
tar -xJf ${BR_VER}-packets.tar.xz
|
fi
|
|
cd ${BR_VER}
|
|
chmod +x build.sh
|
|
./build.sh
|
|
echo ""
|
$INST_PATH/$BUILDROOT_NAME/bin/arm-linux-gcc -v
|
|
echo ""
|
echo " -- crosstool already installed to \"$INST_PATH/$BUILDROOT_NAME\".";
|
echo " -- build workspace path is \"$WORK_SPACE/$BR_VER\", you can remove it now.";
|
echo ""
|