Parker Schuh | 46b4881 | 2019-02-22 20:45:36 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | ############################################################################################################## |
| 4 | # Default settings: |
| 5 | ############################################################################################################## |
| 6 | |
| 7 | CAMERA=ov9650 |
| 8 | if [ -f /boot/sensor ]; then CAMERA=`tail -1 /boot/sensor`; fi |
| 9 | |
| 10 | use_usbserial=1 # Allow using a serial-over-USB to communicate with JeVois command-line interface |
| 11 | use_usbsd=1 # Allow exposing the JEVOIS partition of the microSD as a USB drive |
| 12 | use_serialtty=0 # Use a TTY on the hardware serial and do not use it in jevois-daemon |
| 13 | use_usbserialtty=0 # Use a TTY on the serial-over-USB and do not use it in jevois-daemon |
| 14 | use_maxbandwidth=1 # Use 100% of isochronous bandwidth to minimize latency; disable to connect several cameras |
| 15 | use_quietcmd=0 # Do not say OK after every good command when true |
| 16 | use_nopython=0 # Disable python to save memory when true |
| 17 | |
| 18 | if [ -f /boot/nousbserial ]; then use_usbserial=0; echo "JeVois serial-over-USB disabled"; fi |
| 19 | if [ -f /boot/nousbsd ]; then use_usbsd=0; echo "JeVois microSD access over USB disabled"; fi |
| 20 | if [ -f /boot/multicam ]; then use_maxbandwidth=0; echo "JeVois multi-camera mode enabled"; fi |
| 21 | if [ -f /boot/quietcmd ]; then use_quietcmd=1; echo "JeVois quiet command-line mode enabled"; fi |
| 22 | if [ -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: |
| 25 | usbsdfile="" |
| 26 | if [ -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: |
| 29 | if [ -f /boot/serialtty ]; then use_serialtty=1; echo "Using tty on JeVois hardware serial"; fi |
| 30 | if [ "X${use_usbserial}" != "X1" ]; then use_usbserialtty=0; |
| 31 | elif [ -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 | |
| 37 | cd /lib/modules/3.4.39 |
| 38 | |
| 39 | for 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 |
| 48 | done |
| 49 | |
| 50 | ############################################################################################################## |
| 51 | # Install any new packages: |
| 52 | ############################################################################################################## |
| 53 | |
| 54 | cd /jevois |
| 55 | for 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 |
| 63 | done |
| 64 | |
| 65 | ############################################################################################################## |
| 66 | # Find any newly unpacked postinstall scripts, run them, and delete them: |
| 67 | ############################################################################################################## |
| 68 | |
| 69 | for 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 |
| 80 | done |
| 81 | |
| 82 | ############################################################################################################## |
| 83 | # Build a default videomappings.cfg, if missing: |
| 84 | ############################################################################################################## |
| 85 | |
| 86 | if [ ! -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 |
| 89 | fi |
| 90 | |
| 91 | ############################################################################################################## |
| 92 | # Get a list of all our needed library paths: |
| 93 | ############################################################################################################## |
| 94 | |
| 95 | LIBPATH="/lib:/usr/lib" |
| 96 | for d in `find /jevois/lib -type d -print`; do LIBPATH="${LIBPATH}:${d}"; done |
| 97 | export LD_LIBRARY_PATH=${LIBPATH} |
| 98 | |
| 99 | ############################################################################################################## |
| 100 | # Insert the gadget driver: |
| 101 | ############################################################################################################## |
| 102 | |
| 103 | echo "### Insert gadget driver ###" |
| 104 | MODES=`/usr/bin/jevois-module-param ${CAMERA}` |
| 105 | |
| 106 | echo $MODES |
| 107 | |
| 108 | insmodopts="" |
| 109 | if [ "X${use_usbsd}" = "X1" ]; then insmodopts="${insmodopts} file=${usbsdfile}"; fi |
| 110 | |
| 111 | insmod /lib/modules/3.4.39/g_jevoisa33.ko modes=${MODES} use_serial=${use_usbserial} \ |
| 112 | use_storage=${use_usbsd} max_bandwidth=${use_maxbandwidth} ${insmodopts} |
| 113 | echo 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 | |
| 122 | echo "### Start jevois daemon ###" |
| 123 | opts="" |
| 124 | if [ "X${use_usbserial}" != "X1" -o "X${use_usbserialtty}" = "X1" ]; then opts="${opts} --usbserialdev="; fi |
| 125 | if [ "X${use_serialtty}" = "X1" ]; then opts="${opts} --serialdev="; fi |
| 126 | if [ "X${use_maxbandwidth}" != "X1" ]; then opts="${opts} --multicam=1"; fi |
| 127 | if [ "X${use_quietcmd}" = "X1" ]; then opts="${opts} --quietcmd=1"; fi |
| 128 | if [ "X${use_nopython}" = "X1" ]; then opts="${opts} --python=0"; fi |
| 129 | if [ "X${CAMERA}" != "X" ]; then opts="${opts} --camerasens=${CAMERA}"; fi |
| 130 | |
| 131 | if [ ! -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 |
| 137 | fi |
| 138 | |
| 139 | |
| 140 | # Start the jevois daemon: |
| 141 | echo /usr/bin/jevois-daemon ${opts} |
| 142 | /usr/bin/jevois-daemon ${opts} |