| #!/bin/bash |
| |
| set -e |
| set -o errtrace |
| trap 'echo Fatal error: script $0 aborting at line $LINENO, command \"$BASH_COMMAND\" returned $?; exit 1' ERR |
| |
| ENABLE_64BIT_BUILD=false |
| NUM_JOBS=$(grep -c processor /proc/cpuinfo) |
| |
| top_dir=$(readlink -e $(dirname $0)) |
| toolchain_dir=$(readlink -e ${top_dir}/../prebuilt/toolchain) |
| if [ ${ENABLE_64BIT_BUILD} = "true" ]; then |
| cross_compiler_dir=${toolchain_dir}/aarch64/bin |
| export ARCH=arm64 |
| export CROSS_COMPILE=aarch64-cros-linux-gnu- |
| else |
| cross_compiler_dir=${toolchain_dir}/armv7a/bin |
| export ARCH=arm |
| export CROSS_COMPILE=armv7a-cros-linux-gnueabihf- |
| fi |
| export PATH=${cross_compiler_dir}:$PATH |
| |
| function BuildBootloader() { |
| local board=$1 |
| local eureka_src_path=$(readlink -e $2) |
| |
| if [ -z ${eureka_src_path} ]; then |
| echo "eureka_src_path doesn't exist" |
| exit 1 |
| fi |
| |
| # clean previous build |
| make distclean |
| find . -maxdepth 1 -name "dtb_combined*" -delete |
| rm -f combined_dtb.lds |
| |
| # build config |
| make ipq5018_defconfig |
| diff .config ./configs/ipq5018_defconfig |
| |
| # make u-boot |
| make -j${NUM_JOBS} BOARD_NAME=${board} DEVICE_TREE="${board}" SOURCE_DATE_EPOCH="${U_BOOT_BUILD_TIMESTAMP}" V=1 |
| |
| if [ ! -e u-boot ]; then |
| echo "u-boot build fails!" |
| exit 1 |
| fi |
| |
| # convert u-boot from elf to mbn format |
| python3 ${top_dir}/../sdk/tools/elftombn.py -f u-boot -o u-boot.mbn |
| |
| # install u-boot |
| echo "Install u-boot.mbn" |
| local product=$(echo ${board} | cut -d'-' -f1) |
| mkdir -p ${eureka_src_path}/vendor/qualcomm/${product}/prebuilt/bootloader/ |
| cp u-boot.mbn ${eureka_src_path}/vendor/qualcomm/${product}/prebuilt/bootloader/bootloader.${board} |
| } |
| |
| ######################### |
| ####### Main Entry ###### |
| ######################### |
| U_BOOT_BUILD_TIMESTAMP="" |
| while getopts ":d" arg; do |
| case "${arg}" in |
| d) |
| U_BOOT_BUILD_TIMESTAMP=$(git log -1 -s --format=%ct) |
| ;; |
| ?) |
| exit 1 |
| ;; |
| esac |
| done |
| shift $((OPTIND-1)) |
| |
| if (( $# < 2 )); then |
| exit 1 |
| else |
| BuildBootloader $1 $2 |
| fi |