#!/bin/sh
exec 2>&1
# Load apparmor profile in complain mode
true \
|| exit 1
bootcount=$(/sbin/bootcount)
# Do not start any boards other than model_3 hw2.5/hw3
IS_HW25=$(fgrep "Tesla DAS HW2.5" /sys/firmware/devicetree/base/model)
IS_HW3=$(fgrep "Tesla DAS HW3" /sys/firmware/devicetree/base/model)
if [ -z "$IS_HW25" ] && [ -z "$IS_HW3" ] ; then
exit 1
fi
# Enable WARNING, ERROR, and FATAL logs
export TESLA_ENABLE_GLOG=3
# Allow promotion to SCHED_FIFO priority upto 90
ulimit -l unlimited -r 90
echo "Boot $bootcount: Launching backup-camera $(/sbin/uptime-seconds) s after boot"
IS_MODEL3=$(/sbin/boardid |grep model_3)
if [ "$IS_HW3" ]; then
if [ "$IS_MODEL3" ]; then
exec chpst -o 4096 -u backup_camera:autopilot:camera:display:gpgpu:ipc:rtdv:log /opt/autopilot/bin/backup_camera
fi
else
OPTS=""
if [ -z "$IS_MODEL3" ]; then
# On ModeS/X HW25, only dashcam is on
OPTS="--backupcam=0 --dashcam=1"
else
# On Model3, both backup camera and dashcam is on
OPTS="--backupcam=1 --dashcam=1"
fi
REV_ID=$(/sbin/boardid | grep -i rev | cut -d':' -f2)
exec chpst -o 4096 -u backup_camera:autopilot:camera:display:gpgpu:ipc:rtdv:log /opt/autopilot/bin/backup_camera --rev_id ${REV_ID} ${OPTS}
fi