Preparing NanoPI M1 Plus

From wiki.ferrari.mo.it
Jump to navigation Jump to search

Preparing NanoPI M1 Plus for Eywa

Step 1 - Flash card

Download nanopi-m1-plus_sd_debian-jessie_4.14_armhf_20181119.img from FriendlyElec shared folder.

Then, flash an SD card (we used Toshiba 16Gb) with balena Etcher (or equivalent).

The username/password of the system is root / fa .

Step 2 - Remove the unwanted packages

apt-get --yes --force-yes remove --auto-remove --purge network-manager x11-common x11-proto*

Before rebooting the system, you must configure /etc/network/interfaces with the following (ip, mask and gw are obviously examples):

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.10.10.17
netmask 255.255.255.0
gateway 10.10.10.254

NOTE: the eth0 is unconfigured by default. If you forget to configure it in the file and reboot, the board will be inaccessible by ssh.

Then, remove the unwanted directories:

cd /root
rm -rf demo/ Desktop/ Documents/ Downloads/ mjpg-streamer/ Music/ Pictures/ Public/ Templates/ Videos/ WiringNP/

Step 3 - Install node

sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

apt-get install nodejs

Step 4 - Install Eywa and its packages

Copy the eywa directory to /root . You can include only the following directories and files:

webSocket/
tcpSocket/
REST/
httpREST/
dist/
opencv/
watchdog-eywa.sh
mountstorage.sh
camera.sh
sqlite.db
server.js
package.json.node
labels.properties.en

Then, rename the file package.json.node and install modules:

cd /root/eywa
mv package.json.node package.json
npm install

Then, create the cert/key pair

openssl req -nodes -x509 -newkey rsa:4096 -keyout /etc/ssl/private/key.pem -out /etc/ssl/cert.pem -days 3650

and replace the config lines in the server.js with the following:

var privateKey = fs.readFileSync('/etc/ssl/private/key.pem', 'utf8');
var certificate = fs.readFileSync('/etc/ssl/cert.pem', 'utf8');

Add this line to /etc/crontab:

* * * * * root /root/eywa/watchdog-eywa.sh
* * * * * root /root/eywa/mountstorage.sh
* * * * * root /root/eywa/camera.sh

Step 5 - Correcting scripts

Install dos2unix

apt-get install dos2unix

Install cifs-utils

apt-get install cifs-utils

Correct scripts

dos2unix /root/eywa/*.sh
dos2unix /root/eywa/storage.cfg
chmod +x /root/eywa/*.sh