Skip to content

Commit

Permalink
build.sh, scripts: Add support to build on both x86_64 and aarch64 hosts
Browse files Browse the repository at this point in the history
Download and handle tools based on the host architecture.

Signed-off-by: Sai Sree Kartheek Adivi <[email protected]>
  • Loading branch information
sskartheekadivi committed Dec 11, 2023
1 parent 86897d1 commit 774a678
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 44 deletions.
16 changes: 13 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,33 @@ fi

mkdir -p ${topdir}/build

setup_build_tools

for build in ${builds}
do

echo "${build}"
setup_log_file "${build}"

validate_section "Build" ${build} "${topdir}/builds.toml"

machine=($(read_build_config ${build} machine))
bsp_version=($(read_build_config ${build} bsp_version))
distro_variant=($(read_build_config ${build} distro_variant))

export host_arch=`uname -m`
export native_build=false
export cross_compile=aarch64-none-linux-gnu-
if [ "$host_arch" == "aarch64" ]; then
native_build=true
cross_compile=
fi

echo "machine: ${machine}"
echo "bsp_version: ${bsp_version}"
echo "distro_variant: ${distro_variant}"
echo "host_arch: ${host_arch}"

setup_build_tools

setup_log_file "${build}"

validate_build ${machine} ${bsp_version} ${distro_variant}

Expand Down
20 changes: 10 additions & 10 deletions scripts/build_bsp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,25 @@ machine=$1

cd $TFA_DIR
target_board=($(read_machine_config ${machine} atf_target_board))
make_args=($(read_machine_config ${machine} atf_make_args))

log "> ATF: building .."
make -j`nproc` ARCH=aarch64 CROSS_COMPILE=aarch64-none-linux-gnu- PLAT=k3 TARGET_BOARD=${target_board} SPD=opteed &>>"${LOG_FILE}"

log "> ATF: signing .."
make -j`nproc` ARCH=aarch64 CROSS_COMPILE=${cross_compile} PLAT=k3 TARGET_BOARD=${target_board} SPD=opteed ${make_args} &>>"${LOG_FILE}"
}

function build_optee() {
machine=$1

cd ${OPTEE_DIR}
platform=($(read_machine_config ${machine} optee_platform))
make_args=($(read_machine_config ${machine} optee_make_args))
# Workaround for toml not supporting empty values
if [ ${make_args} == "." ]; then
make_args=""
fi

log "> optee: building .."
make -j`nproc` CROSS_COMPILE64=aarch64-none-linux-gnu- CROSS_COMPILE=arm-none-linux-gnueabihf- PLATFORM=${platform} CFG_ARM64_core=y &>>"${LOG_FILE}"

log "> optee: signing .."
make -j`nproc` CROSS_COMPILE64=${cross_compile} CROSS_COMPILE=arm-none-linux-gnueabihf- PLATFORM=${platform} CFG_ARM64_core=y ${make_args} &>>"${LOG_FILE}"
}

function build_uboot() {
Expand All @@ -131,8 +133,6 @@ machine=$1
uboot_a53_defconfig=($(read_machine_config ${machine} uboot_a53_defconfig))
sysfw_soc=($(read_machine_config ${machine} sysfw_soc))

log "> dmfw: signing .."

cd ${UBOOT_DIR}
log "> uboot-r5: building .."
make -j`nproc` ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- ${uboot_r5_defconfig} O=${UBOOT_DIR}/out/r5 &>>"${LOG_FILE}"
Expand All @@ -141,8 +141,8 @@ machine=$1

cd ${UBOOT_DIR}
log "> uboot-a53: building .."
make -j`nproc` ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ${uboot_a53_defconfig} O=${UBOOT_DIR}/out/a53 &>>"${LOG_FILE}"
make -j`nproc` ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- BL31=${TFA_DIR}/build/k3/lite/release/bl31.bin TEE=${OPTEE_DIR}/out/arm-plat-k3/core/tee-pager_v2.bin O=${UBOOT_DIR}/out/a53 BINMAN_INDIRS=${topdir}/build/${build}/bsp_sources/ti-linux-firmware &>>"${LOG_FILE}"
make -j`nproc` ARCH=arm CROSS_COMPILE=${cross_compile} ${uboot_a53_defconfig} O=${UBOOT_DIR}/out/a53 &>>"${LOG_FILE}"
make -j`nproc` ARCH=arm CROSS_COMPILE=${cross_compile} BL31=${TFA_DIR}/build/k3/lite/release/bl31.bin TEE=${OPTEE_DIR}/out/arm-plat-k3/core/tee-pager_v2.bin O=${UBOOT_DIR}/out/a53 BINMAN_INDIRS=${topdir}/build/${build}/bsp_sources/ti-linux-firmware &>>"${LOG_FILE}"
cp ${UBOOT_DIR}/out/a53/tispl.bin ${topdir}/build/${build}/tisdk-${distro}-${machine}-boot/ &>> ${LOG_FILE}
cp ${UBOOT_DIR}/out/a53/u-boot.img ${topdir}/build/${build}/tisdk-${distro}-${machine}-boot/ &>> ${LOG_FILE}
}
66 changes: 35 additions & 31 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,46 @@ function setup_log_file() {

function setup_build_tools() {
setup_log_file "setup"
log "> Arm Toolchain: checking .."
if [ ! -d "${topdir}/tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/bin" ]; then
mkdir -p ${topdir}/tools/
cd ${topdir}/tools/

log "> Arm Toolchain: not found. Downloading .."
wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz &>>/dev/null
if [ $? -eq 0 ]; then
log "> Arm Toolchain: downloaded .."
tar -Jxf arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz &>>"${LOG_FILE}"
rm arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz
if [ "${host_arch}" != "arm" ]; then
log "> Arm Toolchain: checking .."
if [ ! -d "${topdir}/tools/arm-gnu-toolchain-13.2.Rel1-${host_arch}-arm-none-linux-gnueabihf/bin" ]; then
mkdir -p ${topdir}/tools/
cd ${topdir}/tools/

log "> Arm Toolchain: not found. Downloading .."
wget https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-${host_arch}-arm-none-linux-gnueabihf.tar.xz &>>/dev/null
if [ $? -eq 0 ]; then
log "> Arm Toolchain: downloaded .."
tar -Jxf arm-gnu-toolchain-13.2.rel1-${host_arch}-arm-none-linux-gnueabihf.tar.xz &>>"${LOG_FILE}"
rm arm-gnu-toolchain-13.2.rel1-${host_arch}-arm-none-linux-gnueabihf.tar.xz
else
log "> Arm Toolchain: Failed to download. Exit code: $?"
fi
else
log "> Arm Toolchain: Failed to download. Exit code: $?"
log "> Arm Toolchain: available"
fi
else
log "> Arm Toolchain: available"
export PATH=${topdir}/tools/arm-gnu-toolchain-13.2.Rel1-${host_arch}-arm-none-linux-gnueabihf/bin:$PATH
fi
export PATH=${topdir}/tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/bin:$PATH

log "> Aarch64 Toolchain: checking .."
if [ ! -d "${topdir}/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin" ]; then
mkdir -p ${topdir}/tools/
cd ${topdir}/tools/

log "> Aarch64 Toolchain: not found. downloading .."
wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz &>>/dev/null
if [ $? -eq 0 ]; then
log "> Aarch64 Toolchain: downloaded .."
tar -Jxf arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz &>>"${LOG_FILE}"
rm arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz

if [ "${host_arch}" != "aarch64" ]; then
log "> Aarch64 Toolchain: checking .."
if [ ! -d "${topdir}/tools/arm-gnu-toolchain-13.2.Rel1-${host_arch}-aarch64-none-linux-gnu/bin" ]; then
mkdir -p ${topdir}/tools/
cd ${topdir}/tools/

log "> Aarch64 Toolchain: not found. downloading .."
wget https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-${host_arch}-aarch64-none-linux-gnu.tar.xz &>>/dev/null
if [ $? -eq 0 ]; then
log "> Aarch64 Toolchain: downloaded .."
tar -Jxf arm-gnu-toolchain-13.2.rel1-${host_arch}-aarch64-none-linux-gnu.tar.xz &>>"${LOG_FILE}"
rm arm-gnu-toolchain-13.2.rel1-${host_arch}-aarch64-none-linux-gnu.tar.xz
else
log "> Aarch Toolchain: Failed to download. Exit code: $?"
fi
else
log "> Aarch Toolchain: Failed to download. Exit code: $?"
log "> Aarch64 Toolchain: available"
fi
else
log "> Aarch64 Toolchain: available"
export PATH=${topdir}/tools/arm-gnu-toolchain-13.2.Rel1-${host_arch}-aarch64-none-linux-gnu/bin:$PATH
fi
export PATH=${topdir}/tools/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin:$PATH
}

0 comments on commit 774a678

Please sign in to comment.