| #!/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-b3 or estelle-b4" |
| echo "" |
| echo "out: build artifacts will be copied to <out>/vendor/amlogic" |
| echo "" |
| echo "build_config: test, dev, dogfood, or prod" |
| echo " if unspecified, builds all configs" |
| } |
| |
| readonly dev_options="--dev" |
| readonly dev_folder="dev" |
| readonly dev_config="$dev_folder:$dev_options" |
| |
| readonly test_options="--test" |
| readonly test_folder="test" |
| readonly test_config="$test_folder:$test_options" |
| |
| readonly dogfood_options="--dogfood" |
| readonly dogfood_folder="dogfood" |
| readonly dogfood_config="$dogfood_folder:$dogfood_options" |
| |
| readonly prod_options="--prod" |
| readonly prod_folder="prod" |
| readonly prod_config="$prod_folder:$prod_options" |
| |
| |
| readonly build_config=$3 |
| |
| function building_uboot(){ |
| soc_family_name=$1 |
| local_name=$2 |
| rev=$3 |
| board_name=$4 |
| |
| configs=("$dev_config" "$test_config" "$dogfood_config" "$prod_config") |
| |
| if [[ -n "${build_config}" ]]; then |
| case $build_config in |
| dev) |
| configs=("$dev_config") |
| ;; |
| test) |
| configs=("$test_config") |
| ;; |
| dogfood) |
| configs=("$dogfood_config") |
| ;; |
| prod) |
| configs=("$prod_config") |
| ;; |
| *) |
| echo "Unknown build config '${build_config}'" |
| exit 1 |
| esac |
| fi |
| |
| config=${local_name}_${rev} |
| |
| for cfg in ${configs[@]}; do |
| local folder="${cfg%:*}" |
| local options="${cfg#*:}" |
| |
| echo "building ${build_config} u-boot for ${board}" |
| |
| 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 \ |
| $options |
| popd >/dev/null |
| |
| # make T=1 to use latest git commit time as build timestamp. |
| |
| local product=`echo ${board} | cut -d "-" -f1` |
| if [ ! -z "${out_root}" ]; then |
| local out_dir="${out_root}/vendor/amlogic/${product}/prebuilt/${folder}/bootloader" |
| echo "Copying artifacts to ${out_dir}" |
| mkdir -p "${out_dir}" |
| |
| if [ "$product" == "estelle" ] || [ "$product" == "newman" ] || [ "$product" == "legion" ] ; 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 |
| done |
| } |
| |
| if (( $# < 1 )) |
| then |
| usage |
| exit 2 |
| fi |
| |
| readonly board=$1 |
| readonly out_root=$2 |
| |
| case $board in |
| estelle-p2) |
| building_uboot g12a g12a_estelle p2 $board |
| ;; |
| estelle-b1) |
| building_uboot g12a g12a_estelle bx $board |
| ;; |
| estelle-b3) |
| building_uboot g12a g12a_estelle bx $board |
| ;; |
| estelle-b4) |
| building_uboot g12a g12a_estelle bx $board |
| ;; |
| newman-p1) |
| building_uboot g12b g12b_newman p1 $board |
| ;; |
| legion-p1) |
| building_uboot g12a gl2a_legion p1 $board |
| ;; |
| *) |
| echo "unknown board: $board" |
| exit 1 |
| esac |