blob: 063b7dcafcfd01fd8bd9b9336281c7f3405a28ff [file] [log] [blame]
Parker Schuh46b48812019-02-22 20:45:36 -08001#!/bin/sh
2
3##############################################################################################################
4# Default settings:
5##############################################################################################################
6
7CAMERA=ov9650
8if [ -f /boot/sensor ]; then CAMERA=`tail -1 /boot/sensor`; fi
9
10use_usbserial=1 # Allow using a serial-over-USB to communicate with JeVois command-line interface
11use_usbsd=1 # Allow exposing the JEVOIS partition of the microSD as a USB drive
12use_serialtty=0 # Use a TTY on the hardware serial and do not use it in jevois-daemon
13use_usbserialtty=0 # Use a TTY on the serial-over-USB and do not use it in jevois-daemon
14use_maxbandwidth=1 # Use 100% of isochronous bandwidth to minimize latency; disable to connect several cameras
15use_quietcmd=0 # Do not say OK after every good command when true
16use_nopython=0 # Disable python to save memory when true
17
18if [ -f /boot/nousbserial ]; then use_usbserial=0; echo "JeVois serial-over-USB disabled"; fi
19if [ -f /boot/nousbsd ]; then use_usbsd=0; echo "JeVois microSD access over USB disabled"; fi
20if [ -f /boot/multicam ]; then use_maxbandwidth=0; echo "JeVois multi-camera mode enabled"; fi
21if [ -f /boot/quietcmd ]; then use_quietcmd=1; echo "JeVois quiet command-line mode enabled"; fi
22if [ -f /boot/nopython ]; then use_nopython=1; echo "JeVois python support disabled"; fi
23
24# Block device we present to the host as a USB drive, or empty to not present it at start:
25usbsdfile=""
26if [ -f /boot/usbsdauto ]; then usbsdfile="/dev/mmcblk0p3"; echo "JeVois microSD access over USB is AUTO"; fi
27
28# Login prompts over hardware serial or serial-over-USB:
29if [ -f /boot/serialtty ]; then use_serialtty=1; echo "Using tty on JeVois hardware serial"; fi
30if [ "X${use_usbserial}" != "X1" ]; then use_usbserialtty=0;
31elif [ -f /boot/usbserialtty ]; then use_usbserialtty=1; echo "Using tty on JeVois serial-over-USB"; fi
32
33##############################################################################################################
34# Load all required kernel modules:
35##############################################################################################################
36
37cd /lib/modules/3.4.39
38
39for m in videobuf-core videobuf-dma-contig videodev vfe_os vfe_subdev v4l2-common v4l2-int-device \
40 cci ${CAMERA} vfe_v4l2 ump disp mali ; do
41 if [ $m = "vfe_v4l2" ]; then
42 echo "### insmod ${m}.ko sensor=${CAMERA} ###"
43 insmod ${m}.ko sensor="${CAMERA}"
44 else
45 echo "### insmod ${m}.ko ###"
46 insmod ${m}.ko
47 fi
48done
49
50##############################################################################################################
51# Install any new packages:
52##############################################################################################################
53
54cd /jevois
55for f in packages/*.jvpkg; do
56 if [ -f "${f}" ]; then
57 echo "### Installing package ${f} ###"
58 bzcat "${f}" | tar xvf -
59 sync
60 rm -f "${f}"
61 sync
62 fi
63done
64
65##############################################################################################################
66# Find any newly unpacked postinstall scripts, run them, and delete them:
67##############################################################################################################
68
69for f in modules/*/*/postinstall; do
70 if [ -f "${f}" ]; then
71 echo "### Running ${f} ###"
72 d=`dirname "${f}"`
73 cd "${d}"
74 sh postinstall
75 sync
76 rm -f postinstall
77 sync
78 cd /jevois
79 fi
80done
81
82##############################################################################################################
83# Build a default videomappings.cfg, if missing:
84##############################################################################################################
85
86if [ ! -f /jevois/config/videomappings.cfg ]; then
87 echo 'YUYV 640 360 30.0 YUYV 320 240 30.0 JeVois JeVoisIntro *' > /jevois/config/videomappings.cfg
88 echo 'YUYV 640 480 30.0 YUYV 320 240 30.0 JeVois JeVoisIntro' >> /jevois/config/videomappings.cfg
89fi
90
91##############################################################################################################
92# Get a list of all our needed library paths:
93##############################################################################################################
94
95LIBPATH="/lib:/usr/lib"
96for d in `find /jevois/lib -type d -print`; do LIBPATH="${LIBPATH}:${d}"; done
97export LD_LIBRARY_PATH=${LIBPATH}
98
99##############################################################################################################
100# Insert the gadget driver:
101##############################################################################################################
102
103echo "### Insert gadget driver ###"
104MODES=`/usr/bin/jevois-module-param ${CAMERA}`
105
106echo $MODES
107
108insmodopts=""
109if [ "X${use_usbsd}" = "X1" ]; then insmodopts="${insmodopts} file=${usbsdfile}"; fi
110
111insmod /lib/modules/3.4.39/g_jevoisa33.ko modes=${MODES} use_serial=${use_usbserial} \
112 use_storage=${use_usbsd} max_bandwidth=${use_maxbandwidth} ${insmodopts}
113echo insmod /lib/modules/3.4.39/g_jevoisa33.ko modes=${MODES} use_serial=${use_usbserial} \
114 use_storage=${use_usbsd} max_bandwidth=${use_maxbandwidth} ${insmodopts}
115
116##############################################################################################################
117# Launch jevois-daemon:
118##############################################################################################################
119
120/jevois/deploy/launch.sh
121
122echo "### Start jevois daemon ###"
123opts=""
124if [ "X${use_usbserial}" != "X1" -o "X${use_usbserialtty}" = "X1" ]; then opts="${opts} --usbserialdev="; fi
125if [ "X${use_serialtty}" = "X1" ]; then opts="${opts} --serialdev="; fi
126if [ "X${use_maxbandwidth}" != "X1" ]; then opts="${opts} --multicam=1"; fi
127if [ "X${use_quietcmd}" = "X1" ]; then opts="${opts} --quietcmd=1"; fi
128if [ "X${use_nopython}" = "X1" ]; then opts="${opts} --python=0"; fi
129if [ "X${CAMERA}" != "X" ]; then opts="${opts} --camerasens=${CAMERA}"; fi
130
131if [ ! -f /tmp/do_not_export_sd_card ]; then
132 sync
133 echo "### FALLBACK remount ###"
134 mount -o remount,ro /jevois || exit
135 echo "### FALLBACK disk publish (Device is unusable after this point...) ###"
136 echo /dev/mmcblk0p3 > /sys/devices/platform/sunxi_usb_udc/gadget/lun0/file
137fi
138
139
140# Start the jevois daemon:
141echo /usr/bin/jevois-daemon ${opts}
142/usr/bin/jevois-daemon ${opts}