Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 1 | #!/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 Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 6 | # 2017.05.20-2017.05.26 Update for txlx and ATF1.3 |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 7 | |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 8 | # include compile check script |
| 9 | source fip/check_compile.sh |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 10 | source fip/variables.sh |
| 11 | source fip/lib.sh |
| 12 | source fip/build_bl2.sh |
| 13 | source fip/build_bl30.sh |
| 14 | source fip/build_bl31.sh |
| 15 | source fip/build_bl32.sh |
| 16 | source fip/build_bl33.sh |
| 17 | source fip/build_bl40.sh |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 18 | |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 19 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 20 | function init_variable_early() { |
| 21 | # source uboot pre-build configs |
| 22 | if [ ! -e ${SOURCE_FILE} ]; then |
| 23 | echo "${SOURCE_FILE} doesn't exist!" |
| 24 | cd ${MAIN_FOLDER} |
| 25 | exit -1 |
| 26 | else |
| 27 | source ${SOURCE_FILE} &> /dev/null # ignore warning/error |
| 28 | fi |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 29 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 30 | CUR_SOC=${CONFIG_SYS_SOC} |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 31 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 32 | if [ "y" == "${CONFIG_NEED_BL32}" ]; then |
| 33 | BLX_NEEDFUL[3]="true" |
| 34 | fi |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 35 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 36 | # export variables |
| 37 | #export FIP_BUILD_FOLDER |
| 38 | #export CUR_SOC |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 39 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 40 | export_variables |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 41 | } |
| 42 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 43 | function init_variable_late() { |
| 44 | # after uboot build, source configs |
xiaobo gu | a64f93c | 2018-07-31 21:27:43 +0800 | [diff] [blame] | 45 | local CONFIG_FILE_TMP="${MAIN_FOLDER}/autoconf" |
| 46 | local STR_INVALID="option" |
| 47 | if [ ! -e ${CONFIG_FILE} ]; then |
| 48 | echo "${CONFIG_FILE} doesn't exist!" |
| 49 | cd ${MAIN_FOLDER} |
| 50 | exit -1 |
| 51 | else |
| 52 | # workaround for source file error |
| 53 | while read LINE |
| 54 | do |
| 55 | #echo $LINE |
| 56 | # ignore "*(option)*" lines |
| 57 | if [[ ${LINE} =~ ${STR_INVALID} ]]; then |
| 58 | echo "ignore: $LINE" |
| 59 | else |
| 60 | #echo "LINE: ${LINE}" |
| 61 | echo "$LINE" >> "${CONFIG_FILE_TMP}" |
| 62 | fi |
| 63 | done < ${CONFIG_FILE} |
| 64 | source "${CONFIG_FILE_TMP}" &> /dev/null |
| 65 | rm ${CONFIG_FILE_TMP} |
| 66 | fi |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 67 | if [ "y" == "${CONFIG_SUPPORT_CUSOTMER_BOARD}" ]; then |
| 68 | BOARD_DIR="customer/board/${CONFIG_SYS_BOARD}" |
| 69 | else |
| 70 | BOARD_DIR="${CONFIG_BOARDDIR}" |
| 71 | fi |
xiaobo gu | a64f93c | 2018-07-31 21:27:43 +0800 | [diff] [blame] | 72 | export BOARD_DIR |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | function build_blx_src() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 76 | # compile $name $src_folder $bin_folder $soc |
| 77 | local name=$1 |
| 78 | local src_folder=$2 |
| 79 | local bin_folder=$3 |
| 80 | local soc=$4 |
| 81 | #dbg "compile - name: ${name}, src_folder: ${src_folder}, bin_folder: ${bin_folder}, soc: ${soc}" |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 82 | if [ $name == ${BLX_NAME_GLB[0]} ]; then |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 83 | # bl2 |
| 84 | build_bl2 $src_folder $bin_folder $soc |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 85 | elif [ $name == ${BLX_NAME_GLB[1]} ]; then |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 86 | # bl30 |
| 87 | build_bl30 $src_folder $bin_folder $soc |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 88 | elif [ $name == ${BLX_NAME_GLB[2]} ]; then |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 89 | # bl31 |
| 90 | # some soc use v1.3 |
| 91 | check_bl31_ver $soc |
| 92 | if [ $? != 0 ]; then |
| 93 | echo "check bl31 ver: use v1.3" |
| 94 | build_bl31_v1_3 $src_folder $bin_folder $soc |
| 95 | else |
| 96 | echo "check bl31 ver: use v1.0" |
| 97 | build_bl31 $src_folder $bin_folder $soc |
| 98 | fi |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 99 | elif [ $name == ${BLX_NAME_GLB[3]} ]; then |
xiaobo gu | e8bf44f | 2019-03-18 14:23:36 +0800 | [diff] [blame] | 100 | # control flow for jenkins patchbuild |
| 101 | if [ "$BUILD_TYPE" != "AOSP" ]; then |
| 102 | # bl32 |
| 103 | if [ "y" == "${CONFIG_NEED_BL32}" ]; then |
| 104 | build_bl32 $src_folder $bin_folder $soc |
| 105 | fi |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 106 | fi |
| 107 | fi |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | function build_blx() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 111 | # build each blx |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 112 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 113 | # switch bl31 version |
| 114 | switch_bl31 ${CUR_SOC} |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 115 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 116 | # get version of each blx |
| 117 | get_versions |
Xiaobo Gu | 9dd3f3f | 2017-05-26 17:58:57 +0800 | [diff] [blame] | 118 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 119 | # build loop |
| 120 | for loop in ${!BLX_NAME[@]}; do |
Honglin Zhang | 805bd10 | 2020-02-14 18:23:23 +0800 | [diff] [blame^] | 121 | dbg "BIN_PATH[${loop}]: ${BIN_PATH[$loop]}" |
| 122 | if [ "null" == ${BIN_PATH[$loop]} ]; then |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 123 | get_blx_bin ${loop} |
Honglin Zhang | 805bd10 | 2020-02-14 18:23:23 +0800 | [diff] [blame^] | 124 | elif [ "source" == ${BIN_PATH[$loop]} ]; then |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 125 | dbg "Build blx source code..." |
Honglin Zhang | 805bd10 | 2020-02-14 18:23:23 +0800 | [diff] [blame^] | 126 | build_blx_src ${BLX_NAME[$loop]} ${BLX_SRC_FOLDER[$loop]} ${FIP_BUILD_FOLDER} ${CUR_SOC} |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 127 | else |
Honglin Zhang | 805bd10 | 2020-02-14 18:23:23 +0800 | [diff] [blame^] | 128 | if [ ! -e ${BIN_PATH[$loop]} ]; then |
| 129 | echo "Error: ${BIN_PATH[$loop]} doesn't exist... abort" |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 130 | exit -1 |
| 131 | else |
Honglin Zhang | 805bd10 | 2020-02-14 18:23:23 +0800 | [diff] [blame^] | 132 | cp ${BIN_PATH[$loop]} ${FIP_BUILD_FOLDER} -f |
| 133 | echo "Get ${BLX_NAME[$loop]} from ${BIN_PATH[$loop]}... done" |
| 134 | fi |
| 135 | fi |
| 136 | |
| 137 | # start to check the blx firmware |
| 138 | if [ "bl32" == "${BLX_NAME[$loop]}" ]; then |
| 139 | # no bl32 are exported for users |
| 140 | check_bypass=y |
| 141 | else |
| 142 | check_bypass=n |
| 143 | fi |
| 144 | |
| 145 | if [ "y" != "${check_bypass}" ]; then |
| 146 | if [ "NULL" != "${BLX_BIN_NAME[$loop]}" ] && \ |
| 147 | [ ! -f ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} ]; then |
| 148 | echo "Error Result: ${FIP_BUILD_FOLDER}/${BLX_BIN_NAME[$loop]} doesn't exit... abort" |
| 149 | exit -1 |
| 150 | fi |
| 151 | if [ "y" == "${CONFIG_FIP_IMG_SUPPORT}" ] && \ |
| 152 | [ -n "${BLX_IMG_NAME[$loop]}" ] && \ |
| 153 | [ "NULL" != "${BLX_IMG_NAME[$loop]}" ] && \ |
| 154 | [ ! -f ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} ]; then |
| 155 | echo "Error Result: ${FIP_BUILD_FOLDER}/${BLX_IMG_NAME[$loop]} doesn't exit... abort" |
| 156 | exit -1 |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 157 | fi |
| 158 | fi |
| 159 | done |
| 160 | return |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | copy_bootloader() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 164 | mkdir -p ${BUILD_FOLDER} |
Haixiang Bao | f008dc1 | 2019-05-23 18:47:15 +0800 | [diff] [blame] | 165 | cp ${FIP_BUILD_FOLDER}u-boot.bin* ${BUILD_FOLDER} |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 166 | if [ "y" == "${CONFIG_AML_CRYPTO_IMG}" ]; then |
| 167 | cp ${FIP_BUILD_FOLDER}boot.img.encrypt ${BUILD_FOLDER}boot.img.encrypt |
| 168 | fi |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | function update_bin_path() { |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 172 | for loop in ${!BLX_NAME[@]}; do |
| 173 | if [ "${BLX_NAME[$loop]}" == "${BLX_NAME_GLB[$1]}" ]; then |
Honglin Zhang | cd8a9fc | 2019-11-22 17:52:55 +0800 | [diff] [blame] | 174 | dbg "Update BIN_PATH[$loop]=$2" |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 175 | BIN_PATH[$loop]=$2 |
Honglin Zhang | cd8a9fc | 2019-11-22 17:52:55 +0800 | [diff] [blame] | 176 | break |
xiaobo gu | 8a3907e | 2019-05-22 11:46:49 +0800 | [diff] [blame] | 177 | fi |
| 178 | done |
| 179 | } |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 180 | |
| 181 | function clean() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 182 | echo "Clean up" |
xiaobo gu | 0c2598b | 2019-06-28 11:22:17 +0800 | [diff] [blame] | 183 | if [ -e ${BL33_PATH1} ]; then |
| 184 | cd ${MAIN_FOLDER} |
| 185 | cd ${BL33_PATH1} |
| 186 | make distclean |
| 187 | fi |
| 188 | if [ -e ${BL33_PATH2} ]; then |
| 189 | cd ${MAIN_FOLDER} |
| 190 | cd ${BL33_PATH2} |
| 191 | make distclean |
| 192 | fi |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 193 | cd ${MAIN_FOLDER} |
| 194 | rm ${FIP_BUILD_FOLDER} -rf |
xiaobo gu | 3ce6407 | 2018-03-06 17:20:44 +0800 | [diff] [blame] | 195 | rm ${BUILD_FOLDER}/* -rf |
Haixiang Bao | f008dc1 | 2019-05-23 18:47:15 +0800 | [diff] [blame] | 196 | mkdir -p ${BUILD_FOLDER} |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 197 | return |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | function build() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 201 | # ************************************************* |
| 202 | # IMPORTANT!!!! |
| 203 | # don't change sequence of following function call |
| 204 | # ************************************************* |
| 205 | clean |
| 206 | |
| 207 | # pre-build, get .config defines |
| 208 | pre_build_uboot $@ |
| 209 | |
| 210 | # variable init depends on uboot .config |
| 211 | init_variable_early $@ |
| 212 | |
| 213 | # must source under main function, all sub function can use these variables |
| 214 | # but if source in sub-function, only sub-function(or sub-sub..) can use them |
| 215 | source ${FIP_FOLDER}${CUR_SOC}/variable_soc.sh |
| 216 | |
Honglin Zhang | 694f534 | 2019-12-09 14:54:40 +0800 | [diff] [blame] | 217 | # compile fip tools for ddr_parse and map_tool |
| 218 | prepare_tools |
| 219 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 220 | # source soc package script |
| 221 | source ${FIP_FOLDER}${CUR_SOC}/build.sh |
| 222 | |
| 223 | # update bin path, use bin.git or user defined or source code |
| 224 | bin_path_parser $@ |
xiaobo gu | de8a46a | 2018-03-05 21:41:54 +0800 | [diff] [blame] | 225 | #bin_path_update $@ |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 226 | |
| 227 | # build bl33/bl301..etc |
Liang Ji | 51eee08 | 2019-05-20 14:01:24 +0800 | [diff] [blame] | 228 | if [ ! $CONFIG_SYSTEM_AS_ROOT ]; then |
Xindong Xu | 33eda2d | 2018-09-25 18:52:38 +0800 | [diff] [blame] | 229 | CONFIG_SYSTEM_AS_ROOT=null |
| 230 | fi |
Liang Ji | 51eee08 | 2019-05-20 14:01:24 +0800 | [diff] [blame] | 231 | if [ ! $CONFIG_AVB2 ]; then |
Xindong Xu | 33eda2d | 2018-09-25 18:52:38 +0800 | [diff] [blame] | 232 | CONFIG_AVB2=null |
| 233 | fi |
| 234 | build_uboot ${CONFIG_SYSTEM_AS_ROOT} ${CONFIG_AVB2} |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 235 | |
| 236 | # source other configs after uboot compile |
| 237 | init_variable_late |
| 238 | |
| 239 | # bl2/bl30/bl31..etc, build or copy from bin.git |
| 240 | build_blx $@ |
| 241 | |
| 242 | # cp bl33(uboot) |
| 243 | copy_bl33 |
| 244 | |
| 245 | # cp other firmwares(soc related) |
| 246 | copy_other_soc |
| 247 | |
Zhongfu Luo | 6c2587f | 2019-05-15 16:27:50 +0800 | [diff] [blame] | 248 | # make build directory |
| 249 | mkdir -p ${BUILD_FOLDER} |
| 250 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 251 | # package final bootloader |
| 252 | package |
| 253 | |
Zhongfu Luo | fd0ea3e | 2018-11-30 14:15:16 +0800 | [diff] [blame] | 254 | if [ "y" != "${CONFIG_AML_SIGNED_UBOOT}" ]; then |
| 255 | # copy bootloader to main folder |
| 256 | copy_bootloader |
| 257 | fi |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | function usage() { |
| 261 | cat << EOF |
| 262 | Usage: |
| 263 | $(basename $0) --help |
| 264 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 265 | Bootloader build script. |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 266 | |
| 267 | command list: |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 268 | 1. build default uboot: |
| 269 | ./$(basename $0) [config_name] |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 270 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 271 | 2. build uboot with specified bl[x].bin |
| 272 | ./$(basename $0) [config_name] --bl[x] [path] |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 273 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 274 | 3. build uboot with bl[x]/src source code |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 275 | ./$(basename $0) [config_name] --update-bl[x] |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 276 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 277 | 4. print config list |
| 278 | ./$(basename $0) --config |
| 279 | |
| 280 | 5. check compile status with filter(optional) |
| 281 | ./$(basename $0) --check-compile [filter] |
| 282 | |
xiaobo gu | 6368ebe | 2018-03-29 21:49:25 +0800 | [diff] [blame] | 283 | 6. update aml ddr fw by source code (for g12a and later use) |
| 284 | ./$(basename $0) [config_name] --update-bl2 --ddrfw |
| 285 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 286 | |
| 287 | Example: |
| 288 | 1) ./$(basename $0) gxb_p200_v1 |
| 289 | build gxb_p200_v1 config |
| 290 | |
| 291 | 2) ./$(basename $0) gxb_p200_v1 --bl2 fip/bl2.bin --bl30 fip/bl30.bin |
| 292 | build gxb_p200_v1 with specified bl2.bin and bl30.bin |
| 293 | |
| 294 | 3) ./$(basename $0) gxb_p200_v1 --update-bl31 --update-bl2 |
| 295 | build gxb_p200_v1 with bl31/bl2 source code |
| 296 | |
| 297 | 4) ./$(basename $0) --config |
| 298 | print config list |
| 299 | |
| 300 | 5) ./$(basename $0) --check-compile skt |
| 301 | check all skt board compile status |
| 302 | |
| 303 | Remark: |
| 304 | bl[x].bin/img priority: |
| 305 | 1. uboot will use binaries under bl[x]/bin/ folder by default, bl[x] version specified in .repo/manifest.xml |
| 306 | 2. if you want use your own bl[x].bin, specify path by add "--bl[x] [path]" parameter |
| 307 | 3. if you want use bl[x].bin by compile source code, please add "--update-bl[x]" parameter |
| 308 | |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 309 | |
| 310 | EOF |
| 311 | exit 1 |
| 312 | } |
| 313 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 314 | function print_config() { |
| 315 | cat << EOF |
| 316 | Usable configs: |
| 317 | `uboot_config_list` |
| 318 | EOF |
| 319 | exit 1 |
| 320 | } |
| 321 | |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 322 | function parser() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 323 | local i=0 |
| 324 | local argv=() |
| 325 | for arg in "$@" ; do |
| 326 | argv[$i]="$arg" |
| 327 | i=$((i + 1)) |
| 328 | done |
| 329 | i=0 |
| 330 | while [ $i -lt $# ]; do |
| 331 | arg="${argv[$i]}" |
xiaobo gu | 3ce6407 | 2018-03-06 17:20:44 +0800 | [diff] [blame] | 332 | i=$((i + 1)) # must place here |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 333 | case "$arg" in |
| 334 | -h|--help|help) |
| 335 | usage |
| 336 | exit ;; |
| 337 | --config) |
| 338 | print_config |
xiaobo gu | 3ce6407 | 2018-03-06 17:20:44 +0800 | [diff] [blame] | 339 | return ;; |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 340 | --check-compile) |
xiaobo gu | 66f9529 | 2018-01-11 13:38:13 +0800 | [diff] [blame] | 341 | check_compile "${argv[@]:$((i))}" |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 342 | exit ;; |
| 343 | clean|distclean|-distclean|--distclean) |
| 344 | clean |
| 345 | exit ;; |
| 346 | *) |
| 347 | esac |
| 348 | done |
| 349 | } |
| 350 | |
xiaobo gu | de8a46a | 2018-03-05 21:41:54 +0800 | [diff] [blame] | 351 | function bin_path_update() { |
| 352 | # overwrite path in case some git repository doesn't exist |
| 353 | for loop in ${!BLX_BIN_FOLDER[@]}; do |
| 354 | if [ -ne ${BLX_BIN_FOLDER[$loop]} ]; then |
| 355 | dbg "BLX_BIN_FOLDER[$loop] doesn't exist, use src code" |
| 356 | update_bin_path $loop "source" |
| 357 | fi |
| 358 | done |
| 359 | |
| 360 | for loop in ${!BLX_SRC_FOLDER[@]}; do |
| 361 | echo "" |
| 362 | done |
| 363 | } |
| 364 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 365 | function bin_path_parser() { |
| 366 | local i=0 |
| 367 | local argv=() |
| 368 | for arg in "$@" ; do |
| 369 | argv[$i]="$arg" |
| 370 | i=$((i + 1)) |
| 371 | done |
| 372 | i=0 |
xiaobo gu | 6368ebe | 2018-03-29 21:49:25 +0800 | [diff] [blame] | 373 | # ddr fw define, co-work with bl2 build script |
| 374 | export CONFIG_DDR_FW |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 375 | while [ $i -lt $# ]; do |
| 376 | arg="${argv[$i]}" |
| 377 | i=$((i + 1)) # must pleace here |
| 378 | case "$arg" in |
| 379 | --bl2) |
| 380 | update_bin_path 0 "${argv[@]:$((i))}" |
| 381 | continue ;; |
| 382 | --bl30) |
| 383 | update_bin_path 1 "${argv[@]:$((i))}" |
| 384 | continue ;; |
| 385 | --bl31) |
| 386 | update_bin_path 2 "${argv[@]:$((i))}" |
| 387 | continue ;; |
| 388 | --bl32) |
| 389 | update_bin_path 3 "${argv[@]:$((i))}" |
| 390 | continue ;; |
Zhongfu Luo | 3e54c6f | 2020-02-15 21:30:50 +0800 | [diff] [blame] | 391 | --bl40) |
| 392 | update_bin_path 4 "${argv[@]:$((i))}" |
| 393 | continue ;; |
| 394 | --sign-bl40) |
| 395 | update_bin_path 4 "${argv[@]:$((i))}" |
| 396 | CONFIG_SIGN_BL40=1 |
| 397 | continue ;; |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 398 | --update-bl2) |
| 399 | update_bin_path 0 "source" |
| 400 | continue ;; |
| 401 | --update-bl30) |
| 402 | update_bin_path 1 "source" |
| 403 | continue ;; |
| 404 | --update-bl31) |
| 405 | update_bin_path 2 "source" |
| 406 | continue ;; |
| 407 | --update-bl32) |
| 408 | update_bin_path 3 "source" |
| 409 | continue ;; |
xiaobo gu | 6368ebe | 2018-03-29 21:49:25 +0800 | [diff] [blame] | 410 | --ddrfw) |
| 411 | CONFIG_DDR_FW=1 |
| 412 | export CONFIG_DDR_FW |
| 413 | continue ;; |
Honglin Zhang | 8fa9d15 | 2020-02-10 12:29:27 +0800 | [diff] [blame] | 414 | --cas) |
| 415 | cas="${argv[$i]}" |
| 416 | #limit the "--cas xxx" only works for g12a |
| 417 | if [ "${CUR_SOC}" == "g12a" ]; then |
| 418 | CONFIG_CAS=${cas} |
| 419 | fi |
| 420 | if [[ "${CONFIG_CAS}" == "irdeto" || \ |
| 421 | "${CONFIG_CAS}" == "vmx" || \ |
| 422 | "${CONFIG_CAS}" == "nagra" ]]; then |
| 423 | CONFIG_AML_SIGNED_UBOOT=y |
| 424 | export CONFIG_AML_SIGNED_UBOOT |
| 425 | fi |
Lawrence Mok | 048be0f | 2020-02-24 18:03:43 -0800 | [diff] [blame] | 426 | if [ "${CONFIG_CAS}" == "vmx" ]; then |
| 427 | dbg "Loading CAS VMX config" |
| 428 | source fip/config_cas_vmx.sh |
| 429 | fi |
Honglin Zhang | 8fa9d15 | 2020-02-10 12:29:27 +0800 | [diff] [blame] | 430 | echo "CAS: ${cas},${CONFIG_CAS}" |
| 431 | export CONFIG_CAS |
| 432 | continue ;; |
Xindong Xu | ad0d283 | 2018-07-30 19:15:52 +0800 | [diff] [blame] | 433 | --systemroot) |
| 434 | CONFIG_SYSTEM_AS_ROOT=systemroot |
| 435 | echo "export CONFIG_SYSTEM_AS_ROOT" |
| 436 | export CONFIG_SYSTEM_AS_ROOT=systemroot |
| 437 | continue ;; |
Xindong Xu | 33eda2d | 2018-09-25 18:52:38 +0800 | [diff] [blame] | 438 | --avb2) |
| 439 | CONFIG_AVB2=avb2 |
| 440 | echo "export CONFIG_AVB2" |
| 441 | export CONFIG_AVB2=avb2 |
| 442 | continue ;; |
Matthew Shyu | 4a86371 | 2020-02-19 17:58:17 +0800 | [diff] [blame] | 443 | --avb2-fipkey) |
| 444 | CONFIG_AVB2_KPUB_FROM_FIP=1 |
| 445 | echo "export CONFIG_AVB2_KPUB_FROM_FIP" |
| 446 | export CONFIG_AVB2_KPUB_FROM_FIP=1 |
| 447 | continue ;; |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 448 | *) |
| 449 | esac |
| 450 | done |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | function main() { |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 454 | if [ -z $1 ] |
| 455 | then |
| 456 | usage |
| 457 | return |
| 458 | fi |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 459 | |
xiaobo gu | e6c4686 | 2018-01-10 18:58:09 +0800 | [diff] [blame] | 460 | MAIN_FOLDER=`pwd` |
| 461 | parser $@ |
| 462 | build $@ |
Xiaobo Gu | 059502e | 2017-01-12 21:20:39 +0800 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | main $@ # parse all paras to function |