| #!/bin/bash |
| |
| # Get version. |
| BUILD_PROJECT=`cat build_version | grep PROJECT | cut -d '=' -f 2` |
| BUILD_PARTITION=`cat build_version | grep PARTITION | cut -d '=' -f 2` |
| |
| function ota_init() |
| { |
| if [ ! -d $OTA_BIN_DIR ]; then |
| mkdir -p $OTA_BIN_DIR |
| fi |
| |
| cp marvell/fota/mkota/mkotafbf $OTA_BIN_DIR/ |
| } |
| |
| function dfota_process() |
| { |
| cp -f $1/$2 $1/MBTK_OTA_BLF |
| |
| # 禁用不需要生成差分的分区表 |
| # tim_lapw_qspinand.bin |
| sed -i '/^1_Image_Enable/c\1_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # tim_lapw_qspinand2.bin |
| sed -i '/^2_Image_Enable/c\2_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_TLoader_QSPINAND.bin |
| sed -i '/^3_Image_Enable/c\3_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_TLoader_QSPINAND.bin |
| sed -i '/^4_Image_Enable/c\4_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_CP_ReliableData_CMCC.bin |
| sed -i '/^5_Image_Enable/c\5_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_AP_ReliableData.bin |
| sed -i '/^6_Image_Enable/c\6_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_CP_ReliableData_CMCC.bin |
| sed -i '/^7_Image_Enable/c\7_Image_Enable = 0' $1/MBTK_OTA_BLF |
| # asr1903_AP_ReliableData.bin |
| sed -i '/^8_Image_Enable/c\8_Image_Enable = 0' $1/MBTK_OTA_BLF |
| } |
| |
| function ota_main() |
| { |
| if [ -n "$2" ] ;then #有2个参数 |
| echo "生成差分包:$1->$2" |
| OTA_VERSION=`cat $2/mversion` |
| cp -rf $2 $2/../$OTA_VERSION |
| if [ "$BUILD_PROJECT" == "L901CD-L" ];then |
| dfota_process $1 asr1903_p501_QSPINAND_Trusted_SDTIM_LPDDR2_AB_MBTK.blf |
| elif [ "$BUILD_PROJECT" == "T108" -o "$BUILD_PROJECT" == "T108-2" -o "$BUILD_PROJECT" == "L508_X6" ];then |
| dfota_process $1 asr1806_p301_QSPINAND_Trusted_SDTIM_LPDDR2_AB_MBTK.blf |
| else |
| dfota_process $1 asr1803_p401_QSPINAND_Trusted_CMCC_LPDDR2_AB_MBTK.blf |
| fi |
| |
| ./$OTA_BIN_DIR/mkotafbf -d -f $1/MBTK_OTA_BLF -o $OTA_BIN_DIR/$OUT_VERSION -b $1 -a $2/../$OTA_VERSION |
| |
| [ -f $OTA_BIN_DIR/$OUT_VERSION -a -f mbtk/ota_update ] && mbtk/ota_update -f $OTA_BIN_DIR/$OUT_VERSION -v $2 |
| |
| rm -rf $2/../$OTA_VERSION |
| elif [ -n "$1" ] ;then #有1个参数 |
| echo "生成整包:$1" |
| OTA_VERSION=`cat $1/mversion` |
| |
| if [ "$BUILD_PROJECT" == "L901CD-L" ];then |
| ./$OTA_BIN_DIR/mkotafbf -f $1/asr1903_p501_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION" |
| elif [ "$BUILD_PROJECT" == "T108" -o "$BUILD_PROJECT" == "T108-2" -o "$BUILD_PROJECT" == "L508_X6" ];then |
| ./$OTA_BIN_DIR/mkotafbf -f $1/asr1806_p301_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION" |
| else |
| ./$OTA_BIN_DIR/mkotafbf -f $1/asr1803_p401_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION" |
| fi |
| |
| [ -f $OTA_BIN_DIR/$OTA_VERSION.bin -a -f mbtk/ota_update ] && mbtk/ota_update -f $OTA_BIN_DIR/$OTA_VERSION.bin -v $1 |
| else # 无参数 |
| help |
| fi |
| } |
| |
| help() |
| { |
| echo "usage: ./fota.sh old_dir new_dir out_dir" |
| echo " 生成差分包。 " |
| echo " old_dir : 旧版本目录" |
| echo " new_dir : 新版本目录" |
| echo " out_dir : ota包生成目录" |
| echo |
| echo "usage: ./fota.sh dir out_dir" |
| echo " 生成整包。 " |
| echo " dir : 版本目录" |
| echo " out_dir : ota包生成目录" |
| echo |
| } |
| |
| if [ -n "$3" ] ;then #有3个参数 |
| if [ ! -d $1 ] || [ ! -d $2 ]; then |
| echo "目录不存在." |
| exit 1 |
| fi |
| |
| OTA_HOME_DIR=$3 |
| OTA_BIN_DIR="$OTA_HOME_DIR/ota" |
| OUT_VERSION="updata.bin" |
| |
| echo $BUILD_PROJECT : $BUILD_PARTITION |
| ota_init |
| |
| ota_main $1 $2 |
| elif [ -n "$2" ] ;then #有2个参数 |
| if [ ! -d $1 ]; then |
| echo "目录不存在." |
| exit 1 |
| fi |
| |
| OTA_HOME_DIR=$2 |
| OTA_BIN_DIR="$OTA_HOME_DIR/ota" |
| OUT_VERSION="updata.bin" |
| |
| echo $BUILD_PROJECT : $BUILD_PARTITION |
| ota_init |
| |
| ota_main $1 |
| else # 无参数 |
| help |
| fi |