guowenxue
2024-01-24 b8946817226ec718ec305ad3274d54558b95697b
bootloader/build.sh
@@ -57,20 +57,25 @@
    export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'`
    export MCORE_COMPILE=`jq -r ".bsp.cortexMtool" $CONF_FILE | tr 'A-Z' 'a-z'`
    export SRCS="imx-atf uboot-imx imx-mkimage"
    export BRANCH=$BSP_VER
    export JOBS=`cat /proc/cpuinfo | grep processor | wc -l`
    export ARCH=arm
    # i.MX6ULL only need uboot-imx
    if [[ $BOARD =~ mx6ull ]] ; then
        export SRCS="uboot-imx"
        return ;
    fi
    export SRCS="uboot-imx imx-atf imx-mkimage"
    export_fmver
    export SRCS="imx-atf uboot-imx imx-mkimage"
    if [[ $BOARD =~ mx8mp ]] ; then
        ATF_PLATFORM=imx8mp
        IMX_BOOT_SOC_TARGET=iMX8MP
        IMXBOOT_TARGETS=flash_ddr4_evk
        IMXBOOT_DTB=imx8mp-ddr4-evk.dtb
        IMXBOOT_TARGETS=flash_evk
        IMXBOOT_DTB=imx8mp-evk.dtb
        MKIMG_BIN_PATH=$PRJ_PATH/imx-mkimage/iMX8M/
    elif [[ $BOARD =~ mx8mm ]] ; then
@@ -99,16 +104,19 @@
        git clone $GIT_URL/$src.git -b $BRANCH --depth=1
        # do patch if patch file exist
        PATCH_FILE=$PRJ_PATH/patches/$BOARD/$src-$BSP_VER.patch
        if [ -s $PATCH_FILE ] ; then
        patch_file=$PRJ_PATH/patches/$BOARD/$src-$BSP_VER.patch
        if [ -s $patch_file ] ; then
            pr_warn "do patch for $src now..."
            cd $src
            patch -p1 < $PATCH_FILE
            patch -p1 < $patch_file
            cd -
        fi
    done
    # i.MX6ULL only need uboot-imx
    if [[ $BOARD =~ mx6ull ]] ; then
        return ;
    fi
    mkdir -p $FMW_PATH && cd $FMW_PATH
@@ -178,15 +186,32 @@
function build_uboot()
{
    SRC=uboot-imx
    patch_file=$PRJ_PATH/patches/$BOARD/$SRC-$BSP_VER.patch
    defconfig=${BOARD}_defconfig
    pr_warn "start build $SRC"
    cd $PRJ_PATH/${SRC}
    # do patch if not patched
    if [ ! -s configs/$defconfig -a -s $patch_file ] ; then
        pr_warn "do patch for $SRC now..."
        patch -p1 < $patch_file
    fi
    if [ ! -f .config ] ; then
        make ARCH=arm ${BOARD}_defconfig
    fi
    make -j${JOBS} CROSS_COMPILE=${CROSS_COMPILE} ARCH=arm
    # i.MX6ULL only need uboot-imx
    if [[ $BOARD =~ mx6ull ]] ; then
        cp u-boot-dtb.imx u-boot-${BOARD}.imx
        chmod a+x u-boot-${BOARD}.imx
        set -x
        cp u-boot-${BOARD}.imx $PRFX_PATH
        set +x
        return ;
    fi
    set -x
    cp u-boot.bin $MKIMG_BIN_PATH
@@ -247,13 +272,11 @@
        pr_info "Copy DDR4 firmware to $MKIMG_BIN_PATH"
        cp $FMW_PATH/firmware-imx-*/firmware/hdmi/cadence/signed_hdmi_imx8m.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/ddr4_imem_1d*.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/ddr4_dmem_1d*.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/ddr4_imem_2d*.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/ddr4_dmem_2d*.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/lpddr4_pmu_train_[1-2]d_imem_202006.bin $MKIMG_BIN_PATH
        cp $FMW_PATH/firmware-imx-*/firmware/ddr/synopsys/lpddr4_pmu_train_[1-2]d_dmem_202006.bin $MKIMG_BIN_PATH
    fi
    make SOC=$IMX_BOOT_SOC_TARGET REV=A2 $IMXBOOT_TARGETS
    make SOC=$IMX_BOOT_SOC_TARGET $IMXBOOT_TARGETS
    cp $MKIMG_BIN_PATH/flash.bin u-boot-${BOARD}.imx
    chmod a+x u-boot-${BOARD}.imx
@@ -266,10 +289,16 @@
    cd $PRJ_PATH
    mkdir -p $PRFX_PATH
    build_atf
    #build_cortexM
    build_uboot
    # i.MX6ULL only need uboot-imx
    if [[ ${BOARD} =~ mx6ull ]] ; then
        return ;
    fi
    build_atf
    build_imxboot
    #build_cortexM
}
function do_install()
@@ -283,6 +312,7 @@
    if [[ -n "$INST_PATH" && -w $INST_PATH ]] ; then
        pr_info "install bootloader to '$INST_PATH'"
        cp $PRFX_PATH/u-boot-${BOARD}.imx $INST_PATH
        #sz $PRFX_PATH/u-boot-${BOARD}.imx
    fi
}