Difference between revisions of "Preparing NanoPI M1 Plus"

From wiki.ferrari.mo.it
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
  apt-get --yes --force-yes remove --auto-remove --purge network-manager x11-common x11-proto*
 
  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:
+
Before rebooting the system, you must configure /etc/network/interfaces with the following (ip, mask and gw are obviously examples):
  
 
  auto lo
 
  auto lo
Line 48: Line 48:
 
  httpREST/
 
  httpREST/
 
  dist/
 
  dist/
 +
opencv/
 
  watchdog-eywa.sh
 
  watchdog-eywa.sh
 +
mountstorage.sh
 +
camera.sh
 
  sqlite.db
 
  sqlite.db
 
  server.js
 
  server.js
Line 59: Line 62:
 
  mv package.json.node package.json
 
  mv package.json.node package.json
 
  npm install
 
  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

Latest revision as of 10:04, 13 April 2020

Preparing NanoPI M1 Plus for Eywa[edit]

Step 1 - Flash card[edit]

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[edit]

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[edit]

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[edit]

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[edit]

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