blob: 2b6c3c954b20514529d126d9919dc121bcb1cdaa [file] [log] [blame]
#!/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
KERNEL_ARCH=arm64
LOCAL_PATH=$(pwd)
CROSS_COMPILE=${LOCAL_PATH}/../prebuilt/toolchain/aarch64/bin/aarch64-cros-linux-gnu-
COMPILE_PATH=${LOCAL_PATH}/../prebuilt/toolchain/aarch64/bin/
cc_clang=${LOCAL_PATH}/../prebuilt/toolchain/aarch64/bin/aarch64-cros-linux-gnu-clang
KDIR=${LOCAL_PATH}/../kernel
cpu_num=$(grep -c processor /proc/cpuinfo)
GPU_VERSION_UTGARD=r7p0
GPU_VERSION_BIFROST=r19p0
BIFROST_PATH="${LOCAL_PATH}/bifrost/${GPU_VERSION_BIFROST}"
echo "make mali module KERNEL_ARCH is ${KERNEL_ARCH}"
function usage(){
echo "Usage: ${exec_name} <board> [workspace path]"
echo "supported boards: elaine-(p0 , p1)"
echo " estelle-(p1, p2, b1, b3, b4)"
echo " lucy-(p0)"
echo " newman-(p1, p2, p2_1, b1, b3, b4)"
echo " puddy-(p0, pdfc, p1)"
}
function run_module_make(){
pushd .
echo "***** building $1 *****"
case $1 in
utgard)
echo "GPU_DRV_VERSION is ${GPU_VERSION_UTGARD}"
make -C ${LOCAL_PATH}/utgard KDIR=${KDIR} \
ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} \
GPU_DRV_VERSION=${GPU_VERSION_UTGARD} -j$cpu_num gpu
;;
bifrost)
echo "GPU_DRV_VERSION is ${GPU_VERSION_BIFROST}"
make CC=${cc_clang} LD=${CROSS_COMPILE}ld.lld NM=${COMPILE_PATH}llvm-nm OBJCOPY=${COMPILE_PATH}llvm-objcopy -C ${KDIR} \
ARCH=${KERNEL_ARCH} M=${BIFROST_PATH}/kernel/drivers/gpu/arm/midgard \
EXTRA_CFLAGS="-DCONFIG_MALI_PLATFORM_DEVICETREE -DCONFIG_MALI_MIDGARD_DVFS -DCONFIG_MALI_BACKEND=gpu -I${BIFROST_PATH}/kernel/include \
-DCONFIG_MALI_DMA_BUF_MAP_ON_DEMAND=1 -DCONFIG_MALI_DMA_BUF_LEGACY_COMPAT=0 -Wno-error" \
CONFIG_MALI_MIDGARD=m CONFIG_MALI_PLATFORM_DEVICETREE=y CONFIG_MALI_MIDGARD_DVFS=y CONFIG_MALI_BACKEND=gpu \
-j$cpu_num modules
;;
esac
echo "***** completed building *****"
popd
}
if (( $# < 1 ))
then
usage
exit 2
fi
readonly board=$1
readonly workspace_path=$2
readonly product=`echo ${board} | cut -d "-" -f1`
case $product in
elaine|estelle|lucy|newman|puddy)
run_module_make bifrost
if [ ! -z $workspace_path ]; then
prebuilt_path=${workspace_path}/vendor/amlogic/${product}/prebuilt
mali_ko_path=${prebuilt_path}/kernel/modules
fct_mali_ko_path=${prebuilt_path}/factory/kernel/modules
mkdir -p ${mali_ko_path}
mkdir -p ${fct_mali_ko_path}
cp ${BIFROST_PATH}/kernel/drivers/gpu/arm/midgard/mali_kbase.ko ${mali_ko_path}/mali.${board}.ko
cp ${BIFROST_PATH}/kernel/drivers/gpu/arm/midgard/mali_kbase.ko ${fct_mali_ko_path}/mali.${board}.ko
fi
;;
*)
echo "unknown product: $product"
exit 1
esac