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