You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
380 lines
8.7 KiB
380 lines
8.7 KiB
+++
|
|
title = 'DMRHost on a RaspberryPi 4 with OpenBSD or FreeBSD'
|
|
aliases = [ '/posts/2023-08-26-dmrhost-on-a-raspberrypi4-with-openbsd-or-freebsd' ]
|
|
summary = '''A rather quick demonstration of my recent test to install
|
|
DMRHost on a Raspberry Pi 4 which is running OpenBSD 7.3'''
|
|
date = '2023-08-26T19:07:53+0200'
|
|
lastmod = '2024-09-28T23:48:07+0000'
|
|
categories = [ 'amateur-radio' ]
|
|
tags = [ 'hotspot', 'raspberry-pi', 'mmdvm', 'dmr', 'openbsd' ]
|
|
|
|
+++
|
|
|
|
## OpenBSD
|
|
|
|
### Get the files
|
|
|
|
Download `install73.img` from <https://www.openbsd.org/arm64.html> and
|
|
write it to a USB stick.
|
|
|
|
### Installation of OpenBSD
|
|
|
|
Get yourself comfortable with this nice piece of documentation: [INSTALL.arm64][0]
|
|
|
|
[0]: https://ftp.openbsd.org/pub/OpenBSD/snapshots/arm64/INSTALL.arm64
|
|
|
|
Connect a USB-to-TTL cable to the GPIO pins of the serial console on your Raspberry Pi
|
|
(That means you have to remove the MMDVM hat for now).
|
|
|
|
```console
|
|
$ cu -l /dev/cuaU0 -s 115200
|
|
```
|
|
|
|
To save you another manpage lookup, exit the serial console
|
|
with <kbd>Enter</kbd>, <kbd>~.</kbd>.
|
|
|
|
Boot the Raspberry Pi with no SD-Card plugged in but the USB stick.
|
|
|
|
1. Stop the autoboot process at the bootloader by typing something at
|
|
the boot prompt (and delete the typed characters afterwards)
|
|
|
|
2. Plugin the SD-Card and hit <kbd>Enter</kbd>
|
|
|
|
3. The Installation media starts and detects your SD-Card
|
|
|
|
4. Continue with the installation of OpenBSD
|
|
|
|
We booted without SD-Card because I had problems selecting the USB media for booting.
|
|
You can select this from within Raspbian OS but I did not want to install this in the
|
|
first place.
|
|
|
|
### System configuration
|
|
|
|
Make sure to enable ssh. We will need that because we have to drop support for the
|
|
serial console to use the MMDVM hat.
|
|
|
|
### Disable the use of the serial console
|
|
|
|
Modify `/etc/ttys` (only the first lines are relevant)
|
|
|
|
```aconf {linenos=inline,hl_lines="6"}
|
|
#
|
|
# $OpenBSD: ttys,v 1.2 2020/03/13 13:14:40 patrick Exp $
|
|
#
|
|
# name getty type status comments
|
|
#
|
|
console "/usr/libexec/getty std.115200" vt220 off secure
|
|
ttyC0 "/usr/libexec/getty std.9600" vt220 off secure
|
|
ttyC1 "/usr/libexec/getty std.9600" vt220 on secure
|
|
ttyC2 "/usr/libexec/getty std.9600" vt220 on secure
|
|
```
|
|
|
|
Change **on** to **off**. Now select the framebuffer device
|
|
for your tty.
|
|
|
|
```console
|
|
$ echo "set tty fb0" | doas tee /etc/boot.conf
|
|
```
|
|
|
|
Once you made sure that you can login via ssh, turn off the Raspberry Pi and put on the
|
|
MMDVM hat.
|
|
|
|
Now you should be able to select `/dev/cua00` as the modem
|
|
in your `MMDVM.ini`.
|
|
|
|
### Setup DMRHost
|
|
|
|
#### Installation
|
|
|
|
Get the files: <https://github.com/BrandMeister/DMRHost>.
|
|
|
|
I prefer to use a separate user for this.
|
|
|
|
```console
|
|
$ doas useradd -L daemon -G dialer,users -m -d /home/mmdvm -s /sbin/nologin -c "Radio &" mmdvm
|
|
```
|
|
|
|
Now, let's create the DMRHost executable.
|
|
|
|
```console
|
|
$ cd /home/mmdvm
|
|
$ doas -u mmdvm (mkdir git && cd git)
|
|
$ doas -u mmdvm (git clone https://github.com/BrandMeister/DMRHost && cd DMRHost)
|
|
$ doas -u mmdvm (mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ..)
|
|
$ doas -u mmdvm make && doas make install
|
|
```
|
|
|
|
**Note**: the last command is not executed as the user _mmdvm_
|
|
but as _root_ as it is installing the executable into `/usr/local/bin`.
|
|
Therefore we dropped the `-u mmdvm` on the last `doas` invocation!
|
|
|
|
#### Configuration of DMRHost: `MMDVM.ini`
|
|
|
|
I use `/home/mmdvm/MMDVM.ini` because I'll put everything MMDVM-related
|
|
into `/home/mmdvm`.
|
|
|
|
The essential congiguration changes:
|
|
|
|
```ini
|
|
[...]
|
|
|
|
[Log]
|
|
# Logging levels, 0=No logging, 1=Debug, 2=Message, 3=Info, 4=Warning, 5=Error, 6=Fatal
|
|
SyslogLevel=0
|
|
DisplayLevel=0
|
|
FileLevel=2
|
|
FilePath=/home/mmdvm/logs
|
|
FileRoot=DMRHost
|
|
FileRotate=0
|
|
|
|
[...]
|
|
|
|
[Modem]
|
|
Port=/dev/cua00
|
|
Protocol=uart
|
|
|
|
[...]
|
|
```
|
|
|
|
This is basically the same configuration as in the repository.
|
|
Have a look at the `[Log]` section.
|
|
|
|
#### The rc script `/etc/rc.d/DMRHost`.
|
|
|
|
```bash
|
|
#!/bin/sh
|
|
# rc-script for DMRHost on OpenBSD 7.3
|
|
# Dominic Reich <https://oe7drt.com>
|
|
|
|
DMRHOST="/usr/local/bin/DMRHost"
|
|
MMDVM_INI="/home/mmdvm/MMDVM.ini"
|
|
DMRHOST_PID="/home/mmdvm/DMRHost.pid"
|
|
DOAS="/usr/bin/doas -u mmdvm"
|
|
LOGDIR="/home/mmdvm/logs"
|
|
|
|
case "$1" in
|
|
"start")
|
|
if [ ! -d ${LOGDIR} ] ; then
|
|
mkdir ${LOGDIR}
|
|
chown mmdvm:users ${LOGDIR}
|
|
chmod 0775 ${LOGDIR}
|
|
fi
|
|
if ${DOAS} [ ! -r ${MMDVM_INI} ] ; then
|
|
echo "${MMDVM_INI} is not readable... aborting!"
|
|
exit 1
|
|
fi
|
|
echo -n "Starting DMRHost..."
|
|
${DOAS} ${DMRHOST} ${MMDVM_INI} &
|
|
echo $! > ${DMRHOST_PID}
|
|
echo " done"
|
|
;;
|
|
|
|
"stop")
|
|
echo -n "Stopping DMRHost..."
|
|
if [ -f ${DMRHOST_PID} ] ; then
|
|
kill `cat ${DMRHOST_PID}`
|
|
rm -f ${DMRHOST_PID}
|
|
echo " done"
|
|
else
|
|
echo "not running?"
|
|
fi
|
|
;;
|
|
|
|
"restart")
|
|
$0 stop
|
|
sleep 2
|
|
$0 start
|
|
;;
|
|
|
|
*)
|
|
echo "$0 [start|stop|restart]"
|
|
;;
|
|
|
|
esac
|
|
```
|
|
|
|
#### First test / first start
|
|
|
|
Start DMRHost (not the service)
|
|
|
|
```console
|
|
$ doas -u mmdvm /usr/local/bin/DMRHost /home/mmdvm/MMDVM.ini
|
|
```
|
|
|
|
and see what it does. If it's logging into the master,
|
|
all is good and can be stopped with <kbd>CTRL</kbd>+<kbd>C</kbd>.
|
|
|
|
#### Enable and start the service
|
|
|
|
```console
|
|
$ doas rcctl enable DMRHost
|
|
$ doas rcctl start DMRHost
|
|
```
|
|
|
|
DMRHost runs.
|
|
|
|
### Some additional notes
|
|
|
|
I put myself (another user on the Raspberry Pi) into
|
|
the _users_ group and chmod the `MMDVM.ini` with with 664.
|
|
|
|
That allows me to edit the file as my usual user and I do
|
|
**not** have to use `doas -u mmdvm` everytime I want to
|
|
modify something in that file.
|
|
|
|
## FreeBSD
|
|
|
|
{{< alert >}}
|
|
This section is probably not complete, I had several problems with the
|
|
Raspberry Pi's UART when I finally gave up on the long-term testing.
|
|
{{< /alert >}}
|
|
|
|
I'm using 14.0-CURRENT for this (which is moving to stable soon).
|
|
|
|
<https://download.freebsd.org/ftp/snapshots/arm64/aarch64/ISO-IMAGES/14.0/>
|
|
|
|
```console
|
|
$ doas dd if=FreeBSD-14.0-ALPHA3-arm64-aarch64-RPI-20230825-2af9390e54ed-265022.img of=/dev/rsd2c bs=1m
|
|
```
|
|
|
|
Boot into the system with the serial console. Setup a dedicated user for this and
|
|
disable the serial console after you successfully set up the network (don't forget
|
|
to also test ssh connection).
|
|
|
|
```console
|
|
$ doas pw useradd mmdvm -d /home/mmdvm -m -L daemon -G dialer
|
|
```
|
|
|
|
Do not use the UART for kernel messages.
|
|
Add this line to your `/boot/loader.conf` file.
|
|
|
|
```conf
|
|
hw.fdt.console="NO"
|
|
```
|
|
|
|
Reboot so the serial console can be used for the MMDVM_HS hat.
|
|
|
|
### Install DMRHost
|
|
|
|
You will need a few packages before we can continue. This list could
|
|
be incomplete because I try to remember them from brain memory...
|
|
|
|
```console
|
|
$ doas pkg install git gcc cmake
|
|
```
|
|
|
|
Goto `/home/mmdvm`, build and install DMRHost.
|
|
|
|
```console
|
|
$ doas -u mmdvm mkdir ~/git && cd /home/mmdvm/git
|
|
$ doas -u mmdvm git clone https://github.com/BrandMeister/DMRHost.git
|
|
$ cd DMRHost && doas -u mmdvm mkdir build && cd build
|
|
$ doas -u mmdvm (cmake -DCMAKE_BUILD_TYPE=Release .. && make)
|
|
$ doas make install
|
|
```
|
|
|
|
Create directories and the `MMDVM.ini` file.
|
|
|
|
```console
|
|
$ cd /home/mmdvm && doas -u mmdvm mkdir logs && chmod 0775 logs
|
|
$ doas -u mmdvm nvim MMDVM.ini
|
|
```
|
|
|
|
```ini
|
|
[...]
|
|
|
|
[Log]
|
|
# Logging levels, 0=No logging, 1=Debug, 2=Message, 3=Info, 4=Warning, 5=Error, 6=Fatal
|
|
SyslogLevel=0
|
|
DisplayLevel=0
|
|
FileLevel=2
|
|
FilePath=/home/mmdvm/logs
|
|
FileRoot=DMRHost
|
|
FileRotate=0
|
|
|
|
[...]
|
|
|
|
[Modem]
|
|
Port=/dev/cua00
|
|
Protocol=uart
|
|
|
|
[...]
|
|
```
|
|
|
|
I also add my user to the mmdvm group, so I can edit the MMDVM file.
|
|
(Well, set file permissions to 0664)
|
|
|
|
```console
|
|
$ doas pw usermod <user> -G mmdvm
|
|
```
|
|
|
|
### Test DMRHost
|
|
|
|
```console
|
|
$ doas -u mmdvm /usr/local/bin/DMRHost /home/mmdvm/MMDVM.ini
|
|
|
|
```
|
|
|
|
You may inspect the logfile beforehand: `tail -f /home/mmdvm/logs/DMRHost.log`.
|
|
The startup of DMRHost should end with something like these lines:
|
|
|
|
```log
|
|
M: 2023-08-25 11:03:05.000 DMRHost-20220617-DMRHost is running
|
|
M: 2023-08-25 11:03:15.000 DMR, Logged into the master successfully
|
|
```
|
|
|
|
### Setup an rc file
|
|
|
|
```sh
|
|
#!/bin/sh
|
|
# rc-script for DMRHost on OpenBSD 7.3
|
|
# runs on FreeBSD for now
|
|
# Dominic Reich <https://oe7drt.com>
|
|
|
|
DMRHOST="/usr/local/bin/DMRHost"
|
|
MMDVM_INI="/home/mmdvm/MMDVM.ini"
|
|
DMRHOST_PID="/home/mmdvm/DMRHost.pid"
|
|
DOAS="/usr/local/bin/doas -u mmdvm"
|
|
LOGDIR="/home/mmdvm/logs"
|
|
|
|
case "$1" in
|
|
"start")
|
|
if [ ! -d ${LOGDIR} ] ; then
|
|
mkdir ${LOGDIR}
|
|
chown mmdvm:users ${LOGDIR}
|
|
chmod 0775 ${LOGDIR}
|
|
fi
|
|
if ${DOAS} [ ! -r ${MMDVM_INI} ] ; then
|
|
echo "${MMDVM_INI} is not readable... aborting!"
|
|
exit 1
|
|
fi
|
|
echo -n "Starting DMRHost..."
|
|
${DOAS} ${DMRHOST} ${MMDVM_INI} &
|
|
echo $! | ${DOAS} tee ${DMRHOST_PID} > /dev/null
|
|
echo " done"
|
|
;;
|
|
|
|
"stop")
|
|
echo -n "Stopping DMRHost..."
|
|
if [ -f ${DMRHOST_PID} ] ; then
|
|
kill `cat ${DMRHOST_PID}`
|
|
rm -f ${DMRHOST_PID}
|
|
echo " done"
|
|
else
|
|
echo "not running?"
|
|
fi
|
|
;;
|
|
|
|
"restart")
|
|
$0 stop
|
|
sleep 2
|
|
$0 start
|
|
;;
|
|
|
|
*)
|
|
echo "$0 [start|stop|restart]"
|
|
;;
|
|
|
|
esac
|
|
```
|