| #!/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- |
| KDIR=${LOCAL_PATH}/../kernel |
| cpu_num=$(grep -c processor /proc/cpuinfo) |
| |
| GPU_VERSION_BIFROST=r38p2 |
| EXTRA_INCLUDE=-I${LOCAL_PATH}/bifrost/${GPU_VERSION_BIFROST}/kernel/include |
| |
| echo "make mali module KERNEL_ARCH is ${KERNEL_ARCH}" |
| |
| function usage(){ |
| echo "Usage: ${exec_name} <product> [workspace path]" |
| echo "supported products: sabrina" |
| echo "Note: if [workspace path] is not set, it still builds" |
| } |
| |
| function run_module_make(){ |
| pushd . |
| echo "***** building $1 *****" |
| case $1 in |
| bifrost) |
| make -C ${KDIR} M=${LOCAL_PATH}/bifrost/${GPU_VERSION_BIFROST}/kernel/drivers/gpu/arm/midgard \ |
| ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} \ |
| EXTRA_CFLAGS="-DCONFIG_MALI_PLATFORM_DEVICETREE -DCONFIG_MALI_MIDGARD_DVFS -DCONFIG_MALI_BACKEND=gpu -DCONFIG_MALI_GATOR_SUPPORT " \ |
| CONFIG_MALI_MIDGARD=m CONFIG_MALI_PLATFORM_DEVICETREE=y CONFIG_MALI_MIDGARD_DVFS=y CONFIG_MALI_BACKEND=gpu CONFIG_MALI_GATOR_SUPPORT=y CONFIG_MALI_PLATFORM_NAME="devicetree" \ |
| EXTRA_CFLAGS+="-Wno-error=larger-than=16384 -DCONFIG_MALI_DMA_BUF_MAP_ON_DEMAND=1 -DCONFIG_MALI_DMA_BUF_LEGACY_COMPAT=0 ${EXTRA_INCLUDE}" \ |
| EXTRA_LDFLAGS+="--strip-debug" \ |
| -j$cpu_num modules |
| ;; |
| esac |
| echo "***** completed building *****" |
| popd |
| } |
| |
| if (( $# < 1 )) |
| then |
| usage |
| exit 2 |
| fi |
| |
| readonly product=$1 |
| readonly workspace_path=$2 |
| |
| case $product in |
| sabrina) |
| run_module_make bifrost |
| if [ ! -z $workspace_path ]; then |
| prebuilt_path=${workspace_path}/device/google/sabrina-kernel |
| mali_ko_path=${prebuilt_path}/lib/modules |
| mkdir -p ${mali_ko_path} |
| cp -v ${LOCAL_PATH}/bifrost/${GPU_VERSION_BIFROST}/kernel/drivers/gpu/arm/midgard/mali_kbase.ko ${mali_ko_path}/mali.ko |
| fi |
| ;; |
| *) |
| echo "unknown product: $product" |
| exit 1 |
| esac |