blob: a3fa65e8a3762d326879f59d8d9db59f6ced0acc [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
dongqing.lie538ef82022-08-24 15:11:31 +080090 if [ "y" == "${CONFIG_SUPPORT_CUSTOMER_BOARD}" ]; then
xiaobo gue6c46862018-01-10 18:58:09 +080091 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
Cheng Wang23dcdb062022-02-25 15:33:03 +0800263 if [ ! $BOARD_COMPILE_HDMITX_ONLY ]; then
264 echo "export BOARD_COMPILE_HDMITX_ONLY=null"
265 export BOARD_COMPILE_HDMITX_ONLY=null
266 fi
xiaobo gue6c46862018-01-10 18:58:09 +0800267 pre_build_uboot $@
268
269 # variable init depends on uboot .config
270 init_variable_early $@
271
272 # must source under main function, all sub function can use these variables
273 # but if source in sub-function, only sub-function(or sub-sub..) can use them
274 source ${FIP_FOLDER}${CUR_SOC}/variable_soc.sh
275
Honglin Zhang694f5342019-12-09 14:54:40 +0800276 # compile fip tools for ddr_parse and map_tool
277 prepare_tools
278
xiaobo gue6c46862018-01-10 18:58:09 +0800279 # source soc package script
280 source ${FIP_FOLDER}${CUR_SOC}/build.sh
281
282 # update bin path, use bin.git or user defined or source code
283 bin_path_parser $@
xiaobo gude8a46a2018-03-05 21:41:54 +0800284 #bin_path_update $@
xiaobo gue6c46862018-01-10 18:58:09 +0800285
286 # build bl33/bl301..etc
Liang Ji51eee082019-05-20 14:01:24 +0800287 if [ ! $CONFIG_SYSTEM_AS_ROOT ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800288 CONFIG_SYSTEM_AS_ROOT=null
289 fi
Liang Ji51eee082019-05-20 14:01:24 +0800290 if [ ! $CONFIG_AVB2 ]; then
Xindong Xu33eda2d2018-09-25 18:52:38 +0800291 CONFIG_AVB2=null
292 fi
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800293 if [ ! $CONFIG_CMD_BOOTCTOL_VAB ]; then
294 CONFIG_CMD_BOOTCTOL_VAB=null
Xindong Xua75ab9b2020-05-25 15:54:01 +0800295 fi
Xindong Xuf010cc32022-05-27 11:04:43 +0800296 if [ ! $CONFIG_FASTBOOT_WRITING_CMD ]; then
297 CONFIG_FASTBOOT_WRITING_CMD=null
298 fi
Matthew Shyu9cf81ee2022-08-30 00:09:36 -0700299 if [ ! $CONFIG_AVB2_RECOVERY ]; then
300 CONFIG_AVB2_RECOVERY=null
301 fi
302 build_uboot ${CONFIG_SYSTEM_AS_ROOT} ${CONFIG_AVB2} ${CONFIG_CMD_BOOTCTOL_VAB} ${CONFIG_FASTBOOT_WRITING_CMD} ${CONFIG_AVB2_RECOVERY}
xiaobo gue6c46862018-01-10 18:58:09 +0800303
304 # source other configs after uboot compile
305 init_variable_late
306
307 # bl2/bl30/bl31..etc, build or copy from bin.git
308 build_blx $@
309
qi.wange123e7e2022-06-24 18:39:17 +0800310 if [ "1" == "${CONFIG_NASC_NAGRA_TIER_1}" ]; then
311 # combine bl2f.bin with bl33(uboot)
312 combine_bl2f_with_bl33
313 fi
314
xiaobo gue6c46862018-01-10 18:58:09 +0800315 # cp bl33(uboot)
316 copy_bl33
317
318 # cp other firmwares(soc related)
319 copy_other_soc
320
Zhongfu Luo6c2587f2019-05-15 16:27:50 +0800321 # make build directory
322 mkdir -p ${BUILD_FOLDER}
323
xiaobo gue6c46862018-01-10 18:58:09 +0800324 # package final bootloader
325 package
326
Zhongfu Luofd0ea3e2018-11-30 14:15:16 +0800327 if [ "y" != "${CONFIG_AML_SIGNED_UBOOT}" ]; then
328 # copy bootloader to main folder
329 copy_bootloader
330 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800331}
332
333function usage() {
334 cat << EOF
335 Usage:
336 $(basename $0) --help
337
xiaobo gue6c46862018-01-10 18:58:09 +0800338 Bootloader build script.
Xiaobo Gu059502e2017-01-12 21:20:39 +0800339
340 command list:
Xiaobo Gu059502e2017-01-12 21:20:39 +0800341 1. build default uboot:
342 ./$(basename $0) [config_name]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800343
xiaobo gue6c46862018-01-10 18:58:09 +0800344 2. build uboot with specified bl[x].bin
345 ./$(basename $0) [config_name] --bl[x] [path]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800346
xiaobo gue6c46862018-01-10 18:58:09 +0800347 3. build uboot with bl[x]/src source code
Xiaobo Gu059502e2017-01-12 21:20:39 +0800348 ./$(basename $0) [config_name] --update-bl[x]
Xiaobo Gu059502e2017-01-12 21:20:39 +0800349
xiaobo gue6c46862018-01-10 18:58:09 +0800350 4. print config list
351 ./$(basename $0) --config
352
353 5. check compile status with filter(optional)
354 ./$(basename $0) --check-compile [filter]
355
xiaobo gu6368ebe2018-03-29 21:49:25 +0800356 6. update aml ddr fw by source code (for g12a and later use)
357 ./$(basename $0) [config_name] --update-bl2 --ddrfw
358
dongqing.li5849ac72021-11-24 10:49:26 +0000359 7. build uboot with bl[x]/src source code, and run coverity defect
360 ./$(basename $0) [config_name] --update-bl[x] --cov
361 ./$(basename $0) [config_name] --update-bl[x] --cov-high [path]
xiaobo gue6c46862018-01-10 18:58:09 +0800362
dongqing.lic6275642021-12-17 19:15:52 +0800363 8. build uboot with ramdump function
dongqing.lidf6de9c2022-01-03 22:34:01 +0800364 ./$(basename $0) [config_name] --update-bl[x] --enable-ramdump --chipid [cpu_id]
dongqing.lic6275642021-12-17 19:15:52 +0800365
xiaobo gue6c46862018-01-10 18:58:09 +0800366 Example:
367 1) ./$(basename $0) gxb_p200_v1
368 build gxb_p200_v1 config
369
370 2) ./$(basename $0) gxb_p200_v1 --bl2 fip/bl2.bin --bl30 fip/bl30.bin
371 build gxb_p200_v1 with specified bl2.bin and bl30.bin
372
373 3) ./$(basename $0) gxb_p200_v1 --update-bl31 --update-bl2
374 build gxb_p200_v1 with bl31/bl2 source code
375
376 4) ./$(basename $0) --config
377 print config list
378
379 5) ./$(basename $0) --check-compile skt
380 check all skt board compile status
381
dongqing.lidf6de9c2022-01-03 22:34:01 +0800382 6) ./$(basename $0) sc2_ah212 --update-bl2 --update-bl2e --enable-ramdump --chipid 00D9C73147101D16
383 build uboot with ramdump function, chipid for bl2.
dongqing.lic6275642021-12-17 19:15:52 +0800384
xiaobo gue6c46862018-01-10 18:58:09 +0800385 Remark:
386 bl[x].bin/img priority:
387 1. uboot will use binaries under bl[x]/bin/ folder by default, bl[x] version specified in .repo/manifest.xml
388 2. if you want use your own bl[x].bin, specify path by add "--bl[x] [path]" parameter
389 3. if you want use bl[x].bin by compile source code, please add "--update-bl[x]" parameter
390
Xiaobo Gu059502e2017-01-12 21:20:39 +0800391
392EOF
393 exit 1
394}
395
xiaobo gue6c46862018-01-10 18:58:09 +0800396function print_config() {
397 cat << EOF
398 Usable configs:
399`uboot_config_list`
400EOF
401 exit 1
402}
403
Xiaobo Gu059502e2017-01-12 21:20:39 +0800404function parser() {
xiaobo gue6c46862018-01-10 18:58:09 +0800405 local i=0
406 local argv=()
407 for arg in "$@" ; do
408 argv[$i]="$arg"
409 i=$((i + 1))
410 done
411 i=0
412 while [ $i -lt $# ]; do
413 arg="${argv[$i]}"
xiaobo gu3ce64072018-03-06 17:20:44 +0800414 i=$((i + 1)) # must place here
xiaobo gue6c46862018-01-10 18:58:09 +0800415 case "$arg" in
416 -h|--help|help)
417 usage
418 exit ;;
419 --config)
420 print_config
xiaobo gu3ce64072018-03-06 17:20:44 +0800421 return ;;
Zhongfu Luo019ee832020-11-13 15:56:33 +0800422 # SCRIPT_ARG_CHIPSET_VARIANT is used in source variable
423 # soc, so should add first
424 --chip-varient)
425 SCRIPT_ARG_CHIPSET_VARIANT="${argv[$i]}"
426 export SCRIPT_ARG_CHIPSET_VARIANT
427 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800428 --check-compile)
xiaobo gu66f95292018-01-11 13:38:13 +0800429 check_compile "${argv[@]:$((i))}"
xiaobo gue6c46862018-01-10 18:58:09 +0800430 exit ;;
dongqing.li154e45e2021-11-22 07:47:38 +0000431 --cov|--cov-high)
dongqing.li5849ac72021-11-24 10:49:26 +0000432 PATTERN_PATH="${argv[$i]}"
433 echo "PATTERN_PATH = ${PATTERN_PATH}"
434 export PATTERN_PATH
dongqing.li154e45e2021-11-22 07:47:38 +0000435 check_coverity $@
436 exit ;;
dongqing.lidf6de9c2022-01-03 22:34:01 +0800437 --enable-ramdump)
438 CONFIG_MDUMP_COMPRESS=1
439 export CONFIG_MDUMP_COMPRESS
440 echo "SET CONFIG: CONFIG_MDUMP_COMPRESS"
441 continue ;;
dongqing.li030579d2022-04-11 10:38:27 +0800442 --enable-bl33z)
443 CONFIG_SUPPORT_BL33Z=1
444 export CONFIG_SUPPORT_BL33Z
445 echo "SET CONFIG: CONFIG_SUPPORT_BL33Z"
446 continue ;;
dongqing.li1f3354f2022-07-26 15:48:52 +0800447 --compress-bl2e)
448 CONFIG_COMPRESS_BL2E=1
449 export CONFIG_COMPRESS_BL2E
450 echo "SET CONFIG: CONFIG_COMPRESS_BL2E"
451 continue ;;
dongqing.lic6275642021-12-17 19:15:52 +0800452 --chipid)
453 CONFIG_CHIPID_SUPPORT=1
454 export CONFIG_CHIPID_SUPPORT
455 CONFIG_RAMDUMP_CHIPID="${argv[$i]}"
456 export CONFIG_RAMDUMP_CHIPID
dongqing.lidf6de9c2022-01-03 22:34:01 +0800457 echo "SET CHIP ID: ${CONFIG_RAMDUMP_CHIPID}"
dongqing.lic6275642021-12-17 19:15:52 +0800458 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800459 clean|distclean|-distclean|--distclean)
460 clean
461 exit ;;
462 *)
463 esac
464 done
465}
466
xiaobo gude8a46a2018-03-05 21:41:54 +0800467function bin_path_update() {
468 # overwrite path in case some git repository doesn't exist
469 for loop in ${!BLX_BIN_FOLDER[@]}; do
470 if [ -ne ${BLX_BIN_FOLDER[$loop]} ]; then
471 dbg "BLX_BIN_FOLDER[$loop] doesn't exist, use src code"
472 update_bin_path $loop "source"
473 fi
474 done
475
476 for loop in ${!BLX_SRC_FOLDER[@]}; do
477 echo ""
478 done
479}
480
xiaobo gue6c46862018-01-10 18:58:09 +0800481function bin_path_parser() {
482 local i=0
483 local argv=()
484 for arg in "$@" ; do
485 argv[$i]="$arg"
486 i=$((i + 1))
487 done
488 i=0
xiaobo gu6368ebe2018-03-29 21:49:25 +0800489 # ddr fw define, co-work with bl2 build script
490 export CONFIG_DDR_FW
xiaobo gue6c46862018-01-10 18:58:09 +0800491 while [ $i -lt $# ]; do
492 arg="${argv[$i]}"
493 i=$((i + 1)) # must pleace here
494 case "$arg" in
495 --bl2)
496 update_bin_path 0 "${argv[@]:$((i))}"
497 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400498 --bl2e)
499 update_bin_path 5 "${argv[@]:$((i))}"
500 continue ;;
Tao Zeng73e504b2021-07-13 12:29:08 +0800501 --bl2e-size)
502 BL2E_PAYLOAD_SIZE="${argv[i]}"
503 export BL2E_PAYLOAD_SIZE
504 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400505 --bl2x)
506 update_bin_path 6 "${argv[@]:$((i))}"
507 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800508 --bl30)
509 update_bin_path 1 "${argv[@]:$((i))}"
510 continue ;;
511 --bl31)
512 update_bin_path 2 "${argv[@]:$((i))}"
513 continue ;;
514 --bl32)
515 update_bin_path 3 "${argv[@]:$((i))}"
516 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400517 --bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800518 update_bin_path 4 "${argv[@]:$((i))}"
519 continue ;;
Tao Zeng68361e62021-01-06 17:29:40 +0800520 --ddr-fip)
521 DDR_FIP_EXTERN_PATH="${argv[@]:$((i))}"
522 export DDR_FIP_EXTERN_PATH
523 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400524 --sign-bl40)
Zhongfu Luo3e54c6f2020-02-15 21:30:50 +0800525 update_bin_path 4 "${argv[@]:$((i))}"
526 CONFIG_SIGN_BL40=1
527 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800528 --update-bl2)
529 update_bin_path 0 "source"
530 continue ;;
Honglin Zhang637c38b2020-06-28 02:16:39 -0400531 --update-bl2e)
532 update_bin_path 5 "source"
qi.wange123e7e2022-06-24 18:39:17 +0800533 if [ "1" == "${CONFIG_NASC_NAGRA_TIER_1}" ]; then
534 BL2F_UPDATE_TYPE=y
535 export BL2F_UPDATE_TYPE
536 fi
Tao Zeng332fda22021-07-23 17:52:42 +0800537 if [[ ${argv[i]} == "sto" || ${argv[i]} == "usb" ]]; then
538 BL2E_UPDATE_TYPE=${argv[i]}
539 export BL2E_UPDATE_TYPE
540 fi
Honglin Zhang637c38b2020-06-28 02:16:39 -0400541 continue ;;
542 --update-bl2x)
543 update_bin_path 6 "source"
544 continue ;;
Tao Zeng68361e62021-01-06 17:29:40 +0800545 --update-ddr-fip)
546 GENERATE_DDR_FIP=1
547 export GENERATE_DDR_FIP
548 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800549 --update-bl30)
550 update_bin_path 1 "source"
551 continue ;;
552 --update-bl31)
553 update_bin_path 2 "source"
554 continue ;;
555 --update-bl32)
556 update_bin_path 3 "source"
557 continue ;;
Tao Zengff03b402020-12-09 15:01:44 +0800558 --bl2-branch)
559 BL2_BRANCH_ARG="${argv[i]}"
560 export BL2_BRANCH_ARG
561 continue ;;
xiaobo gu6368ebe2018-03-29 21:49:25 +0800562 --ddrfw)
563 CONFIG_DDR_FW=1
564 export CONFIG_DDR_FW
565 continue ;;
Bo Lv9edb6992021-09-06 11:31:00 +0800566 --jenkins-sign)
567 CONFIG_JENKINS_SIGN=1
568 export CONFIG_JENKINS_SIGN
569 continue ;;
570 --former-sign)
571 CONFIG_FORMER_SIGN=1
572 export CONFIG_FORMER_SIGN
573 continue ;;
Zhongfu Luo43f1a8a2022-03-16 19:13:07 +0800574 --build-unsign)
575 CONFIG_BUILD_UNSIGN=1
576 export CONFIG_BUILD_UNSIGN
577 continue ;;
qi.wange123e7e2022-06-24 18:39:17 +0800578 --nasc_nagra_tier_1)
579 CONFIG_NASC_NAGRA_TIER_1=1
580 export CONFIG_NASC_NAGRA_TIER_1
581 continue;;
Bo Lvc8e2bee2022-09-28 12:48:45 +0800582 --build-nogit)
583 CONFIG_WITHOUT_BIN_GIT=1
584 export CONFIG_WITHOUT_BIN_GIT
585 continue ;;
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800586 --cas)
587 cas="${argv[$i]}"
588 #limit the "--cas xxx" only works for g12a
Lawrence Mok762306e2020-05-13 20:38:08 -0700589 if [ "${CUR_SOC}" == "g12a" ] ||
590 ( [ "${cas}" == "vmx" ] && [ "${CUR_SOC}" == "gxl" ] ); then
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800591 CONFIG_CAS=${cas}
592 fi
Sangho Lee6be1bf22021-05-24 07:54:37 +0800593 if [ "${CUR_SOC}" == "sc2" ] && [ "${cas}" == "nsk" ]; then
594 CONFIG_CAS=${cas}
595 fi
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800596 if [[ "${CONFIG_CAS}" == "irdeto" || \
597 "${CONFIG_CAS}" == "vmx" || \
598 "${CONFIG_CAS}" == "nagra" ]]; then
599 CONFIG_AML_SIGNED_UBOOT=y
600 export CONFIG_AML_SIGNED_UBOOT
601 fi
Lawrence Mok048be0f2020-02-24 18:03:43 -0800602 if [ "${CONFIG_CAS}" == "vmx" ]; then
603 dbg "Loading CAS VMX config"
604 source fip/config_cas_vmx.sh
605 fi
Doosan Baek284dc972022-02-11 11:04:26 +0800606 if [ "${CUR_SOC}" == "s4" ] && [ "${cas}" == "gs" ]; then
607 CONFIG_CAS=${cas}
608 fi
Honglin Zhang8fa9d152020-02-10 12:29:27 +0800609 echo "CAS: ${cas},${CONFIG_CAS}"
610 export CONFIG_CAS
611 continue ;;
Xindong Xuad0d2832018-07-30 19:15:52 +0800612 --systemroot)
613 CONFIG_SYSTEM_AS_ROOT=systemroot
614 echo "export CONFIG_SYSTEM_AS_ROOT"
615 export CONFIG_SYSTEM_AS_ROOT=systemroot
616 continue ;;
Xindong Xu33eda2d2018-09-25 18:52:38 +0800617 --avb2)
618 CONFIG_AVB2=avb2
619 echo "export CONFIG_AVB2"
620 export CONFIG_AVB2=avb2
621 continue ;;
Xindong Xu9cf4afc2020-07-24 17:10:21 +0800622 --vab)
623 CONFIG_CMD_BOOTCTOL_VAB=1
624 echo "export CONFIG_CMD_BOOTCTOL_VAB"
625 export CONFIG_CMD_BOOTCTOL_VAB=1
Xindong Xua75ab9b2020-05-25 15:54:01 +0800626 continue ;;
Xindong Xuf010cc32022-05-27 11:04:43 +0800627 --fastboot-write)
628 CONFIG_FASTBOOT_WRITING_CMD=1
629 echo "export CONFIG_FASTBOOT_WRITING_CMD"
630 export CONFIG_FASTBOOT_WRITING_CMD=1
631 continue ;;
Matthew Shyu9cf81ee2022-08-30 00:09:36 -0700632 --avb2-recovery)
633 CONFIG_AVB2_RECOVERY=1
634 echo "export CONFIG_AVB2_RECOVERY"
635 export CONFIG_AVB2_RECOVERY=1
636 continue ;;
xiaobo gue6c46862018-01-10 18:58:09 +0800637 *)
638 esac
639 done
Xiaobo Gu059502e2017-01-12 21:20:39 +0800640}
641
qi.wange123e7e2022-06-24 18:39:17 +0800642function combine_bl2f_with_bl33() {
643 if [ "1" == "${CONFIG_NASC_NAGRA_TIER_1}" ]; then
644 # place bl2f at end of u-boot.bin, _end align(4096)
645 if [ "y" == "${BL2F_UPDATE_TYPE}" ]; then
646 BL2F_BIN=bl2/ree/bl2f/bl2f.bin
647 else
648 echo CUR_SOC is $CUR_SOC
649 echo CONFIG_CHIPSET_NAME is $CONFIG_CHIPSET_NAME
650 BL2F_BIN=bl2/bin/$CUR_SOC/$CONFIG_CHIPSET_NAME/bl2f.bin
651 fi
652
653 if [ ! -f ${BL2F_BIN} ]; then
654 echo No $BL2F_BIN
655 exit -1
656 fi
657
658 END_LENS=`stat -c "%s" "./bl33/v2019/build/u-boot.bin"`
659 END_ALIGN=4096
660 BL2F_LOAD=`echo "((($END_LENS-1) / $END_ALIGN * $END_ALIGN) + $END_ALIGN)" | bc`
661 echo "uboot.bin size:$END_LENS, align:$END_ALIGN, new uboot size:$BL2F_LOAD"
662
663 dd if=/dev/zero of=./bl33/v2019/u-boot.tmp bs=$BL2F_LOAD count=1
664 dd if=./bl33/v2019/build/u-boot.bin of=./bl33/v2019/u-boot.tmp conv=notrunc &> /dev/null
665 cat $BL2F_BIN >> bl33/v2019/u-boot.tmp
666 cp -rf bl33/v2019/u-boot.tmp bl33/v2019/build/u-boot.bin
667 echo "Append bl2f.bin to the end of uboot.bin OK."
668 fi
669}
670
Xiaobo Gu059502e2017-01-12 21:20:39 +0800671function main() {
xiaobo gue6c46862018-01-10 18:58:09 +0800672 if [ -z $1 ]
673 then
674 usage
675 return
676 fi
Xiaobo Gu059502e2017-01-12 21:20:39 +0800677
xiaobo gue6c46862018-01-10 18:58:09 +0800678 MAIN_FOLDER=`pwd`
679 parser $@
680 build $@
Xiaobo Gu059502e2017-01-12 21:20:39 +0800681}
682
683main $@ # parse all paras to function