blob: 73dc99277123dcade0392e3f7af8ff6aa8c47879 [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
dongqing.li154e45e2021-11-22 07:47:38 +000018source fip/check_coverity.sh
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080019
Bo Lv78837da2020-12-16 04:13:04 -050020function parse_bl33_global_config() {
21 local oldifs="$IFS"
22 IFS=$'\n'
23
24 BL33_GLOBAL_CONFIG=
25 for line in `cat ${SOURCE_FILE}`; do
26 # add any global configs which define in BL33 and need
27 # to used under bl2/bl2x/bl2e/bl31/....
28 if [[ "${line}" == "CONFIG_PXP_"* ]]; then
29 tmp=${line%=*} # delete =y
30 BL33_GLOBAL_CONFIG="${BL33_GLOBAL_CONFIG}"" -D""${tmp}"
31 fi
Tao Zeng68361e62021-01-06 17:29:40 +080032 if [[ "${line}" == "CONFIG_DDR_FULL_FW"* ]]; then
33 tmp=${line%=*} # delete =y
34 BL33_GLOBAL_CONFIG="${BL33_GLOBAL_CONFIG}"" -D""${tmp}"
35 fi
Bo Lv78837da2020-12-16 04:13:04 -050036 done
37 export BL33_GLOBAL_CONFIG
38 echo "==== BL33 GLOBAL CONFIG: ${BL33_GLOBAL_CONFIG} ==="
39 IFS="$oldifs"
40}
Xiaobo Gu059502e2017-01-12 21:20:39 +080041
xiaobo gue6c46862018-01-10 18:58:09 +080042function init_variable_early() {
43 # source uboot pre-build configs
44 if [ ! -e ${SOURCE_FILE} ]; then
45 echo "${SOURCE_FILE} doesn't exist!"
46 cd ${MAIN_FOLDER}
47 exit -1
48 else
49 source ${SOURCE_FILE} &> /dev/null # ignore warning/error
50 fi
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080051
xiaobo gue6c46862018-01-10 18:58:09 +080052 CUR_SOC=${CONFIG_SYS_SOC}
Honglin Zhange358be42020-08-12 02:16:02 -040053 BL30_SELECT=${CONFIG_BL30_SELECT}
Xiaobo Gu059502e2017-01-12 21:20:39 +080054
xiaobo gue6c46862018-01-10 18:58:09 +080055 if [ "y" == "${CONFIG_NEED_BL32}" ]; then
56 BLX_NEEDFUL[3]="true"
57 fi
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +080058
xiaobo gue6c46862018-01-10 18:58:09 +080059 # export variables
60 #export FIP_BUILD_FOLDER
61 #export CUR_SOC
Xiaobo Gu059502e2017-01-12 21:20:39 +080062
xiaobo gue6c46862018-01-10 18:58:09 +080063 export_variables
Xiaobo Gu059502e2017-01-12 21:20:39 +080064}
65
xiaobo gue6c46862018-01-10 18:58:09 +080066function init_variable_late() {
67 # after uboot build, source configs
xiaobo gua64f93c2018-07-31 21:27:43 +080068 local CONFIG_FILE_TMP="${MAIN_FOLDER}/autoconf"
69 local STR_INVALID="option"
70 if [ ! -e ${CONFIG_FILE} ]; then
71 echo "${CONFIG_FILE} doesn't exist!"
72 cd ${MAIN_FOLDER}
73 exit -1
74 else
75 # workaround for source file error
76 while read LINE
77 do
78 #echo $LINE
79 # ignore "*(option)*" lines
80 if [[ ${LINE} =~ ${STR_INVALID} ]]; then
81 echo "ignore: $LINE"
82 else
83 #echo "LINE: ${LINE}"
84 echo "$LINE" >> "${CONFIG_FILE_TMP}"
85 fi
86 done < ${CONFIG_FILE}
87 source "${CONFIG_FILE_TMP}" &> /dev/null
88 rm ${CONFIG_FILE_TMP}
89 fi
xiaobo gue6c46862018-01-10 18:58:09 +080090 if [ "y" == "${CONFIG_SUPPORT_CUSOTMER_BOARD}" ]; then
91 BOARD_DIR="customer/board/${CONFIG_SYS_BOARD}"
92 else
93 BOARD_DIR="${CONFIG_BOARDDIR}"
94 fi
xiaobo gua64f93c2018-07-31 21:27:43 +080095 export BOARD_DIR
Xiaobo Gu059502e2017-01-12 21:20:39 +080096}
97
98function build_blx_src() {
xiaobo gue6c46862018-01-10 18:58:09 +080099 # compile $name $src_folder $bin_folder $soc
100 local name=$1
101 local src_folder=$2
102 local bin_folder=$3
103 local soc=$4
104 #dbg "compile - name: ${name}, src_folder: ${src_folder}, bin_folder: ${bin_folder}, soc: ${soc}"
Bo Lv78837da2020-12-16 04:13:04 -0500105
xiaobo gu8a3907e2019-05-22 11:46:49 +0800106 if [ $name == ${BLX_NAME_GLB[0]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800107 # bl2
108 build_bl2 $src_folder $bin_folder $soc
Honglin Zhang637c38b2020-06-28 02:16:39 -0400109 elif [ $name == ${BLX_NAME_GLB[5]} ]; then
110 # bl2e
111 build_bl2e $src_folder $bin_folder $soc
112 elif [ $name == ${BLX_NAME_GLB[6]} ]; then
113 # bl2x
114 build_bl2x $src_folder $bin_folder $soc
xiaobo gu8a3907e2019-05-22 11:46:49 +0800115 elif [ $name == ${BLX_NAME_GLB[1]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800116 # bl30
117 build_bl30 $src_folder $bin_folder $soc
xiaobo gu8a3907e2019-05-22 11:46:49 +0800118 elif [ $name == ${BLX_NAME_GLB[2]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800119 # bl31
120 # some soc use v1.3
121 check_bl31_ver $soc
Honglin Zhang637c38b2020-06-28 02:16:39 -0400122 if [ $? != 0 ]; then
123 echo "check bl31 ver: use v1.3"
124 build_bl31_v1_3 $src_folder $bin_folder $soc
125 else
126 echo "check bl31 ver: use v1.0"
127 build_bl31 $src_folder $bin_folder $soc
128 fi
xiaobo gu8a3907e2019-05-22 11:46:49 +0800129 elif [ $name == ${BLX_NAME_GLB[3]} ]; then
xiaobo gue8bf44f2019-03-18 14:23:36 +0800130 # control flow for jenkins patchbuild
131 if [ "$BUILD_TYPE" != "AOSP" ]; then
132 # bl32
133 if [ "y" == "${CONFIG_NEED_BL32}" ]; then
134 build_bl32 $src_folder $bin_folder $soc
135 fi
xiaobo gue6c46862018-01-10 18:58:09 +0800136 fi
137 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800138}
139
140function build_blx() {
xiaobo gue6c46862018-01-10 18:58:09 +0800141 # build each blx
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800142
xiaobo gue6c46862018-01-10 18:58:09 +0800143 # switch bl31 version
144 switch_bl31 ${CUR_SOC}
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800145
xiaobo gue6c46862018-01-10 18:58:09 +0800146 # get version of each blx
147 get_versions
Xiaobo Gu9dd3f3f2017-05-26 17:58:57 +0800148
Bo Lv78837da2020-12-16 04:13:04 -0500149 # parse bl33 global configs, so BL33 config in .config/config.h
150 # can be used for BL2/2e/2x/31...
151 parse_bl33_global_config $@
152
xiaobo gue6c46862018-01-10 18:58:09 +0800153 # build loop
154 for loop in ${!BLX_NAME[@]}; do
Honglin Zhang805bd102020-02-14 18:23:23 +0800155 dbg "BIN_PATH[${loop}]: ${BIN_PATH[$loop]}"
156 if [ "null" == ${BIN_PATH[$loop]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800157 get_blx_bin ${loop}
Honglin Zhang805bd102020-02-14 18:23:23 +0800158 elif [ "source" == ${BIN_PATH[$loop]} ]; then
xiaobo gue6c46862018-01-10 18:58:09 +0800159 dbg "Build blx source code..."
Honglin Zhang805bd102020-02-14 18:23:23 +0800160 build_blx_src ${BLX_NAME[$loop]} ${BLX_SRC_FOLDER[$loop]} ${FIP_BUILD_FOLDER} ${CUR_SOC}
xiaobo gue6c46862018-01-10 18:58:09 +0800161 else
Honglin Zhang805bd102020-02-14 18:23:23 +0800162 if [ ! -e ${BIN_PATH[$loop]} ]; then
163 echo "Error: ${BIN_PATH[$loop]} doesn't exist... abort"
xiaobo gue6c46862018-01-10 18:58:09 +0800164 exit -1
165 else
Honglin Zhanga5041212020-03-05 21:11:31 +0800166 if [ "y" == "${CONFIG_FIP_IMG_SUPPORT}" ] && \
167 [ -n "${BLX_IMG_NAME[$loop]}" ] && \
168 [ "NULL" != "${BLX_IMG_NAME[$loop]}" ]; then
169 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} -f
Zhongfu Luoa1e540c2020-07-17 15:44:37 +0800170 elif [[ -n "${BLX_IMG_NAME[$loop]}" && "NULL" != "${BLX_BIN_NAME[$loop]}" ]]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800171 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} -f
172 else
173 cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER} -f
174 fi
175
Honglin Zhang805bd102020-02-14 18:23:23 +0800176 echo "Get ${BLX_NAME[$loop]} from ${BIN_PATH[$loop]}... done"
177 fi
178 fi
179
180 # start to check the blx firmware
181 if [ "bl32" == "${BLX_NAME[$loop]}" ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800182 # no bl32/bin are exported for users
Honglin Zhang805bd102020-02-14 18:23:23 +0800183 check_bypass=y
184 else
185 check_bypass=n
186 fi
187
Zhongfu Luo3a6e5342020-12-27 13:11:54 +0800188 if [ "$ADVANCED_BOOTLOADER" == "1" ]; then
Zhongfu Luo7bd99c92020-07-14 19:37:52 +0800189 check_bypass=y
190 fi
191
Honglin Zhang805bd102020-02-14 18:23:23 +0800192 if [ "y" != "${check_bypass}" ]; then
193 if [ "NULL" != "${BLX_BIN_NAME[$loop]}" ] && \
Honglin Zhanga5041212020-03-05 21:11:31 +0800194 [ -n "${BLX_BIN_NAME[$loop]}" ] && \
Honglin Zhang0b81ed72020-03-07 10:38:35 +0800195 [ "NULL" == "${BLX_IMG_NAME[$loop]}" ] && \
Honglin Zhang805bd102020-02-14 18:23:23 +0800196 [ ! -f ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800197 echo "Error ${BLX_NAME[$loop]}: ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} doesn't exit... abort"
Honglin Zhang805bd102020-02-14 18:23:23 +0800198 exit -1
199 fi
200 if [ "y" == "${CONFIG_FIP_IMG_SUPPORT}" ] && \
201 [ -n "${BLX_IMG_NAME[$loop]}" ] && \
202 [ "NULL" != "${BLX_IMG_NAME[$loop]}" ] && \
203 [ ! -f ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} ]; then
Honglin Zhanga5041212020-03-05 21:11:31 +0800204 echo "Error ${BLX_NAME[$loop]}: ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} doesn't exit... abort"
Honglin Zhang805bd102020-02-14 18:23:23 +0800205 exit -1
xiaobo gue6c46862018-01-10 18:58:09 +0800206 fi
207 fi
208 done
209 return
Xiaobo Gu059502e2017-01-12 21:20:39 +0800210}
211
212copy_bootloader() {
xiaobo gue6c46862018-01-10 18:58:09 +0800213 mkdir -p ${BUILD_FOLDER}
Haixiang Baof008dc12019-05-23 18:47:15 +0800214 cp ${FIP_BUILD_FOLDER}u-boot.bin* ${BUILD_FOLDER}
xiaobo gue6c46862018-01-10 18:58:09 +0800215 if [ "y" == "${CONFIG_AML_CRYPTO_IMG}" ]; then
216 cp ${FIP_BUILD_FOLDER}boot.img.encrypt ${BUILD_FOLDER}boot.img.encrypt
217 fi
dongqing.lic6275642021-12-17 19:15:52 +0800218
219 if [ ! -z ${CONFIG_CHIPID_SUPPORT} ]; then
220 mv ${BUILD_FOLDER}/u-boot.bin.signed ${BUILD_FOLDER}/u-boot.bin.${CONFIG_RAMDUMP_CHIPID}.signed
221 mv ${BUILD_FOLDER}/u-boot.bin.sd.bin.signed ${BUILD_FOLDER}/u-boot.bin.${CONFIG_RAMDUMP_CHIPID}.sd.bin.signed
222 mv ${BUILD_FOLDER}/u-boot.bin.usb.signed ${BUILD_FOLDER}/u-boot.bin.${CONFIG_RAMDUMP_CHIPID}.usb.signed
223 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800224}
225
226function update_bin_path() {
xiaobo gu8a3907e2019-05-22 11:46:49 +0800227 for loop in ${!BLX_NAME[@]}; do
228 if [ "${BLX_NAME[$loop]}" == "${BLX_NAME_GLB[$1]}" ]; then
Honglin Zhangcd8a9fc2019-11-22 17:52:55 +0800229 dbg "Update BIN_PATH[$loop]=$2"
xiaobo gu8a3907e2019-05-22 11:46:49 +0800230 BIN_PATH[$loop]=$2
Honglin Zhangcd8a9fc2019-11-22 17:52:55 +0800231 break
xiaobo gu8a3907e2019-05-22 11:46:49 +0800232 fi
233 done
234}
Xiaobo Gu059502e2017-01-12 21:20:39 +0800235
236function clean() {
xiaobo gue6c46862018-01-10 18:58:09 +0800237 echo "Clean up"
xiaobo gu0c2598b2019-06-28 11:22:17 +0800238 if [ -e ${BL33_PATH1} ]; then
239 cd ${MAIN_FOLDER}
240 cd ${BL33_PATH1}
241 make distclean
242 fi
243 if [ -e ${BL33_PATH2} ]; then
244 cd ${MAIN_FOLDER}
245 cd ${BL33_PATH2}
246 make distclean
247 fi
xiaobo gue6c46862018-01-10 18:58:09 +0800248 cd ${MAIN_FOLDER}
249 rm ${FIP_BUILD_FOLDER} -rf
xiaobo gu3ce64072018-03-06 17:20:44 +0800250 rm ${BUILD_FOLDER}/* -rf
Haixiang Baof008dc12019-05-23 18:47:15 +0800251 mkdir -p ${BUILD_FOLDER}
xiaobo gue6c46862018-01-10 18:58:09 +0800252 return
Xiaobo Gu059502e2017-01-12 21:20:39 +0800253}
254
255function build() {
xiaobo gue6c46862018-01-10 18:58:09 +0800256 # *************************************************
257 # IMPORTANT!!!!
258 # don't change sequence of following function call
259 # *************************************************
260 clean
261
262 # pre-build, get .config defines
263 pre_build_uboot $@
264
265 # variable init depends on uboot .config
266 init_variable_early $@
267
268 # must source under main function, all sub function can use these variables
269 # but if source in sub-function, only sub-function(or sub-sub..) can use them
270 source ${FIP_FOLDER}${CUR_SOC}/variable_soc.sh
271
Honglin Zhang694f5342019-12-09 14:54:40 +0800272 # compile fip tools for ddr_parse and map_tool
273 prepare_tools
274
xiaobo gue6c46862018-01-10 18:58:09 +0800275 # source soc package script
276 source ${FIP_FOLDER}${CUR_SOC}/build.sh
277
278 # update bin path, use bin.git or user defined or source code
279 bin_path_parser $@
xiaobo gude8a46a2018-03-05 21:41:54 +0800280 #bin_path_update $@
xiaobo gue6c46862018-01-10 18:58:09 +0800281
282 # build bl33/bl301..etc
Liang Ji51eee082019-05-20 14:01:24 +0800283 if [ ! $CONFIG_SYSTEM_AS_ROOT ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800284 CONFIG_SYSTEM_AS_ROOT=null
285 fi
Liang Ji51eee082019-05-20 14:01:24 +0800286 if [ ! $CONFIG_AVB2 ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800287 CONFIG_AVB2=null
288 fi
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800289 if [ ! $CONFIG_CMD_BOOTCTOL_VAB ]; then
290 CONFIG_CMD_BOOTCTOL_VAB=null
Xindong Xua75ab9b2020-05-25 15:54:01 +0800291 fi
Matthew Shyu26233f52021-06-03 21:00:19 -0700292 if [ ! $CONFIG_AVB2_KPUB_FROM_FIP ]; then
293 CONFIG_AVB2_KPUB_FROM_FIP=0
294 fi
295 build_uboot ${CONFIG_SYSTEM_AS_ROOT} ${CONFIG_AVB2} ${CONFIG_CMD_BOOTCTOL_VAB} ${CONFIG_AVB2_KPUB_FROM_FIP}
xiaobo gue6c46862018-01-10 18:58:09 +0800296
297 # source other configs after uboot compile
298 init_variable_late
299
300 # bl2/bl30/bl31..etc, build or copy from bin.git
301 build_blx $@
302
303 # cp bl33(uboot)
304 copy_bl33
305
306 # cp other firmwares(soc related)
307 copy_other_soc
308
Zhongfu Luo6c2587f2019-05-15 16:27:50 +0800309 # make build directory
310 mkdir -p ${BUILD_FOLDER}
311
xiaobo gue6c46862018-01-10 18:58:09 +0800312 # package final bootloader
313 package
314
Zhongfu Luofd0ea3e2018-11-30 14:15:16 +0800315 if [ "y" != "${CONFIG_AML_SIGNED_UBOOT}" ]; then
316 # copy bootloader to main folder
317 copy_bootloader
318 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800319}
320
321function usage() {
322 cat << EOF
323 Usage:
324 $(basename $0) --help
325
xiaobo gue6c46862018-01-10 18:58:09 +0800326 Bootloader build script.
Xiaobo Gu059502e2017-01-12 21:20:39 +0800327
328 command list:
Xiaobo Gu059502e2017-01-12 21:20:39 +0800329 1. build default uboot:
330 ./$(basename $0) [config_name]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800331
xiaobo gue6c46862018-01-10 18:58:09 +0800332 2. build uboot with specified bl[x].bin
333 ./$(basename $0) [config_name] --bl[x] [path]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800334
xiaobo gue6c46862018-01-10 18:58:09 +0800335 3. build uboot with bl[x]/src source code
Xiaobo Gu059502e2017-01-12 21:20:39 +0800336 ./$(basename $0) [config_name] --update-bl[x]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800337
xiaobo gue6c46862018-01-10 18:58:09 +0800338 4. print config list
339 ./$(basename $0) --config
340
341 5. check compile status with filter(optional)
342 ./$(basename $0) --check-compile [filter]
343
xiaobo gu6368ebe2018-03-29 21:49:25 +0800344 6. update aml ddr fw by source code (for g12a and later use)
345 ./$(basename $0) [config_name] --update-bl2 --ddrfw
346
dongqing.li5849ac72021-11-24 10:49:26 +0000347 7. build uboot with bl[x]/src source code, and run coverity defect
348 ./$(basename $0) [config_name] --update-bl[x] --cov
349 ./$(basename $0) [config_name] --update-bl[x] --cov-high [path]
xiaobo gue6c46862018-01-10 18:58:09 +0800350
dongqing.lic6275642021-12-17 19:15:52 +0800351 8. build uboot with ramdump function
dongqing.lidf6de9c2022-01-03 22:34:01 +0800352 ./$(basename $0) [config_name] --update-bl[x] --enable-ramdump --chipid [cpu_id]
dongqing.lic6275642021-12-17 19:15:52 +0800353
xiaobo gue6c46862018-01-10 18:58:09 +0800354 Example:
355 1) ./$(basename $0) gxb_p200_v1
356 build gxb_p200_v1 config
357
358 2) ./$(basename $0) gxb_p200_v1 --bl2 fip/bl2.bin --bl30 fip/bl30.bin
359 build gxb_p200_v1 with specified bl2.bin and bl30.bin
360
361 3) ./$(basename $0) gxb_p200_v1 --update-bl31 --update-bl2
362 build gxb_p200_v1 with bl31/bl2 source code
363
364 4) ./$(basename $0) --config
365 print config list
366
367 5) ./$(basename $0) --check-compile skt
368 check all skt board compile status
369
dongqing.lidf6de9c2022-01-03 22:34:01 +0800370 6) ./$(basename $0) sc2_ah212 --update-bl2 --update-bl2e --enable-ramdump --chipid 00D9C73147101D16
371 build uboot with ramdump function, chipid for bl2.
dongqing.lic6275642021-12-17 19:15:52 +0800372
xiaobo gue6c46862018-01-10 18:58:09 +0800373 Remark:
374 bl[x].bin/img priority:
375 1. uboot will use binaries under bl[x]/bin/ folder by default, bl[x] version specified in .repo/manifest.xml
376 2. if you want use your own bl[x].bin, specify path by add "--bl[x] [path]" parameter
377 3. if you want use bl[x].bin by compile source code, please add "--update-bl[x]" parameter
378
Xiaobo Gu059502e2017-01-12 21:20:39 +0800379
380EOF
381 exit 1
382}
383
xiaobo gue6c46862018-01-10 18:58:09 +0800384function print_config() {
385 cat << EOF
386 Usable configs:
387`uboot_config_list`
388EOF
389 exit 1
390}
391
Xiaobo Gu059502e2017-01-12 21:20:39 +0800392function parser() {
xiaobo gue6c46862018-01-10 18:58:09 +0800393 local i=0
394 local argv=()
395 for arg in "$@" ; do
396 argv[$i]="$arg"
397 i=$((i + 1))
398 done
399 i=0
400 while [ $i -lt $# ]; do
401 arg="${argv[$i]}"
xiaobo gu3ce64072018-03-06 17:20:44 +0800402 i=$((i + 1)) # must place here
xiaobo gue6c46862018-01-10 18:58:09 +0800403 case "$arg" in
404 -h|--help|help)
405 usage
406 exit ;;
407 --config)
408 print_config
xiaobo gu3ce64072018-03-06 17:20:44 +0800409 return ;;
Zhongfu Luo019ee832020-11-13 15:56:33 +0800410 # SCRIPT_ARG_CHIPSET_VARIANT is used in source variable
411 # soc, so should add first
412 --chip-varient)
413 SCRIPT_ARG_CHIPSET_VARIANT="${argv[$i]}"
414 export SCRIPT_ARG_CHIPSET_VARIANT
415 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800416 --check-compile)
xiaobo gu66f95292018-01-11 13:38:13 +0800417 check_compile "${argv[@]:$((i))}"
xiaobo gue6c46862018-01-10 18:58:09 +0800418 exit ;;
dongqing.li154e45e2021-11-22 07:47:38 +0000419 --cov|--cov-high)
dongqing.li5849ac72021-11-24 10:49:26 +0000420 PATTERN_PATH="${argv[$i]}"
421 echo "PATTERN_PATH = ${PATTERN_PATH}"
422 export PATTERN_PATH
dongqing.li154e45e2021-11-22 07:47:38 +0000423 check_coverity $@
424 exit ;;
dongqing.lidf6de9c2022-01-03 22:34:01 +0800425 --enable-ramdump)
426 CONFIG_MDUMP_COMPRESS=1
427 export CONFIG_MDUMP_COMPRESS
428 echo "SET CONFIG: CONFIG_MDUMP_COMPRESS"
429 continue ;;
dongqing.lic6275642021-12-17 19:15:52 +0800430 --chipid)
431 CONFIG_CHIPID_SUPPORT=1
432 export CONFIG_CHIPID_SUPPORT
433 CONFIG_RAMDUMP_CHIPID="${argv[$i]}"
434 export CONFIG_RAMDUMP_CHIPID
dongqing.lidf6de9c2022-01-03 22:34:01 +0800435 echo "SET CHIP ID: ${CONFIG_RAMDUMP_CHIPID}"
dongqing.lic6275642021-12-17 19:15:52 +0800436 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800437 clean|distclean|-distclean|--distclean)
438 clean
439 exit ;;
440 *)
441 esac
442 done
443}
444
xiaobo gude8a46a2018-03-05 21:41:54 +0800445function bin_path_update() {
446 # overwrite path in case some git repository doesn't exist
447 for loop in ${!BLX_BIN_FOLDER[@]}; do
448 if [ -ne ${BLX_BIN_FOLDER[$loop]} ]; then
449 dbg "BLX_BIN_FOLDER[$loop] doesn't exist, use src code"
450 update_bin_path $loop "source"
451 fi
452 done
453
454 for loop in ${!BLX_SRC_FOLDER[@]}; do
455 echo ""
456 done
457}
458
xiaobo gue6c46862018-01-10 18:58:09 +0800459function bin_path_parser() {
460 local i=0
461 local argv=()
462 for arg in "$@" ; do
463 argv[$i]="$arg"
464 i=$((i + 1))
465 done
466 i=0
xiaobo gu6368ebe2018-03-29 21:49:25 +0800467 # ddr fw define, co-work with bl2 build script
468 export CONFIG_DDR_FW
xiaobo gue6c46862018-01-10 18:58:09 +0800469 while [ $i -lt $# ]; do
470 arg="${argv[$i]}"
471 i=$((i + 1)) # must pleace here
472 case "$arg" in
473 --bl2)
474 update_bin_path 0 "${argv[@]:$((i))}"
475 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400476 --bl2e)
477 update_bin_path 5 "${argv[@]:$((i))}"
478 continue ;;
Tao Zeng73e504b2021-07-13 12:29:08 +0800479 --bl2e-size)
480 BL2E_PAYLOAD_SIZE="${argv[i]}"
481 export BL2E_PAYLOAD_SIZE
482 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400483 --bl2x)
484 update_bin_path 6 "${argv[@]:$((i))}"
485 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800486 --bl30)
487 update_bin_path 1 "${argv[@]:$((i))}"
488 continue ;;
489 --bl31)
490 update_bin_path 2 "${argv[@]:$((i))}"
491 continue ;;
492 --bl32)
493 update_bin_path 3 "${argv[@]:$((i))}"
494 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400495 --bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800496 update_bin_path 4 "${argv[@]:$((i))}"
497 continue ;;
Tao Zeng68361e62021-01-06 17:29:40 +0800498 --ddr-fip)
499 DDR_FIP_EXTERN_PATH="${argv[@]:$((i))}"
500 export DDR_FIP_EXTERN_PATH
501 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400502 --sign-bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800503 update_bin_path 4 "${argv[@]:$((i))}"
504 CONFIG_SIGN_BL40=1
505 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800506 --update-bl2)
507 update_bin_path 0 "source"
508 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400509 --update-bl2e)
510 update_bin_path 5 "source"
Tao Zeng332fda22021-07-23 17:52:42 +0800511 if [[ ${argv[i]} == "sto" || ${argv[i]} == "usb" ]]; then
512 BL2E_UPDATE_TYPE=${argv[i]}
513 export BL2E_UPDATE_TYPE
514 fi
Honglin Zhang637c38b2020-06-28 02:16:39 -0400515 continue ;;
516 --update-bl2x)
517 update_bin_path 6 "source"
518 continue ;;
Tao Zeng68361e62021-01-06 17:29:40 +0800519 --update-ddr-fip)
520 GENERATE_DDR_FIP=1
521 export GENERATE_DDR_FIP
522 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800523 --update-bl30)
524 update_bin_path 1 "source"
525 continue ;;
526 --update-bl31)
527 update_bin_path 2 "source"
528 continue ;;
529 --update-bl32)
530 update_bin_path 3 "source"
531 continue ;;
Tao Zengff03b402020-12-09 15:01:44 +0800532 --bl2-branch)
533 BL2_BRANCH_ARG="${argv[i]}"
534 export BL2_BRANCH_ARG
535 continue ;;
xiaobo gu6368ebe2018-03-29 21:49:25 +0800536 --ddrfw)
537 CONFIG_DDR_FW=1
538 export CONFIG_DDR_FW
539 continue ;;
Bo Lv9edb6992021-09-06 11:31:00 +0800540 --jenkins-sign)
541 CONFIG_JENKINS_SIGN=1
542 export CONFIG_JENKINS_SIGN
543 continue ;;
544 --former-sign)
545 CONFIG_FORMER_SIGN=1
546 export CONFIG_FORMER_SIGN
547 continue ;;
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800548 --cas)
549 cas="${argv[$i]}"
550 #limit the "--cas xxx" only works for g12a
Lawrence Mok762306e2020-05-13 20:38:08 -0700551 if [ "${CUR_SOC}" == "g12a" ] ||
552 ( [ "${cas}" == "vmx" ] && [ "${CUR_SOC}" == "gxl" ] ); then
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800553 CONFIG_CAS=${cas}
554 fi
Sangho Lee6be1bf22021-05-24 07:54:37 +0800555 if [ "${CUR_SOC}" == "sc2" ] && [ "${cas}" == "nsk" ]; then
556 CONFIG_CAS=${cas}
557 fi
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800558 if [[ "${CONFIG_CAS}" == "irdeto" || \
559 "${CONFIG_CAS}" == "vmx" || \
560 "${CONFIG_CAS}" == "nagra" ]]; then
561 CONFIG_AML_SIGNED_UBOOT=y
562 export CONFIG_AML_SIGNED_UBOOT
563 fi
Lawrence Mok048be0f2020-02-24 18:03:43 -0800564 if [ "${CONFIG_CAS}" == "vmx" ]; then
565 dbg "Loading CAS VMX config"
566 source fip/config_cas_vmx.sh
567 fi
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800568 echo "CAS: ${cas},${CONFIG_CAS}"
569 export CONFIG_CAS
570 continue ;;
Xindong Xuad0d2832018-07-30 19:15:52 +0800571 --systemroot)
572 CONFIG_SYSTEM_AS_ROOT=systemroot
573 echo "export CONFIG_SYSTEM_AS_ROOT"
574 export CONFIG_SYSTEM_AS_ROOT=systemroot
575 continue ;;
Xindong Xu33eda2d2018-09-25 18:52:38 +0800576 --avb2)
577 CONFIG_AVB2=avb2
578 echo "export CONFIG_AVB2"
579 export CONFIG_AVB2=avb2
580 continue ;;
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800581 --vab)
582 CONFIG_CMD_BOOTCTOL_VAB=1
583 echo "export CONFIG_CMD_BOOTCTOL_VAB"
584 export CONFIG_CMD_BOOTCTOL_VAB=1
Xindong Xua75ab9b2020-05-25 15:54:01 +0800585 continue ;;
Matthew Shyu4a863712020-02-19 17:58:17 +0800586 --avb2-fipkey)
587 CONFIG_AVB2_KPUB_FROM_FIP=1
588 echo "export CONFIG_AVB2_KPUB_FROM_FIP"
589 export CONFIG_AVB2_KPUB_FROM_FIP=1
590 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800591 *)
592 esac
593 done
Xiaobo Gu059502e2017-01-12 21:20:39 +0800594}
595
596function main() {
xiaobo gue6c46862018-01-10 18:58:09 +0800597 if [ -z $1 ]
598 then
599 usage
600 return
601 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800602
xiaobo gue6c46862018-01-10 18:58:09 +0800603 MAIN_FOLDER=`pwd`
604 parser $@
605 build $@
Xiaobo Gu059502e2017-01-12 21:20:39 +0800606}
607
608main $@ # parse all paras to function