AX.25 on a Raspberry Pi. Linux Raspberry

Updated 14 Sept 2018

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. The basic Raspberry Pi stuff will be referenced and linked.

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

You might also be interested in PAT a cross platform Winlink client written in GO.

Links

Raspberry Quick Start - a good place to start.
Raspberry Pi Index page
Raspberry Pi Wiki
My How to - details on ax.25 and RMS configuration.
RMS Install - Linux RMS Gateway 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 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.

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.

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

Log on and switch to the root User.
The SUDO SU command allows you to adopt root privileges.

sudo su

Once you have the system configured and running you should :

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 aTNC-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 Network 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 that 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.

You can download the Install Script and run it as root or execute commands one at a time.

wget http://k4gbb.no-ip.info/docs/scripts/InstAX25.sh

We are going to execute all of the following as root.

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 autoconf autogen libtool

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 Raspbian Ax.25 support packages do not include the latest updates. They are often 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 somewhat cutting edge. You may choose to use files from the "Official" Ax.25 archive, which are more up-to-date than the .DEB packages.

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 policies are compatible 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/

mkdir /usr/local/etc && mkdir /usr/local/etc/ax25
mkdir /usr/local/var && mkdir /usr/local/var/ax25
ln -s /usr/local/etc/ax25 /etc/ax25
ln -s /usr/local/var/ax25 /var/ax25

Compile & Install the Ax.25 files

We will be working out of the /usr/local/src/ax25/ directory.
Enter the following commands from the command line as root.

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

To download and unpack the AX.25 source files
execute the following steps via the command line as root.

wget https://github.com/ve7fet/linuxax25/archive/master.zip
unzip master.zip

Ax.25 Runtime Library.

Enter the following commands from the command line as root.

cd /usr/local/src/ax25/linuxax25-master/libax25/
./autogen.sh
./configure
make
make install

Enable the new Run Time Library files so that the ax25 apps and ax25 tools may use the new library functions.

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

Ax25 Apps

cd /usr/local/src/ax25/linuxax25-master/ax25apps/
./autogen.sh
./configure
make
make install

Ax25-tools.

cd /usr/local/src/ax25/linuxax25-master/ax25tools/
./autogen.sh
./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.no-ip.info/docs/scripts/ax25 && chmod 755 ax25
cd /usr/local/etc/ax25
wget -qt3 http://k4gbb.no-ip.info/docs/rpi/ax25-up.pi && mv ax25-up.pi ax25-up
wget -qt3 http://k4gbb.no-ip.info/docs/scripts/ax25-down && chmod 755 ax25-*
wget -qt3 http://k4gbb.no-ip.info/docs/rpi/axports
wget -qt3 http://k4gbb.no-ip.info/docs/rpi/ax25d.conf
touch nrports
touch rsports
cd /usr/local/sbin/
wget -qt3 http://k4gbb.no-ip.info/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.
See man axports for file description.

DO NOT leave any blank lines in the file.

    Example :


# /etc/ax25/axports
# Port	 Callsign	Baud	PacLen	MaxFram   Description
0	W3EGP-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..
See man ax25d.conf for file description.

EXAMPLE :

# /etc/ax25/ax25d.conf
[w3egp-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 some of the earlier Raspberian FS creates sockets that are unattached and cause the system to run out of sockets. Later images have corrected the problem. If your system shows a series of unattached rose or ax sockets 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

Ax.25 is a System Service and should be treated as a major component of the system. In order to accomplish this there must be a script that exercises control at Boot-up and Shutdown. Jump to Starting AX25 for a more complete explanation of the /etc/init.d/ax25 file and how to set it up.

Manual Start up

The ax25 start-up is accomplished with the command:

service 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]

Start at Boot up

To configure AX25 to run at start up enter the following command as root.

update-rc.d ax25 defaults

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 and place it in the /usr/local/sbin/ directory.
Change the permissions so that it is executable.
Don't try to use the one from a X86 system. Execute the utility.

cd /usr/local/sbin
wget http://k4gbb.no-ip.info/docs/rpi/calibrate_pi
mv calibrate_pi 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.


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+="/etc/init.d/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/ttyUSB0 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.