Pi4 with Raspbian Bullseye: Difference between revisions

From Global Meteor Network
Jump to navigation Jump to search
(Fix package list)
 
(10 intermediate revisions by 2 users not shown)
Line 146: Line 146:


Next install additional packages which are needed by RMS. This command will install even mopre packages that you specify. This is because some packages depend on others. And some packages won't be installed, because they are already present.
Next install additional packages which are needed by RMS. This command will install even mopre packages that you specify. This is because some packages depend on others. And some packages won't be installed, because they are already present.
   sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 g++ g++-10 gcc-10 gcc-10-base gcc-7-base gcc-8-base gcc-9-base gfortran gfortran-10 gstreamer1.0* libgstreamer-opencv1.0-0 python3-opencv python3-opencv-apps  ros-opencv-apps opencv-data opencv-doc libopencv* python3-setuptools python3-scipy cython3 cython3-dbg python3-pytest-cython python3-astropy* python3-paramiko python3-matplotlib* libcfitsio9 libwcs7 python3-pyqtgraph python3-git python3-pil git git-man wxpython-tools wx3.0-headers wx-common python3-wxgtk4.0 libwxgtk3.0-gtk3-dev libwxgtk3.0-gtk3-0v5 libwxbase3.0-dev libwxbase3.0-0v5 screen python3-six python3-numpy python3-imageio libgstreamer-plugins-base1.0-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37 dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev  libnotify-dev freeglut3 freeglut3-dev libghc-gtk3-dev python-tk
   sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 g++ g++-10 gcc-10 gcc-10-base gcc-7-base gcc-8-base gcc-9-base gfortran gfortran-10 libgstreamer-opencv1.0-0 python3-opencv python3-opencv-apps  ros-opencv-apps opencv-data opencv-doc libopencv* python3-setuptools python3-scipy cython3 cython3-dbg python3-pytest-cython python3-astropy* python3-paramiko python3-matplotlib* libcfitsio9 libwcs7 python3-pyqtgraph python3-git python3-pil git git-man wxpython-tools wx3.0-headers wx-common python3-wxgtk4.0 libwxgtk3.0-gtk3-dev libwxgtk3.0-gtk3-0v5 libwxbase3.0-dev libwxbase3.0-0v5 screen python3-six python3-numpy python3-imageio libgstreamer-plugins-base1.0-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37 dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev  libnotify-dev freeglut3 freeglut3-dev libghc-gtk3-dev python-tk gstreamer1.0-tools gstreamer1.0-plugins-base-apps gstreamer1.0-rtsp gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-python3-plugin-loader gstreamer1.0-opencv gstreamer1.0-pulseaudio gstreamer1.0-libav gstreamer1.0-plugins-rtp gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl


Finally, install the Python virtual environment tool with:
Finally, install the Python virtual environment tool with:
Line 175: Line 175:


Create the virtual environment:
Create the virtual environment:
  cd ~
   virtualenv vRMS
   virtualenv vRMS


Line 197: Line 198:
   pip3 install pyqtgraph
   pip3 install pyqtgraph
   pip3 install pyqt5 --config-settings --confirm-license= --verbose
   pip3 install pyqt5 --config-settings --confirm-license= --verbose
  pip3 install opencv-python


And exit the ''rms'' account:
And exit the ''rms'' account:
Line 265: Line 267:
   fi
   fi


Raspbian is runnign a program named ''cron'' to execute tasks at certain times. The script above needs to be started every 10 minutes. That way RMS is (re-)started automatically. By creating the file ''/tmp/RESTART_RMS'' RMS can be stopped and restarted 10 minutes later. The effect of this is that RMS is updated.
Raspbian is running a program named ''cron'' to execute tasks at certain times. The script above needs to be started every 10 minutes. That way RMS is (re-)started automatically. By creating the file ''/tmp/RESTART_RMS'' RMS can be stopped and restarted 10 minutes later. The effect of this is that RMS is updated.
   sudo nano /etc/crontab
   sudo nano /etc/crontab


Line 285: Line 287:


== Installing CMN Binviewer ==
== Installing CMN Binviewer ==
To view the binary files of RMS you can use the Binviewer program from the Croation Meteor Network. Best practise is to install this under your normal user account (''[Yourname]''). In the default Raspbian installation you have read access to the files of other users. If you want to open files you can browse to /home/rms/RMS_data. Since data is read only, you run no risk of disturbing your RMS installation. You need to run the graphic desktop environment for this though. Alternatively you can setup the Binviewer on another computer and transfer the files there. If you want to run Samba to get the files from the Raspberry, be careful though. RMS may store over 5000 files in one directory. Samba will create a heavy system load when opening the directories. It is better to copy the files locally using secure copy (''scp''). If you want to install CMN Binviewer locally (not on the Raspberry) then look here: [https://github.com/CroatianMeteorNetwork/cmn_binviewer]
To view the binary files of RMS you can use the Binviewer program (previously from the Croatian Meteor Network CMN, now maintained by Mark McIntyre). If you're using Bullseye or an earlier version of Raspian, install this under your normal user account (''[Yourname]''). If you're using Bookworm, install it in the rms user account as the newer OS does not permit access to other account's files. If you want to open files you can browse to /home/rms/RMS_data. Since data is read only, you run no risk of disturbing your RMS installation. You need to run the graphic desktop environment for this though. Alternatively you can setup the Binviewer on another computer and transfer the files there. If you want to run Samba to get the files from the Raspberry, be careful though. RMS may store over 5000 files in one directory. Samba will create a heavy system load when opening the directories. It is better to copy the files locally using secure copy (''scp''). If you want to install CMN Binviewer locally (not on the Raspberry) then look here: [https://github.com/CroatianMeteorNetwork/cmn_binviewer]


To install on the Rasberry under your own account, first log in. Then do:
Note: these instructions assume you have already installed RMS on your Raspberry Pi. If you've not done that, do it first. This is needed because RMS and Binviewer require many of the same system libraries installed with apt.
  git clone https://github.com/CroatianMeteorNetwork/cmn_binviewer.git
 
  virtualenv --system-site-packages -p python3 ~/vBinviewer
To install on the Rasberry Pi, first log in. Then do:
  source ~/vBinviewer/bin/activate
mkdir -p ~/source
  cd cmn_binviewer
cd ~/source
  pip install -r requirements.txt
git clone https://github.com/CroatianMeteorNetwork/cmn_binviewer.git
virtualenv -p python3 ~/vBinviewer
source ~/vBinviewer/bin/activate
cd ~/source/cmn_binviewer
pip install -r requirements.txt


Then create the startscript for CMN Binviewer:
Then create the startscript for CMN Binviewer:
  sudo nano ~/vBinviewer/CMN_Binviewer
sudo nano ~/vBinviewer/CMN_Binviewer


And paste these contents in it:
And paste these contents in it:
  #!/usr/bin/bash
#!/usr/bin/bash
  source ~/vBinviewer/bin/activate   
source ~/vBinviewer/bin/activate   
  cd cmn_binviewer
cd ~/source/cmn_binviewer
  python CMN_binViewer.py
python CMN_binViewer.py
 
Make the script executable and create a link to the script from the Desktop:
chmod +x ~/vBinviewer/CMN_Binviewer
ln -s ~/vBinviewer/CMN_Binviewer ~/Desktop/CMN_Binviewer


And to create a link to the script from the Desktop:
Support notes:
  ln -s ~/vBinviewer/CMN_Binviewer ~/Desktop/CMN_Binviewer
* If you get "ImportError: libopenblas.so.0" try running this in a Terminal window - sudo apt-get install -y libopenblas-dev

Latest revision as of 09:05, 17 May 2024

Introduction

The Raspberry Pi is excellent in the role of RMS station. It has just enough processing power with proper external connections. The task of RMS station can be combined with other tasks, as long as they are not too heavy. Possible examples:

  • ADSB receiver
  • NTP server

Pi4 cpu usage.png

Memory usage, on average, stays below 1GB so any model would suffice. If your have more memory you could do without a swap partition. This is especially useful if the station uses a flash card as storage. The RMS station task causes a lot of read/write actions. The best way would be to add an external USB3 disk. Any disk would do. External power for the disk should not be necessary, as long as relatively small SSD disks are used.

Pi4 memory usage.png

If you decide to add an SSD disk to the Raspberry, see these instructions to boot from SSD by default. [1]

The easiest way to run an RMS station is by using the standard RMS image. If you want to have more control, because the Pi will be doing other things as well, or want to have more control over versions used you can build your own. With the latest version of Raspbian, this is not a hard task. You can start by flashing either the default or the lite version of Raspbian Bullseye to your flash card or USB disk.

This howto assumes you are logged into the Pi with SSH (secure shell). You can also connect monitor and keyboard or use VNC to connect to the Raspberry (enable VNC using raspi-config).

Connecting to the network

There are several option to setup networking connections. The best way would be to connect the camera and the Raspberry to a switch. If you have no wired network available you could connect the camera to the Raspberry directy and then connect the Raspberry to the main network over Wifi.

If you want to connect the camera to your Pi directly

If you want to do this you have to setup a DHCP service on the Raspberry. You can find the proper way to configure the camera in the manual to build one. Make sure to use and address range different from your main network. (Note: These instructions were copied over from the original manual)

1. First, install the DHCP server:

 sudo apt-get install -y isc-dhcp-server

2. Edit the DHCP configuration file:

 sudo nano /etc/dhcp/dhcpd.conf

We need to add a fixed address for the camera, so append this at the end of the file:

 subnet 192.168.42.0 netmask 255.255.255.0 {
   authoritative;
   pool {
 	  range 192.168.42.10 192.168.42.10;
   }
   option broadcast-address 192.168.42.255;
   default-lease-time 600;
   max-lease-time 7200;
   option domain-name "local";
 }

This will assign a fixed IP address 192.168.42.10 to the camera.

3. Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the file:

 sudo nano /etc/default/isc-dhcp-server

and edit the line with INTERFACESv4 by adding "eth0":

 INTERFACESv4="eth0"

4. Next, we need to give the ethernet interface the proper subnet. Open:

 sudo nano /etc/dhcpcd.conf

and add this at the end of the file:

 interface eth0
 static ip_address=192.168.42.1/24

This will give the ethernet interface a static IP address.

5. Finally, the DHCP server will try to run before the ethernet interface is up, which will produce an error. We can tell it to try again, until it is successful. Run the following commands:

 sudo cp /run/systemd/generator.late/isc-dhcp-server.service /etc/systemd/system
 sudo nano /etc/systemd/system/isc-dhcp-server.service

Edit the [Service] section:

  • set Restart=on-failure
  • add RestartSec=5 to instruct systemd to wait 5 seconds before restarting a failed service.

Add the [Install] section which is missing, and add the follow line to it:

 WantedBy=multi-user.target

Run the commands:

 sudo systemctl daemon-reload
 sudo systemctl disable isc-dhcp-server
 sudo systemctl enable isc-dhcp-server

6. Reboot so to test the configuration:

 sudo reboot

Make sure the camera is connected to the Pi’s ethernet interface, and that a fixed IP address of 192.168.42.10 is set on the camera.

7. Now, if you run arp -a, you will be able to see the IP camera: ? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0 If not, check the status of the DHCP server service:

 sudo service isc-dhcp-server status

The service should be active.

Preparation of the Raspberry Pi to run RMS

If the Raspberry is already running. Check if your filesystem is using the full disk. To do this log in to the Pi and run the command:

 df -h

The size of /dev/root should be near your disk size. If it is not, you still need to expand the filesystem. Use raspi-config for this task.

 sudo raspi-config

- Choose “Advanced Options” (6) and then “Expand Filesystem” (A1)

While you are in raspi-config also set GPU memory to 256

- Choose “Performance options” (4) and then “GPU Memory” (P2)

And set the timezone to UTC

- Choose “Localisation options” (5) and then “None of the above” and then “UTC”

Save your settings and exit raspi-config without rebooting the Pi

If your Raspberry has 2GB of memory or less, you can enable swap by editing (sudo nano /etc/dphys-swapfile) the file /etc/dphys-swapfile and set

 CONF_SWAPSIZE=1024

Save the file and do:

 service dphys-swapfile restart

Reboot the pi

 sudo shutdown -r now


Create user accounts

After reboot, login as user pi and create an account to run RMS and an account for yourself. You could also use the pi account, but using non-default usernames is a best (security) practise.

 sudo useradd -m [your name] -g pi -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,render,netdev,spi,i2c,gpio,lpadmin
 sudo passwd [yourname]
 sudo echo [yourname] ALL=(ALL) NOPASSWD: ALL > /etc/sudoers.d/011_user_nopasswd
 sudo useradd -m rms
 sudo passwd -l rms

Now you have an account on your name equal to the pi account and a locked rms account. we don’t need interactive logon for rms so blocking it is a wise thing to do.

Now log out of the Pi and login under your own account. Then do:

 sudo passwd -l pi

By default the /tmp directory is used for temporary file storage. This directory is located in the working memory of the Pi and not on disk. As such, there is not enough space available in this directory to do the installation. So we need to use another location.

Become user rms and use another directory for temporary file storage:

 sudo su - rms
 mkdir tmp
 echo export TMP=/home/rms/tmp >> .profile
 echo export TEMP=/home/rms/tmp >> .profile
 exit

Install packages

Before installing any new packages lets first make sure all current software is up to date

 sudo apt-get update
 sudo apt-get upgrade -y

The first command updates the copy of the package list and the second upgrades any outdated packages (The -y options means you wont have to confirm the upgrade). It is a wise thing to do this at least on a weekly basis.

Next install additional packages which are needed by RMS. This command will install even mopre packages that you specify. This is because some packages depend on others. And some packages won't be installed, because they are already present.

 sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 g++ g++-10 gcc-10 gcc-10-base gcc-7-base gcc-8-base gcc-9-base gfortran gfortran-10 libgstreamer-opencv1.0-0 python3-opencv python3-opencv-apps  ros-opencv-apps opencv-data opencv-doc libopencv* python3-setuptools python3-scipy cython3 cython3-dbg python3-pytest-cython python3-astropy* python3-paramiko python3-matplotlib* libcfitsio9 libwcs7 python3-pyqtgraph python3-git python3-pil git git-man wxpython-tools wx3.0-headers wx-common python3-wxgtk4.0 libwxgtk3.0-gtk3-dev libwxgtk3.0-gtk3-0v5 libwxbase3.0-dev libwxbase3.0-0v5 screen python3-six python3-numpy python3-imageio libgstreamer-plugins-base1.0-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-37 dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev  libnotify-dev freeglut3 freeglut3-dev libghc-gtk3-dev python-tk gstreamer1.0-tools gstreamer1.0-plugins-base-apps gstreamer1.0-rtsp gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-python3-plugin-loader gstreamer1.0-opencv gstreamer1.0-pulseaudio gstreamer1.0-libav gstreamer1.0-plugins-rtp gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl

Finally, install the Python virtual environment tool with:

 sudo pip3 install virtualenv

Some of the later tasks also require a Rust compiler. This is not available in the Raspbian package repository and needs to be installed by hand in the rms account.

 sudo su - rms
 curl https://sh.rustup.rs -sSf | sh

And proceed with installation. Verify correct installation with:

 sudo -i -u rms rustc --version

While you are here download the RMS software as well:

 mkdir Desktop (might already exist)
 mkdir source
 cd source
 git clone https://github.com/CroatianMeteorNetwork/RMS.git

and exit the rms account:

 exit

Finally, install the Python virtual environment tool with:

 sudo pip3 install virtualenv

Create the virtual Python environment for RMS

Become the user rms (you can exit the user rms with the command exit)

 sudo su - rms

Create the virtual environment:

 cd ~
 virtualenv vRMS

Activate the virtual environment:

 source ~/vRMS/bin/activate

And activate it on re-login:

 echo source ~/vRMS/bin/activate >> ~/.bashrc
 echo cd ~/source/RMS >> ~/.bashrc

Now install the nescessary Python modules. This takes a while:

 pip3 install -U pip setuptools
 pip3 install Pillow
 pip3 install gitpython cython pyephem astropy paramiko
 pip3 install matplotlib
 pip3 install imreg_dft
 pip3 install configparser==4.0.2
 pip3 install numpy==1.23.5
 pip3 install imageio==2.6.1
 pip3 install scipy==1.6.0
 pip3 install pyfits
 pip3 install pyqtgraph
 pip3 install pyqt5 --config-settings --confirm-license= --verbose
 pip3 install opencv-python

And exit the rms account:

 exit

Setting up RMS

Become the user rms with:

 sudo su - rms

Configure git so that the script can stash changes in the repo and update the code:

 git config --global user.email "rms@gmn.uwo.ca"
 git config --global user.name "RMS"

Ready the RMS software with (you should already be in the directory /source/RMS):

 python setup.py install
 ./Scripts/GenerateDesktopLinks.sh

Now find your coordinates on the globe. Your location needs to be known very accurately (to 5 decimal places). Use GPS for this or an accurate map. Put this information in the .config file in the RMS directory.

 nano .config

Also, change the configuration of the camera.

Now run RMS for the first time.

 ./Scripts/RMS_FirstRun.sh

If you have no station-ID yet. Request one with the instructions shown on screen and then abort the script by pressing the Ctrl-C key combination. Start again when you have your Station-ID in your config file.

When RMS runs successfully, stop RMS. In the next chapter a script will be created to automatically start and update RMS and restart RMS when it is not running for some reason.

Exit the rms account

Create startscripts to run RMS

Create a script to (re-)start RMS automatically. Create a new script file by doing:

 sudo nano /usr/local/bin/RMS.sh

and put the following contents in it and save:

 #!/usr/bin/bash
 MYHOME=/home/rms
 RESTART=/tmp/RESTART_RMS
 STARTAT=/tmp/START_RMS
 # Set environment variables
 export HOME=${MYHOME}
 export PATH=${MYHOME}/vRMS/bin:${MYHOME}/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 source ${MYHOME}/vRMS/bin/activate
 # Check if FirstRun is running and start if not
 ps -ef | grep -v grep | grep RMS_FirstRun.sh >/dev/null 2>&1
 if [ $? -eq 0 ]
 then
   # Check if restart token is set
   if [ -f ${RESTART} ]
   then
     # Nicely kill FirstRun first
     FRPID=`ps -ef | grep -v grep | grep -vi screen | grep RMS_FirstRun.sh | head -n1 | tr -s ' ' | cut -f 2 -d ' '`
     kill -11 $FRPID
     echo $FRPID > ${STARTAT}
     rm ${RESTART}
     # Will be restarted at the next run
   fi
 else
   date > ${STARTAT}
   screen -d -m ${MYHOME}/source/RMS/Scripts/RMS_FirstRun.sh
   if [ -f ${RESTART} ]
   then
     rm ${RESTART}
   fi
 fi

Raspbian is running a program named cron to execute tasks at certain times. The script above needs to be started every 10 minutes. That way RMS is (re-)started automatically. By creating the file /tmp/RESTART_RMS RMS can be stopped and restarted 10 minutes later. The effect of this is that RMS is updated.

 sudo nano /etc/crontab

And add the following lines before the last line:

 */10 *  * * *   rms /usr/local/bin/RMS.sh >/dev/null 2>&1
 22 12   * * *   rms touch /tmp/RESTART_RMS

This will run the script as user RMS.

If you want to see what the script is doing, you can attach your session to it.

First become the user rms

 sudo su - rms

The attach your session by issuing the command:

 screen -r

If you want to exit press ctrl-a and then d. Then exit the user rms with exit.

Installing CMN Binviewer

To view the binary files of RMS you can use the Binviewer program (previously from the Croatian Meteor Network CMN, now maintained by Mark McIntyre). If you're using Bullseye or an earlier version of Raspian, install this under your normal user account ([Yourname]). If you're using Bookworm, install it in the rms user account as the newer OS does not permit access to other account's files. If you want to open files you can browse to /home/rms/RMS_data. Since data is read only, you run no risk of disturbing your RMS installation. You need to run the graphic desktop environment for this though. Alternatively you can setup the Binviewer on another computer and transfer the files there. If you want to run Samba to get the files from the Raspberry, be careful though. RMS may store over 5000 files in one directory. Samba will create a heavy system load when opening the directories. It is better to copy the files locally using secure copy (scp). If you want to install CMN Binviewer locally (not on the Raspberry) then look here: [2]

Note: these instructions assume you have already installed RMS on your Raspberry Pi. If you've not done that, do it first. This is needed because RMS and Binviewer require many of the same system libraries installed with apt.

To install on the Rasberry Pi, first log in. Then do:

mkdir -p ~/source
cd ~/source
git clone https://github.com/CroatianMeteorNetwork/cmn_binviewer.git
virtualenv -p python3 ~/vBinviewer
source ~/vBinviewer/bin/activate
cd ~/source/cmn_binviewer
pip install -r requirements.txt

Then create the startscript for CMN Binviewer:

sudo nano ~/vBinviewer/CMN_Binviewer

And paste these contents in it:

#!/usr/bin/bash
source ~/vBinviewer/bin/activate  
cd ~/source/cmn_binviewer
python CMN_binViewer.py

Make the script executable and create a link to the script from the Desktop:

chmod +x ~/vBinviewer/CMN_Binviewer
ln -s ~/vBinviewer/CMN_Binviewer ~/Desktop/CMN_Binviewer

Support notes:

  • If you get "ImportError: libopenblas.so.0" try running this in a Terminal window - sudo apt-get install -y libopenblas-dev