Updated Dride to Raspbian Stretch (#1)

* Stretch base system working W/O DRIDE

- Currently removed Dride edits/software to get base OS working

* Enabled Ether over USB

I slightly rearranged a few startups in stage2 to give us room for more expansion later.  Boot files update important to come prior to Dride software.
Stretch base system working W/O DRIDE

* Dride+Stretch working

- wifi works with specific Dride network
- usb0 interface also works if you need to debug/hack

All Dride network items have been separated into this step

* DrideOS gets Dride software added back in on Debian Stretch

- software base; testing commencing

* Added new dride partition, clean, updated README

- updated README to explain how this has been modified vs. upstream
- removed and cleaned unused scripts
- added dride partition creation on startup (runonce)
- drideOS conditional renamed to dride-plus

* Use the /dride path and provide soft links during software installation

- updated README
This commit is contained in:
Mark 2018-02-11 03:34:42 -05:00 committed by Yossi Neiman
parent 70fb0a72b8
commit 23b2c929a2
26 changed files with 602 additions and 486 deletions

View File

@ -36,3 +36,48 @@ maintenance and allows for more easy customization.
creates necessary groups and gives the pi user access to sudo and the
standard console hardware permission groups.
----
###Explaination of changes vs. upstream main repo
The goal is to keep minimal changes from upstream such that pulling updates is easier. Therefore we added Dride OS changes and software installation as subsequent steps within stage2.
* stage 0 - unchanged from upstream
* stage 1 - unchanged from upstream
* stage 2 - `00-copies-and-fills`, `01-sys-tweaks`, `02-net-tweaks` and `10-cleanup` are unchanged
* stage 3, 4, 5 - removed
NOTE: resizing the `root` parition apart of the stage 2 upstream step is overruled by a subsequent step (03-boot-files) found below. Hence the root partition is **not** resized.
Changes/complimentary for DrideOS
Within Stage 2, the following additions have been made:
* `03-boot-files`
* `04-dride-filesystem`
* `05-dride-net`
* `06-dride-base`
`03-boot-files`
Modifies the boot config files to **enable** Ether over USB. This is very helpful when you wish to plug your Dride via USB port into your computer and access via SSH.
This also keeps the Dride WiFi access point working as well.
`04-dride-filesystem`
Ommitted for this current version.
`05-dride-net`
Enable Dride WiFi access point.
`06-dride-base`
Install all the Dride software and any dependencies needed to run the software.
This takes an optional environment argument that will allow differentiation between two software modes.
The base software package - essentials - is installed if you do not provide any specific mention of the enviornment variable. This consists of minimal software to get the Dride working.
```export OS_TYPE="dride-plus"```
Optionally, if you set the environment varable **before** build time - you can add additonal software features best reserved for a Raspberry Pi 3 or similar hardware.

View File

@ -134,8 +134,6 @@ fi
export USE_QEMU=${USE_QEMU:-0}
export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"}
export OS_TYPE=$1
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export SCRIPT_DIR="${BASE_DIR}/scripts"
export WORK_DIR=${WORK_DIR:-"${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}"}

2
config
View File

@ -1 +1 @@
IMG_NAME=drideOS
IMG_NAME='drideOS'

View File

@ -1,7 +1,7 @@
Index: export-jessie/rootfs/etc/apt/sources.list.d/raspi.list
Index: export-stretch/rootfs/etc/apt/sources.list.d/raspi.list
===================================================================
--- export-jessie.orig/rootfs/etc/apt/sources.list.d/raspi.list
+++ export-jessie/rootfs/etc/apt/sources.list.d/raspi.list
--- export-stretch.orig/rootfs/etc/apt/sources.list.d/raspi.list
+++ export-stretch/rootfs/etc/apt/sources.list.d/raspi.list
@@ -1,3 +1,3 @@
-deb http://archive.raspberrypi.org/debian/ stretch main ui staging
+deb http://archive.raspberrypi.org/debian/ stretch main ui

View File

@ -1,7 +1,7 @@
Index: jessie-stage1/rootfs/etc/hosts
Index: stretch-stage1/rootfs/etc/hosts
===================================================================
--- jessie-stage1.orig/rootfs/etc/hosts
+++ jessie-stage1/rootfs/etc/hosts
--- stretch-stage1.orig/rootfs/etc/hosts
+++ stretch-stage1/rootfs/etc/hosts
@@ -3,3 +3,4 @@
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

View File

@ -1,7 +1,7 @@
Index: jessie-stage2/rootfs/etc/default/useradd
Index: stretch-stage2/rootfs/etc/default/useradd
===================================================================
--- jessie-stage2.orig/rootfs/etc/default/useradd
+++ jessie-stage2/rootfs/etc/default/useradd
--- stretch-stage2.orig/rootfs/etc/default/useradd
+++ stretch-stage2/rootfs/etc/default/useradd
@@ -5,7 +5,7 @@
# Similar to DHSELL in adduser. However, we use "sh" here because
# useradd is a low level utility and should be as general

View File

@ -1,7 +1,7 @@
Index: jessie-stage2/rootfs/etc/dphys-swapfile
Index: stretch-stage2/rootfs/etc/dphys-swapfile
===================================================================
--- jessie-stage2.orig/rootfs/etc/dphys-swapfile
+++ jessie-stage2/rootfs/etc/dphys-swapfile
--- stretch-stage2.orig/rootfs/etc/dphys-swapfile
+++ stretch-stage2/rootfs/etc/dphys-swapfile
@@ -13,7 +13,7 @@
# set size to absolute value, leaving empty (default) then uses computed value

View File

@ -1,7 +1,7 @@
Index: jessie-stage2/rootfs/etc/inputrc
Index: stretch-stage2/rootfs/etc/inputrc
===================================================================
--- jessie-stage2.orig/rootfs/etc/inputrc
+++ jessie-stage2/rootfs/etc/inputrc
--- stretch-stage2.orig/rootfs/etc/inputrc
+++ stretch-stage2/rootfs/etc/inputrc
@@ -65,3 +65,7 @@ $endif
# "\e[F": end-of-line

View File

@ -1,7 +1,7 @@
Index: jessie-stage2/rootfs/etc/login.defs
Index: stretch-stage2/rootfs/etc/login.defs
===================================================================
--- jessie-stage2.orig/rootfs/etc/login.defs
+++ jessie-stage2/rootfs/etc/login.defs
--- stretch-stage2.orig/rootfs/etc/login.defs
+++ stretch-stage2/rootfs/etc/login.defs
@@ -100,7 +100,7 @@ HUSHLOGIN_FILE .hushlogin
#
# (they are minimal, add the rest in the shell startup files)
@ -11,10 +11,10 @@ Index: jessie-stage2/rootfs/etc/login.defs
#
# Terminal permissions
Index: jessie-stage2/rootfs/etc/profile
Index: stretch-stage2/rootfs/etc/profile
===================================================================
--- jessie-stage2.orig/rootfs/etc/profile
+++ jessie-stage2/rootfs/etc/profile
--- stretch-stage2.orig/rootfs/etc/profile
+++ stretch-stage2/rootfs/etc/profile
@@ -4,7 +4,7 @@
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

View File

@ -1,7 +1,7 @@
Index: jessie-stage2/rootfs/etc/rc.local
Index: stretch-stage2/rootfs/etc/rc.local
===================================================================
--- jessie-stage2.orig/rootfs/etc/rc.local
+++ jessie-stage2/rootfs/etc/rc.local
--- stretch-stage2.orig/rootfs/etc/rc.local
+++ stretch-stage2/rootfs/etc/rc.local
@@ -11,4 +11,10 @@
#
# By default this script does nothing.

View File

@ -1,10 +1,5 @@
#!/bin/bash -e
install -m 755 files/resize2fs_once ${ROOTFS_DIR}/etc/init.d/
install -m 755 files/resize2fs_once ${ROOTFS_DIR}/etc/init.d/
install -d ${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d
@ -63,382 +58,3 @@ usermod --pass='*' root
EOF
rm -f ${ROOTFS_DIR}/etc/ssh/ssh_host_*_key*
on_chroot << EOF
#-------------------------------------------------------
# Script to check if all is good before install script runs
#-------------------------------------------------------
echo "====== Dride install script ======"
echo ""
echo ""
echo ""
echo "██████╗ ██████╗ ██╗██████╗ ███████╗"
echo "██╔══██╗██╔══██╗██║██╔══██╗██╔════╝"
echo "██║ ██║██████╔╝██║██║ ██║█████╗ "
echo "██║ ██║██╔══██╗██║██║ ██║██╔══╝ "
echo "██████╔╝██║ ██║██║██████╔╝███████╗"
echo "╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝"
echo ""
echo ""
echo "This will install all the necessary dependences and software for dride."
echo "======================================================="
echo ""
echo ""
echo ""
echo ""
echo "==============================="
echo "*******************************"
echo " *** STARTING INSTALLATION ***"
echo " ** this may take a while **"
echo " *************************"
echo " ========================="
echo ""
echo ""
cd /home
# Install dependencies
echo "========== Update Aptitude ==========="
# sudo apt-get update -y
# sudo apt-get upgrade
if [ ${OS_TYPE} == "drideOS" ]; then
echo "========== Installing build-essential ============"
sudo apt-get install build-essential -y
echo "========== Installing libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev ============"
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev -y
fi
echo "========== Installing gpac ============"
sudo apt-get install gpac -y
echo "========== Installing htop ============"
sudo apt-get install htop -y
echo "========== Setup libav ============"
sudo apt-get install libav-tools -y
# Install Node
echo "========== Installing Node ============"
wget -O - https://raw.githubusercontent.com/sdesalas/node-pi-zero/master/install-node-v8.9.0.sh | bash
echo "========== Installing pip ============"
sudo apt-get install python-pip -y
if [ ${OS_TYPE} == "drideOS" ]; then
echo "========== Installing Numpy ============"
sudo pip install numpy
fi
echo "========== Install picamera ============"
sudo apt-get install python3-picamera
# enable camera on raspi-config and allocate more ram to the GPU
echo "" >> /boot/config.txt
echo "#enable piCaera" >> /boot/config.txt
echo "start_x=1" >> /boot/config.txt
echo "gpu_mem=128" >> /boot/config.txt
echo "dtparam=spi=on" >> /boot/config.txt
if [ ${OS_TYPE} == "drideOS" ]; then
echo "========== Install mpg123 ============"
sudo apt-get install mpg123 -y
fi
# Install WIFi
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
sudo apt-get install hostapd isc-dhcp-server -y
sudo apt-get install iptables-persistent -y
cd /home
# get the dhcpd config file
sudo wget https://dride.io/code/dhcpd.conf
sudo cp dhcpd.conf /etc/dhcp/dhcpd.conf
sudo rm dhcpd.conf
sudo bash -c 'echo "INTERFACES=\"wlan0\""> /etc/default/isc-dhcp-server'
sudo ifdown wlan0
sudo wget https://dride.io/code/interfaces
sudo cp interfaces /etc/network/interfaces
sudo rm interfaces
sudo ifconfig wlan0 192.168.42.1
sudo wget https://dride.io/code/hostapd.conf
sudo cp hostapd.conf /etc/hostapd/hostapd.conf
sudo rm hostapd.conf
sudo bash -c 'echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\""> /etc/default/hostapd'
sudo wget https://dride.io/code/hostapd
sudo cp hostapd /etc/init.d/hostapd
sudo rm hostapd
sudo bash -c 'echo "net.ipv4.ip_forward=1"> /etc/sysctl.conf'
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/
sudo service hostapd start
sudo service isc-dhcp-server start
sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable
sudo pip install pyserial
#startup script's
sudo wget https://dride.io/code/startup/dride-ws
if [ ${OS_TYPE} == "drideOS" ]; then
sudo wget https://dride.io/code/startup/dride-core
sudo wget https://dride.io/code/startup/drideOS-resize
else
sudo wget https://dride.io/code/startup/dride-core
fi;
# express on startup
sudo cp dride-ws /etc/init.d/dride-ws
sudo chmod +x /etc/init.d/dride-ws
sudo update-rc.d dride-ws defaults
sudo rm dride-ws
# dride-core on startup
if [ ${OS_TYPE} == "drideOS" ]; then
sudo cp dride-core /etc/init.d/dride-core
else
sudo cp dride-core /etc/init.d/dride-core
fi;
sudo chmod +x /etc/init.d/dride-core
sudo update-rc.d dride-core defaults
sudo rm dride-core
# drideOS-resize on startup
if [ ${OS_TYPE} == "drideOS" ]; then
sudo cp drideOS-resize /etc/init.d/drideOS-resize
sudo chmod +x /etc/init.d/drideOS-resize
sudo update-rc.d drideOS-resize defaults
sudo rm drideOS-resize
fi;
if [ ${OS_TYPE} == "drideOS" ]; then
## GPS https://www.raspberrypi.org/forums/viewtopic.php?p=947968#p947968
echo "========== Install GPS ============"
sudo apt-get install gpsd gpsd-clients cmake subversion build-essential espeak freeglut3-dev imagemagick libdbus-1-dev libdbus-glib-1-dev libdevil-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgarmin-dev libglc-dev libgps-dev libgtk2.0-dev libimlib2-dev libpq-dev libqt4-dev libqtwebkit-dev librsvg2-bin libsdl-image1.2-dev libspeechd-dev libxml2-dev ttf-liberation -y
echo "" >> /boot/config.txt
echo "enable_uart=1" >> /boot/config.txt
# this will be done after initial boot
# echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes spidev.bufsiz=32768 rootwait" > /boot/cmdline.txt
# 3)Run
sudo systemctl stop serial-getty@ttyS0.service
sudo systemctl disable serial-getty@ttyS0.service
sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket
# reboot
# 5) Execute the daemon reset
#sudo killall gpsd
#sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock
fi
if [ ${OS_TYPE} == "drideOS" ]; then
echo "========== Downloading and installing OpenCV ============"
cd /
# git clone https://github.com/Itseez/opencv.git --depth 1
wget -c -O "opencv-3.1.0.zip" "https://github.com/Itseez/opencv/archive/3.1.0.zip"
sudo apt-get install unzip
unzip -q -n "opencv-3.1.0.zip"
cd opencv-3.1.0
echo "======== Building OpenCV ============"
cd /home/opencv-3.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D BUILD_opencv_apps=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
echo "==>>>====== This might take a long time.. ============"
make -j1
sudo make install
sudo ldconfig
# remove the installation file
cd /
sudo rm opencv-3.1.0.zip
# TODO: Add a test if openCV was installed correctly
fi
echo "========== Setup sound to I2S ============"
sudo curl -sS https://dride.io/code/i2samp.sh | bash
echo "========== Setup mic ============"
# https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test
echo "========== Setup RTC ============"
# https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time
sudo apt-get install python-smbus i2c-tools
# TODO: turn on ISC on raspi-config...
# add to sudo nano /boot/config.txt
echo "dtoverlay=i2c-rtc,ds3231" >> /boot/config.txt
echo "dtparam=i2c_arm=on" >> /boot/config.txt
# Remove hw-clock
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
# copy new file to
sudo wget https://dride.io/code/hwclock-set
sudo cp hwclock-set /lib/udev/hwclock-set
sudo rm hwclock-set
# we will sync the current date form the app using BLE
# looks at /daemon/bluetooth/updateDate.js
echo "========== Setup Accelerometer ============"
# http://www.stuffaboutcode.com/2014/06/raspberry-pi-adxl345-accelerometer.html
# enable i2c 0
echo "dtparam=i2c_vc=on" >> /boot/config.txt
echo "========== Install Dride-core [Cardigan] ============"
cd /home
# https://s3.amazonaws.com/dride/releases/cardigan/latest.zip
sudo mkdir Cardigan && cd Cardigan
sudo wget -c -O "cardigan.zip" "https://s3.amazonaws.com/dride/releases/cardigan/latest.zip"
sudo unzip "cardigan.zip"
sudo rm -R cardigan.zip
# make the video dir writable
sudo chmod 777 -R /home/Cardigan/modules/video/
sudo chmod 777 -R /home/Cardigan/modules/settings/
#make gps position writable
sudo chmod +x /home/Cardigan/daemons/gps/position
# make the firmware dir writable
sudo chmod 777 -R /home/Cardigan/firmware/
# run npm install on video module
cd /home/Cardigan/modules/video
sudo npm i --production
# run npm install on dride-ws
cd /home/Cardigan/dride-ws
sudo npm i --production
# setup clear cron job
crontab -l > cleanerJob
echo "* * * * * node /home/Cardigan/modules/video/helpers/cleaner.js" >> cleanerJob
#install new cron file
crontab cleanerJob
rm cleanerJob
echo "========== Install Indicators ============"
echo "# Needed for SPI LED" >> /boot/config.txt
echo "core_freq=250" >> /boot/config.txt
sudo apt-get install scons
cd /home/Cardigan/modules/indicators
sudo scons
sudo apt-get install python-dev swig -y
cd /home/Cardigan/modules/indicators/python
sudo python setup.py install
echo "========== Setup bluetooth ============"
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev -y
# run npm install on Bluetooth daemon
cd /home/Cardigan/daemons/bluetooth
sudo npm i --production
echo ""
echo '============================='
echo '*****************************'
echo '========= Finished =========='
echo '*****************************'
echo '============================='
echo ""
EOF

View File

@ -1,42 +0,0 @@
#! /bin/sh
# /etc/init.d/dride-core
### BEGIN INIT INFO
# Provides: dride-core
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: will run the main dride-core process
# Description:
### END INIT INFO
case "$1" in
start)
echo "Starting dride-core"
# run application you want to start
sudo python /home/Cardigan/mainPiZero.py &
# run gps daemon
sudo python /home/Cardigan/daemons/gps/helper.py &
# run button / bluetooth daemon
sudo python /home/Cardigan/daemons/bluetooth/initPin.py &
sleep 5 && sudo BLENO_DEVICE_NAME="dride" node /home/Cardigan/daemons/bluetooth/main.js &
;;
stop)
echo "Stopping dride-core"
# kill application you want to stop
killall python
;;
*)
echo "Usage: /etc/init.d/dride-core{start|stop}"
exit 1
;;
esac
exit 0

View File

@ -1,18 +0,0 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: drideOS-resize
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: will resize the file system & reboot
# Description:
### END INIT INFO
echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait" > /boot/cmdline.txt
# Delete the script
rm $0
# reboot
sudo reboot

4
stage2/03-boot-files/00-run.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash -e
install -m 644 files/cmdline.txt ${ROOTFS_DIR}/boot/
install -m 644 files/config.txt ${ROOTFS_DIR}/boot/

View File

@ -0,0 +1 @@
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether init=/usr/lib/raspi-config/init_resize.sh

View File

@ -0,0 +1,59 @@
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# ether over usb
dtoverlay=dwc2

View File

@ -1,5 +0,0 @@
#!/bin/bash -e
# on_chroot << EOF
# bash -c "$(curl -s https://dride.io/code/install.sh)"
# EOF

View File

@ -0,0 +1,3 @@
hostapd
#isc-dhcp-server
dnsmasq

71
stage2/05-dride-net/00-run.sh Executable file
View File

@ -0,0 +1,71 @@
#!/bin/bash -e
# on_chroot << EOF
# bash -c "$(curl -s https://dride.io/code/install.sh)"
# EOF
on_chroot << EOC
#apt-get remove --purge hostapd -yqq
#apt-get update -yqq
#apt-get upgrade -yqq
#apt-get install hostapd dnsmasq -yqq
cat > /etc/dnsmasq.conf <<EOF
interface=wlan0
dhcp-range=192.168.42.10,192.168.42.20,255.255.255.0,12h
EOF
cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlan0
hw_mode=g
channel=10
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
wpa_passphrase=ilovedride
ssid=dride
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
EOF
sed -i -- 's/allow-hotplug wlan0//g' /etc/network/interfaces
sed -i -- 's/iface wlan0 inet manual//g' /etc/network/interfaces
sed -i -- 's/ wpa-conf \/etc\/wpa_supplicant\/wpa_supplicant.conf//g' /etc/network/interfaces
sed -i -- 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd
cat >> /etc/network/interfaces <<EOF
auto usb0
allow-hotplug usb0
iface usb0 inet dhcp
# Added by rPi Access Point Setup
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
network 192.168.42.0
broadcast 192.168.42.255
EOF
echo "denyinterfaces wlan0" >> /etc/dhcpcd.conf
sudo systemctl disable dhcpcd.service
sudo systemctl enable hostapd
sudo systemctl enable dnsmasq
sudo service hostapd start
sudo service dnsmasq start
echo "All done! Please reboot"
EOC
# fix Stretch dhcpcd5 to not ignore in /etc/network/interfaces
install -m 644 files/usr_lib_dhcpcd ${ROOTFS_DIR}/usr/lib/dhcpcd5/dhcpcd

View File

@ -0,0 +1,28 @@
#!/bin/sh -e
#
# This file belongs in /usr/lib/dhcpcd5/dhcpcd how you get it there is up to you
#
DHCPCD=/sbin/dhcpcd
INTERFACES=/etc/network/interfaces
REGEX="^[[:space:]]*iface[[:space:]](*.*)[[:space:]]*inet[[:space:]]*(dhcp|static)"
EXCLUDES=""
if grep -q -E $REGEX $INTERFACES; then
#echo "Not running dhcpcd because $INTERFACES"
#echo "defines some interfaces that will use a"
#echo "DHCP client or static address"
#exit 6
for iface in `grep -E $REGEX $INTERFACES | cut -f2 -d" "`
do
if [[ $EXCLUDES != "" ]]; then
EXCLUDES="${EXCLUDES}|${iface}"
else
EXCLUDES="${iface}"
fi
done
EXCLUDES="(${EXCLUDES})"
fi
exec $DHCPCD -Z $EXCLUDES $@

View File

@ -0,0 +1,14 @@
Index: stretch-stage2/rootfs/boot/config.txt
===================================================================
--- stretch-stage2.orig/rootfs/boot/config.txt
+++ stretch-stage2/rootfs/boot/config.txt
@@ -57,3 +57,9 @@
# ether over usb
dtoverlay=dwc2
+
+# enable piCamera
+start_x=1
+gpu_mem=128
+dtparam=spi=on
+

309
stage2/06-dride-base/00-run.sh Executable file
View File

@ -0,0 +1,309 @@
#!/bin/bash -e
# Please ensure you specify "OS_TYPE"="dride-plus" as an environment variable
# IF you wish to enable advanced feature for Dride/Rpi3
# Do not include if you are building for RPiZW
install -m 755 files/etc_initd_dride-ws ${ROOTFS_DIR}/etc/init.d/dride-ws
install -m 755 files/etc_initd_dride-core ${ROOTFS_DIR}/etc/init.d/dride-core
install -m 644 files/lib_udev_hwclock-set ${ROOTFS_DIR}/lib/udev/hwclock-set
on_chroot << EOF
#-------------------------------------------------------
# Script to check if all is good before install script runs
#-------------------------------------------------------
echo "====== Dride install script ======"
echo ""
echo ""
echo ""
echo "██████╗ ██████╗ ██╗██████╗ ███████╗"
echo "██╔══██╗██╔══██╗██║██╔══██╗██╔════╝"
echo "██║ ██║██████╔╝██║██║ ██║█████╗ "
echo "██║ ██║██╔══██╗██║██║ ██║██╔══╝ "
echo "██████╔╝██║ ██║██║██████╔╝███████╗"
echo "╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝"
echo ""
echo ""
echo "This will install all the necessary dependences and software for dride."
echo "======================================================="
echo ""
echo ""
echo ""
echo ""
echo "==============================="
echo "*******************************"
echo " *** STARTING INSTALLATION ***"
echo " ** this may take a while **"
echo " *************************"
echo " ========================="
echo ""
echo ""
echo "========== Create DRIDE path ==========="
# create the video/content destination
sudo mkdir -p /dride/clip /dride/thumb /dride/tmp_clip
cd /home
# Install dependencies
echo "========== Update Aptitude ==========="
# sudo apt-get update -y
# sudo apt-get upgrade
if [ ${OS_TYPE} == "dride-plus" ]; then
echo "========== Installing build-essential ============"
sudo apt-get install build-essential -y
echo "========== Installing libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev ============"
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libjasper-dev python2.7-dev -y
fi
echo "========== Installing gpac ============"
# provides MP4Box
sudo apt-get install gpac -y
echo "========== Installing htop ============"
sudo apt-get install htop -y
echo "========== Setup libav ============"
# provides avconv
sudo apt-get install libav-tools -y
echo "========== Installing Node ============"
wget -O - https://raw.githubusercontent.com/sdesalas/node-pi-zero/master/install-node-v8.9.0.sh | bash
echo "========== Installing pip ============"
sudo apt-get install python-pip -y
if [ ${OS_TYPE} == "dride-plus" ]; then
echo "========== Installing Numpy ============"
sudo pip install numpy
fi
echo "========== Install picamera ============"
sudo apt-get install python3-picamera
# enable camera on raspi-config and allocate more ram to the GPU
echo "" >> /boot/config.txt
echo "#enable piCaera" >> /boot/config.txt
echo "start_x=1" >> /boot/config.txt
echo "gpu_mem=128" >> /boot/config.txt
echo "dtparam=spi=on" >> /boot/config.txt
if [ ${OS_TYPE} == "dride-plus" ]; then
echo "========== Install mpg123 ============"
sudo apt-get install mpg123 -y
fi
echo "========== Install pyserial ============"
sudo pip install pyserial
#startup script's
# sudo wget https://dride.io/code/startup/dride-ws
# if [ ${OS_TYPE} == "dride-plus" ]; then
# sudo wget https://dride.io/code/startup/dride-core
# else
# sudo wget https://dride.io/code/startup/dride-core
# fi;
# express on startup
# sudo cp dride-ws /etc/init.d/dride-ws
# sudo chmod +x /etc/init.d/dride-ws
sudo update-rc.d dride-ws defaults
# sudo rm dride-ws
# dride-core on startup
# if [ ${OS_TYPE} == "dride-plus" ]; then
# sudo cp dride-core /etc/init.d/dride-core
# else
# sudo cp dride-core /etc/init.d/dride-core
# fi;
# sudo chmod +x /etc/init.d/dride-core
sudo update-rc.d dride-core defaults
# sudo rm dride-core
if [ ${OS_TYPE} == "dride-plus" ]; then
## GPS https://www.raspberrypi.org/forums/viewtopic.php?p=947968#p947968
echo "========== Install GPS ============"
sudo apt-get install gpsd gpsd-clients cmake subversion build-essential espeak freeglut3-dev imagemagick libdbus-1-dev libdbus-glib-1-dev libdevil-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgarmin-dev libglc-dev libgps-dev libgtk2.0-dev libimlib2-dev libpq-dev libqt4-dev libqtwebkit-dev librsvg2-bin libsdl-image1.2-dev libspeechd-dev libxml2-dev ttf-liberation -y
echo "" >> /boot/config.txt
echo "enable_uart=1" >> /boot/config.txt
# this will be done after initial boot
# echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes spidev.bufsiz=32768 rootwait" > /boot/cmdline.txt
# 3)Run
sudo systemctl stop serial-getty@ttyS0.service
sudo systemctl disable serial-getty@ttyS0.service
sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket
# reboot
# 5) Execute the daemon reset
#sudo killall gpsd
#sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock
fi
if [ ${OS_TYPE} == "dride-plus" ]; then
echo "========== Downloading and installing OpenCV ============"
cd /
# git clone https://github.com/Itseez/opencv.git --depth 1
wget -c -O "opencv-3.1.0.zip" "https://github.com/Itseez/opencv/archive/3.1.0.zip"
sudo apt-get install unzip
unzip -q -n "opencv-3.1.0.zip"
cd opencv-3.1.0
echo "======== Building OpenCV ============"
cd /home/opencv-3.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D BUILD_opencv_apps=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
echo "==>>>====== This might take a long time.. ============"
make -j1
sudo make install
sudo ldconfig
# remove the installation file
cd /
sudo rm opencv-3.1.0.zip
# TODO: Add a test if openCV was installed correctly
fi
echo "========== Setup sound to I2S ============"
sudo curl -sS https://dride.io/code/i2samp.sh | bash
echo "========== Setup mic ============"
# https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test
echo "========== Setup RTC ============"
# https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time
sudo apt-get install python-smbus i2c-tools
# TODO: turn on ISC on raspi-config...
# add to sudo nano /boot/config.txt
echo "dtoverlay=i2c-rtc,ds3231,dwc2" >> /boot/config.txt
echo "dtparam=i2c_arm=on" >> /boot/config.txt
# Remove hw-clock
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
# copy new file to
# sudo wget https://dride.io/code/hwclock-set
# sudo cp hwclock-set /lib/udev/hwclock-set
# sudo rm hwclock-set
# we will sync the current date form the app using BLE
# looks at /daemon/bluetooth/updateDate.js
echo "========== Setup Accelerometer ============"
# http://www.stuffaboutcode.com/2014/06/raspberry-pi-adxl345-accelerometer.html
# enable i2c 0
echo "# Accelerometer" >> /boot/config.txt
echo "dtparam=i2c_vc=on" >> /boot/config.txt
echo "========== Install Dride-core [Cardigan] ============"
cd /home
# https://s3.amazonaws.com/dride/releases/cardigan/latest.zip
sudo mkdir Cardigan && cd Cardigan
sudo wget -c -O "cardigan.zip" "https://s3.amazonaws.com/dride/releases/cardigan/latest.zip"
sudo unzip "cardigan.zip"
sudo rm -R cardigan.zip
# make the video dir writable
sudo chmod 777 -R /home/Cardigan/modules/video/
sudo chmod 777 -R /home/Cardigan/modules/settings/
# make gps position writable
sudo chmod +x /home/Cardigan/daemons/gps/position
# make the firmware dir writable
sudo chmod 777 -R /home/Cardigan/firmware/
# run npm install on video module
cd /home/Cardigan/modules/video
sudo npm i --production
# set proper soft links to use /dride path
sudo rm -rf tmp_clip/
sudo ln -s /dride/tmp_clip/ tmp_clip
sudo rm -rf thumb/
sudo ln -s /dride/thumb/ thumb
sudo rm -rf clip/
sudo ln -s /dride/clip/ clip
# run npm install on dride-ws
cd /home/Cardigan/dride-ws
sudo npm i --production
# setup clear cron job
crontab -l > cleanerJob
echo "* * * * * node /home/Cardigan/modules/video/helpers/cleaner.js" >> cleanerJob
# install new cron file
crontab cleanerJob
rm cleanerJob
echo "========== Install Indicators ============"
echo "# Needed for SPI LED" >> /boot/config.txt
echo "core_freq=250" >> /boot/config.txt
sudo apt-get install scons
cd /home/Cardigan/modules/indicators
sudo scons
sudo apt-get install python-dev swig -y
cd /home/Cardigan/modules/indicators/python
sudo python setup.py install
echo "========== Setup bluetooth ============"
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev -y
# run npm install on Bluetooth daemon
cd /home/Cardigan/daemons/bluetooth
sudo npm i --production
echo ""
echo '============================='
echo '*****************************'
echo '========= Finished =========='
echo '*****************************'
echo '============================='
echo ""
EOF

View File

@ -15,15 +15,18 @@
case "$1" in
start)
echo "Starting dride-core"
# run application you want to start
sudo python /home/Cardigan/mainPi.py &
#blink LED
sudo python /home/Cardigan/modules/indicators/python/states/standalone.py welcome
# run gps daemon
sudo python /home/Cardigan/daemons/gps/helper.py &
# decode undecoded clips on startup
sudo node /home/Cardigan/modules/video/helpers/ensureAllClipsAreDecoded.js &
# start recording
sudo node /home/Cardigan/modules/video/index.js &
# run button / bluetooth daemon
sudo python /home/Cardigan/daemons/bluetooth/initPin.py &
sleep 5 && sudo BLENO_DEVICE_NAME="dride" node /home/Cardigan/daemons/bluetooth/main.js &
sudo python /home/Cardigan/daemons/bluetooth/initPin.py &
sudo BLENO_DEVICE_NAME="dride" node /home/Cardigan/daemons/bluetooth/main.js &
;;
stop)
echo "Stopping dride-core"
@ -37,6 +40,3 @@ case "$1" in
esac
exit 0

View File

@ -28,4 +28,4 @@ case "$1" in
;;
esac
exit 0
exit 0

View File

@ -0,0 +1,33 @@
#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.
dev=$1
if [ -e /run/udev/hwclock-set ]; then
exit 0
fi
if [ -f /etc/default/rcS ] ; then
. /etc/default/rcS
fi
# These defaults are user-overridable in /etc/default/hwclock
BADYEAR=no
HWCLOCKACCESS=yes
HWCLOCKPARS=
HCTOSYS_DEVICE=rtc0
if [ -f /etc/default/hwclock ] ; then
. /etc/default/hwclock
fi
if [ yes = "$BADYEAR" ] ; then
/sbin/hwclock --rtc=$dev --systz --badyear
/sbin/hwclock --rtc=$dev --hctosys --badyear
else
/sbin/hwclock --rtc=$dev --systz
/sbin/hwclock --rtc=$dev --hctosys
fi
# Note 'touch' may not be available in initramfs
> /run/udev/hwclock-set