RMS Gate on a Raspberry Pi. Linux RPi

Updated 3 March 2014

Charles S. Schuman, K4GBB
k4gbb1@gmail.com

Introduction

The Raspberry Pi was developed as an educational tool to provide a platform for students to learn Linux and programing. It's Size and price make this credit card sized computer a great choice for Packet Radio Remote Sites and other HAM Radio applications. The SoC, System on Chip, uses an ARM11 architecture. There are a great number of people “playing” with this device and having great success with it.

I started writing this page from notes that I have collected from the various resources. It was too much like re-inventing the wheel. So, I set the notes aside and collected links. The various resources do a super job for both the Advanced and the Beginner. The page contains notes and comments specific to the Ax.25 service and the Linux RMS Gate software. The basic Raspberry Pi stuff will be referenced and linked.

This page is the mainly for setting up the RPi stuff and is CLI, Command Line Interface, orientated. More information on setting up the File System and Ax.25 Service may be found at My How-To page for installing RMS on a X86 system.

Links

Rasberry Quick Start - a good place to start.
Raspberry Pi Index page
Raspberry Pi Wiki
Amateur Radio RPi Users Forum
My How to - details on ax.25 and RMS configuration.
RMS Install - Linux RMS Gateway Install document.

Hardware

For the Hardware setup You will need :

  1. Power supply – minimum 700mA at 5VDC.
    Proper and Stable operation is dependent on adequate power.
  2. SD card - with an preloaded Raspbian “wheezy” operating system so that you can boot the RPi.
  3. Display - monitor with DVI or HDMI input and a HDMI/ or composite video cable.
    A TV with HDMI or Composite video inputs may also be used.
  4. Keyboard and Mouse – USB interface.
  5. Ethernet patch cable.
  6. Internet access.
  7. TNC with USB interface or USB adapter.

Operating System

The first time you power up a New Raspbian “wheezy” SD card should have a Keyboard connected.
This is so that you can interact with the Configuration Menu.

The Configuration Menu will allow you to :

You may re-run the config menu at any time by issuing the command sudo raspi-config.

Note: It is important to shutdown the system with the halt or shutdown command BEFORE removing the power.
Powering down the RPi with the OS running can cause problems if the system was in the process of writing to the SD card.
Watch the Green LED when you shutdown. It will flash 5 times in sequence to indicated that the shutdown is compete and it is safe to power down the board.

Once you have the system configured and running you may want to :

At this point you can remove the Keyboard, Monitor and Mouse and access the RPi host via SSH.

Log on and switch to the root User.

sudo su


TNC setup

TNC-Pi

The TNC-Pi may be configured to be attached to the Raspberry's single serial port or attached to the I2C buss. Attaching the TNC-Pi to the I2C buss allows the use of several TNC-Pis. For more information on TNC-Pi setups go to TNC-Pi configuration.

TNC-X

I have not had any success using the TNC-X with the optional USB interface. The Interface is not the problem. The FTDI module in the Raspberian Distro is just not stable. I have installed the TNC-X with a USB dongle and found this combination to be stable.

You may also connect the TNC-X directly to the Raspberry's single port.

		Use Caution Here!
          
      Remove Jumpers 
   TNC-X JP5  1 - 2  (TxD)
   TNC-X JP5  3 - 4  (RxD)
   TNC-X JP4        (Power)

      Connect (wire) between
	    TNC-X  --------- RPi
    JP5 - 1  TxD  ----- J1 - 10  RxD
    JP5 - 3  RxD  ----- J1 - 8   TxD
    JP5 - 7  Gnd  ----- J1 - 6   Gnd
    JP4 - 2  5VDC ----- J1 - 2   5V 

Configure the Raspberry as you would if you were using a TNC-Pi setup for a serial port.

Other TNCs

Almost any TNC with KISS can be used by using a USB to serial dongle.

Install Ax.25

Ax.25 is a service. The Run Time Library routines and various modules are included in most Linux distros. However, you have to configure the service in order to make use of it. You will need to install the Support applications and tools make Packet Radio Programs operational.

Installing the Build Tools.

The first step is to install the tools that will allow us to compile the programs and utilities that we need.
Build support is the GC Compiler and the compiler support libraries.

We are going to execute all of the following as root.
You can download the Install Script and run it as root or execute commands one at a time.

First we need to update the package list and the upgrade the distribution.

apt-get update && apt-get dist-upgrade

Next get the Compiler Package and the development Libraries for Ax.25.

apt-get install build-essential libax25-dev libx11-dev zlib1g-dev libncurses5-dev

We now have the tools to compile our ax.25 sources.

Install the AX.25 Support.

The basic Ax.25 support packages are :

Raspberian Ax.25 packages

The Raspberian Wheezy Ax.25 packages do not include the latest Ax.25 updates. They are more than a year behind the development curve. It is best to compile from the source when installing the AX.25 Service I use an “Unofficial” version that is closer to the development process. You may choose to use files from the "Official" Ax.25 archive, which are also somewhat outdated.

IMPORTANT NOTE

    If you use the Unofficial source, check to be sure that there are no libax25 files installed in the /usr/lib/ directory.
    If they are - move them! The new RT Lib files will be placed in /usr/local/lib/.

mkdir /usr/lib/ax25lib
mv /usr/lib/libax25* /usr/lib/ax25lib/

File structure

The Debian policy for Ax.25 file locations would have ax25 binary files placed in /usr/sbin/ or bin, configuration files in /etc/ax25, and data files in /var/ax25.

I find that these file locations are already heavily populated and finding the needed file in the crowded directory is sometimes difficult. Most developers agree and have moved the binary files to /usr/local/sbin, the configuration files to /usr/local/etc/ax25 and the data files to /usr/local/var/ax25.

To make sure the two file structures work I placed everything in the /usr/local/..... directories and symlinked the Debian locations.

/etc/ax25/ > /usr/local/etc/ax25/
/var/ax25/ > /usr/local/var/ax25/

Get the AX.25 source files.

As root execute the following steps via the command line.

We will be working out of the /usr/local/src/ax25/ directory.

mkdir /usr/local/src/ax25 && cd /usr/local/src/ax25

Get Libax25 and unpack Tar file.

wget -qt3 http://linuxax25.googlecode.com/files/libax25-1.0.3.tar.gz && tar xf libax25-1.0.3.tar.gz

Get Ax25 tools and unpack the Tar file.

wget -qt3 http://linuxax25.googlecode.com/files/ax25tools-1.0.2.tar.gz && tar xf ax25tools-1.0.2.tar.gz

Get Ax25 Apps and unpack the Tar file

wget -qt3 http://linuxax25.googlecode.com/files/ax25apps-1.0.2.tar.gz && tar xf ax25apps-1.0.2.tar.gz

Compile the Ax.25 files

You are now ready to start compiling Ax.25.
Enter the following commands from the command line as root.

Compile & Install Runtime Lib files.

cd /usr/local/src/ax25/libax25-1.0.3
./configure
make
make install

Enable the New RT Lib files so that the ax25 apps and ax25 tools use the new library function.

echo "/usr/local/lib" >> /etc/ld.so.conf && /sbin/ldconfig

Compile Ax25 Apps

cd /usr/local/src/ax25/ax25apps-1.0.2
./configure
make
make install

Compile Ax25-tools.

cd /usr/local/src/ax25/ax25tools-1.0.2
./configure
make
make install

Prepare Files System.

Set permissions for /usr/local/sbin/.

cd /usr/local/sbin
chmod 2755 *

The AX.25 modules (drivers) ax25, rose, mkiss, 6pack, netrom, etc .. are already installed, but need to be loaded into RAM.

modprobe ax25
modprobe rose
modprobe mkiss

You can preload the ax25 and mkiss modules by adding them to the /etc/modules file.

The Command lsmod will display the list of modules modules that are loaded.

Ax25 is now installed.

Set up "start up" files

cd /etc/init.d wget -qt3 http://k4gbb.us/docs/scripts/ax25
ln -s /etc/init.d/ax25 /usr/sbin/ax25
cd /etc/ax25
wget -qt3 http://k4gbb.us/docs/rpi/ax25-up.pi && mv ax25-up.pi ax25-up
wget -qt3 http://k4gbb.us/docs/scripts/ax25-down && chmod 755 ax25-*
wget -qt3 http://k4gbb.us/docs/rpi/axports
wget -qt3 http://k4gbb.us/docs/rpi/ax25d.conf
cd /usr/local/sbin/
wget -qt3 http://k4gbb.us/docs/rpi/calibrate.pi && mv calibrate.pi calibrate


Configure the Ax.25 Service

Once the ax.25 Service is installed you will need to configure it with your call. For those who have not been down this road... check out My How-to section.

axports

Create or Edit /etc/ax25/axports.
DO NOT leave any blank lines in the file.
It should look something like this.

# /etc/ax25/axports
# Port Callsign Baud PacLen MaxFram Description
0 N4TPO-1 19200 256 7 1200 baud - 145.030 MHz
# End /etc/ax25/axports

Change the call and baud rate to match your TNC.

ax25d.conf

Create or Edit /etc/ax25/ax25d.conf..
It should look something like this.

# /etc/ax25/ax25d.conf
[n4tpo-10 via 0 ]
NOCALL * * * * * * L
default * * * * * * - rmsgw /usr/local/bin/rmsgw rmsgw -P 0 %U
# End /etc/ax25/ax25d.conf

Ax.25 socket

ifplugd

The Hot Plug setup of the Raspberian OS creates sockets that are unattached and cause the system to run out of sockets. To disable this function edit /etc/default/ifplugd

Change HOTPLUG_INTERFACES="all"
to HOTPLUG_INTERFACES="wlan0"

TTY Device

If you are using the TNC-PI you will have to edit /etc/ax25/ax25-up and change the device from /dev/ttyUSB0 to /dev/ttyAMA0 by moving the # character

/usr/local/sbin/kissattach /dev/ttyAMA0 0 44.128.1.1 >/tmp/ax25-config.tmp
# /usr/local/sbin/kissattach /dev/ttyUSB0 0 44.128.1.1 >/tmp/ax25-config.tmp

Starting/Stopping AX.25 Service

Quick & Easy

The ax25 start-up is accomplished with the command:

ax25 start

If the start/stop commands executed without an error you have an operational Ax.25 system. You will want to test the setup and troubleshot any problems before installing the RMS Gate software.

Other options are ax25 [stop] [restart] [status]

Test your TNC

Start the ax25 service

Calibrate

The Calibrate utility will send full frames (256 chars) to the TNC and allow you to set the audio Txd level.
Download the Calibrate file.
Don't try to use the one from a X86 system. Execute the utility.

wget http://k4gbb.us/docs/scripts/calibrate_pi /usr/local/sbin/calibrate
chmod 2755 /usr/local/sbin/calibrate
calibrate <port-name>

The console should display the message to "press Enter to stop" and the PTT LED on the TNC should lite.

Call

The Call utility is a simple Terminal Program which allows you to make a connect request and when connected to send and receive.

The syntax is:
call <Port_name> -s <MYcall> <call-ssid> <path>

call 0 -s n4tpo k4gbb-10 v k4gbb-3

Use ~.to exit.


Install RMS Gate software

The INSTALLING file in the Linux RMS package is pretty straight forward. Brian & Hans have done an excellent job on the install process and documentation.

Execute the follow commands or download and run the Install Linux RMS Gate script

Switch to Super User

sudo su

Create a user account – w/o a home directory.

adduser rmsgw –no-create-home

Install the packages needed for compiling the RMS Gate software.

apt-get install xutils-dev libxml2 mysql-client libmysqlclient15-dev libxml2-dev

Optional –

apt-get install xml utilities

Download the RMS Gate .tar file into /usr/local/src/ax25 and unpack the file.
Change directory into the Directory that was created by the unpacking of the tar file.

cd /usr/local/src/ax25
wget -qt 3 http://k4gbb.us/docs/scripts/rmsgw-2.3.0-151.tgz
tar xf rmsgw-2.3.0-151.tgz
cd rmsgw-2.2.0-151

make

make install

Configure RMS

Once the install is complete you will have to configure the RMS Gate for your call and location.

As of January 25, 2013, all sysops must obtain an authorization for gateway connections.
To request gateway station authorization contact Steve Waterman, K4CJX."

If you previously operated a gateway and your station has been on line less than 24/7/365 at any time in the past, you need to ask for an authorization.

The INSTALL file from the package [/usr/share/doc/rmsgw-2.3.0/] contains the information needed for editing the files in /etc/rmsgw/ - channels.xml, banner and gateway.conf. The INSTALL file from the source package can be viewed as a HTML page here.

Help files and Manual Documents may be viewed from the command line with the man command

man rmsgw
man rmsgw-aci.1

SEE ALSO syslog.3, syslog.conf, syslogd.conf, ax25d.confg, rms-config, cms-hosts, rms-channels

Testing the Gate

To check your Automatic Check In (ACI) - start Ax.25 and run.

rmsgw_aci.


To test the configuration files, Run

rmsgw -P <portname> <call>.

Example:

rmsgw -P 1 k4gbb

ax25d

The RMS Gate programe only runs when called. The ax25d programe listens for a connect request and when it detects the request causes rmsgw to run. Ax25d is usually started as part of the start up of the ax25 service. Ax25d is setup by the /etc/ax25/qx25d.conf file.

# /etc/ax25/ax25d.conf
[k4gbb-10 via 0 ]
NOCALL * * * * * * L
default * * * * * * - rmsgw /usr/local/bin/rmsgw rmsgw -l notice -P 0 %U
#
# (End)

Now connect to the Linux RMS gate via RF. If your ax25d.conf is configured properly you should get a connect and be able to send commands and messages to the CMS.


Sysop Tools

The Sysop Tools Suite contains utilities to maintain the RMS Gate Sysop's contact information in the WL2K Database. Currently it is an ADD-ON, but will be added to the RMS Gate package at the next upgrade.


USB Issues

The USB Hubs on the Raspberry are Version 1.1.
There have been problems with certain Powered hubs and USB devices. The ethernet port is actually a USB device. One of the problems experienced is a locked up Ethernet port.
If you experience locks ups try running the port at half duplex by adding the following two line to /boot/config.txt

# eth0 to halfduplex
smsc95xx.turbo_mode=N

It slows the port somewhat, but not enough to effect the packet thru-put.

I have found is that when a USB interface loses it's power it drops the Device's Hardware Id. When the USB is powered back up the system assigns a new Device ID. As a result the ax25 port is no longer associated with the hardware device. The same goes for other USB to Serial adapters.

We need to reference the port interface with a constant ID and link it to the hardware ID, /dev/ttyUSB(x), even if that Id changes. This is called Constant Device Enumeration. To do this we will write a Udev rule.

  1. Identify the TNC-X usb interface.
    Attach the TNC-X to the computer and execute the command..

    udevadm info -an /dev/ttyUSB0

    You will get a rather long output.
    Due to a Bug in the Rasberrian OS it WILL lock up the System after it displays the list.

    Look for a section that list the adaptor for the TNC-X It should look something like this:

     looking at parent device '/devices/pci0000:00/0000:00:1f.2/usb1/1-1':
        KERNELS=="1-1"
        SUBSYSTEMS=="usb"
        DRIVERS=="usb"
        ATTRS{configuration}==""
        ATTRS{bNumInterfaces}==" 1"
        ATTRS{bConfigurationValue}=="1"
        ATTRS{bmAttributes}=="80"
        ATTRS{bMaxPower}=="100mA"
        ATTRS{urbnum}=="1280557415"
        ATTRS{idVendor}=="0403"
        ATTRS{idProduct}=="6001"
        ATTRS{bcdDevice}=="0600"
        ATTRS{bDeviceClass}=="00"
        ATTRS{bDeviceSubClass}=="00"
        ATTRS{bDeviceProtocol}=="00"
        ATTRS{bNumConfigurations}=="1"
        ATTRS{bMaxPacketSize0}=="8"
        ATTRS{speed}=="12"
        ATTRS{busnum}=="1"
        ATTRS{devnum}=="2"
        ATTRS{version}==" 2.00"
        ATTRS{maxchild}=="0"
        ATTRS{quirks}=="0x0"
        ATTRS{authorized}=="1"
        ATTRS{manufacturer}=="Coastal ChipWorks"
        ATTRS{product}=="TNC-X by W2FS"
        ATTRS{serial}=="FTTAEGI2"

    Note the ATTRS{serial}=="FTTAEGI2" line and copy the string of characters behind the == ("FTTAEGI2").

  2. Create a Udev rule file named - /etc/udev/rules.d/99-usb-serial.rules

    Paste the following two lines into that file.

    #Device #1 - Coastal ChipWorks TNC-X by W2FS - 1-port USB to serial adapter (FTDI-based)
    SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="FTTAEGI2", SYMLINK+="tncx", RUN+="/usr/sbin/ax25 restart"

    Edit the ATTRS{serial}== part of second line so that the ATTRS{serial}=="FTTAEGI2" part of the text reflects the serial that you copied down in the first step.
    Save the file..

    The RUN+="...." in this example reinitializes the ax25 service. There is no need to restart udev. It will pickup the new rule as soon as you save the file. However, it will not execute the RUN command/script until you cycle the TNC power. That is easily done by removing the USB cable and reconnecting it.

  3. Edit the Port file or the kissattach statement that creates the port for the TNC-X.
    Change the /dev/ttyUSB(x) to /dev/tncx
    Example:
    /usr/local/sbin/kissattach /dev/ttyS0 0
    to
    /usr/local/sbin/kissattach /dev/tncx 0

  4. Test by unplugging the USB cable and plugging it back in.
    Check to see if the tncx link file is present in /dev/

    ls -l /dev/tncx

    The /dev/tncx file should be a link to /dev/ttyUSB(x).
    Check the transmit function with the Calibrate command to insure that the PTT led lites.



Valid CSS! Valid HTML 4.0 Transitional