guowenxue
2024-01-26 8e61092dcc0e3dd733d8632f6fd83eb75c332c87
Build:IGKBoard-All:Add SDK download from server support

Add SDK download from server support

Signed-off-by: guowenxue <guowenxue@gmail.com>
4 files modified
273 ■■■■ changed files
bootloader/build.sh 102 ●●●●● patch | view | raw | blame | history
images/build.sh 60 ●●●●● patch | view | raw | blame | history
kernel/build.sh 82 ●●●● patch | view | raw | blame | history
yocto/build.sh 29 ●●●● patch | view | raw | blame | history
bootloader/build.sh
@@ -13,7 +13,10 @@
PRFX_PATH=$PRJ_PATH/install
# binaries finally install path if needed
INST_PATH=/tftp
#INST_PATH=/tftp
# download taballs path
TARBALL_PATH=$PRJ_PATH/tarballs
# config file path
CONF_FILE=$TOP_PATH/config.json
@@ -37,6 +40,51 @@
    echo -e "\033[40;32m $1 \033[0m"
}
# decompress a packet to destination path
function do_unpack()
{
    tarball=$1
    dstpath=`pwd`
    if [[ $# == 2 ]] ; then
        dstpath=$2
    fi
    pr_info "decompress $tarball => $dstpath"
    mkdir -p $dstpath
    case $tarball in
        *.tar.gz)
            tar -xzf $tarball -C $dstpath
            ;;
        *.tar.bz2)
            tar -xjf $tarball -C $dstpath
            ;;
        *.tar.xz)
            tar -xJf $tarball -C $dstpath
            ;;
        *.tar.zst)
            tar -I zstd -xf $tarball -C $dstpath
            ;;
        *.tar)
            tar -xf $tarball -C $dstpath
            ;;
        *.zip)
            unzip -qo $tarball -d $dstpath
            ;;
        *)
            pr_error "decompress Unsupport packet: $tarball"
            return 1;
            ;;
    esac
}
# select firmware version by BSP version
function export_fmver()
{
@@ -56,7 +104,7 @@
{
    export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
    export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE`
    export MCORE_COMPILE=`jq -r ".bsp.cortexMtool" $CONF_FILE`
@@ -104,7 +152,20 @@
        fi
        pr_info "start fetch $src source code"
        git clone $GIT_URL/$src.git -b $BRANCH --depth=1
        if [[ $BSP_URL =~ github.com ]] ; then
            git clone $BSP_URL/$src.git -b $BRANCH --depth=1
        else
            mkdir -p $TARBALL_PATH
            # Download source code packet
            if [ ! -s $TARBALL_PATH/$src.tar.xz ] ; then
                wget $BSP_URL/bsp/$BSP_VER/$src.tar.xz -P $TARBALL_PATH
            fi
            # decompress source code packet
            do_unpack $TARBALL_PATH/$src.tar.xz
        fi
        # do patch if patch file exist
        patch_file=$PRJ_PATH/patches/$BOARD/$src-$BSP_VER.patch
@@ -121,6 +182,35 @@
        return ;
    fi
    # Download CortexM FreeRTOS SDK if needed
    if [ "$BUILD_MCORE" == "yes" ] ; then
        src=cortexm-sdk
        cd $PRJ_PATH
        if [ -d $src ] ; then
            pr_info "$src source code fetched already"
        else
            pr_info "start fetch $src source code"
            if [[ $BSP_URL =~ github.com ]] ; then
                pr_error "INFO: Please download $BOARD CortexM SDK from https://mcuxpresso.nxp.com by manual."
            else
                pack=cortexm-sdk-${BOARD}
                # Download source code packet
                if [ ! -s $TARBALL_PATH/$pack.tar.gz ] ; then
                    wget $BSP_URL/bsp/$BSP_VER/$pack.tar.gz -P $TARBALL_PATH
                fi
                # decompress source code packet
                do_unpack $TARBALL_PATH/$pack.tar.gz $PRJ_PATH/$src
            fi
        fi
    fi
    # Download firmware from NXP official URL
    mkdir -p $FMW_PATH && cd $FMW_PATH
    for fmw in $FMWS
@@ -155,7 +245,7 @@
# Cortex-M SDK download from https://mcuxpresso.nxp.com/ by manual
function build_cortexM()
{
    SRC=mcore-sdk
    SRC=cortexm-sdk
    if [ "$BUILD_MCORE" != "yes" ] ; then
        pr_warn "Skip build Cortex-M core SDK source code '$SRC'"
@@ -304,8 +394,8 @@
    fi
    build_atf
    build_cortexM
    build_imxboot
    build_cortexM
}
function do_install()
@@ -331,6 +421,8 @@
    done
    rm -rf $PRJ_PATH/firmware
    rm -rf $PRJ_PATH/cortexm-sdk
    rm -rf $PRJ_PATH/tarballs
    rm -rf $PRFX_PATH
}
images/build.sh
@@ -10,7 +10,10 @@
PRFX_PATH=$PRJ_PATH/install
# binaries finally install path if needed
INST_PATH=/tftp
#INST_PATH=/tftp
# download taballs path
TARBALL_PATH=$PRJ_PATH/tarballs
# config file path
CONF_FILE=$TOP_PATH/config.json
@@ -85,6 +88,8 @@
{
    export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
    export DIS_TYPE=`jq -r ".system.distro" $CONF_FILE | tr 'A-Z' 'a-z'`
    export DIS_VER=`jq -r ".system.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export IMAGE_SIZE=`jq -r ".system.imgsize" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BOOT_SIZE=`jq -r ".system.bootsize" $CONF_FILE | tr 'A-Z' 'a-z'`
@@ -95,7 +100,6 @@
    export ROOTFS=rootfs-${DIS_VER}
    export UBOOT_BINPATH=$TOP_PATH/bootloader/install/
    export KERNEL_BINPATH=$TOP_PATH/kernel/install/
    export ROOTFS_TARPATH=$TOP_PATH/images/tarballs/
    export ROOTFS_YCTPATH=$TOP_PATH/yocto/install/
    if [[ $BOARD =~ mx8ulp ]] || [[ $BOARD =~ mx8mq ]] || [[ $BOARD =~ mx8mm ]] ; then
@@ -111,38 +115,53 @@
{
    cd $PRJ_PATH
    SRCS=$ROOTFS
    for src in $SRCS
    do
        if [ -d $ROOTFS/bin ] ; then
            pr_info "$src fetched already"
            continue
        pr_info "$ROOTFS fetched already"
        return ;
        fi
        for tarball in $ROOTFS_TARPATH/rootfs*${DIS_VER}.tar.*
        do
            if [ -s $tarball ] ; then
                pr_warn "Decompress $ROOTFS from tarballs"
                mkdir -p $ROOTFS
                do_unpack $tarball $ROOTFS
                break;
    if [[ $DIS_TYPE == yocto ]] ; then
        TAR_TYPE=tar.zst
    else
        TAR_TYPE=tar.xz
            fi
        done
        for tarball in $ROOTFS_YCTPATH/rootfs.tar.*
    # Decompress the rootfs form Yocto build install path
    if [[ $DIS_TYPE == yocto ]] ; then
        for tarball in $ROOTFS_YCTPATH/*$BOARD*.${TAR_TYPE}
        do
            if [ -s $tarball ] ; then
                pr_warn "Decompress $ROOTFS from yocto install path"
                mkdir -p $ROOTFS
                do_unpack $tarball $ROOTFS
                break;
                return ;
            fi
        done
    fi
    done
    tarball=rootfs-${DIS_TYPE}-${DIS_VER}.${TAR_TYPE}
    if [ ! -d $ROOTFS ] ; then
    if [[ $BSP_URL =~ github.com ]] ; then
        pr_error "INFO: Please download $tarball and decompress it to folder '$PRJ_PATH/$ROOTFS'"
    else
        pr_info "INFO: download $tarball form $BSP_URL"
        mkdir -p $TARBALL_PATH
        # Download source code packet
        if [ ! -s $TARBALL_PATH/$tarball ] ; then
            wget $BSP_URL/${BOARD}/rootfs/$tarball -P $TARBALL_PATH
        fi
        # decompress source code packet
        do_unpack $TARBALL_PATH/$tarball $ROOTFS
    fi
    if [ ! -d $ROOTFS/bin ] ; then
        pr_error "Fetch rootfs $ROOTFS failed"
        exit ;
    fi
@@ -262,6 +281,7 @@
        rm -rf $PRJ_PATH/$d
    done
    rm -rf $PRJ_PATH/tarballs
    rm -rf $PRFX_PATH
    rm -f *.img
}
kernel/build.sh
@@ -12,6 +12,9 @@
# binaries finally install path if needed
#INST_PATH=/tftp
# download taballs path
TARBALL_PATH=$PRJ_PATH/tarballs
# config file path
CONF_FILE=$TOP_PATH/config.json
@@ -34,17 +37,62 @@
    echo -e "\033[40;32m $1 \033[0m"
}
# decompress a packet to destination path
function do_unpack()
{
    tarball=$1
    dstpath=`pwd`
    if [[ $# == 2 ]] ; then
        dstpath=$2
    fi
    pr_info "decompress $tarball => $dstpath"
    mkdir -p $dstpath
    case $tarball in
        *.tar.gz)
            tar -xzf $tarball -C $dstpath
            ;;
        *.tar.bz2)
            tar -xjf $tarball -C $dstpath
            ;;
        *.tar.xz)
            tar -xJf $tarball -C $dstpath
            ;;
        *.tar.zst)
            tar -I zstd -xf $tarball -C $dstpath
            ;;
        *.tar)
            tar -xf $tarball -C $dstpath
            ;;
        *.zip)
            unzip -qo $tarball -d $dstpath
            ;;
        *)
            pr_error "decompress Unsupport packet: $tarball"
            return 1;
            ;;
    esac
}
# parser configure file and export environment variable
function export_env()
{
    export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'`
    export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
    export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE`
    export SRCS="linux-imx"
    export BRANCH=$BSP_VER
    export KER_PATH=$PRJ_PATH/linux-imx
    export KER_SRC=linux-imx
    export KER_PATH=$PRJ_PATH/$KER_SRC
    export JOBS=`cat /proc/cpuinfo | grep processor | wc -l`
@@ -58,7 +106,7 @@
function build_kernel()
{
    defconfig=${BOARD}_defconfig
    patch_file=$PRJ_PATH/patches/$BOARD/linux-imx-$BSP_VER.patch
    patch_file=$PRJ_PATH/patches/$BOARD/${KER_SRC}-$BSP_VER.patch
    cd $PRJ_PATH
@@ -66,7 +114,20 @@
        pr_info "linux kernel source code fetched already"
    else
        pr_info "start fetch linux kernel source code"
        git clone $GIT_URL/linux-imx.git -b $BRANCH --depth=1
        if [[ $BSP_URL =~ github.com ]] ; then
            git clone $BSP_URL/$KER_SRC.git -b $BRANCH --depth=1
        else
            mkdir -p $TARBALL_PATH
            # Download source code packet
            if [ ! -s $TARBALL_PATH/$KER_SRC.tar.xz ] ; then
                wget $BSP_URL/bsp/$BSP_VER/$KER_SRC.tar.xz -P $TARBALL_PATH
            fi
            # decompress source code packet
            do_unpack $TARBALL_PATH/$KER_SRC.tar.xz
        fi
    fi
    pr_info "Start build linux kernel source code"
@@ -109,7 +170,7 @@
        set -x
        cp -f arch/${ARCH}/boot/Image $PRFX_PATH
        cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}.dtb $PRFX_PATH
        cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}/*.dtbo $PRFX_PATH/overlays
        #cp -f arch/${ARCH}/boot/dts/freescale/${BOARD}/*.dtbo $PRFX_PATH/overlays
        set +x
    fi
@@ -140,11 +201,8 @@
{
    cd $PRJ_PATH
    for d in $SRCS
    do
        rm -rf $PRJ_PATH/$d
    done
    rm -rf $PRJ_PATH/$KER_SRC
    rm -rf $PRJ_PATH/tarballs
    rm -rf $PRFX_PATH
}
yocto/build.sh
@@ -25,7 +25,7 @@
CONF_FILE=$TOP_PATH/config.json
# Download path
DL_PATH="/srv/yocto_packets/"
#DL_PATH="/srv/yocto_packets/"
# shell script will exit once get command error
set -e
@@ -97,21 +97,26 @@
    export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export YCT_VER=`jq -r ".system.version" $CONF_FILE | tr 'A-Z' 'a-z'`
    export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
    export YCT_BOARD=`echo $BOARD| cut -d- -f1`
    export YCT_META=meta-$YCT_BOARD
    export YCT_PATH=$PRJ_PATH/$YCT_VER-$BSP_VER
    export YCT_SRC=$YCT_VER-$BSP_VER
    export YCT_PATH=$PRJ_PATH/$YCT_SRC
    export BUILD_DIR=${BOARD}
}
function do_fetch()
{
    cd $PRJ_PATH
    mkdir -p $YCT_PATH && cd $YCT_PATH
    if [ ! -d $YCT_SRC/sources ] ; then
    if [ ! -d sources ] ; then
        if [[ $BSP_URL =~ github.com ]] ; then
        pr_info "start repo fetch Yocto $YCT_VER source code"
            mkdir -p $YCT_PATH && cd $YCT_PATH
        if ! command -v repo > /dev/null 2>&1 ; then
            curl https://storage.googleapis.com/git-repo-downloads/repo > repo
@@ -124,6 +129,22 @@
        repo sync && rm -f repo
    else
            pr_info "start download fetch Yocto $YCT_VER source code"
            mkdir -p $TARBALL_PATH
            # Download source code packet
            if [ ! -s $TARBALL_PATH/$YCT_SRC.tar.xz ] ; then
                wget $BSP_URL/bsp/$BSP_VER/$YCT_SRC.tar.xz -P $TARBALL_PATH
            fi
            # decompress source code packet
            do_unpack $TARBALL_PATH/$YCT_SRC.tar.xz
        fi
    else
        pr_warn "Yocto $YCT_VER source code fetched already"
    fi