Difference between revisions of "Installing Video/Audio device"

From wiki.ferrari.mo.it
Jump to navigation Jump to search
 
(16 intermediate revisions by one other user not shown)
Line 1: Line 1:
=== Installing Video/Audio device ===
+
= Installing Video/Audio device =
  
 
The chosen device is a Nanopi M4 from FriendlyElec.
 
The chosen device is a Nanopi M4 from FriendlyElec.
Line 7: Line 7:
 
Per device: $ 80.97, including:
 
Per device: $ 80.97, including:
  
- Board;
+
* Board;
- Power adapter and cable;
+
* Power adapter and cable;
- Heat sink;
+
* Heat sink;
- EMMC module (16GB);
+
* EMMC module (16GB);
- American/European adapter.
+
* American/European adapter.
  
 
Plus, shipping costs ($ 11.00).
 
Plus, shipping costs ($ 11.00).
Line 25: Line 25:
 
Then, extract the 'rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-20190718.img' file and flash it through balenaEtcher to a (minimum 16GB) SD card.
 
Then, extract the 'rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-20190718.img' file and flash it through balenaEtcher to a (minimum 16GB) SD card.
  
= Software =
+
Insert both the eMMC module and the SD card on the NanoPI M4 device, and power on it. Connect a monitor and a keyboard/mouse to the device, and flash the eMMC module. Then remove the SD card and restart it.
 +
 
 +
=== Software ===
  
 
Connect via SSH, and install the required modules.
 
Connect via SSH, and install the required modules.
Line 36: Line 38:
 
  apt-get install libreoffice
 
  apt-get install libreoffice
 
  apt-get install smbclient
 
  apt-get install smbclient
 +
apt-get install dos2unix
 +
 +
Maybe vlc should be started with the command:
 +
 +
vlc --vout x11
 +
 +
=== Configuration ===
  
 
Then configure the board:
 
Then configure the board:
Line 43: Line 52:
 
Set:
 
Set:
  
- timezone;
+
* timezone;
- language;
+
* language;
- name of the device;
+
* name of the device;
- audio device.
+
* audio device.
  
 
From the GUI, configure the audio via the left-top corner icon. Both the devices listed should be set to 'analog audio' and set to active.
 
From the GUI, configure the audio via the left-top corner icon. Both the devices listed should be set to 'analog audio' and set to active.
  
 +
Transfer your background (1920x1080) and, with right-click on the desktop, select desktop preferences and set the background image.
 +
 +
Icons:
 +
 +
* From a terminal, go to '/home/pi/desktop' and move the unneeded files;
 +
* from the left-top menu, select the needed icons and right-click, then select 'add to desktop'.
 +
 +
=== VNC ===
 +
 +
Command to run x11vnc:
 +
 +
x11vnc -auth /var/run/lightdm/root/:0 -loop
 +
 +
=== Remote and local storage ===
 +
 +
Create a local link to the desktop for the (optional) local storage:
 +
 +
ln -s /local /home/pi/Desktop/localstorage
 +
 +
/xxxx is the path of the local storage, maybe this should be mounted with the usual command
 +
 +
mkdir /local
 +
mount /dev/xyz /local
  
Insert both the eMMC module and the SD card on the NanoPI M4 device, and power on it. Connect a monitor and a keyboard/mouse to the device, and flash the eMMC module. Then remove the SD card and restart it.
+
Create a remote link to the desktop for the remote storage:
 +
 
 +
mkdir /remote
 +
mount -t cifs //<IP>/<DIR> /remote -o username=<X>,password=<Y>,vers=2.0
 +
ln -s /remote /home/pi/Desktop/remotestorage
 +
 
 +
Use this script
 +
 
 +
#!/bin/sh
 +
 +
POINT=`cat /root/eywa/storage.cfg | grep POINT | sed -e s/POINT=//`
 +
MOUNT=`cat /root/eywa/storage.cfg | grep MOUNT | sed -e s/MOUNT=//`
 +
USER=`cat /root/eywa/storage.cfg | grep USER | sed -e s/USER=//`
 +
PASSWORD=`cat /root/eywa/storage.cfg | grep PASSWORD | sed -e s/PASSWORD=//`
 +
MOUNTED=`df ${POINT} --output=target | tail -1`
 +
 +
if [ "x${MOUNT}x" != "xx" -a "x${MOUNTED}x" != "x${POINT}x" ]
 +
then
 +
    echo "Not mounted, mounting..."
 +
    if [ "x${USER}x" = "xx" ]
 +
    then
 +
        mount -t cifs ${MOUNT} ${POINT}
 +
    else
 +
        mount -t cifs ${MOUNT} -o username=${USER},password=${PASSWORD} ${POINT}
 +
    fi
 +
    sleep 1
 +
    NEWMOUNTED=`df | grep ${POINT} | wc -l`
 +
    echo "Newmounted = ${NEWMOUNTED}"
 +
    if [ ${NEWMOUNTED} = 1 ]
 +
    then
 +
        echo "Killing processes for logging"
 +
        killall node
 +
        killall CaptureImage1
 +
    fi
 +
fi
 +
 
 +
and this configuration file
 +
 
 +
POINT=/mnt
 +
MOUNT=//10.10.10.151/xxx
 +
USER=fabio
 +
PASSWORD=xxxxxxx
 +
 
 +
to mount shared folder at boot, the /etc/crontab line should look like this
 +
 
 +
* * * * * root /root/mountstorage.sh
 +
 
 +
Then go to /home/pi/Desktop and execute
 +
 
 +
ln -s /mnt share
 +
 
 +
=== Start at boot ===
 +
 
 +
Create the file /etc/systemd/system/x11vnc.service:
 +
 
 +
[Unit]
 +
Description="x11vnc"
 +
Requires=display-manager.service
 +
After=display-manager.service
 +
 +
[Service]
 +
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
 +
ExecStop=/usr/bin/killall x11vnc
 +
Restart=on-failure
 +
Restart-sec=2
 +
 +
[Install]
 +
WantedBy=multi-user.target
 +
 
 +
Then, enable it:
 +
 
 +
systemctl enable x11vnc.service
 +
 
 +
Create a password
 +
 
 +
x11vnc -storepasswd
 +
 
 +
and copy it to the /etc/x11vnc.pass file
 +
 
 +
cp /root/.vnc/passwd /etc/x11vnc.pass
 +
 
 +
=== Disable screen ===
 +
 
 +
Go to the menu, and then to Preferences - Light Locker settings. Disable it.
 +
 
 +
You should create a script that executes this command:
 +
 
 +
xset dpms force off
 +
 
 +
If the monitor is seeking for a signal, maybe it will we reactivated in seconds. So, maybe you have to do a script that repeats the same command every second until the monitor gives up searching.
 +
 
 +
In order to prevent to accidentally log-out (and make it impossible to reconnect again), edit the file
 +
 
 +
/home/pi/.config/lxpanel/LXDE/panels/panel
 +
 
 +
and comment the last stanza:
 +
 
 +
#Plugin {
 +
#  type=launchbar
 +
#  Config {
 +
#    Button {
 +
#      id=lxde-screenlock.desktop
 +
#    }
 +
#    Button {
 +
#      id=lxde-logout.desktop
 +
#    }
 +
#  }
 +
#}
 +
 
 +
Create the script disable.sh
 +
 
 +
#!/bin/sh
 +
 +
END=30
 +
 +
for i in $(seq 1 ${END})
 +
do
 +
  xset dpms force off
 +
  sleep 1
 +
  echo "."
 +
done
 +
 
 +
and create a symbolic link in the Desktop
 +
 
 +
ln -s /root/disable.sh /home/pi/Desktop/disable.desktop
 +
 
 +
== Mount and share NVMe ==
 +
 
 +
Create partition and file system:
 +
 
 +
fdisk /dev/nvme0n1
 +
 
 +
apt-get install xfsprogs
 +
mkfs -t xfs /dev/nvme0n1p1
 +
 
 +
Create directory and mount it
 +
 
 +
mkdir /home/pi/Desktop/shared
 +
blkid
 +
 
 +
Extract UUID and edit /etc/fstab
 +
 
 +
UUID=the_uuid /home/pi/Desktop/shared xfs defaults 0 0
 +
 
 +
Install and configure samba
 +
 
 +
apt-get install samba
 +
 
 +
Edit /etc/samba/smb.conf and add
 +
 
 +
[shared]
 +
  path = /home/pi/Desktop/shared
 +
  read only = no
 +
  guest ok = yes
 +
 
 +
Make it accessible
 +
 
 +
cd /
 +
chmod 777 home
 +
cd home
 +
chmod 777 pi
 +
cd pi
 +
chmod 777 Desktop
 +
cd Desktop
 +
chmod 777 shared

Latest revision as of 23:13, 3 December 2021

Installing Video/Audio device[edit]

The chosen device is a Nanopi M4 from FriendlyElec.

Estimated hardware costs:

Per device: $ 80.97, including:

  • Board;
  • Power adapter and cable;
  • Heat sink;
  • EMMC module (16GB);
  • American/European adapter.

Plus, shipping costs ($ 11.00).

In the case of fast and secure shipping with DHL (recommended), an average of $ 5.00, plus the VAT on the entire costs will be added.

Total cost: € 85 (plus VAT) per piece.

Installation[edit]

Download the 'Official-ROMs-eMMC-20190718.7z' file from the FriendlyArm Google repository (about 16GB).

Then, extract the 'rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-20190718.img' file and flash it through balenaEtcher to a (minimum 16GB) SD card.

Insert both the eMMC module and the SD card on the NanoPI M4 device, and power on it. Connect a monitor and a keyboard/mouse to the device, and flash the eMMC module. Then remove the SD card and restart it.

Software[edit]

Connect via SSH, and install the required modules.

apt-get update
apt-get install x11vnc
apt-get install vlc
apt-get install clementine
apt-get install shotwell
apt-get install libreoffice
apt-get install smbclient
apt-get install dos2unix

Maybe vlc should be started with the command:

vlc --vout x11

Configuration[edit]

Then configure the board:

npi-config

Set:

  • timezone;
  • language;
  • name of the device;
  • audio device.

From the GUI, configure the audio via the left-top corner icon. Both the devices listed should be set to 'analog audio' and set to active.

Transfer your background (1920x1080) and, with right-click on the desktop, select desktop preferences and set the background image.

Icons:

  • From a terminal, go to '/home/pi/desktop' and move the unneeded files;
  • from the left-top menu, select the needed icons and right-click, then select 'add to desktop'.

VNC[edit]

Command to run x11vnc:

x11vnc -auth /var/run/lightdm/root/:0 -loop

Remote and local storage[edit]

Create a local link to the desktop for the (optional) local storage:

ln -s /local /home/pi/Desktop/localstorage

/xxxx is the path of the local storage, maybe this should be mounted with the usual command

mkdir /local
mount /dev/xyz /local

Create a remote link to the desktop for the remote storage:

mkdir /remote
mount -t cifs //<IP>/<DIR> /remote -o username=<X>,password=<Y>,vers=2.0
ln -s /remote /home/pi/Desktop/remotestorage

Use this script

#!/bin/sh

POINT=`cat /root/eywa/storage.cfg | grep POINT | sed -e s/POINT=//`
MOUNT=`cat /root/eywa/storage.cfg | grep MOUNT | sed -e s/MOUNT=//`
USER=`cat /root/eywa/storage.cfg | grep USER | sed -e s/USER=//`
PASSWORD=`cat /root/eywa/storage.cfg | grep PASSWORD | sed -e s/PASSWORD=//`
MOUNTED=`df ${POINT} --output=target | tail -1`

if [ "x${MOUNT}x" != "xx" -a "x${MOUNTED}x" != "x${POINT}x" ]
then
    echo "Not mounted, mounting..."
    if [ "x${USER}x" = "xx" ]
    then
        mount -t cifs ${MOUNT} ${POINT}
    else
        mount -t cifs ${MOUNT} -o username=${USER},password=${PASSWORD} ${POINT}
    fi
    sleep 1
    NEWMOUNTED=`df | grep ${POINT} | wc -l`
    echo "Newmounted = ${NEWMOUNTED}"
    if [ ${NEWMOUNTED} = 1 ]
    then
        echo "Killing processes for logging"
        killall node
        killall CaptureImage1
    fi
fi

and this configuration file

POINT=/mnt
MOUNT=//10.10.10.151/xxx
USER=fabio
PASSWORD=xxxxxxx

to mount shared folder at boot, the /etc/crontab line should look like this

* * * * * root /root/mountstorage.sh

Then go to /home/pi/Desktop and execute

ln -s /mnt share

Start at boot[edit]

Create the file /etc/systemd/system/x11vnc.service:

[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2

[Install]
WantedBy=multi-user.target

Then, enable it:

systemctl enable x11vnc.service

Create a password

x11vnc -storepasswd

and copy it to the /etc/x11vnc.pass file

cp /root/.vnc/passwd /etc/x11vnc.pass

Disable screen[edit]

Go to the menu, and then to Preferences - Light Locker settings. Disable it.

You should create a script that executes this command:

xset dpms force off

If the monitor is seeking for a signal, maybe it will we reactivated in seconds. So, maybe you have to do a script that repeats the same command every second until the monitor gives up searching.

In order to prevent to accidentally log-out (and make it impossible to reconnect again), edit the file

/home/pi/.config/lxpanel/LXDE/panels/panel

and comment the last stanza:

#Plugin {
#  type=launchbar
#  Config {
#    Button {
#      id=lxde-screenlock.desktop
#    }
#    Button {
#      id=lxde-logout.desktop
#    }
#  }
#}

Create the script disable.sh

#!/bin/sh

END=30

for i in $(seq 1 ${END})
do
  xset dpms force off
  sleep 1
  echo "."
done

and create a symbolic link in the Desktop

ln -s /root/disable.sh /home/pi/Desktop/disable.desktop

Mount and share NVMe[edit]

Create partition and file system:

fdisk /dev/nvme0n1
apt-get install xfsprogs
mkfs -t xfs /dev/nvme0n1p1

Create directory and mount it

mkdir /home/pi/Desktop/shared
blkid

Extract UUID and edit /etc/fstab

UUID=the_uuid /home/pi/Desktop/shared xfs defaults 0 0

Install and configure samba

apt-get install samba

Edit /etc/samba/smb.conf and add

[shared]
  path = /home/pi/Desktop/shared
  read only = no
  guest ok = yes

Make it accessible

cd /
chmod 777 home
cd home
chmod 777 pi
cd pi
chmod 777 Desktop
cd Desktop
chmod 777 shared