| #!/bin/bash |
| exec_name=$0 |
| |
| set -o errtrace |
| trap 'echo Fatal error: script ${exec_name} aborting at line $LINENO, command \"$BASH_COMMAND\" returned $?; exit 1' ERR |
| |
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| |
| function usage(){ |
| echo "Usage: ${exec_name} <board> <out> [build_config]" |
| echo "" |
| echo "board: estelle-p1, estelle-p2" |
| echo " newman-p2, newman-p2_1, newman-b1, newman-b3, newman-b4" |
| echo " legion-p1" |
| echo " puddy-p0, puddy-pdfc, puddy-p1" |
| echo " lucy-px" |
| echo "" |
| echo "out: build artifacts will be copied to <out>/vendor/amlogic" |
| echo "" |
| echo "build_config: dev, dogfood, or prod" |
| echo " defaults to dev" |
| } |
| |
| function building_uboot(){ |
| local -r soc_family_name=$1 |
| local -r local_name=$2 |
| local -r rev=$3 |
| local -r board_name=$4 |
| local -r debug_flag=$5 |
| local -r cfg_suffix=$6 |
| |
| local -r config=${local_name}_${rev}${cfg_suffix} |
| echo "building ${BUILD_CONFIG} u-boot for ${board}" |
| |
| # This controls whether running u-boot from RAM (`update bl2_boot <image>`) |
| # stops at the u-boot commandline or not. We want to use fastboot instead so |
| # we normally disable this, but it can be turned on locally for development |
| # if the u-boot commandline is needed. |
| export ENABLE_UBOOT_UPDATE=0 |
| |
| # Even though we guard this behind device unlock, we still don't want it |
| # on release builds. The commandline gives a lot of power, and it's possible |
| # someone could make changes that persist even after re-locking. |
| export ENABLE_COMMANDLINE=0 |
| if [ "${debug_flag}" == debug ]; then |
| ENABLE_COMMANDLINE=1 |
| fi |
| |
| pushd "${DIR}" >/dev/null |
| ./mk ${config} --board_name ${board_name} \ |
| --bl2 "fip/${soc_family_name}/bl2.bin" \ |
| --bl30 "fip/${soc_family_name}/bl30.bin" \ |
| --bl31 "fip/${soc_family_name}/bl31.img" \ |
| --bl32 "fip/${soc_family_name}/bl32.img" \ |
| ${debug_flag} |
| popd >/dev/null |
| |
| # make T=1 to use latest git commit time as build timestamp. |
| |
| product=`echo ${board} | cut -d "-" -f1` |
| if [ ! -z "${out_root}" ]; then |
| out_dir="${out_root}/vendor/amlogic/${product}/prebuilt/${BUILD_CONFIG}/bootloader" |
| echo "Copying artifacts to ${out_dir}" |
| mkdir -p "${out_dir}" |
| |
| if [ "${product}" == "estelle" ] || [ "${product}" == "newman" ] || [ "${product}" == "legion" ] || [ "${product}" == "puddy" ] || [ "${product}" == "lucy" ]; then |
| # Copy bl2 and bl3x images for bootloader signing. |
| cp "${DIR}/fip/build/bl2_new.bin" "${out_dir}/bl2_new.bin.${board}" |
| cp "${DIR}/fip/build/bl30_new.bin" "${out_dir}/bl30_new.bin.${board}" |
| cp "${DIR}/fip/build/bl31.img" "${out_dir}/bl31.img.${board}" |
| cp "${DIR}/fip/build/bl32.img" "${out_dir}/bl32.img.${board}" |
| cp "${DIR}/fip/build/bl33.bin" "${out_dir}/bl33.bin.${board}" |
| |
| # Copy ddr bin for bootloader signing. |
| # TODO(ljchen): Remove hard code of ddr files under vendor/amlogic. |
| cp "${DIR}/fip/${soc_family_name}/ddr4_1d.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/ddr4_2d.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/ddr3_1d.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/piei.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/lpddr4_1d.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/lpddr4_2d.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/diag_lpddr4.fw" "${out_dir}" |
| cp "${DIR}/fip/${soc_family_name}/aml_ddr.fw" "${out_dir}" |
| |
| else |
| cp "${DIR}/fip/${soc_family_name}/u-boot.bin.usb.bl2" "${out_dir}/u-boot.bin.usb.bl2" |
| cp "${DIR}/fip/${soc_family_name}/u-boot.bin.usb.tpl" "${out_dir}/u-boot.bin.usb.tpl" |
| cp "${DIR}/fip/${soc_family_name}/u-boot.bin" "${out_dir}/u-boot.bin" |
| fi |
| fi |
| } |
| |
| if (( $# < 1 )) |
| then |
| usage |
| exit 2 |
| fi |
| |
| readonly board=$1 |
| readonly out_root=$2 |
| readonly build_config=$3 |
| |
| zircon_cfg="_zircon" |
| |
| case "$build_config" in |
| prod | release) |
| dbg_flag="release" |
| export BUILD_CONFIG="prod" |
| ;; |
| dogfood) |
| dbg_flag="release" |
| export BUILD_CONFIG="dogfood" |
| ;; |
| dev | "") |
| dbg_flag="debug" |
| export BUILD_CONFIG="dev" |
| ;; |
| *) |
| usage |
| exit 1 |
| ;; |
| esac |
| |
| case ${board} in |
| estelle-p1) |
| building_uboot g12a g12a_estelle p1 ${board} |
| ;; |
| estelle-p2) |
| building_uboot g12a g12a_estelle p2 ${board} |
| ;; |
| newman-p2) |
| building_uboot g12b g12b_newman px ${board} ${dbg_flag} ${zircon_cfg} |
| ;; |
| newman-p2_1) |
| building_uboot g12b g12b_newman p2_1 ${board} ${dbg_flag} ${zircon_cfg} |
| ;; |
| newman-b1|newman-b3) |
| building_uboot g12b g12b_newman bx ${board} ${dbg_flag} ${zircon_cfg} |
| ;; |
| newman-b4) |
| building_uboot g12b g12b_newman bx ${board} ${dbg_flag} ${zircon_cfg} |
| ;; |
| legion-p1) |
| building_uboot g12a gl2a_legion p1 ${board} |
| ;; |
| puddy-p0|puddy-pdfc|puddy-p1) |
| building_uboot g12b g12b_puddy px ${board} ${dbg_flag} ${zircon_cfg} |
| ;; |
| lucy-px) |
| building_uboot g12b g12b_lucy px ${board} ${dbg_flag} |
| ;; |
| *) |
| echo "unknown board: ${board}" |
| exit 1 |
| esac |