forked from rrcarlosr/Jetpack
99 lines
3.0 KiB
Bash
Executable File
99 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# * Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# * Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
# contributors may be used to endorse or promote products derived
|
|
# from this software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
# This script builds uboot sources in this directory.
|
|
# Usage: ./${SCRIPT_NAME}.sh [OPTIONS]
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(dirname $(readlink -f "${0}"))"
|
|
SCRIPT_NAME="$(basename "${0}")"
|
|
|
|
source "${SCRIPT_DIR}/nvcommon_build.sh"
|
|
|
|
function usage {
|
|
cat <<EOM
|
|
Usage: ./${SCRIPT_NAME} [OPTIONS]
|
|
This script builds uboot sources in this directory.
|
|
It supports following options.
|
|
OPTIONS:
|
|
-h Displays this help
|
|
EOM
|
|
}
|
|
|
|
# parse input parameters
|
|
function parse_input_param {
|
|
while [ $# -gt 0 ]; do
|
|
case ${1} in
|
|
-h)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Error: Invalid option ${1}"
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
function build_uboot_sources {
|
|
echo "Building u-boot sources.."
|
|
|
|
# execute building steps
|
|
source_dir="${SCRIPT_DIR}/u-boot/"
|
|
local config_file=
|
|
if [ "${NV_TARGET_BOARD}" = "t210ref" ]; then
|
|
config_file="p2371-2180_defconfig"
|
|
elif [ "${NV_TARGET_BOARD}" = "t186ref" ]; then
|
|
config_file="p2771-0000-500_defconfig"
|
|
else
|
|
echo "${FUNCNAME[0]}: ${NV_TARGET_BOARD} is not supported"
|
|
return 0
|
|
fi
|
|
|
|
"${MAKE_BIN}" -C "${source_dir}" \
|
|
CROSS_COMPILE="${CROSS_COMPILE_AARCH64}" \
|
|
"${config_file}"
|
|
"${MAKE_BIN}" -C "${source_dir}" \
|
|
CROSS_COMPILE="${CROSS_COMPILE_AARCH64}" \
|
|
-j"${NPROC}" --output-sync=target
|
|
|
|
bin="${source_dir}/u-boot.bin"
|
|
if [ ! -f "${bin}" ]; then
|
|
echo "Error: Missing output binary ${bin}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "U-boot sources compiled successfully."
|
|
}
|
|
|
|
parse_input_param $@
|
|
check_vars "NV_TARGET_BOARD"
|
|
build_uboot_sources
|