Pi4 with Raspbian Bookworm: Difference between revisions

From Global Meteor Network
Jump to navigation Jump to search
mNo edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:


This page explains how to set up RMS on a Pi with the 64-bit version of Bookworm.


== Burn an SD Card ==
== Burn an SD Card ==
Line 14: Line 15:


== Configure the Operating System ==
== Configure the Operating System ==
'''Note: all of the commands shown below must be run in a Terminal window or ssh session'''
* Login as the rms user you created above and run the following commands to install the system libraries required by RMS.  
* Login as the rms user you created above and run the following commands to install the system libraries required by RMS.  


  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 python3-opencv libcairo2-dev
  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 python3-opencv libcairo2-dev screen python3-virtualenv


  sudo apt-get install -y gobject-introspection libgirepository1.0-dev
  sudo apt-get install -y gobject-introspection libgirepository1.0-dev
  sudo apt-get install -y gstreamer1.0-libav gstreamer1.0-plugins-bad
  sudo apt-get install -y gstreamer1.0-libav gstreamer1.0-plugins-bad
sudo apt-get install -y chrony


* now create a python environment for RMS and ensure its always active:
* now create a python environment for RMS and ensure its always active:
  python -m venv ~/vRMS
  virtualenv ~/vRMS
  echo source ~/vRMS/bin/activate >> ~/.bashrc
  echo source ~/vRMS/bin/activate >> ~/.bashrc
  echo cd ~/source/RMS >> ~/.bashrc
  echo cd ~/source/RMS >> ~/.bashrc


We recommend at this point you reboot the pi to pick up all the changes you've just made.  
We recommend at this point you should reboot the pi, to pick up all the changes you've just made.  
  sudo reboot
  sudo reboot


== Connect a Camera ==
== Connect a Camera ==
Out-of-the box, Bookworm can connect to any camera attached to your network. So, for testing you should be able to plug the camera into your router and supply power to it. If you prefer to connect the camera directly to the Pi, jump ahead to [#Connecting_a_Camera this] section.
Out-of-the box, RMS on Bookworm can connect to any camera attached to your network. This is the simplest way. If you prefer to connect the camera directly to the Pi, jump ahead to [https://globalmeteornetwork.org/wiki/index.php?title=Pi4_with_Raspbian_Bookworm#Direct_Camera_connection this] section. If you're happy using a connection via your router, plug the camera in and find its IP address as explained [https://globalmeteornetwork.org/wiki/index.php?title=Focusing_a_camera_and_the_first_tests#Find_its_IP_Address here].  


== Install RMS ==
== Install RMS ==
* Login to the Pi again and download the code:
* Login to the Pi again and download the RMS application:
  mkdir ~/source
  mkdir ~/source
  cd ~/source
  cd ~/source
Line 46: Line 51:
  pip install -U pip setuptools
  pip install -U pip setuptools
  pip install -r requirements.txt
  pip install -r requirements.txt
pip install opencv-python


* Configure git so that the script can stash changes in the repo and update the code:
* Configure git so that the script can stash changes in the repo and update the code:
Line 51: Line 57:
  git config --global user.name "RMS"
  git config --global user.name "RMS"


* Ready the RMS software for use. This may take some time as the app is built and installed.  
* Ready the RMS software for use. This may take some time while the app is built and installed.  
  cd ~/source/RMS
  cd ~/source/RMS
  python setup.py install
  python setup.py install
Line 57: Line 63:


== Configure RMS ==  
== Configure RMS ==  
* Fnd your coordinates on the globe. Your location needs to be known very accurately to 5 decimal places for Meteor Science. Use GPS for this or an accurate map. Put this information in the ''.config'' file in the RMS directory. If you already have a stationID you can add this to the config file too.
* Edit the configuraton file
  nano ~/source/RMS/.config
  nano ~/source/RMS/.config
** Fnd your latitude, longitude and elevation above sea level. These need to be known to 5 decimal places for Meteor Science so use a GPS or an accurate map. Be careful to enter longitude as negative if west of Greenwich, and note you must enter decimals not minutes and seconds. For example 1 degree 18 minutes 12 seconds West would be entered as -1.30333.
** If you already have a ''stationID'' you can add this to the config file too.
** Finally, find the ''device:'' line in the file and update it to contain your camera's IP address.


* Now run RMS for the first time. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
* Now run RMS for the first time using the command below. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
   ./Scripts/RMS_FirstRun.sh
   ./Scripts/RMS_FirstRun.sh


NB: 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. Once you have your station ID, add it into the ''.config'' file and rerun this step.  
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. Once you have your station ID, add it into the ''.config'' file and rerun this step.
 
* Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.


* Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.  
== Autostart RMS ==
We want RMS to automatically start whenever the Pi is restarted. To do this edit we'll use the autostart feature of the Desktop.
 
First, create the required folder, then create the script that will auto-start RMS:
 
mkdir -p ~/.config/autostart
nano $HOME/.config/autostart/StartCapture.desktop
 
Now paste the following into the file
[Desktop Entry]
Name=Startcapture
Type=Application
Exec=lxterminal --title=RMS -e "~/source/RMS/Scripts/RMS_FirstRun.sh"
Hidden=false
NoDisplay=false
Icon=lxterminal
 
Save and exit the editor, then reboot the Pi and you should see the RMS script running.
 
== Stopping RMS ==
To stop RMS, click on the RMS window and press Control-C. RMS will shutdown gracefully which sometimes takes several minutes. If it hasn't shut down completely after about five minutes, press Control-C again or just kill the window. To restart RMS, just reboot the Pi.
 
== Job done ==
Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now '''[https://globalmeteornetwork.org/wiki/index.php?title=Installing_a_camera_into_the_position install your camera outdoors]''', then wait for a clear night to '''[https://globalmeteornetwork.org/wiki/index.php?title=The_last_steps#Making_a_detection_mask make a mask and calibrate the field of view]'''.
 
== Installing CMN_BinViewer ==
Follow [https://globalmeteornetwork.org//wiki/index.php?title=Pi4_with_Raspbian_Bullseye#Installing_CMN_Binviewer these] instructions.  


== Direct Camera connection ==
== Direct Camera connection ==
The simplest approach is to connect the camera to your router. However, ff you have no wired network available you could connect the camera to the Raspberry directly and then connect the Raspberry Pi to your network over Wifi. If you want to do this, proceed as follows:


1. First, install the DHCP server:
This is an optional step, only required if you prefer to connect the camera directly to the Pi's ethernet port.  The simplest approach is to connect the camera to your router. However, if you have no wired network available you could connect the camera to the Raspberry directly and then connect the Raspberry Pi to your network over Wifi.
  sudo apt-get install -y isc-dhcp-server
 
If you want to do this, proceed as follows:


2. Edit the DHCP configuration file:
* First, install the DHCP server - it'll fail to start, don't worry - thats normal!
  sudo nano /etc/dhcp/dhcpd.conf
sudo apt-get install -y isc-dhcp-server


We need to add a fixed address for the camera, so append this at the end of the file:
* Edit the DHCP configuration file:
sudo nano /etc/dhcp/dhcpd.conf


and add this text at the bottom:
   subnet 192.168.42.0 netmask 255.255.255.0 {
   subnet 192.168.42.0 netmask 255.255.255.0 {
     authoritative;
     authoritative;
Line 87: Line 126:
     max-lease-time 7200;
     max-lease-time 7200;
     option domain-name "local";
     option domain-name "local";
    interface eth0;
   }
   }


This will assign a fixed IP address 192.168.42.10 to the camera.
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:
* Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the config file:
   sudo nano /etc/default/isc-dhcp-server
   sudo nano /etc/default/isc-dhcp-server


Line 97: Line 137:
   INTERFACESv4="eth0"
   INTERFACESv4="eth0"


4. Next, we need to give the ethernet interface the proper subnet. Open:
* We also need to set a fixed address for the Pi. Bookworm is using Networkmanager, so we must use that to configure the ethernet port:
   sudo nano /etc/dhcpcd.conf
** First, check what the connection's name is. We're lookgin for the ethernet type:
nmcli c
   NAME                UUID                                  TYPE      DEVICE
  preconfigured      137ea6e2-d8a3-43a3-9a6c-0d601193ec3a  wifi      wlan0
  lo                  c504c605-679b-4ea3-be4d-45f22e606dcb  loopback  lo
  Wired connection 1  7e2afc3b-b0e9-3399-9a93-ad18501176c5  ethernet  --


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.
** Now, set the ethernet port to a fixed address:
sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.42.1/24 ipv4.method manual


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:
* We must also add a route to ethernet port. Do do this edit ''rc.local''
sudo nano /etc/rc.local
then just above the last line, add
sudo route add -net 192.168.42.0 netmask 255.255.255.0 metric 100 dev eth0
 
* 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 cp /run/systemd/generator.late/isc-dhcp-server.service /etc/systemd/system
   sudo nano /etc/systemd/system/isc-dhcp-server.service
   sudo nano /etc/systemd/system/isc-dhcp-server.service
Line 122: Line 170:
   sudo systemctl enable isc-dhcp-server
   sudo systemctl enable isc-dhcp-server


6. Reboot so to test the configuration:
* Now plug the camera into the Pi’s ethernet interface, and reboot to test the configuration:
   sudo reboot
   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.
* To check, run the following commands:
ping -c 1 192.168.42.10
arp -a
The first should return a trip-time, and the second should show the camera's IP address in a list of conections:
? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0


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:
If not, check the status of the DHCP server service:
  sudo service isc-dhcp-server status
sudo service isc-dhcp-server status


The service should be active.
The service should be active.


 
'''Note that if you unplug the ethernet cable, you will need to reboot to regain camera connection.'''
(more to come)

Latest revision as of 11:49, 22 September 2024

This page explains how to set up RMS on a Pi with the 64-bit version of Bookworm.

Burn an SD Card

  • Download the Raspberry Pi Imager from https://www.raspberrypi.com/software/
  • Run the tool, select your model of Pi, then select Bookworm 64-bit.
  • Select your SD card and click Next and then Edit Settings. Make the following changes:
    • If you know your station ID set the Hostname to match it but in lower case. For example if your station is UK1234 set the hostname to uk1234
    • otherwise set the hostname to be something you'll remember
    • Set the username to rms and enter a password of your choice. Remember this!
    • Add your Wifi network details
    • Set the locale to UTC and the keyboard layout to match your keyboard.
    • save settings, and on the next screen click Yes and then Yes again
  • Once the image has been burned, insert the SD card into your Pi power it on. The Pi will reboot a few times as it sets things up.

Configure the Operating System

Note: all of the commands shown below must be run in a Terminal window or ssh session

  • Login as the rms user you created above and run the following commands to install the system libraries required by RMS.
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 python3-opencv libcairo2-dev screen python3-virtualenv
sudo apt-get install -y gobject-introspection libgirepository1.0-dev
sudo apt-get install -y gstreamer1.0-libav gstreamer1.0-plugins-bad
sudo apt-get install -y chrony
  • now create a python environment for RMS and ensure its always active:
virtualenv ~/vRMS
echo source ~/vRMS/bin/activate >> ~/.bashrc
echo cd ~/source/RMS >> ~/.bashrc

We recommend at this point you should reboot the pi, to pick up all the changes you've just made.

sudo reboot

Connect a Camera

Out-of-the box, RMS on Bookworm can connect to any camera attached to your network. This is the simplest way. If you prefer to connect the camera directly to the Pi, jump ahead to this section. If you're happy using a connection via your router, plug the camera in and find its IP address as explained here.

Install RMS

  • Login to the Pi again and download the RMS application:
mkdir ~/source
cd ~/source
git clone https://github.com/CroatianMeteorNetwork/RMS.git
  • Activate the python environment, if not already active. The prompt will change to (vRMS) rms@yourhostname: if its active.
source ~/vRMS/bin/activate


  • Now, set up Python in the environment we just created:
cd ~/source/RMS
pip install -U pip setuptools
pip install -r requirements.txt
pip install opencv-python
  • 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 for use. This may take some time while the app is built and installed.
cd ~/source/RMS
python setup.py install
./Scripts/GenerateDesktopLinks.sh

Configure RMS

  • Edit the configuraton file
nano ~/source/RMS/.config
    • Fnd your latitude, longitude and elevation above sea level. These need to be known to 5 decimal places for Meteor Science so use a GPS or an accurate map. Be careful to enter longitude as negative if west of Greenwich, and note you must enter decimals not minutes and seconds. For example 1 degree 18 minutes 12 seconds West would be entered as -1.30333.
    • If you already have a stationID you can add this to the config file too.
    • Finally, find the device: line in the file and update it to contain your camera's IP address.
  • Now run RMS for the first time using the command below. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
 ./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. Once you have your station ID, add it into the .config file and rerun this step.

  • Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.

Autostart RMS

We want RMS to automatically start whenever the Pi is restarted. To do this edit we'll use the autostart feature of the Desktop.

First, create the required folder, then create the script that will auto-start RMS:

mkdir -p ~/.config/autostart
nano $HOME/.config/autostart/StartCapture.desktop

Now paste the following into the file

[Desktop Entry]
Name=Startcapture
Type=Application
Exec=lxterminal --title=RMS -e "~/source/RMS/Scripts/RMS_FirstRun.sh"
Hidden=false
NoDisplay=false
Icon=lxterminal

Save and exit the editor, then reboot the Pi and you should see the RMS script running.

Stopping RMS

To stop RMS, click on the RMS window and press Control-C. RMS will shutdown gracefully which sometimes takes several minutes. If it hasn't shut down completely after about five minutes, press Control-C again or just kill the window. To restart RMS, just reboot the Pi.

Job done

Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now install your camera outdoors, then wait for a clear night to make a mask and calibrate the field of view.

Installing CMN_BinViewer

Follow these instructions.

Direct Camera connection

This is an optional step, only required if you prefer to connect the camera directly to the Pi's ethernet port. The simplest approach is to connect the camera to your router. However, if you have no wired network available you could connect the camera to the Raspberry directly and then connect the Raspberry Pi to your network over Wifi.

If you want to do this, proceed as follows:

  • First, install the DHCP server - it'll fail to start, don't worry - thats normal!
sudo apt-get install -y isc-dhcp-server
  • Edit the DHCP configuration file:
sudo nano /etc/dhcp/dhcpd.conf

and add this text at the bottom:

 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";
   interface eth0;
 }

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

  • Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the config file:
 sudo nano /etc/default/isc-dhcp-server

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

 INTERFACESv4="eth0"
  • We also need to set a fixed address for the Pi. Bookworm is using Networkmanager, so we must use that to configure the ethernet port:
    • First, check what the connection's name is. We're lookgin for the ethernet type:
nmcli c
 NAME                UUID                                  TYPE      DEVICE
 preconfigured       137ea6e2-d8a3-43a3-9a6c-0d601193ec3a  wifi      wlan0
 lo                  c504c605-679b-4ea3-be4d-45f22e606dcb  loopback  lo
 Wired connection 1  7e2afc3b-b0e9-3399-9a93-ad18501176c5  ethernet  --


    • Now, set the ethernet port to a fixed address:
sudo nmcli c mod "Wired connection 1" ipv4.addresses 192.168.42.1/24 ipv4.method manual
  • We must also add a route to ethernet port. Do do this edit rc.local
sudo nano /etc/rc.local

then just above the last line, add

sudo route add -net 192.168.42.0 netmask 255.255.255.0 metric 100 dev eth0
  • 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
  • Now plug the camera into the Pi’s ethernet interface, and reboot to test the configuration:
 sudo reboot
  • To check, run the following commands:
ping -c 1 192.168.42.10
arp -a

The first should return a trip-time, and the second should show the camera's IP address in a list of conections:

? (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.

Note that if you unplug the ethernet cable, you will need to reboot to regain camera connection.