blob: 301a0d585e4e14dc115bb692e3462ad594a7be22 [file] [log] [blame]
Xiaobo Gu059502e2017-01-12 21:20:39 +08001#!/bin/bash
2#
3# author: xiaobo.gu@amlogic.com
4# 2016.09.28
5# 2016.12.01-2016.12.20 Update for bootloader repo
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +08006# 2017.05.20-2017.05.26 Update for txlx and ATF1.3
Xiaobo Gu059502e2017-01-12 21:20:39 +08007
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +08008# include compile check script
9source fip/check_compile.sh
xiaobo gue6c46862018-01-10 18:58:09 +080010source fip/variables.sh
11source fip/lib.sh
12source fip/build_bl2.sh
13source fip/build_bl30.sh
14source fip/build_bl31.sh
15source fip/build_bl32.sh
16source fip/build_bl33.sh
17source fip/build_bl40.sh
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080018
Bo Lv78837da2020-12-16 04:13:04 -050019function parse_bl33_global_config() {
20 local oldifs="$IFS"
21 IFS=$'\n'
22
23 BL33_GLOBAL_CONFIG=
24 for line in `cat ${SOURCE_FILE}`; do
25 # add any global configs which define in BL33 and need
26 # to used under bl2/bl2x/bl2e/bl31/....
27 if [[ "${line}" == "CONFIG_PXP_"* ]]; then
28 tmp=${line%=*} # delete =y
29 BL33_GLOBAL_CONFIG="${BL33_GLOBAL_CONFIG}"" -D""${tmp}"
30 fi
31 done
32 export BL33_GLOBAL_CONFIG
33 echo "==== BL33 GLOBAL CONFIG: ${BL33_GLOBAL_CONFIG} ==="
34 IFS="$oldifs"
35}
Xiaobo Gu059502e2017-01-12 21:20:39 +080036
xiaobo gue6c46862018-01-10 18:58:09 +080037function init_variable_early() {
38 # source uboot pre-build configs
39 if [ ! -e ${SOURCE_FILE} ]; then
40 echo "${SOURCE_FILE} doesn't exist!"
41 cd ${MAIN_FOLDER}
42 exit -1
43 else
44 source ${SOURCE_FILE} &> /dev/null # ignore warning/error
45 fi
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080046
xiaobo gue6c46862018-01-10 18:58:09 +080047 CUR_SOC=${CONFIG_SYS_SOC}
Honglin Zhange358be42020-08-12 02:16:02 -040048 BL30_SELECT=${CONFIG_BL30_SELECT}
Xiaobo Gu059502e2017-01-12 21:20:39 +080049
xiaobo gue6c46862018-01-10 18:58:09 +080050 if [ "y" == "${CONFIG_NEED_BL32}" ]; then
51 BLX_NEEDFUL[3]="true"
52 fi
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080053
xiaobo gue6c46862018-01-10 18:58:09 +080054 # export variables
55 #export FIP_BUILD_FOLDER
56 #export CUR_SOC
Xiaobo Gu059502e2017-01-12 21:20:39 +080057
xiaobo gue6c46862018-01-10 18:58:09 +080058 export_variables
Xiaobo Gu059502e2017-01-12 21:20:39 +080059}
60
xiaobo gue6c46862018-01-10 18:58:09 +080061function init_variable_late() {
62 # after uboot build, source configs
xiaobo gua64f93c2018-07-31 21:27:43 +080063 local CONFIG_FILE_TMP="${MAIN_FOLDER}/autoconf"
64 local STR_INVALID="option"
65 if [ ! -e ${CONFIG_FILE} ]; then
66 echo "${CONFIG_FILE} doesn't exist!"
67 cd ${MAIN_FOLDER}
68 exit -1
69 else
70 # workaround for source file error
71 while read LINE
72 do
73 #echo $LINE
74 # ignore "*(option)*" lines
75 if [[ ${LINE} =~ ${STR_INVALID} ]]; then
76 echo "ignore: $LINE"
77 else
78 #echo "LINE: ${LINE}"
79 echo "$LINE" >> "${CONFIG_FILE_TMP}"
80 fi
81 done < ${CONFIG_FILE}
82 source "${CONFIG_FILE_TMP}" &> /dev/null
83 rm ${CONFIG_FILE_TMP}
84 fi
xiaobo gue6c46862018-01-10 18:58:09 +080085 if [ "y" == "${CONFIG_SUPPORT_CUSOTMER_BOARD}" ]; then
86 BOARD_DIR="customer/board/${CONFIG_SYS_BOARD}"
87 else
88 BOARD_DIR="${CONFIG_BOARDDIR}"
89 fi
xiaobo gua64f93c2018-07-31 21:27:43 +080090 export BOARD_DIR
Xiaobo Gu059502e2017-01-12 21:20:39 +080091}
92
93function build_blx_src() {
xiaobo gue6c46862018-01-10 18:58:09 +080094 # compile $name $src_folder $bin_folder $soc
95 local name=$1
96 local src_folder=$2
97 local bin_folder=$3
98 local soc=$4
99 #dbg "compile - name: ${name}, src_folder: ${src_folder}, bin_folder: ${bin_folder}, soc: ${soc}"
Bo Lv78837da2020-12-16 04:13:04 -0500100
xiaobo gu8a3907e2019-05-22 11:46:49 +0800101 if [ $name == ${BLX_NAME_GLB[0]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800102 # bl2
103 build_bl2 $src_folder $bin_folder $soc
Honglin Zhang637c38b2020-06-28 02:16:39 -0400104 elif [ $name == ${BLX_NAME_GLB[5]} ]; then
105 # bl2e
106 build_bl2e $src_folder $bin_folder $soc
107 elif [ $name == ${BLX_NAME_GLB[6]} ]; then
108 # bl2x
109 build_bl2x $src_folder $bin_folder $soc
xiaobo gu8a3907e2019-05-22 11:46:49 +0800110 elif [ $name == ${BLX_NAME_GLB[1]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800111 # bl30
112 build_bl30 $src_folder $bin_folder $soc
xiaobo gu8a3907e2019-05-22 11:46:49 +0800113 elif [ $name == ${BLX_NAME_GLB[2]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800114 # bl31
115 # some soc use v1.3
116 check_bl31_ver $soc
Honglin Zhang637c38b2020-06-28 02:16:39 -0400117 if [ $? != 0 ]; then
118 echo "check bl31 ver: use v1.3"
119 build_bl31_v1_3 $src_folder $bin_folder $soc
120 else
121 echo "check bl31 ver: use v1.0"
122 build_bl31 $src_folder $bin_folder $soc
123 fi
xiaobo gu8a3907e2019-05-22 11:46:49 +0800124 elif [ $name == ${BLX_NAME_GLB[3]} ]; then
xiaobo gue8bf44f2019-03-18 14:23:36 +0800125 # control flow for jenkins patchbuild
126 if [ "$BUILD_TYPE" != "AOSP" ]; then
127 # bl32
128 if [ "y" == "${CONFIG_NEED_BL32}" ]; then
129 build_bl32 $src_folder $bin_folder $soc
130 fi
xiaobo gue6c46862018-01-10 18:58:09 +0800131 fi
132 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800133}
134
135function build_blx() {
xiaobo gue6c46862018-01-10 18:58:09 +0800136 # build each blx
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800137
xiaobo gue6c46862018-01-10 18:58:09 +0800138 # switch bl31 version
139 switch_bl31 ${CUR_SOC}
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800140
xiaobo gue6c46862018-01-10 18:58:09 +0800141 # get version of each blx
142 get_versions
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800143
Bo Lv78837da2020-12-16 04:13:04 -0500144 # parse bl33 global configs, so BL33 config in .config/config.h
145 # can be used for BL2/2e/2x/31...
146 parse_bl33_global_config $@
147
xiaobo gue6c46862018-01-10 18:58:09 +0800148 # build loop
149 for loop in ${!BLX_NAME[@]}; do
Honglin Zhang805bd102020-02-14 18:23:23 +0800150 dbg "BIN_PATH[${loop}]: ${BIN_PATH[$loop]}"
151 if [ "null" == ${BIN_PATH[$loop]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800152 get_blx_bin ${loop}
Honglin Zhang805bd102020-02-14 18:23:23 +0800153 elif [ "source" == ${BIN_PATH[$loop]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800154 dbg "Build blx source code..."
Honglin Zhang805bd102020-02-14 18:23:23 +0800155 build_blx_src ${BLX_NAME[$loop]} ${BLX_SRC_FOLDER[$loop]} ${FIP_BUILD_FOLDER} ${CUR_SOC}
xiaobo gue6c46862018-01-10 18:58:09 +0800156 else
Honglin Zhang805bd102020-02-14 18:23:23 +0800157 if [ ! -e ${BIN_PATH[$loop]} ]; then
158 echo "Error: ${BIN_PATH[$loop]} doesn't exist... abort"
xiaobo gue6c46862018-01-10 18:58:09 +0800159 exit -1
160 else
Honglin Zhanga5041212020-03-05 21:11:31 +0800161 if [ "y" == "${CONFIG_FIP_IMG_SUPPORT}" ] && \
162 [ -n "${BLX_IMG_NAME[$loop]}" ] && \
163 [ "NULL" != "${BLX_IMG_NAME[$loop]}" ]; then
164 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} -f
Zhongfu Luoa1e540c2020-07-17 15:44:37 +0800165 elif [[ -n "${BLX_IMG_NAME[$loop]}" && "NULL" != "${BLX_BIN_NAME[$loop]}" ]]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800166 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} -f
167 else
168 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER} -f
169 fi
170
Honglin Zhang805bd102020-02-14 18:23:23 +0800171 echo "Get ${BLX_NAME[$loop]} from ${BIN_PATH[$loop]}... done"
172 fi
173 fi
174
175 # start to check the blx firmware
176 if [ "bl32" == "${BLX_NAME[$loop]}" ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800177 # no bl32/bin are exported for users
Honglin Zhang805bd102020-02-14 18:23:23 +0800178 check_bypass=y
179 else
180 check_bypass=n
181 fi
182
Zhongfu Luo7bd99c92020-07-14 19:37:52 +0800183 if [ "${CUR_SOC}" == "sc2" ]; then
184 check_bypass=y
185 fi
186
Honglin Zhang805bd102020-02-14 18:23:23 +0800187 if [ "y" != "${check_bypass}" ]; then
188 if [ "NULL" != "${BLX_BIN_NAME[$loop]}" ] && \
Honglin Zhanga5041212020-03-05 21:11:31 +0800189 [ -n "${BLX_BIN_NAME[$loop]}" ] && \
Honglin Zhang0b81ed72020-03-07 10:38:35 +0800190 [ "NULL" == "${BLX_IMG_NAME[$loop]}" ] && \
Honglin Zhang805bd102020-02-14 18:23:23 +0800191 [ ! -f ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800192 echo "Error ${BLX_NAME[$loop]}: ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} doesn't exit... abort"
Honglin Zhang805bd102020-02-14 18:23:23 +0800193 exit -1
194 fi
195 if [ "y" == "${CONFIG_FIP_IMG_SUPPORT}" ] && \
196 [ -n "${BLX_IMG_NAME[$loop]}" ] && \
197 [ "NULL" != "${BLX_IMG_NAME[$loop]}" ] && \
198 [ ! -f ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800199 echo "Error ${BLX_NAME[$loop]}: ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} doesn't exit... abort"
Honglin Zhang805bd102020-02-14 18:23:23 +0800200 exit -1
xiaobo gue6c46862018-01-10 18:58:09 +0800201 fi
202 fi
203 done
204 return
Xiaobo Gu059502e2017-01-12 21:20:39 +0800205}
206
207copy_bootloader() {
xiaobo gue6c46862018-01-10 18:58:09 +0800208 mkdir -p ${BUILD_FOLDER}
Haixiang Baof008dc12019-05-23 18:47:15 +0800209 cp ${FIP_BUILD_FOLDER}u-boot.bin* ${BUILD_FOLDER}
xiaobo gue6c46862018-01-10 18:58:09 +0800210 if [ "y" == "${CONFIG_AML_CRYPTO_IMG}" ]; then
211 cp ${FIP_BUILD_FOLDER}boot.img.encrypt ${BUILD_FOLDER}boot.img.encrypt
212 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800213}
214
215function update_bin_path() {
xiaobo gu8a3907e2019-05-22 11:46:49 +0800216 for loop in ${!BLX_NAME[@]}; do
217 if [ "${BLX_NAME[$loop]}" == "${BLX_NAME_GLB[$1]}" ]; then
Honglin Zhangcd8a9fc2019-11-22 17:52:55 +0800218 dbg "Update BIN_PATH[$loop]=$2"
xiaobo gu8a3907e2019-05-22 11:46:49 +0800219 BIN_PATH[$loop]=$2
Honglin Zhangcd8a9fc2019-11-22 17:52:55 +0800220 break
xiaobo gu8a3907e2019-05-22 11:46:49 +0800221 fi
222 done
223}
Xiaobo Gu059502e2017-01-12 21:20:39 +0800224
225function clean() {
xiaobo gue6c46862018-01-10 18:58:09 +0800226 echo "Clean up"
xiaobo gu0c2598b2019-06-28 11:22:17 +0800227 if [ -e ${BL33_PATH1} ]; then
228 cd ${MAIN_FOLDER}
229 cd ${BL33_PATH1}
230 make distclean
231 fi
232 if [ -e ${BL33_PATH2} ]; then
233 cd ${MAIN_FOLDER}
234 cd ${BL33_PATH2}
235 make distclean
236 fi
xiaobo gue6c46862018-01-10 18:58:09 +0800237 cd ${MAIN_FOLDER}
238 rm ${FIP_BUILD_FOLDER} -rf
xiaobo gu3ce64072018-03-06 17:20:44 +0800239 rm ${BUILD_FOLDER}/* -rf
Haixiang Baof008dc12019-05-23 18:47:15 +0800240 mkdir -p ${BUILD_FOLDER}
xiaobo gue6c46862018-01-10 18:58:09 +0800241 return
Xiaobo Gu059502e2017-01-12 21:20:39 +0800242}
243
244function build() {
xiaobo gue6c46862018-01-10 18:58:09 +0800245 # *************************************************
246 # IMPORTANT!!!!
247 # don't change sequence of following function call
248 # *************************************************
249 clean
250
251 # pre-build, get .config defines
252 pre_build_uboot $@
253
254 # variable init depends on uboot .config
255 init_variable_early $@
256
257 # must source under main function, all sub function can use these variables
258 # but if source in sub-function, only sub-function(or sub-sub..) can use them
259 source ${FIP_FOLDER}${CUR_SOC}/variable_soc.sh
260
Honglin Zhang694f5342019-12-09 14:54:40 +0800261 # compile fip tools for ddr_parse and map_tool
262 prepare_tools
263
xiaobo gue6c46862018-01-10 18:58:09 +0800264 # source soc package script
265 source ${FIP_FOLDER}${CUR_SOC}/build.sh
266
267 # update bin path, use bin.git or user defined or source code
268 bin_path_parser $@
xiaobo gude8a46a2018-03-05 21:41:54 +0800269 #bin_path_update $@
xiaobo gue6c46862018-01-10 18:58:09 +0800270
271 # build bl33/bl301..etc
Liang Ji51eee082019-05-20 14:01:24 +0800272 if [ ! $CONFIG_SYSTEM_AS_ROOT ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800273 CONFIG_SYSTEM_AS_ROOT=null
274 fi
Liang Ji51eee082019-05-20 14:01:24 +0800275 if [ ! $CONFIG_AVB2 ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800276 CONFIG_AVB2=null
277 fi
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800278 if [ ! $CONFIG_CMD_BOOTCTOL_VAB ]; then
279 CONFIG_CMD_BOOTCTOL_VAB=null
Xindong Xua75ab9b2020-05-25 15:54:01 +0800280 fi
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800281 build_uboot ${CONFIG_SYSTEM_AS_ROOT} ${CONFIG_AVB2} ${CONFIG_CMD_BOOTCTOL_VAB}
xiaobo gue6c46862018-01-10 18:58:09 +0800282
283 # source other configs after uboot compile
284 init_variable_late
285
286 # bl2/bl30/bl31..etc, build or copy from bin.git
287 build_blx $@
288
289 # cp bl33(uboot)
290 copy_bl33
291
292 # cp other firmwares(soc related)
293 copy_other_soc
294
Zhongfu Luo6c2587f2019-05-15 16:27:50 +0800295 # make build directory
296 mkdir -p ${BUILD_FOLDER}
297
xiaobo gue6c46862018-01-10 18:58:09 +0800298 # package final bootloader
299 package
300
Zhongfu Luofd0ea3e2018-11-30 14:15:16 +0800301 if [ "y" != "${CONFIG_AML_SIGNED_UBOOT}" ]; then
302 # copy bootloader to main folder
303 copy_bootloader
304 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800305}
306
307function usage() {
308 cat << EOF
309 Usage:
310 $(basename $0) --help
311
xiaobo gue6c46862018-01-10 18:58:09 +0800312 Bootloader build script.
Xiaobo Gu059502e2017-01-12 21:20:39 +0800313
314 command list:
Xiaobo Gu059502e2017-01-12 21:20:39 +0800315 1. build default uboot:
316 ./$(basename $0) [config_name]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800317
xiaobo gue6c46862018-01-10 18:58:09 +0800318 2. build uboot with specified bl[x].bin
319 ./$(basename $0) [config_name] --bl[x] [path]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800320
xiaobo gue6c46862018-01-10 18:58:09 +0800321 3. build uboot with bl[x]/src source code
Xiaobo Gu059502e2017-01-12 21:20:39 +0800322 ./$(basename $0) [config_name] --update-bl[x]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800323
xiaobo gue6c46862018-01-10 18:58:09 +0800324 4. print config list
325 ./$(basename $0) --config
326
327 5. check compile status with filter(optional)
328 ./$(basename $0) --check-compile [filter]
329
xiaobo gu6368ebe2018-03-29 21:49:25 +0800330 6. update aml ddr fw by source code (for g12a and later use)
331 ./$(basename $0) [config_name] --update-bl2 --ddrfw
332
xiaobo gue6c46862018-01-10 18:58:09 +0800333
334 Example:
335 1) ./$(basename $0) gxb_p200_v1
336 build gxb_p200_v1 config
337
338 2) ./$(basename $0) gxb_p200_v1 --bl2 fip/bl2.bin --bl30 fip/bl30.bin
339 build gxb_p200_v1 with specified bl2.bin and bl30.bin
340
341 3) ./$(basename $0) gxb_p200_v1 --update-bl31 --update-bl2
342 build gxb_p200_v1 with bl31/bl2 source code
343
344 4) ./$(basename $0) --config
345 print config list
346
347 5) ./$(basename $0) --check-compile skt
348 check all skt board compile status
349
350 Remark:
351 bl[x].bin/img priority:
352 1. uboot will use binaries under bl[x]/bin/ folder by default, bl[x] version specified in .repo/manifest.xml
353 2. if you want use your own bl[x].bin, specify path by add "--bl[x] [path]" parameter
354 3. if you want use bl[x].bin by compile source code, please add "--update-bl[x]" parameter
355
Xiaobo Gu059502e2017-01-12 21:20:39 +0800356
357EOF
358 exit 1
359}
360
xiaobo gue6c46862018-01-10 18:58:09 +0800361function print_config() {
362 cat << EOF
363 Usable configs:
364`uboot_config_list`
365EOF
366 exit 1
367}
368
Xiaobo Gu059502e2017-01-12 21:20:39 +0800369function parser() {
xiaobo gue6c46862018-01-10 18:58:09 +0800370 local i=0
371 local argv=()
372 for arg in "$@" ; do
373 argv[$i]="$arg"
374 i=$((i + 1))
375 done
376 i=0
377 while [ $i -lt $# ]; do
378 arg="${argv[$i]}"
xiaobo gu3ce64072018-03-06 17:20:44 +0800379 i=$((i + 1)) # must place here
xiaobo gue6c46862018-01-10 18:58:09 +0800380 case "$arg" in
381 -h|--help|help)
382 usage
383 exit ;;
384 --config)
385 print_config
xiaobo gu3ce64072018-03-06 17:20:44 +0800386 return ;;
Zhongfu Luo019ee832020-11-13 15:56:33 +0800387 # SCRIPT_ARG_CHIPSET_VARIANT is used in source variable
388 # soc, so should add first
389 --chip-varient)
390 SCRIPT_ARG_CHIPSET_VARIANT="${argv[$i]}"
391 export SCRIPT_ARG_CHIPSET_VARIANT
392 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800393 --check-compile)
xiaobo gu66f95292018-01-11 13:38:13 +0800394 check_compile "${argv[@]:$((i))}"
xiaobo gue6c46862018-01-10 18:58:09 +0800395 exit ;;
396 clean|distclean|-distclean|--distclean)
397 clean
398 exit ;;
399 *)
400 esac
401 done
402}
403
xiaobo gude8a46a2018-03-05 21:41:54 +0800404function bin_path_update() {
405 # overwrite path in case some git repository doesn't exist
406 for loop in ${!BLX_BIN_FOLDER[@]}; do
407 if [ -ne ${BLX_BIN_FOLDER[$loop]} ]; then
408 dbg "BLX_BIN_FOLDER[$loop] doesn't exist, use src code"
409 update_bin_path $loop "source"
410 fi
411 done
412
413 for loop in ${!BLX_SRC_FOLDER[@]}; do
414 echo ""
415 done
416}
417
xiaobo gue6c46862018-01-10 18:58:09 +0800418function bin_path_parser() {
419 local i=0
420 local argv=()
421 for arg in "$@" ; do
422 argv[$i]="$arg"
423 i=$((i + 1))
424 done
425 i=0
xiaobo gu6368ebe2018-03-29 21:49:25 +0800426 # ddr fw define, co-work with bl2 build script
427 export CONFIG_DDR_FW
xiaobo gue6c46862018-01-10 18:58:09 +0800428 while [ $i -lt $# ]; do
429 arg="${argv[$i]}"
430 i=$((i + 1)) # must pleace here
431 case "$arg" in
432 --bl2)
433 update_bin_path 0 "${argv[@]:$((i))}"
434 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400435 --bl2e)
436 update_bin_path 5 "${argv[@]:$((i))}"
437 continue ;;
438 --bl2x)
439 update_bin_path 6 "${argv[@]:$((i))}"
440 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800441 --bl30)
442 update_bin_path 1 "${argv[@]:$((i))}"
443 continue ;;
444 --bl31)
445 update_bin_path 2 "${argv[@]:$((i))}"
446 continue ;;
447 --bl32)
448 update_bin_path 3 "${argv[@]:$((i))}"
449 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400450 --bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800451 update_bin_path 4 "${argv[@]:$((i))}"
452 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400453 --sign-bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800454 update_bin_path 4 "${argv[@]:$((i))}"
455 CONFIG_SIGN_BL40=1
456 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800457 --update-bl2)
458 update_bin_path 0 "source"
459 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400460 --update-bl2e)
461 update_bin_path 5 "source"
462 continue ;;
463 --update-bl2x)
464 update_bin_path 6 "source"
465 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800466 --update-bl30)
467 update_bin_path 1 "source"
468 continue ;;
469 --update-bl31)
470 update_bin_path 2 "source"
471 continue ;;
472 --update-bl32)
473 update_bin_path 3 "source"
474 continue ;;
xiaobo gu6368ebe2018-03-29 21:49:25 +0800475 --ddrfw)
476 CONFIG_DDR_FW=1
477 export CONFIG_DDR_FW
478 continue ;;
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800479 --cas)
480 cas="${argv[$i]}"
481 #limit the "--cas xxx" only works for g12a
Lawrence Mok762306e2020-05-13 20:38:08 -0700482 if [ "${CUR_SOC}" == "g12a" ] ||
483 ( [ "${cas}" == "vmx" ] && [ "${CUR_SOC}" == "gxl" ] ); then
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800484 CONFIG_CAS=${cas}
485 fi
486 if [[ "${CONFIG_CAS}" == "irdeto" || \
487 "${CONFIG_CAS}" == "vmx" || \
488 "${CONFIG_CAS}" == "nagra" ]]; then
489 CONFIG_AML_SIGNED_UBOOT=y
490 export CONFIG_AML_SIGNED_UBOOT
491 fi
Lawrence Mok048be0f2020-02-24 18:03:43 -0800492 if [ "${CONFIG_CAS}" == "vmx" ]; then
493 dbg "Loading CAS VMX config"
494 source fip/config_cas_vmx.sh
495 fi
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800496 echo "CAS: ${cas},${CONFIG_CAS}"
497 export CONFIG_CAS
498 continue ;;
Xindong Xuad0d2832018-07-30 19:15:52 +0800499 --systemroot)
500 CONFIG_SYSTEM_AS_ROOT=systemroot
501 echo "export CONFIG_SYSTEM_AS_ROOT"
502 export CONFIG_SYSTEM_AS_ROOT=systemroot
503 continue ;;
Xindong Xu33eda2d2018-09-25 18:52:38 +0800504 --avb2)
505 CONFIG_AVB2=avb2
506 echo "export CONFIG_AVB2"
507 export CONFIG_AVB2=avb2
508 continue ;;
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800509 --vab)
510 CONFIG_CMD_BOOTCTOL_VAB=1
511 echo "export CONFIG_CMD_BOOTCTOL_VAB"
512 export CONFIG_CMD_BOOTCTOL_VAB=1
Xindong Xua75ab9b2020-05-25 15:54:01 +0800513 continue ;;
Matthew Shyu4a863712020-02-19 17:58:17 +0800514 --avb2-fipkey)
515 CONFIG_AVB2_KPUB_FROM_FIP=1
516 echo "export CONFIG_AVB2_KPUB_FROM_FIP"
517 export CONFIG_AVB2_KPUB_FROM_FIP=1
518 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800519 *)
520 esac
521 done
Xiaobo Gu059502e2017-01-12 21:20:39 +0800522}
523
524function main() {
xiaobo gue6c46862018-01-10 18:58:09 +0800525 if [ -z $1 ]
526 then
527 usage
528 return
529 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800530
xiaobo gue6c46862018-01-10 18:58:09 +0800531 MAIN_FOLDER=`pwd`
532 parser $@
533 build $@
Xiaobo Gu059502e2017-01-12 21:20:39 +0800534}
535
536main $@ # parse all paras to function