From fe3873a5423e587161941ba833bfbd266cc37f6a Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 28 Jun 2023 22:08:51 +0800 Subject: [PATCH] update buildroot install build shell script --- tools/setup_tools.sh | 19 ++-- tools/buildroot/buildroot.sh | 166 +++++++++++------------------------------ 2 files changed, 53 insertions(+), 132 deletions(-) diff --git a/tools/buildroot/buildroot.sh b/tools/buildroot/buildroot.sh index 878ed57..da154b8 100755 --- a/tools/buildroot/buildroot.sh +++ b/tools/buildroot/buildroot.sh @@ -1,136 +1,60 @@ #!/bin/bash -LYFTP_PUB=http://weike-iot.com:2211/imx6ull/tools/lintools - -PRJ_PATH=`pwd` -WORK_SPACE=${HOME}/buildroot/ -INST_PATH=/opt/buildroot/cortexA7 - -BR_VER=buildroot-2021.02.7 -BR_PAK=${BR_VER}-packets - -BR_TAR=${BR_PAK}.tar.bz2 -BR_CONF=${BR_VER}-cortexA7.config - -# This configure file support QT, opencv... -#BR_CONF=${BR_VER}-cortexA7-multimedia.config - -JOBS=`cat /proc/cpuinfo | grep processor | wc -l` - -set -u +# exit shell script when command get error set -e -if [ `id -u` == 0 ] ; then - echo "ERROR: This shell script shouldn't be excuted by root!" - exit ; +# 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 -STAGE=0 -function msg_banner() -{ - STAGE=`expr $STAGE + 1` - - echo "" - echo "+---------------------------------------------+" - printf " Stage $STAGE: $1\n" - echo "+---------------------------------------------+" - echo "" -} - -function do_fetch() -{ - msg_banner "Fetch ${BR_VER} packets" - - if [ -d $BR_VER ] ; then - printf "\n\n -- ${BR_VER} fetched already -- \n\n" - return ; - fi - - if [ ! -s $BR_TAR ] ; then - printf "\n\n -- fetch ${BR_VER} packet -- \n\n" - wget ${LYFTP_PUB}/$BR_TAR - fi - - if [ ! -d $BR_PAK ] ; then - printf "\n\n -- decompress ${BR_TAR} packet -- \n\n" - tar -xjf ${BR_TAR} - fi - - printf "\n\n -- decompress ${BR_VER} -- \n\n" - tar -xjf ${BR_PAK}/buildroot/${BR_VER}.tar.bz2 - - mv ${BR_PAK} ${BR_VER}/tarballs -} - -function do_patch() -{ - msg_banner "Patch for ${BR_VER} " - - cd $BR_VER - - cp tarballs/buildroot/$BR_CONF .config - cp tarballs/busybox/busybox.config package/busybox/ - sed -i "s|^BR2_HOST_DIR=.*|BR2_HOST_DIR=\"${INST_PATH}\"|g" .config - - cd - -} - -function do_build() -{ - msg_banner "Build ${BR_VER} " - cd $BR_VER - - make -j ${JOBS} - - cd - -} - -function do_install() -{ - msg_banner "Install ${BR_VER} " - - # Packet and install crosstool - cd `dirname $INST_PATH` - tar -cjf ${PRJ_PATH}/${BR_VER}-`basename $INST_PATH`.tar.bz2 `basename $INST_PATH` - - # Install rootfs tarball - cp $WORK_SPACE/$BR_VER/output/images/rootfs.tar.bz2 ${PRJ_PATH}/rootfs_buildroot.tar.bz2 - - echo "" - echo " -- 1. Crosstool already installed to \"$INST_PATH\"."; - echo " -- 2. Crosstool and rootfs packet installed to \"$PRJ_PATH\""; - echo " -- 3. Build workspace path is \"$WORK_SPACE\", you can remove it now."; - echo "" -} - -function do_prepare() -{ - INST_DIR=`dirname $INST_PATH` +# check install path is writable or not +if [ ! -w $INST_PATH ] ; then CUR_USER=`whoami` - if [ ! -w $INST_DIR ] ; then - echo "" - echo "ERROR: Crosstool install path \"$INST_DIR\" not writable, please solve it by follow command: " - echo " sudo sh -c 'mkdir -p $INST_DIR && chown $CUR_USER.$CUR_USER $INST_DIR' " - echo "" - exit ; - fi + 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 - echo "" - echo "" - echo " Switch work space to \"$WORK_SPACE\" " - echo "" - mkdir -p $WORK_SPACE - cd $WORK_SPACE -} -do_prepare +cd $WORK_SPACE -do_fetch +# 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 -do_patch +if [ ! -d ${BR_VER} ] ; then + tar -xJf ${BR_VER}-packets.tar.xz +fi -do_build +cd ${BR_VER} -do_install +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 "" diff --git a/tools/setup_tools.sh b/tools/setup_tools.sh index 02cb804..43b67ba 100755 --- a/tools/setup_tools.sh +++ b/tools/setup_tools.sh @@ -2,7 +2,7 @@ # This shell script used to setup imx6ull build envrionment # -LYFTP_PUB=http://wekei-iot.com:2211/imx/igkboard/tools/lintools +LYFTP_PUB=http://master.iot-yun.club:2211/imx/crosstool # display in yellow function pr_warn() { @@ -76,11 +76,8 @@ function install_buildroot() { BUILDROOT_PATH=/opt/buildroot - BUILDROOT_NAME=cortexA7 - - BUILDROOT_VER=buildroot-2021.02.7-cortexA7 - BUILDROOT_TAR=${BUILDROOT_VER}.tar.bz2 - BUILDROOT_DLADDR=${LYFTP_PUB}/$BUILDROOT_TAR + BUILDROOT_NAME=gcc-10.4-cortexA7-2023.02 + BUILDROOT_TAR=$BUILDROOT_NAME.tar.xz if [ -d ${BUILDROOT_PATH}/${BUILDROOT_NAME} ] ; then pr_warn "Buildroot already installed to $BUILDROOT_PATH/$BUILDROOT_NAME" @@ -90,12 +87,12 @@ mkdir -p ${BUILDROOT_PATH} if [ ! -f $BUILDROOT_TAR ] ; then - pr_info "download $BUILDROOT_VER now..." - wget -c $BUILDROOT_DLADDR + pr_info "download $BUILDROOT_NAME now..." + wget -c $LYFTP_PUB/$BUILDROOT_TAR fi - pr_info "install $BUILDROOT_VER to $BUILDROOT_PATH/$BUILDROOT_NAME now..." - tar -xjf ${BUILDROOT_TAR} -C ${BUILDROOT_PATH} + pr_info "install $BUILDROOT_NAME to $BUILDROOT_PATH now..." + tar -xJf ${BUILDROOT_TAR} -C ${BUILDROOT_PATH} $BUILDROOT_PATH/$BUILDROOT_NAME/bin/arm-linux-gcc -v @@ -127,7 +124,7 @@ tar -xJf $ARMTOOL_PACK.tar.xz -C /opt rm -f $ARMTOOL_PACK.tar.xz - mv /opt/$ARMTOOL_PACK /opt/$ARMTOOL_NAME + mv /opt/$ARMTOOL_PACK /opt/$ARMTOOL_NAME /opt/$ARMTOOL_NAME/bin/arm-none-linux-gnueabihf-gcc -v pr_info "cross compiler installed to \"/opt/$ARMTOOL_NAME\" successfully" -- Gitblit v1.9.1