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