#!/usr/bin/env bash

COMPATIBLE=$(cat /proc/device-tree/compatible)


ln -fs /usr/bin/npu_transfer_proxy_normal /usr/bin/npu_transfer_proxy
if [ -e "/sys/firmware/devicetree/base/PCIE_RK1808_OPTIMIZATION/status" ] ;then
    cat /sys/firmware/devicetree/base/PCIE_RK1808_OPTIMIZATION/status | grep okay
    if [ $? -eq 0 ]; then
	ln -fs /usr/bin/npu_transfer_proxy_pcie /usr/bin/npu_transfer_proxy
	export TRANSFER_PCIE_BUFFER_SIZE=131072
	echo "Using npu_transfer_proxy_pcie to optimize the transmission speed of RK1808 using PCIE bus"
    fi
fi


if [[ $COMPATIBLE =~ "rk3399" && $COMPATIBLE =~ "rk3399pro" ]];then
	CHIPNAME="rk3399pro"
	/usr/bin/npu-image.sh
	sleep 1
	start-stop-daemon --start --oknodo --pidfile /var/run/npu-transfer.pid --background --startas /usr/bin/npu_transfer_proxy
fi

exit 0

