blob: 3cbc69008633b7359765dd446defda8d882cd347 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#!/bin/bash
2
3# Get version.
4BUILD_PROJECT=`cat build_version | grep PROJECT | cut -d '=' -f 2`
5BUILD_PARTITION=`cat build_version | grep PARTITION | cut -d '=' -f 2`
6
7function ota_init()
8{
9 if [ ! -d $OTA_BIN_DIR ]; then
10 mkdir -p $OTA_BIN_DIR
11 fi
12
13 cp marvell/fota/mkota/mkotafbf $OTA_BIN_DIR/
14}
15
16function dfota_process()
17{
18 cp -f $1/$2 $1/MBTK_OTA_BLF
19
20 # 禁用不需要生成差分的分区表
21 # tim_lapw_qspinand.bin
22 sed -i '/^1_Image_Enable/c\1_Image_Enable = 0' $1/MBTK_OTA_BLF
23 # tim_lapw_qspinand2.bin
24 sed -i '/^2_Image_Enable/c\2_Image_Enable = 0' $1/MBTK_OTA_BLF
25 # asr1903_TLoader_QSPINAND.bin
26 sed -i '/^3_Image_Enable/c\3_Image_Enable = 0' $1/MBTK_OTA_BLF
27 # asr1903_TLoader_QSPINAND.bin
28 sed -i '/^4_Image_Enable/c\4_Image_Enable = 0' $1/MBTK_OTA_BLF
29 # asr1903_CP_ReliableData_CMCC.bin
30 sed -i '/^5_Image_Enable/c\5_Image_Enable = 0' $1/MBTK_OTA_BLF
31 # asr1903_AP_ReliableData.bin
32 sed -i '/^6_Image_Enable/c\6_Image_Enable = 0' $1/MBTK_OTA_BLF
33 # asr1903_CP_ReliableData_CMCC.bin
34 sed -i '/^7_Image_Enable/c\7_Image_Enable = 0' $1/MBTK_OTA_BLF
35 # asr1903_AP_ReliableData.bin
36 sed -i '/^8_Image_Enable/c\8_Image_Enable = 0' $1/MBTK_OTA_BLF
37}
38
39function ota_main()
40{
41 if [ -n "$2" ] ;then #有2个参数
42 echo "生成差分包:$1->$2"
43 OTA_VERSION=`cat $2/mversion`
44 cp -rf $2 $2/../$OTA_VERSION
45 if [ "$BUILD_PROJECT" == "L901CD-L" ];then
46 dfota_process $1 asr1903_p501_QSPINAND_Trusted_SDTIM_LPDDR2_AB_MBTK.blf
47 elif [ "$BUILD_PROJECT" == "T108" -o "$BUILD_PROJECT" == "T108-2" -o "$BUILD_PROJECT" == "L508_X6" ];then
48 dfota_process $1 asr1806_p301_QSPINAND_Trusted_SDTIM_LPDDR2_AB_MBTK.blf
49 else
50 dfota_process $1 asr1803_p401_QSPINAND_Trusted_CMCC_LPDDR2_AB_MBTK.blf
51 fi
52
53 ./$OTA_BIN_DIR/mkotafbf -d -f $1/MBTK_OTA_BLF -o $OTA_BIN_DIR/$OUT_VERSION -b $1 -a $2/../$OTA_VERSION
54
55 [ -f $OTA_BIN_DIR/$OUT_VERSION -a -f mbtk/ota_update ] && mbtk/ota_update -f $OTA_BIN_DIR/$OUT_VERSION -v $2
56
57 rm -rf $2/../$OTA_VERSION
58 elif [ -n "$1" ] ;then #有1个参数
59 echo "生成整包:$1"
60 OTA_VERSION=`cat $1/mversion`
61
62 if [ "$BUILD_PROJECT" == "L901CD-L" ];then
63 ./$OTA_BIN_DIR/mkotafbf -f $1/asr1903_p501_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION"
64 elif [ "$BUILD_PROJECT" == "T108" -o "$BUILD_PROJECT" == "T108-2" -o "$BUILD_PROJECT" == "L508_X6" ];then
65 ./$OTA_BIN_DIR/mkotafbf -f $1/asr1806_p301_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION"
66 else
67 ./$OTA_BIN_DIR/mkotafbf -f $1/asr1803_p401_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF -o $OTA_BIN_DIR/$OTA_VERSION.bin -v "$OTA_VERSION"
68 fi
69
70 [ -f $OTA_BIN_DIR/$OTA_VERSION.bin -a -f mbtk/ota_update ] && mbtk/ota_update -f $OTA_BIN_DIR/$OTA_VERSION.bin -v $1
71 else # 无参数
72 help
73 fi
74}
75
76help()
77{
78 echo "usage: ./fota.sh old_dir new_dir out_dir"
79 echo " 生成差分包。 "
80 echo " old_dir : 旧版本目录"
81 echo " new_dir : 新版本目录"
82 echo " out_dir : ota包生成目录"
83 echo
84 echo "usage: ./fota.sh dir out_dir"
85 echo " 生成整包。 "
86 echo " dir : 版本目录"
87 echo " out_dir : ota包生成目录"
88 echo
89}
90
91if [ -n "$3" ] ;then #有3个参数
92 if [ ! -d $1 ] || [ ! -d $2 ]; then
93 echo "目录不存在."
94 exit 1
95 fi
96
97 OTA_HOME_DIR=$3
98 OTA_BIN_DIR="$OTA_HOME_DIR/ota"
99 OUT_VERSION="updata.bin"
100
101 echo $BUILD_PROJECT : $BUILD_PARTITION
102 ota_init
103
104 ota_main $1 $2
105elif [ -n "$2" ] ;then #有2个参数
106 if [ ! -d $1 ]; then
107 echo "目录不存在."
108 exit 1
109 fi
110
111 OTA_HOME_DIR=$2
112 OTA_BIN_DIR="$OTA_HOME_DIR/ota"
113 OUT_VERSION="updata.bin"
114
115 echo $BUILD_PROJECT : $BUILD_PARTITION
116 ota_init
117
118 ota_main $1
119else # 无参数
120 help
121fi