#!/bin/bash

atf_dir=trusted-firmware-a

echo "building ARM Trusted firmware.."

if [ ! -d "$atf_dir" ]; then
	echo "ARM Trusted firmware source tree not found. Please clone it first in $(pwd)"
	exit 1
fi

cd "$atf_dir"
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3568 -j $(nproc)

if [ ! $? = 0 ]; then
	echo "build process failed!"
	exit 1
fi

echo "Build success!"
cp build/rk3568/release/bl31/bl31.elf ../

