DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

Building a Digital Mobile Radio Repeater Part 4: Raspberry Pi Configuration

Setting up the Raspberry Pi and MMDVM Host software.

This series of posts covers the building of a Digital Mobile Radio (DMR) repeater for amateur radio use on the 70cm band (UHF). The first post introduced DMR basics and a modem platform based around an STM32F446 NUCLEO board plus an interface shield. The second covered the major and housing these all in a rack enclosure, with the third moving on to cabling.

In this post, we take a look at configuring the Raspberry Pi and installing MMDVMHost software, which will drive the repeater and facilitate connection to global repeater networks via TCP/IP.

Raspbian

 

Most good Raspberry Pi projects start out with similar steps and so to lets quickly cover what has now become something of a mantra (assumes you’re using a Linux computer):

  1. Write out Raspbian to a Micro SD card
  2. Remove it from the computer and re-insert
  3. Edit the etc/hostname and etc/hosts files on the root partition to set a new hostname
  4. Create an empty file called ssh on the boot partition
  5. Unmount and remove the card
  6. Insert the card into the Raspberry Pi
  7. Boot the Pi and log in
  8. Run sudo apt-get update followed by sudo apt-get upgrade

In our case we used a hostname of repeater and logged in over SSH, using the mDNS hostname, repeater.local. Of course, you could use a keyboard and monitor if you prefer. If you used a Windows computer to write out the card and didn’t have a Linux one to hand, you could edit/create the aforementioned files after booting and logging in via keyboard and monitor.

Status and shutdown

As mentioned previously we need a mechanism whereby the Raspberry Pi can be safely shut down without a keyboard and monitor attached, or perhaps by someone with no Linux experience at all.

In part three we described how the front panel pushbutton was wired across one GPIO pin and ground, while the status LED above it was wired across a second GPIO and ground with a resistor in series. Thanks to the magic of device tree overlays these will allow us to shut down the Pi safely at the push of a button and to confirm status via the LED.

To configure this we simply edit /boot/config.txt and add three lines:

dtoverlay=pi3-act-led,gpio=12

dtparam=act_led_trigger=heartbeat

dtoverlay=gpio-shutdown,gpio_pin=16

The first of these loads the activity LED overlay and configures this to use GPIO12. The default behaviour is for this to indicate SD card activity, so the second line configures the LED instead to provide a system heartbeat, meaning that we can quickly ascertain if it’s running or halted.

The third line in config.txt loads the GPIO driven shutdown overlay and configures this to monitor pin 16. If this is pulled low, shutdown is triggered.

Having these sort of capabilities available via device tree overlays is very cool and configuration couldn’t be simpler — no need for additional software or building custom kernels/modules.

For details of all the available DT overlays, see the Raspberry Pi Firmware overlay README.

MMDVMHost Build

First, we need to install a few dependencies:

$ sudo apt-get install build-essential git

Then we can clone the MMDVHost software sources:

$ git clone https://github.com/g4klx/MMDVMHost.git

Next, we cd into these and build with:

$ cd MMDVMHost

$ make

And if all goes well this should complete without errors.

Initial test

The included example configuration file, MMDVM.iniwas modified to set the following parameters:

[General]

Display=Nextion

[Modem]

Port=/dev/ttyACM0

[Nextion]

Port=modem

Note that only the modified parameters and their sections are shown — just enough for some basic testing and a lot more configuration will be required later.

Then we could run up the application with:

$ sudo ./MMDVMHost MMDVM.ini

The application couldn't communicate with the MMDVM firmware on the STM32F446. Something wasn’t right...

After a little head-scratching, it was decided to remove the STM32F446 and MMDVM shield from the enclosure for closer inspection. Upon separating the two boards and looking at the headers, it became apparent the shield had been plugged into the wrong side of the STM32F446!

The shield was promptly swapped over so that the STM32F446 Mini USB port was on the outside and not located between the two boards.

The Pi was booted and this time things looked much better, with LEDs on the shield illuminating and the Nextion from panel LCD springing into life.

Starting, stopping and restarting

There is no MMDVMHost make install target and configuration for automatic start-up is a fairly manual process. When configured to run in daemon (background) mode an mmdvm user account and group are required for it to switch to, so we’ll create these first.

$ sudo useradd mmdvm -G dialout -m -s /bin/false

Oddly, it seemed that we also needed to add the root account to the dialout group, otherwise the application was unable to open the modem.

$ sudo usermod -G dialout -a root

Next, we created a directory each for the configuration file and logs.

$ sudo mkdir /etc/mmdvmhost

$ sudo mkdir /var/log/mmdvmhost

We then copied the executable and config files into place.

$ sudo cp MMDVMHost /usr/local/bin

$ sudo mv MMDVM.ini /etc/mmdvmhost

A service handler (start|stop|restart) script is provided, but we found we had to modify this a little. Firstly, to specify the full path of the config file and not just the directory it is located in. Secondly, to execute the application directly and without “runuser -l”; the app will switch to the mmdvm user and group by itself, and runuser caused problems. The logfile location was also changed.

So once copied into place with:

$ sudo cp linux/systemd/mmdvmhost_service /usr/local/sbin

The runuser -l $ USER … lines were replaced with simply:

${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}

And the lines for the aforementioned variables were updated accordingly:

CONFIG=/etc/mmdvmhost/MMDVM.ini

LOGDIR=/var/log/mmdvm

This file will also need to be made executable:

$ sudo chmod +x /usr/local/sbin/mmdvmhost_service

At this point if Daemon=1 is set in MMDVM.ini we should be able to start, stop, restart and check the status of the modem service with:

$ sudo /usr/local/sbin/mmdvmhost_service start|stop|restart|status

Next steps

Now all the parts are in place, next we will need to configure the repeater as a whole system:

    • Radio programming, e.g. for Tx and Rx frequencies.
    • Full configuration of MMDVMHost, e.g. repeater call sign and network connections.
    • Flash the Nextion LCD configuration (different screen layouts are supported).
    • Setting modem audio levels.

Andrew Back

 

Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.

2 Aug 2018, 12:41

Comments

January 23, 2019 09:12

Hi there, I can't seem to find the link to the rest of this instructional post?

0 Votes

[Comment was deleted]

January 25, 2019 10:08

@GrahamMark Part 5 should be coming next month (Feb 19).

April 25, 2019 07:59

@Andrew Back great instructions! Did you manage to upload Part 5 as yet? Rgds