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