blob: af7dd2eff617a9aeaf9cf0c95032e45eae418aa7 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#!/bin/bash
2
3# Get version.
4versionFile='mbtk/include/mbtk_device_info.h'
5version=`cat $versionFile | grep -w 'MBTK_DEVICES_REVISION' | cut -d '"' -f 2 `
6BUILD_PROJECT=`cat build_version | grep PROJECT | cut -d '=' -f 2`
7# CUSTOM_MODEL=`cat build_version | grep CUSTOM_MODEL | cut -d '=' -f 2`
8BUILD_PARTITION=`cat build_version | grep PARTITION | cut -d '=' -f 2`
9BUILD_CUSTOM=`cat build_version | grep CUSTOM | cut -d '=' -f 2`
10SEC_SUPPORT=`cat build_version | grep SEC_SUPPORT | cut -d '=' -f 2`
11
12if [ -f mbtk/mbtk_version ];then
13 PATCH_INDEX=`cat mbtk/mbtk_version | grep PATCH_INDEX | cut -d '=' -f 2`
14 if [ -z $PATCH_INDEX ];then
15 PATCH_INDEX=0
16 fi
17 if [ $PATCH_INDEX -lt 10 ];then
18 PATCH_INDEX=00"$PATCH_INDEX"
19 else
20 if [ $PATCH_INDEX -lt 100 ];then
21 PATCH_INDEX=0"$PATCH_INDEX"
22 fi
23 fi
24
25 # T108v05.02b01_YX.00
26 MBTK_M1901_VERSION=${version#*:= }
27 MBTK_M1901_VERSION_1=`echo $MBTK_M1901_VERSION | cut -d '.' -f 1`
28 MBTK_M1901_VERSION_2=`echo $MBTK_M1901_VERSION | cut -d '.' -f 2`
29 MBTK_M1901_VERSION_3=`echo $MBTK_M1901_VERSION | cut -d '.' -f 3`
30 if [[ $MBTK_M1901_VERSION_3 == *_* ]];then # 有 '_'
31 MBTK_M1901_VERSION_3_1=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 1`
32 MBTK_M1901_VERSION_3_2=`echo $MBTK_M1901_VERSION_3 | cut -d '_' -f 2`
33
34 MBTK_M1901_VERSION=$MBTK_M1901_VERSION_1.$MBTK_M1901_VERSION_2."$PATCH_INDEX"_$MBTK_M1901_VERSION_3_2
35 else
36 MBTK_M1901_VERSION=$MBTK_M1901_VERSION_1.$MBTK_M1901_VERSION_2.$PATCH_INDEX
37 fi
38else
39 MBTK_M1901_VERSION=${version#*:= }
40fi
41
42MBTK_M1901_VERSION_DIR=out/$MBTK_M1901_VERSION
43MBTK_M1901_MDB_DIR=$MBTK_M1901_VERSION_DIR/MDB
44
45# BIN_LIC=-glibc
46
47if [ "$BUILD_PARTITION" == "ab" ];then
48 CUSTOM_MODEL="$BUILD_PROJECT"_AB_V2
49else
50 CUSTOM_MODEL="$BUILD_PROJECT"_A_V2
51fi
52
53if [ ! -z $BUILD_CUSTOM ];then
54 CUSTOM_MODEL="$CUSTOM_MODEL"_$BUILD_CUSTOM
55fi
56
57if [ "$BUILD_PROJECT" == "L901CD-L" ];then
58 BUILD_TARGAT=asr1903
59 BUILD_FLAG=p501
60 if [ "$SEC_SUPPORT" == "Y" ];then
61 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG"sec"$BIN_LIC"/swd
62 if [ "$BUILD_PARTITION" == "ab" ];then
63 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_AB
64 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_AB_OTA_BLF
65 else
66 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2
67 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_OTA_BLF
68 fi
69 else
70 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG""$BIN_LIC"/swd
71 if [ "$BUILD_PARTITION" == "ab" ];then
72 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_AB
73 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_AB_OTA_BLF
74 else
75 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2
76 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF
77 fi
78 fi
79elif [ "$BUILD_PROJECT" == "T108" -o "$BUILD_PROJECT" == "L508_X6" -o "$BUILD_PROJECT" == "T108-2" ];then
80 BUILD_TARGAT=asr1806
81 BUILD_FLAG=p301
82 if [ "$SEC_SUPPORT" == "Y" ];then
83 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG"sec"$BIN_LIC"/swd
84 if [ "$BUILD_PARTITION" == "ab" ];then
85 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_AB
86 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_AB_OTA_BLF
87 else
88 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2
89 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_SDTIM_LPDDR2_OTA_BLF
90 fi
91 else
92 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG""$BIN_LIC"/swd
93 if [ "$BUILD_PARTITION" == "ab" ];then
94 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_AB
95 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_AB_OTA_BLF
96 else
97 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2
98 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF
99 fi
100 fi
101else
102 BUILD_TARGAT=asr1803
103 BUILD_FLAG=p401
104 if [ "$SEC_SUPPORT" == "Y" ];then
105 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG"sec/swd
106 if [ "$BUILD_PARTITION" == "ab" ];then
107 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_CMCC_LPDDR2_AB
108 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_CMCC_LPDDR2_AB_OTA_BLF
109 else
110 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_CMCC_LPDDR2
111 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_TOS_CMCC_LPDDR2_OTA_BLF
112 fi
113 else
114 OUT_DIR=bin/"$BUILD_TARGAT""$BUILD_FLAG""$BIN_LIC"/swd
115 if [ "$BUILD_PARTITION" == "ab" ];then
116 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_CMCC_LPDDR2_AB
117 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_CMCC_LPDDR2_AB_OTA_BLF
118 else
119 BIN_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_CMCC_LPDDR2
120 BIN_OTA_BLF="$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_CMCC_LPDDR2_OTA_BLF
121 fi
122 fi
123fi
124
125
126
127echo "PROJECT = $BUILD_PROJECT"
128echo $MBTK_M1901_VERSION : $BUILD_PARTITION : $1
129echo "CUSTOM_MODEL=$CUSTOM_MODEL"
130
131function excmd()
132{
133 echo -e "\e[32mExcmd:\e[0m $@ " && sleep 0.05
134 $@
135}
136
137function copy()
138{
139 excmd cp $OUT_DIR/$1 $MBTK_M1901_VERSION_DIR
140}
141
142function mk_dir()
143{
144 if [ -d $MBTK_M1901_VERSION_DIR ]; then
145 excmd rm -rf $MBTK_M1901_VERSION_DIR
146 fi
147
148 if [ -f $MBTK_M1901_VERSION_DIR.zip ]; then
149 excmd rm -f $MBTK_M1901_VERSION_DIR.zip
150 fi
151
152 excmd mkdir -p $MBTK_M1901_VERSION_DIR
153 excmd mkdir -p $MBTK_M1901_MDB_DIR
154
155 if [ "$BUILD_TARGAT" == "asr1903" ];then
156 excmd mkdir -p $MBTK_M1901_VERSION_DIR/LAPW
157 elif [ "$BUILD_TARGAT" == "asr1806" ];then
158 excmd mkdir -p $MBTK_M1901_VERSION_DIR/FACT
159 else
160 excmd mkdir -p $MBTK_M1901_VERSION_DIR/FLCN
161 fi
162}
163
164function generate_version_bin()
165{
166 if [ -d $VERSION_STR_CN ];then
167 rm -rf $VERSION_STR_CN
168 fi
169 if [ -d $VERSION_STR_EU ];then
170 rm -rf $VERSION_STR_EU
171 fi
172 if [ -d $VERSION_STR_LA ];then
173 rm -rf $VERSION_STR_LA
174 fi
175
176 cp -r $MBTK_M1901_VERSION $VERSION_STR_CN
177 cd $VERSION_STR_CN
178 rm "DEF(全擦).blf"
179 rm "EU(全擦).blf"
180 rm "LA(全擦).blf"
181 cd ..
182 zip -q -r $VERSION_STR_CN.zip $VERSION_STR_CN
183
184 cp -r $MBTK_M1901_VERSION $VERSION_STR_EU
185 cd $VERSION_STR_EU
186 rm "DEF(全擦).blf"
187 rm "CN(全擦).blf"
188 rm "LA(全擦).blf"
189 cd ..
190 zip -q -r $VERSION_STR_EU.zip $VERSION_STR_EU
191
192 cp -r $MBTK_M1901_VERSION $VERSION_STR_LA
193 cd $VERSION_STR_LA
194 rm "DEF(全擦).blf"
195 rm "EU(全擦).blf"
196 rm "CN(全擦).blf"
197 cd ..
198 zip -q -r $VERSION_STR_LA.zip $VERSION_STR_LA
199}
200
201function copy_bin_1806()
202{
203 excmd cp $OUT_DIR/../fota/$BIN_OTA_BLF $MBTK_M1901_VERSION_DIR/"$BUILD_TARGAT"_"$BUILD_FLAG"_QSPINAND_Trusted_SDTIM_LPDDR2_OTA_BLF
204 if [ -n "$1" -a "$1" == "mobiletek" ] ;then
205 copy $BIN_BLF.blf
206 echo $MBTK_M1901_VERSION | grep DEMO
207 if [ $? -eq 0 ];then
208 copy "$BIN_BLF"_MBTK.blf
209 fi
210 else
211 copy "$BIN_BLF"_MBTK.blf
212 fi
213
214 # 修改版本号
215 # T108v05.02b01_YX.00 or T108v05.02b01_YX.001
216 VERSION_STR_1=`echo $MBTK_M1901_VERSION | cut -d '.' -f 1`
217 VERSION_STR_2=`echo $MBTK_M1901_VERSION | cut -d '.' -f 2`
218 VERSION_STR_3=`echo $MBTK_M1901_VERSION | cut -d '.' -f 3`
219 if [[ $VERSION_STR_2 == *_* ]];then # 有 '_'
220 VERSION_STR_2_1=`echo $VERSION_STR_2 | cut -d '_' -f 1`
221 VERSION_STR_2_2=`echo $VERSION_STR_2 | cut -d '_' -f 2`
222 VERSION_STR_CN=$VERSION_STR_1."$VERSION_STR_2_1"CN_$VERSION_STR_2_2.$VERSION_STR_3
223 VERSION_STR_EU=$VERSION_STR_1."$VERSION_STR_2_1"EU_$VERSION_STR_2_2.$VERSION_STR_3
224 VERSION_STR_LA=$VERSION_STR_1."$VERSION_STR_2_1"LA_$VERSION_STR_2_2.$VERSION_STR_3
225 else
226 VERSION_STR_CN=$VERSION_STR_1."$VERSION_STR_2"CN.$VERSION_STR_3
227 VERSION_STR_EU=$VERSION_STR_1."$VERSION_STR_2"EU.$VERSION_STR_3
228 VERSION_STR_LA=$VERSION_STR_1."$VERSION_STR_2"LA.$VERSION_STR_3
229 fi
230
231# echo "CN : $VERSION_STR_CN"
232# echo "EU : $VERSION_STR_EU"
233# echo "LA : $VERSION_STR_LA"
234# echo "DEF : $MBTK_M1901_VERSION"
235
236 if [ -n "$1" -a "$1" == "mobiletek" ] ;then
237 date_str=`date "+%Y/%m/%d %H:%M:%S"`
238 asr_baseline=`cat $OUT_DIR/mversion`
239 echo $date_str
240 if [ "$BUILD_TARGAT" == "asr1903" ];then
241 # 支持4G、5G
242 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_CN -d $BUILD_PROJECT -e $CUSTOM_MODEL -f cn -g "$date_str" -h 19 -i 12 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_cn.bin
243 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_EU -d $BUILD_PROJECT -e $CUSTOM_MODEL -f eu -g "$date_str" -h 19 -i 12 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_eu.bin
244 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_LA -d $BUILD_PROJECT -e $CUSTOM_MODEL -f sa -g "$date_str" -h 19 -i 12 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_la.bin
245 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $MBTK_M1901_VERSION -d $BUILD_PROJECT -e $CUSTOM_MODEL -g "$date_str" -h 19 -i 12 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_def.bin
246 else
247 # 支持2G、3G、4G
248 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_CN -d $BUILD_PROJECT -e $CUSTOM_MODEL -f cn -g "$date_str" -h 15 -i 7 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_cn.bin
249 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_EU -d $BUILD_PROJECT -e $CUSTOM_MODEL -f eu -g "$date_str" -h 15 -i 7 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_eu.bin
250 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $VERSION_STR_LA -d $BUILD_PROJECT -e $CUSTOM_MODEL -f sa -g "$date_str" -h 15 -i 7 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_la.bin
251 [ -f mbtk/device_info_generate ] && mbtk/device_info_generate -a ab -b $MBTK_M1901_VERSION -d $BUILD_PROJECT -e $CUSTOM_MODEL -g "$date_str" -h 15 -i 7 -j $asr_baseline -o $MBTK_M1901_VERSION_DIR/dev_info_def.bin
252 fi
253
254 if [ -f $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf ];then
255 cp $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf $MBTK_M1901_VERSION_DIR/"CN(全擦)".blf
256 cp $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf $MBTK_M1901_VERSION_DIR/"EU(全擦)".blf
257 cp $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf $MBTK_M1901_VERSION_DIR/"LA(全擦)".blf
258 cp $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf $MBTK_M1901_VERSION_DIR/"DEF(全擦)".blf
259 rm $MBTK_M1901_VERSION_DIR/$BIN_BLF.blf
260
261 sed -i "s/dev_info.bin/dev_info_cn.bin/" $MBTK_M1901_VERSION_DIR/"CN(全擦)".blf
262 sed -i "s/dev_info.bin/dev_info_eu.bin/" $MBTK_M1901_VERSION_DIR/"EU(全擦)".blf
263 sed -i "s/dev_info.bin/dev_info_la.bin/" $MBTK_M1901_VERSION_DIR/"LA(全擦)".blf
264 sed -i "s/dev_info.bin/dev_info_def.bin/" $MBTK_M1901_VERSION_DIR/"DEF(全擦)".blf
265 fi
266 if [ -f $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf ];then
267 cp $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf $MBTK_M1901_VERSION_DIR/MBTK_CN.blf
268 cp $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf $MBTK_M1901_VERSION_DIR/MBTK_EU.blf
269 cp $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf $MBTK_M1901_VERSION_DIR/MBTK_LA.blf
270 cp $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf $MBTK_M1901_VERSION_DIR/MBTK_DEF.blf
271 rm $MBTK_M1901_VERSION_DIR/"$BIN_BLF"_MBTK.blf
272
273 sed -i "s/dev_info.bin/dev_info_cn.bin/" $MBTK_M1901_VERSION_DIR/MBTK_CN.blf
274 sed -i "s/dev_info.bin/dev_info_eu.bin/" $MBTK_M1901_VERSION_DIR/MBTK_EU.blf
275 sed -i "s/dev_info.bin/dev_info_la.bin/" $MBTK_M1901_VERSION_DIR/MBTK_LA.blf
276 sed -i "s/dev_info.bin/dev_info_def.bin/" $MBTK_M1901_VERSION_DIR/MBTK_DEF.blf
277 fi
278
279 copy "$BUILD_TARGAT"_CP_ReliableData_CMCC.bin
280 fi
281
282 copy "$BUILD_TARGAT"_AP_ReliableData.bin
283 copy "$BUILD_TARGAT"_TLoader_QSPINAND.bin
284 if [ "$BUILD_TARGAT" == "asr1903" ];then
285 excmd cp $OUT_DIR/LAPW/hotfix.bin $MBTK_M1901_VERSION_DIR/LAPW/
286 copy tim_lapw_qspinand.bin
287 copy tim_lapw_qspinand2.bin
288 copy "$BUILD_TARGAT"_TUpdater_QSPINAND.bin
289 copy "$BUILD_TARGAT"_BX2.bin
290 elif [ "$BUILD_TARGAT" == "asr1806" ];then
291 excmd cp $OUT_DIR/FACT/hotfix.bin $MBTK_M1901_VERSION_DIR/FACT/
292 copy tim_fact_qspinand.bin
293 copy tim_fact_qspinand2.bin
294 copy "$BUILD_TARGAT"_TUpdater_QSPINAND.bin
295 copy "$BUILD_TARGAT"_MSA.bin
296 else
297 excmd cp $OUT_DIR/FLCN/hotfix.bin $MBTK_M1901_VERSION_DIR/FLCN/
298 copy "$BUILD_TARGAT"_MSA.bin
299 fi
300 copy "$BUILD_TARGAT"_TLoader_QSPINAND_ProductBuild.bin
301
302 copy "$BUILD_TARGAT"_ARBEL.bin
303 copy "$BUILD_TARGAT"_RFPLUGIN.bin
304 copy openwrt-mmp-"$BUILD_TARGAT"-u-boot.bin
305 copy openwrt-mmp-"$BUILD_TARGAT"-zImage
306 copy openwrt-mmp-"$BUILD_TARGAT"-root.squashfs
307 copy openwrt-mmp-"$BUILD_TARGAT"-oem_data.ubi
308 copy DTim.Primary
309 copy DTim.PPsetting
310 copy DTim.PPsetting2
311 copy DTim.Recovery
312 copy mversion
313 copy SWDownloader.exe
314 if [ "$SEC_SUPPORT" == "Y" ];then
315 copy "$BUILD_TARGAT"_tos.bin
316 copy DDR_*
317 copy DKB_timheader.bin
318 fi
319 if [ -f marvell/swd/FALCON/logo.img ];then
320 cp marvell/swd/FALCON/logo.img $MBTK_M1901_VERSION_DIR
321 fi
322
323 excmd cp $OUT_DIR/Boerne_DIAG.mdb.txt $MBTK_M1901_MDB_DIR/AP_MDB.txt
324 excmd cp $OUT_DIR/MDB.txt $MBTK_M1901_MDB_DIR/CP_MDB.txt
325# excmd cp $OUT_DIR/vmlinux.bin $MBTK_M1901_MDB_DIR/vmlinux.bin
326
327 CUR_PWD=`pwd`
328 cd out
329
330 # 生成各地区的固件
331 if [ -n "$1" -a "$1" == "mobiletek" ] ;then
332 generate_version_bin
333 fi
334
335 zip -q -r $MBTK_M1901_VERSION.zip $MBTK_M1901_VERSION
336 cd $CUR_PWD
337}
338
339mk_dir
340if [ -n "$1" ];then
341 copy_bin_1806 $1
342else
343 copy_bin_1806
344fi
345