blob: 9d607d8cbe4962f66b19e55353e87a687c88aff7 [file] [log] [blame]
dongqing.li93ffff32022-07-25 10:38:31 +08001#!/bin/bash
2
3# =============================================================================
4# @module: BootLoader stable branch tools: checkout, pull, push ...
5# @author: Li Dongqing (dongqing.li@amlogic.com)
6# @License: Copyright (c) 2019 Amlogic, Inc. All rights reserved.
7# @Changes:
8# 1. 2022.05.25 v0.1 - Creat stable sub version update tools.
9# 2. 2022.07.13 v0.2 - Add option for s4 branch in bl2/core.
10# 3. 2022.09.18 v0.3 - Support submitting uboot.bin to Android dir.
11# =============================================================================
12
13#
14# Settings
15#
16
17#set -e
18
19# Set these ENV externally, cmd: export ENV=${ENV}
20if [[ -z "${STABLE_MAJOR_VERSION}" ]]; then
wenbo.wang4185a322023-04-28 22:04:11 +080021 STABLE_MAJOR_VERSION="3.5.0"
dongqing.li93ffff32022-07-25 10:38:31 +080022else
23 echo "External settings env: STABLE_MAJOR_VERSION=${STABLE_MAJOR_VERSION}"
24fi
25
26if [[ -z "${ANDROID_ROOT_DIR}" ]]; then
wenbo.wang67fe0402023-05-08 19:20:47 +080027 ANDROID_ROOT_DIR="/mnt/fileroot/wenbo.wang/Android/android_T"
dongqing.li93ffff32022-07-25 10:38:31 +080028else
29 echo "External settings env: ANDROID_ROOT_DIR=${ANDROID_ROOT_DIR}"
30fi
31
32if [[ -z "${ANDROID_TARGET_BRANCH}" ]]; then
wenbo.wang67fe0402023-05-08 19:20:47 +080033 ANDROID_TARGET_BRANCH="t-tv-dev"
dongqing.li93ffff32022-07-25 10:38:31 +080034else
35 echo "External settings env: ANDROID_TARGET_BRANCH=${ANDROID_TARGET_BRANCH}"
36fi
37
38# update, show. 1/s:stable; 2/t:trunk
39SWITCH_TARGET_BRANCH=0
40SHOW_STABLE_VERSION=0
41SHOW_LAST_COMMIT=0
42STABLE_OPTION_TYPE=0
43
44# modify, push
45MODIFY_STABLE_VERSION=0
46ADD_COMMIT_MESSAGE=0
47PUSH_TOPIC_COMMON=0
48
49# openlinux stable branch
50BL2_SC2_BRANCH="projects/openlinux/bl-sc2-${STABLE_MAJOR_VERSION}"
51BL2_S4_BRANCH="projects/openlinux/bl-s4-${STABLE_MAJOR_VERSION}"
wenbo.wang4185a322023-04-28 22:04:11 +080052BL2_S5_BRANCH="projects/openlinux/bl-s5-${STABLE_MAJOR_VERSION}"
dongqing.li93ffff32022-07-25 10:38:31 +080053
54# push uboot.bin to android dir
wenbo.wang4185a322023-04-28 22:04:11 +080055declare -a OPENLINUX_BOARD_TYPE=("ohm" "oppen" "tyson")
56declare -a OPENLINUX_BOARD_BRANCH=("${BL2_SC2_BRANCH}" "${BL2_S4_BRANCH}" "${BL2_S5_BRANCH}")
57declare -a OPENLINUX_BOARD_CONFIG=("sc2_ah212" "s4_ap222" "s5_ax201")
dongqing.li93ffff32022-07-25 10:38:31 +080058ANDROID_DEV_DIR="device/amlogic"
59ANDROID_DIR_OHM="${ANDROID_ROOT_DIR}/${ANDROID_DEV_DIR}/${OPENLINUX_BOARD_TYPE[0]}"
60ANDROID_DIR_OPPEN="${ANDROID_ROOT_DIR}/${ANDROID_DEV_DIR}/${OPENLINUX_BOARD_TYPE[1]}"
wenbo.wang4185a322023-04-28 22:04:11 +080061ANDROID_DIR_TYSON="${ANDROID_ROOT_DIR}/${ANDROID_DEV_DIR}/${OPENLINUX_BOARD_TYPE[2]}"
dongqing.li93ffff32022-07-25 10:38:31 +080062
wenbo.wang4185a322023-04-28 22:04:11 +080063declare -a ANDROID_DIR_LIST=("${ANDROID_DIR_OHM}" "${ANDROID_DIR_OPPEN}" "${ANDROID_DIR_TYSON}")
dongqing.li93ffff32022-07-25 10:38:31 +080064
65#
66# Array
67#
wenbo.wang4185a322023-04-28 22:04:11 +080068declare -a BLX_NAME=( \
69 "bl2 " \
70 "bl2e " \
71 "bl2x " \
72 "bl30 " \
73 "rtos_sdk " \
74 "bl31_1.3 " \
75 "bl32_3.8 " \
76 "bl32_3.18 " \
77 "bl33_v2019 " \
78 "fip ")
79
80declare -a RTOS_NAME=( \
81 "rtos_arch" \
82 "rtos_boards" \
83 "rtos_build" \
84 "rtos_driver_aocpu" \
85 "rtos_freertos" \
86 "rtos_libc" \
87 "rtos_products_aocpu" \
88 "rtos_scripts" \
89 "rtos_soc" )
dongqing.li93ffff32022-07-25 10:38:31 +080090
91declare -a BLX_PATH=( \
92 "bl2/core" \
93 "bl2/ree" \
94 "bl2/tee" \
95 "bl30/src_ao" \
wenbo.wang4185a322023-04-28 22:04:11 +080096 "bl30/rtos_sdk" \
wenbo.wang0eadc462023-06-13 09:46:53 +080097 "bl31_1.3/src" \
98 "bl32_3.8/src" \
99 "bl32_3.18/src" \
dongqing.li93ffff32022-07-25 10:38:31 +0800100 "bl33/v2019" \
wenbo.wang4185a322023-04-28 22:04:11 +0800101 "fip" )
102
103declare -a RTOS_PATH=( \
104 "bl30/rtos_sdk/arch/riscv" \
105 "bl30/rtos_sdk/boards/riscv" \
106 "bl30/rtos_sdk/build_system" \
107 "bl30/rtos_sdk/drivers_aocpu" \
108 "bl30/rtos_sdk/kernel/freertos" \
109 "bl30/rtos_sdk/lib/libc" \
110 "bl30/rtos_sdk/products/aocpu" \
111 "bl30/rtos_sdk/scripts" \
112 "bl30/rtos_sdk/soc/riscv" )
dongqing.li93ffff32022-07-25 10:38:31 +0800113
114declare -a BLX_COMMIT=( \
115 " " \
116 " " \
117 " " \
118 " " \
119 " " \
120 " " \
121 " " \
wenbo.wang4185a322023-04-28 22:04:11 +0800122 " " \
123 " " \
dongqing.li93ffff32022-07-25 10:38:31 +0800124 " ")
125
126declare -a BLX_REMOTE=( \
127 "firmware" \
128 "firmware" \
129 "firmware" \
130 "firmware" \
wenbo.wang4185a322023-04-28 22:04:11 +0800131 "origin" \
132 "firmware" \
dongqing.li93ffff32022-07-25 10:38:31 +0800133 "firmware" \
134 "firmware" \
135 "uboot" \
136 "fip")
137
138declare -a BLX_STABLE_BRANCH=( \
139 "projects/openlinux/bl-sc2-$STABLE_MAJOR_VERSION" \
140 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
141 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
142 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
143 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
144 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
145 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
146 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
wenbo.wang4185a322023-04-28 22:04:11 +0800147 "projects/openlinux/bl-$STABLE_MAJOR_VERSION" \
dongqing.li93ffff32022-07-25 10:38:31 +0800148 "projects/openlinux/bl-$STABLE_MAJOR_VERSION")
149
150declare -a BLX_TRUNK_BRANCH=( \
151 "projects/sc2" \
152 "projects/amlogic-dev" \
153 "projects/amlogic-dev" \
154 "projects/amlogic-dev" \
wenbo.wang4185a322023-04-28 22:04:11 +0800155 "projects/amlogic-dev" \
dongqing.li93ffff32022-07-25 10:38:31 +0800156 "amlogic-dev-1.3" \
157 "amlogic-dev-3.8.0" \
wenbo.wang4185a322023-04-28 22:04:11 +0800158 "amlogic-dev-3.18.0" \
dongqing.li93ffff32022-07-25 10:38:31 +0800159 "amlogic-dev-2019" \
160 "amlogic-dev")
161
162declare -a STABLE_VER_FILE=( \
163 "Makefile.gcc" \
164 "Makefile.gcc" \
165 "Makefile.gcc" \
166 "demos/amlogic/makedefs" \
wenbo.wang4185a322023-04-28 22:04:11 +0800167 "build_system/Makefile" \
dongqing.li93ffff32022-07-25 10:38:31 +0800168 "Makefile" \
169 "core/arch/arm/plat-meson/conf.mk" \
wenbo.wang4185a322023-04-28 22:04:11 +0800170 "core/arch/arm/plat-meson/conf.mk" \
dongqing.li93ffff32022-07-25 10:38:31 +0800171 "Makefile" \
172 "NULL")
173
wenbo.wang4185a322023-04-28 22:04:11 +0800174declare -a STABLE_VER_INFO=(\
175 " " \
176 " " \
177 " " \
178 " " \
179 " " \
180 " " \
181 " " \
182 " " \
183 " " \
dongqing.li93ffff32022-07-25 10:38:31 +0800184 " ")
dongqing.li93ffff32022-07-25 10:38:31 +0800185declare -a STABLE_VER_TOPIC=( \
186 "bl2-sc2" \
187 "bl2e" \
188 "bl2x" \
189 "bl30" \
wenbo.wang4185a322023-04-28 22:04:11 +0800190 "rtos_sdk" \
dongqing.li93ffff32022-07-25 10:38:31 +0800191 "bl31" \
192 "bl32" \
wenbo.wang4185a322023-04-28 22:04:11 +0800193 "bl32" \
dongqing.li93ffff32022-07-25 10:38:31 +0800194 "bl33" \
195 "NULL")
196
197#
198# function
199#
200function go_proj() {
201 cd $rootdir
202
203 output="./pxp_output_$1/"
204
205 if [ -d ${output} ] ; then
206 rm -fr ${output}
207 fi
208 mkdir ${output}
209
210 echo "go proj [ $1 ] !!!!!!!!!!!"
211 echo "./mk $1_pxp --update-bl2 --update-bl2e --update-bl2x --update-bl31"
212 echo ""
213 sleep 2
214
215 ./mk $1_pxp --update-bl2 --update-bl2e --update-bl2x --update-bl31
216
217 if [ -f "./build/u-boot.bin" ]; then
218 echo "run mk ok, found ./build/u-boot.bin"
219 cp -f ./build/u-boot.bin ${output}
220 else
221 echo "run mk error, not find ./build/u-boot.bin"
222 fi
223
224 cp -f ./bl2/core/bl2.bin.sto ${output}bl2.bin
225 cp -f ./bl2/ree/bl2e.bin ${output}bl2e.bin
226 cp -f ./bl2/tee/bl2x.bin ${output}bl2x.bin
227
228 cp -f ./bl31_1.3/src/bl31.bin ${output}bl31.bin
229 cp -f ./fip/_tmp/device-fip.bin ${output}device-fip.bin
230 cp -f ./bl33/v2019/build/u-boot.bin ${output}bl33.bin
231
232 dd if=${output}bl2.bin of=${output}bl2-u1.bin bs=1 count=86016
233 dd if=${output}bl2.bin of=${output}bl2-u2.bin bs=1 skip=86016
234
235 ./fip/c1/aml_encrypt_c1 --bin2hex --input ${output}bl2-u1.bin --usize 32 --bsize 262144 --output ${output}bl2-sram-u1.hex
236 ./fip/c1/aml_encrypt_c1 --bin2hex --input ${output}bl2-u2.bin --usize 32 --bsize 262144 --output ${output}bl2-sram-u2.hex
237
238 rm -f ${output}bl2-u*.bin
239 tar -czf pxp_output_$1.tar.gz ${output}
240
241 echo "-------------------------------------------------------------------------"
242 echo "all patterns for [$1] Z1 are ready in ${output}"
243 echo "-------------------------------------------------------------------------"
244 ls -la ${output}
245 echo
246}
247
248function choose_whether_to_continue() {
249 read -r -p "$1 [y/n] " input
250
251 case $input in
252 [yY][eE][sS]|[yY])
253 echo "ok, run continue ..."
254 ;;
255 [nN][oO]|[nN])
256 echo "ok, exit."
257 exit 1
258 ;;
259 *)
260 echo "Invalid input..."
261 exit 1
262 ;;
263 esac
264}
265
266function err_exit()
267{
268 echo "Error: $1"
269 exit 1
270}
271
272function sync_code() {
273 #echo "begin sync branch: $1/$2"
274 if [ -z $2 ]; then
275 err_exit "branch($2) error !"
276 fi
277 git reset --hard
278 cnt=`git branch |grep test1 -c`
279 if [ $cnt -eq 0 ]; then
280 git checkout -b test1
281 else
282 git checkout test1
283 fi
284 cnt=`git branch |grep $2 -c`
285 if [ ! $cnt -eq 0 ]; then
286 git branch -D $2 > /dev/null
287 fi
288 git checkout -t $1/$2 || err_exit "git checkout -t $1/$2 faild !"
289 git fetch --all
290 git reset --hard $1/$2
291 git pull
292 git branch -D test1
293 echo
294}
295
296function show_setting_commit() {
297 echo
298 echo "git_show_setting_commit:"
299 echo "==============================="
300 for((i=0;i<${#BLX_NAME[@]};i++)); do
301 echo "# ${BLX_NAME[$i]} : ${BLX_COMMIT[$i]}"
302 done
303 echo "==============================="
304 echo
305}
306
307function show_setting_branch() {
308 echo
309 echo "show_setting_branch:"
310 echo "==============================="
311 for((i=0;i<${#BLX_NAME[@]};i++)); do
312 echo "# ${BLX_NAME[$i]} : ${BLX_BRANCH[$i]}"
313 done
314 echo "==============================="
315 echo
316}
317
318function show_stable_branch_version() {
319 echo
320 echo "show_stable_branch_version:"
321 echo "==============================="
322
323 #for i in $(seq 0 ${BLX_NAME[@]}); do
324 for((i=0;i<${#BLX_NAME[@]}-1;i++)); do
325 if [ -d $rootdir/${BLX_PATH[$i]} ]; then
326 cd $rootdir/${BLX_PATH[$i]}
327 # stable branch version format: bl-x.y.z;
328 # x is major version, y is minor version, z is patch version
329 if [ "${STABLE_VER_FILE[$i]}" != "NULL" ]; then
330 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[$i]} |grep '=' |awk '{print $3}'`
331 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[$i]} |grep '=' |awk '{print $3}'`
332 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[$i]} |grep '=' |awk '{print $3}'`
333 STABLE_VER_INFO[$i]="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
334 fi
335
336 CURRENT_BRANCH=`git branch |grep "*"| awk '{print $2}'`
337 if [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BLX_STABLE_BRANCH[0]}" ];then
338 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
339 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
340 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
341 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
342 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
343 echo "# bl2-s4 : ${STABLE_VER_EXT}"
wenbo.wang4185a322023-04-28 22:04:11 +0800344
345 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
346 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
347 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
348 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
349 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
350 echo "# bl2-s5 : ${STABLE_VER_EXT}"
351
dongqing.li93ffff32022-07-25 10:38:31 +0800352 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
353
354 elif [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BL2_S4_BRANCH}" ];then
355 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
356 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
357 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
358 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
359 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
360 echo "# bl2-sc2 : ${STABLE_VER_EXT}"
wenbo.wang4185a322023-04-28 22:04:11 +0800361
362 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
363 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
364 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
365 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
366 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
367 echo "# bl2-s5 : ${STABLE_VER_EXT}"
368
dongqing.li93ffff32022-07-25 10:38:31 +0800369 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
wenbo.wang4185a322023-04-28 22:04:11 +0800370
371 elif [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BL2_S5_BRANCH}" ];then
372 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
373 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
374 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
375 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
376 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
377 echo "# bl2-sc2 : ${STABLE_VER_EXT}"
378
379 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
380 VER_MAJOR=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
381 VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
382 VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[0]} |grep '=' |awk '{print $3}'`
383 STABLE_VER_EXT="bl-${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
384 echo "# bl2-s4 : ${STABLE_VER_EXT}"
385
386 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
387
dongqing.li93ffff32022-07-25 10:38:31 +0800388 fi
389 fi
390 done
391
392 for((i=0;i<${#BLX_NAME[@]}-1;i++)); do
393 echo "# ${BLX_NAME[$i]} : ${STABLE_VER_INFO[$i]}"
394 done
395 echo "==============================="
396 echo
397}
398
wenbo.wang4185a322023-04-28 22:04:11 +0800399function modify_stable_branch_version_info() {
400 local index=$1
401 # stable branch version format: bl-x.y.z;
402 # x is major version, y is minor version, z is patch version
403 if [ "${STABLE_VER_FILE[${index}]}" != "NULL" ]; then
404 ######################### 1. modify version ############################
405 # major
406 CURRENT_VER_MAJOG=`grep 'MAJOR_VERSION ' ./${STABLE_VER_FILE[${index}]} |grep '=' |awk '{print $3}'`
407 MODIFY_VER_MAJOR=`echo $MODIFY_STABLE_VERSION | cut -d '.' -f 1`
408 sed -i '/MAJOR_VERSION /s/'$CURRENT_VER_MAJOG'/'$MODIFY_VER_MAJOR'/g' ${STABLE_VER_FILE[${index}]}
409
410 # minor
411 CURRENT_VER_MINOR=`grep 'MINOR_VERSION ' ./${STABLE_VER_FILE[${index}]} |grep '=' |awk '{print $3}'`
412 MODIFY_VER_MINOR=`echo $MODIFY_STABLE_VERSION | cut -d '.' -f 2`
413 sed -i '/MINOR_VERSION /s/'$CURRENT_VER_MINOR'/'$MODIFY_VER_MINOR'/g' ${STABLE_VER_FILE[${index}]}
414
415 # patch
416 CURRENT_VER_PATCH=`grep 'PATCH_VERSION ' ./${STABLE_VER_FILE[${index}]} |grep '=' |awk '{print $3}'`
417 MODIFY_VER_PATCH=`echo $MODIFY_STABLE_VERSION | cut -d '.' -f 3`
418 sed -i '/PATCH_VERSION /s/'$CURRENT_VER_PATCH'/'$MODIFY_VER_PATCH'/g' ${STABLE_VER_FILE[${index}]}
419
420 ######################### 1. modify version ############################
421 ######################### 2. git add file ############################
422 git add ${STABLE_VER_FILE[${index}]}
423
424 CHECK_COMMIT_FORMAT=`echo $ADD_COMMIT_MESSAGE | grep -c '-'`
425 if [ $CHECK_COMMIT_FORMAT -eq 1 ]; then
426 ######################### 3. git commit -m ############################
427 git commit --sign -m "
428 ${BLX_PATH[${index}]}: stable branch update version: bl-${MODIFY_VER_MAJOR}.${MODIFY_VER_MINOR}.${MODIFY_VER_PATCH} [1/1]
429
430 PD#${ADD_COMMIT_MESSAGE}
431
432 Problem:
433 bootloader stable branch(openlinux/bl-${STABLE_MAJOR_VERSION}) update
434
435 Solution:
436 add version to build message: bl-${MODIFY_VER_MAJOR}.${MODIFY_VER_MINOR}.${MODIFY_VER_PATCH}
437
438 Verify:
439 ohm/oppen/tyson"
440 fi
441 fi
442}
443
dongqing.li93ffff32022-07-25 10:38:31 +0800444function modify_stable_branch_version() {
445 echo
446 echo "modify_stable_branch_version to: bl-$MODIFY_STABLE_VERSION"
447 #for i in $(seq 0 ${BLX_NAME[@]}); do
448 for((i=0;i<${#BLX_NAME[@]}-1;i++)); do
449 if [ -d $rootdir/${BLX_PATH[$i]} ]; then
450 cd $rootdir/${BLX_PATH[$i]}
wenbo.wang4185a322023-04-28 22:04:11 +0800451 modify_stable_branch_version_info $i
452
dongqing.li93ffff32022-07-25 10:38:31 +0800453 fi
454 done
455
456}
457
458function push_stable_branch_version() {
459 echo
460 echo "push_stable_branch_version:"
461 #for i in $(seq 0 ${BLX_NAME[@]}); do
462 for((i=0;i<${#BLX_NAME[@]}-1;i++)); do
463 if [ -d $rootdir/${BLX_PATH[$i]} ]; then
wenbo.wang4185a322023-04-28 22:04:11 +0800464 if [ ${BLX_NAME[$i]} == "rtos_sdk" ]; then
465 cd $rootdir/${RTOS_PATH[2]}
466 else
467 cd $rootdir/${BLX_PATH[$i]}
468 fi
dongqing.li93ffff32022-07-25 10:38:31 +0800469
470 #check bl2/core is at sc2 branch
471 CURRENT_BRANCH=`git branch |grep "*"| awk '{print $2}'`
472 if [ $i -eq 0 -a "${CURRENT_BRANCH}" != "${BLX_STABLE_BRANCH[0]}" ];then
473 echo "bl2 core is not at sc2 branch. please switch branch first !"
474 echo ""
475 continue
476 fi
477
478 # stable branch version format: bl-x.y.z;
479 # x is major version, y is minor version, z is patch version
480 if [ "${STABLE_VER_TOPIC[$i]}" != "NULL" ]; then
481 echo ""
482 echo "PUSH ${STABLE_VER_TOPIC[$i]} ==>>"
483 git push review HEAD:refs/for/${BLX_STABLE_BRANCH[$i]}%topic=${PUSH_TOPIC_COMMON}-${STABLE_VER_TOPIC[$i]}
484 echo ""
wenbo.wang4185a322023-04-28 22:04:11 +0800485 if [ "${STABLE_VER_TOPIC[$i]}" == "bl2-sc2" ];then
dongqing.li93ffff32022-07-25 10:38:31 +0800486 echo ""
487 echo "PUSH bl2-s4 ==>>"
488 BL2_SC2_LAST_COMMIT=`git log --pretty=format:"%h" | head -1 | awk '{print $1}'`
489 git checkout ${BL2_S4_BRANCH} > /dev/null
490 git cherry-pick ${BL2_SC2_LAST_COMMIT}
491 git push review HEAD:refs/for/${BL2_S4_BRANCH}%topic=${PUSH_TOPIC_COMMON}-bl2-s4
492 git checkout ${BLX_STABLE_BRANCH[$i]} > /dev/null
493 echo ""
wenbo.wang4185a322023-04-28 22:04:11 +0800494
495 echo ""
496 echo "PUSH bl2-s5 ==>>"
497 BL2_SC2_LAST_COMMIT=`git log --pretty=format:"%h" | head -1 | awk '{print $1}'`
498 git checkout ${BL2_S5_BRANCH} > /dev/null
499 git cherry-pick ${BL2_SC2_LAST_COMMIT}
500 git push review HEAD:refs/for/${BL2_S5_BRANCH}%topic=${PUSH_TOPIC_COMMON}-bl2-s5
501 git checkout ${BLX_STABLE_BRANCH[$i]} > /dev/null
502 echo ""
dongqing.li93ffff32022-07-25 10:38:31 +0800503 fi
504 fi
505 fi
506 done
507
508 echo
509}
510
511function show_current_branch_info() {
512 echo
513 echo "show_current_branch_commit_info:"
514 echo "==============================="
515 #for i in $(seq 0 ${BLX_NAME[@]}); do
516 for((i=0;i<${#BLX_NAME[@]};i++)); do
517 if [ -d $rootdir/${BLX_PATH[$i]} ]; then
wenbo.wang4185a322023-04-28 22:04:11 +0800518 if [ ${BLX_NAME[$i]} == "rtos_sdk" ]; then
519 cd $rootdir/${RTOS_PATH[2]}
520 else
521 cd $rootdir/${BLX_PATH[$i]}
522 fi
523
dongqing.li93ffff32022-07-25 10:38:31 +0800524 commit=`git rev-parse HEAD`
525 # compare setting commit with current commit
526 if [ ${#BLX_COMMIT[$i]} -gt 20 ]; then
527 if [ "${BLX_COMMIT[$i]}" == "$commit" ]; then
528 echo "[eq] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --oneline -1`"
529 else
530 echo "[no] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --oneline -1`"
531 fi
532 else
533 #echo "= ${BLX_NAME[$i]}: `git branch --show-current && git log --oneline -1 | tr -d '\n'`"
534 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
535 CURRENT_BRANCH=`git branch |grep "*"| awk '{print $2}'`
536 if [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BLX_STABLE_BRANCH[0]}" ];then
537 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
538 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
wenbo.wang4185a322023-04-28 22:04:11 +0800539
540 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
541 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
542
dongqing.li93ffff32022-07-25 10:38:31 +0800543 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
544 elif [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BL2_S4_BRANCH}" ];then
545 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
546 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
wenbo.wang4185a322023-04-28 22:04:11 +0800547
548 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
549 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
550
dongqing.li93ffff32022-07-25 10:38:31 +0800551 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
wenbo.wang4185a322023-04-28 22:04:11 +0800552 elif [ $i -eq 0 -a "${CURRENT_BRANCH}" = "${BL2_S5_BRANCH}" ];then
553 git checkout ${BLX_STABLE_BRANCH[0]} > /dev/null 2>&1
554 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
555
556 git checkout ${BL2_S4_BRANCH} > /dev/null 2>&1
557 echo "[--] ${BLX_NAME[$i]}: [`git branch --show-current`] `git log --abbrev=8 --oneline -1 `"
558
559 git checkout ${BL2_S5_BRANCH} > /dev/null 2>&1
dongqing.li93ffff32022-07-25 10:38:31 +0800560 fi
561 fi
562 else
563 echo "[--] ${BLX_NAME[$i]}: ------"
564 fi
565 done
566 echo "==============================="
567 echo
568}
569
570function switch_to_target_branch() {
571 echo
572 if [ $SWITCH_TARGET_BRANCH -eq 1 ] ; then
573 echo "branch: trunk"
574 BLX_BRANCH=(${BLX_TRUNK_BRANCH[*]})
575 elif [ $SWITCH_TARGET_BRANCH -eq 2 ]; then
576 echo "branch: stable"
577 BLX_BRANCH=(${BLX_STABLE_BRANCH[*]})
578 else
579 exit
580 fi
581 show_setting_branch
582
583 echo "switch_to_target_branch:"
584 for((i=0;i<${#BLX_NAME[@]}-1;i++)); do
585 if [ -d $rootdir/${BLX_PATH[$i]} ]; then
586 echo "path: ${BLX_PATH[$i]}"
587 cd $rootdir/${BLX_PATH[$i]}
588 sync_code ${BLX_REMOTE[$i]} ${BLX_BRANCH[$i]}
589 if [ ${#BLX_COMMIT[$i]} -gt 20 ]; then
590 git reset --hard ${BLX_COMMIT[$i]}
591 fi
592 else
593 echo "error, path($rootdir/${BLX_PATH[$i]}) not exist!"
594 fi
595 done
596
597 echo
598}
599
600function modify_stable_sub_version() {
601 echo
602 echo "# push_uboot_img_to_android_repo"
603 # 1. switch to target branch
604 if [ $SWITCH_TARGET_BRANCH -ne 0 ]; then
605 switch_to_target_branch
606 fi
607
608 # 2. show current branch branch and commit
609 if [ $SHOW_LAST_COMMIT -eq 1 ]; then
610 show_current_branch_info
611 fi
612
613 # 3. show stable branch last version
614 if [ $SHOW_STABLE_VERSION -eq 1 ]; then
615 show_stable_branch_version
616 fi
617
618 # 4. modify stable branch last version
619 CHECK_VERSION_FORMAT=`echo $MODIFY_STABLE_VERSION | awk -F'.' '{print NF-1}'`
620 if [ $CHECK_VERSION_FORMAT -eq 2 ]; then
621 modify_stable_branch_version
622 show_stable_branch_version
623 fi
wenbo.wang4185a322023-04-28 22:04:11 +0800624
dongqing.li93ffff32022-07-25 10:38:31 +0800625 # 5. push stable branch last version
626 if [ "$PUSH_TOPIC_COMMON" != "0" ]; then
627 push_stable_branch_version
628 show_current_branch_info
629 fi
630}
631
632function compile_stable_uboot_bin() {
633
634 for((i=0;i<${#OPENLINUX_BOARD_TYPE[@]};i++)); do
635 echo
636 echo "<$i.${OPENLINUX_BOARD_TYPE[$i]}>############################### push_uboot_img_to_android_repo."
637
638 echo
639 echo "#1. check android dev path"
640 if [ -d ${ANDROID_DIR_LIST[$i]} ];then
641 cd ${ANDROID_DIR_LIST[$i]}
642 git reset --hard HEAD^
643 git clean -df
644 git fetch --all && git reset --hard && git pull
645 cd -
646 else
647 err_exit "Android dir is not exist! (${ANDROID_DIR_LIST[$i]})"
648 fi
649
650 if [ -f "./build-${OPENLINUX_BOARD_TYPE[i]}-${PUSH_TOPIC_COMMON}/u-boot.bin.signed" ]; then
651
652 echo
653 echo "# 2/3. build bootloader manual already, copy it directly"
654 cp -fv ./build-${OPENLINUX_BOARD_TYPE[i]}-${PUSH_TOPIC_COMMON}/u-boot.bin.signed ${ANDROID_DIR_LIST[$i]}/bootloader.img
655 cp -fv ./build-${OPENLINUX_BOARD_TYPE[i]}-${PUSH_TOPIC_COMMON}/u-boot.bin.usb.signed ${ANDROID_DIR_LIST[$i]}/upgrade/
656 cp -fv ./build-${OPENLINUX_BOARD_TYPE[i]}-${PUSH_TOPIC_COMMON}/u-boot.bin.sd.bin.signed ${ANDROID_DIR_LIST[$i]}/upgrade
657
658 else
659 echo
660 echo "# 2. build booloader image"
661 cd bl2/core && git checkout ${OPENLINUX_BOARD_BRANCH[$i]} || err_exit "cd bl2/core faild !"
662 cd -
663 runcmd="./mk ${OPENLINUX_BOARD_CONFIG[i]} --update-bl2 --update-bl2e --update-bl2x --update-bl31 --update-bl32 --avb2 --vab"
664 echo "[run cmd]: ${runcmd}"
665 ${runcmd} || err_exit "./mk ${OPENLINUX_BOARD_CONFIG[i]} faild !"
666 if [ -f "./build/u-boot.bin.signed" ];then
667 echo "\n build booloader(${OPENLINUX_BOARD_TYPE[$i]}) SUCCESS."
668 else
669 err_exit "build booloader(${OPENLINUX_BOARD_TYPE[$i]}) FAILED."
670 fi
671
672 echo
673 echo "# 3. copy booloader img to android dir"
674 cp -fv ./build/u-boot.bin.signed ${ANDROID_DIR_LIST[$i]}/bootloader.img
675 cp -fv ./build/u-boot.bin.usb.signed ${ANDROID_DIR_LIST[$i]}/upgrade/
676 cp -fv ./build/u-boot.bin.sd.bin.signed ${ANDROID_DIR_LIST[$i]}/upgrade/
677 fi
678
679 echo
680 echo "# 4. add commit message"
681 cd ${ANDROID_DIR_LIST[$i]}
682 if [ ! -f "${ANDROID_DIR_LIST[$i]}/bootloader.img" ]; then
683 err_exit " copy bootloader img error, exit."
684 fi
685 git add -u
686git commit --sign -m "
687${OPENLINUX_BOARD_TYPE[$i]}: bootloader stable branch bin for ${PUSH_TOPIC_COMMON} [1/1]
688
689PD#${ADD_COMMIT_MESSAGE}
690
691Problem:
692bootloader stable branch(openlinux/bl-${STABLE_MAJOR_VERSION}) update
693
694Solution:
695add version to build message: ${PUSH_TOPIC_COMMON}
696
697Verify:
698local ${OPENLINUX_BOARD_TYPE[$i]}"
699
700 echo
701 echo "# 5. push booloader img to device/amlogic"
702 git push review HEAD:refs/for/${ANDROID_TARGET_BRANCH}%topic=BL${STABLE_MAJOR_VERSION} || err_exit " push bootloader img error."
703 cd -
704 echo "<$i.${OPENLINUX_BOARD_TYPE[$i]}># done."
705 echo
706 done
707}
708
709show_help()
710{
711 echo -e "\e[1;35m [usage] V0.3 2022.09.18\e[0m"
712 echo " $0 -[o:/s/t/c/v/m:/a:/p/j:/h]"
713 echo ""
714 echo -e "\e[1;35m [option] \e[0m"
715 echo " -o : option type. 1:modify stable sub version; 2:compile stable uboot.bin"
716 echo " -s : switch to stable branch, sync code."
717 echo " -t : switch to trunk branch, sync code."
718 echo " -c : print current branch last commit."
719 echo " -v : print stable branch last version."
720 echo " -m : modify stable branch last version x.y.z, eg: -m 3.4.5"
721 echo " -a : add version change and commit message, eg: -a SWPL-83088"
722 echo " -p : push stable branch with topic info. eg: -p BL3.4.4-20220620"
723 echo " -j : set stable branch major version. eg: -j 3.4.0"
724 echo " -h : show help"
725 echo ""
726 echo -e "\e[1;35m [external ENV] \e[0m"
727 echo " Set these ENV externally(not necessary), cmd: export ENV=\${ENV}"
728 echo " STABLE_MAJOR_VERSION (default:${STABLE_MAJOR_VERSION})"
729 echo " ANDROID_ROOT_DIR (default:${ANDROID_ROOT_DIR})"
730 echo " ANDROID_TARGET_BRANCH (default:${ANDROID_TARGET_BRANCH})"
731 echo ""
732 echo -e "\e[1;35m [example]\e[0m"
733 echo " (1) modify stable sub version, and push to stable"
734 echo " $0 -o 1 -m 3.4.9 -a SWPL-85641 -p BL3.4.9-20220912"
735 echo ""
736 echo " (2) compile stable uboot.bin, and push to android"
737 echo " $0 -o 2 -m 3.4.9 -a SWPL-85641 -p BL3.4.9-20220912"
738 echo ""
739 echo " (3) manual compile stable uboot.bin (sc2_ah212 / s4_ap222)"
740 echo " ./mk sc2_ah212 --update-bl2 --update-bl2e --update-bl2x --update-bl31 --update-bl32 --avb2 --vab"
741 echo ""
742 exit 1
743}
744
745function parser() {
746
747 if [ -z $1 ]; then
748 show_help
749 return
750 fi
751
752 while getopts sStThcCvVm:M:o:O:p:P:a:A:j:J:hH opt; do
753 case ${opt} in
754 o|O)
755 STABLE_OPTION_TYPE=${OPTARG}
756 ;;
757 s|S)
758 SWITCH_TARGET_BRANCH=2
759 ;;
760 t|T)
761 SWITCH_TARGET_BRANCH=1
762 ;;
763 c|C)
764 SHOW_LAST_COMMIT=1
765 ;;
766 v|V)
767 SHOW_STABLE_VERSION=1
768 ;;
769 m|M)
770 MODIFY_STABLE_VERSION=${OPTARG}
771 ;;
772 a|A)
773 ADD_COMMIT_MESSAGE=${OPTARG}
774 ;;
775 j|J)
776 STABLE_MAJOR_VERSION=${OPTARG}
777 ;;
778 p|P)
779 PUSH_TOPIC_COMMON=${OPTARG}
780 ;;
781 h|H)
782 show_help
783 ;;
784 *)
785 show_help
786 ;;
787 esac
788 done
789}
790
791
792function main() {
793 if [ -f "build_bl2.sh" ]; then
794 rootdir=`pwd -P`/../
795 fi
796 if [ -d "fip" ]; then
797 rootdir=`pwd -P`
798 fi
799
800 echo
801 echo "Run start: $rootdir "
802 echo
803
804 parser $@
805
806 # check option type
807 if [ "$STABLE_OPTION_TYPE" = "0" ]; then
808 show_help
809 elif [ "$STABLE_OPTION_TYPE" = "1" ]; then
810 modify_stable_sub_version
811 elif [ "$STABLE_OPTION_TYPE" = "2" ]; then
812 compile_stable_uboot_bin
813 fi
814
815 echo
816 echo "Run finish."
817 echo
818}
819
820#
821# start here.
822#
823main $@