Howto: AX25 as a Systemd Service

In this article we’ll see how to run AX25 as a Systemd service, bringing the AX25 interface up on every boot and also putting the TNC into kiss mode. Having an AX25 interface allows you to share it among different applications like an APRS Digipeater or Winlink.

To setup an AX25 interface under linux the following is required: proper AX25 configuration, TNC attached to computer, Put the TNC into KISS mode, Run kissattach in the background.

In the past I had done this using commands started from /etc/rc.local not only is this ugly but it is not failure safe. I eventually came up with a more modern systemd based solution.

What follows has been tested on a Raspberry Pi under Raspbian 9.9 Stretch and on a PC running Debian 10 Buster.

First make sure you have git installed:

sudo apt install git

Clone the code to your machine, in your home directory.

cd ~
git clone https://github.com/F4FXL/ax25systemd.gitCode language: Shell Session (shell)

Change to the freshly cloned directory and run the makefile that will perform all the installation task.

cd ax25systemd
sudo make install

We need to tell the AX25 utilities some things about the future interface. We so this by editing the file /etc/ax25/axports. I use tabs between each fields. The speed value is NOT the on-air speed! It is actually the speed used on the serial port to talk to the TNC.

This is how my axports file looks like:

# /etc/ax25/axports
#
# The format of this file is:
#
# name callsign speed paclen window description
#
APRS    F4FXL-3 9600    255     7       144.800 MHz (APRS 1200  bps)
Code language: Bash (bash)

Next step is to tell the system which ax port we want to bring up and how to put the TNC into KISS mode. The Linux AX25 layer is expecting the TNC to be in KISS mode before attaching to it.

This is done by editing the file /etc/default/ax25

Some explanation about the values you need to edit:

  • AXPORT needs to match the name you cconfigured into /etc/ax25/axports
  • HBAUD is the serial port speed for the computer to talk to the TNC, NOT the on-air speed.
  • IPADDR is the AX25 interface interface. Leave ampty if none is required
  • DEV the serial device, if you use an USB to Serial adapter it’ll probably be /dev/ttyUSB0

At the bottom of the file there are two commented out lines, one is for Nordlink T7F based TNC and the other for the Alinco EJ50u. Those lines call configuration scripts to put the TNC into KISS mode.
The EJ50u is very similar to the TNC found in the Kenwood radios therefore we can use its initilisation script for the Kenwood radios also. I successfully tested it with my TM-D710.

This is how the file looks like on my system.

# Configuration for AX.25 systemd unit file

# The axport from /etc/ax25/axports to bring up.
AXPORT=APRS

# The AX.25 baudrate the TNC is configured for.
# Make sure this matches the HBAUD setting of your TNC.
# This is NOT the on-air baudrate, this is the serial baud-rate i.e. between computer and TNC
HBAUD=9600

# IP Address and netmask, in CIDR notation e.g. 192.168.123.45/24 for 192.168.123.45 with netmask 255.255.255.0.
# Leave empty if you do not need the AX interface to have an ip
IPADDR=

# The TNC serial path.
DEV=/dev/ttyUSB0

# Initializing the TNC into KISS mode. Uncomment the line matching your TNC
#
# Line below is for TNC2 running Nordlink T7F ROM
#TNC_INIT_CMD="/bin/stty -raw -parenb cs8 $HBAUD < $DEV && /usr/share/kissinit/nordlink_1k2 > $DEV && /bin/sleep 1"
# 
# Line below is for Alinco ej50u TNC, also works for TMD710, THD7x etc
#TNC_INIT_CMD="/bin/stty -raw -parenb cs8 $HBAUD < $DEV && /usr/share/kissinit/ej50u > $DEV && /bin/sleep 1"
Code language: PHP (php)

Now you need to restart the ax25 service.

sudo service ax25 restartCode language: Shell Session (shell)

Check if the network interface comes up

sudo ifconfig ax0Code language: Shell Session (shell)

Should output something similar to this

ax0: flags=67<UP,BROADCAST,RUNNING>  mtu 256
        ax25 F4FXL-3  txqueuelen 10  (AMPR AX.25)
        RX packets 5  bytes 599 (599.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0Code language: Shell Session (shell)

To conclude their are a few limitations. The on-air speed is hardcoded to 1200bps, this could be easily adjusted by changing the KISS initialisation scripts. Only one interface can be handled for now, this could also be changed as systemd allows such constructs. There is no IP cconfigured on the interface As of 2019-07-07, it is possible to specify an IP address. Since I did not need such feature for the time being I have made the deliberate choice to not over engineer the whole thing.

15 Comments

  1. I was just about to create a startup script/service to start my ax25 port on my raspberry pi startup. However, I googled to see if someone else already had done this work for me, which you had! Works flawlessly-thank you!

    1. I Robert, thank you for your comment! It still has some “quirks” as the configuration needs to be done and repeated in many files, but once running it works quite good!
      Please report any issues here or on GitHub.
      Happy new year ! 🙂

  2. thanks thanks
    see below
    Now I have to fix my transceiver.

    pi@raspberrypi:~ $ systemctl status ax25
    ● ax25.service – AX.25 KISS interface
    Loaded: loaded (/lib/systemd/system/ax25.service; enabled; vendor preset: enabled)
    Active: active (running) since Sun 2019-07-07 19:23:32 CEST; 5min ago
    Process: 492 ExecStart=/usr/sbin/axup ${DEV} ${AXPORT} ${IPADDR} (code=exited, status=0/SUCCESS)
    Main PID: 547 (kissattach)
    Memory: 672.0K
    CGroup: /system.slice/ax25.service
    └─547 /usr/sbin/kissattach /dev/ttyAMA0 1k2 -m 256

    Jul 07 19:23:29 raspberrypi systemd[1]: Starting AX.25 KISS interface…
    Jul 07 19:23:31 raspberrypi axup[492]: AX.25 port 1k2 bound to device ax0
    Jul 07 19:23:31 raspberrypi axup[492]: AX.25 port 1k2 bound to device ax0
    Jul 07 19:23:32 raspberrypi systemd[1]: Started AX.25 KISS interface.
    pi@raspberrypi:~ $ ip addr show
    1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
    2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:3b:52:c0 brd ff:ff:ff:ff:ff:ff
    inet 10.72.192.22/24 brd 10.72.192.255 scope global dynamic eth0
    valid_lft 86084sec preferred_lft 86084sec
    inet6 2001:985:b4d4:1:70c:e1d3:38c6:548d/64 scope global dynamic mngtmpaddr noprefixroute
    valid_lft 6281sec preferred_lft 3284sec
    inet6 fe80::46b7:aca2:8f0e:e618/64 scope link
    valid_lft forever preferred_lft forever
    3: ax0: mtu 256 qdisc pfifo_fast state UNKNOWN group default qlen 10
    link/ax25 a0:82:66:88:a6:86:02 brd a2:a6:a8:40:40:40:00
    inet 44.137.24.22/32 scope global ax0
    valid_lft forever preferred_lft forever

        1. Looks very cool! Since the TNCPi is per design a KISS only TNC you are saving yourself the hassle of putting it into kiss mode. Maybe you might want to make sure it can handle 256 bytes frames, as all my stuff assumes the TNC can handle such frame length.

  3. I m hacking around but can not find how to do kissattach to give the port an IP address. Reason is kissattach: device /dev/ttyAMA0 already in use. And I’m not a script-kiddie. I’m glad to understand but can not create scripts. Please Jeoffrey can you extend your precedure with a IP address?

    martin
      1. I like to make a packet link to my friends. There is a IRLP node and a wspr transmitter. A 1200 bd is sufficent to do some command line actions.
        73 martin pa3dsc

        martin
        1. Nice! I really love the id of not going through internet for that!
          Ok I have made something, it is now possible to specify an IP address for the interface. The interface gets an IP yet I did not test if it is possible to transmit something over it via IP.

          You need to update as follow:
          Go into the directory here you cloned the code:
          cd ~/ax25systeemd

          Update the code:
          git pull

          Install new files:
          sudo make install

          Unfortunately you need to edit the /etc/default/ax25 file once more and to put back port name and there is a new option for IP address.

          One more question what kind of TNC are you using ?

  4. After edit the file /etc/default/ax25 and changed DEV=/dev/ttyAMA0 in stead of ttyS0 things went OK like below.
    Next give the port an IP address.
    Will be continnued
    thanks Geoffrey

    root@raspberrypi:/etc/default# systemctl status ax25.service
    ● ax25.service – AX.25 KISS interface
    Loaded: loaded (/lib/systemd/system/ax25.service; enabled; vendor preset: enabled)
    Active: active (running) since Sat 2019-07-06 13:37:45 CEST; 15min ago
    Process: 2541 ExecStart=/usr/sbin/axup ${DEV} ${AXPORT} ${HBAUD} (code=exited, status=0/SUCCESS)
    Main PID: 2548 (kissattach)
    Memory: 248.0K
    CGroup: /system.slice/ax25.service
    └─2548 /usr/sbin/kissattach /dev/ttyAMA0 1k2 -m 256

    Jul 06 13:37:44 raspberrypi systemd[1]: Starting AX.25 KISS interface…
    Jul 06 13:37:45 raspberrypi axup[2541]: AX.25 port 1k2 bound to device ax0
    Jul 06 13:37:45 raspberrypi axup[2541]: AX.25 port 1k2 bound to device ax0
    Jul 06 13:37:45 raspberrypi systemd[1]: Started AX.25 KISS interface.
    root@raspberrypi:/etc/default#

    root@raspberrypi:/etc/default# ifconfig
    ax0: flags=67 mtu 256
    ax25 PA3DSC-1 txqueuelen 10 (AMPR AX.25)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    martin
  5. I have a problem configure the ax25 files.

    /etc/ax25/axports
    1k2 PA3DSC-1 1200 255 2 144.825 MHz (1200 bps)

    /etc/ax25d.conf
    #
    [PA3DSC-1 VIA 1k2]
    NOCALL * * * * * * L
    default * * * * * * – root /usr/local/sbin/ttylinkd ttylinkd
    #parameters_extAX25 VC-wait-login VC-disc-on-linkfailure-msg VC-log-connections
    #
    #
    [PA3DSC-2 VIA 1k2]
    NOCALL * * * * * * L
    default * * * * * * – root /usr/sbin/node node
    #
    ~/ax25systemd/ax25.default

    # The TNC serial path.
    DEV=/dev/ttyAMA0
    # Line below is for Alinco ej50u TNC, also works for TMD710, THD7x etc
    TNC_INIT_CMD=”/bin/stty -raw -parenb cs8 $HBAUD $DEV && /bin/sleep 1″

    The serial via USB I changed ttyS0 >ttyAMA0

    Where is the NOCALL error message coming from?
    Where can I tell the kissatachto find the correct port?

    root@raspberrypi:/home/pi/ax25systemd# service ax25 restart
    Job for ax25.service failed because the control process exited with error code.
    See “systemctl status ax25.service” and “journalctl -xe” for details.
    root@raspberrypi:/home/pi/ax25systemd# systemctl status ax25.service
    ● ax25.service – AX.25 KISS interface
    Loaded: loaded (/lib/systemd/system/ax25.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sat 2019-07-06 11:27:22 CEST; 5s ago
    Process: 2163 ExecStart=/usr/sbin/axup ${DEV} ${AXPORT} ${HBAUD} (code=exited, status=1/FAILURE)

    Jul 06 11:27:22 raspberrypi systemd[1]: Starting AX.25 KISS interface…
    Jul 06 11:27:22 raspberrypi axup[2163]: kissattach: cannot find port N0CALL in axports
    Jul 06 11:27:22 raspberrypi systemd[1]: ax25.service: Control process exited, code=exited, status=1/FAILURE
    Jul 06 11:27:22 raspberrypi systemd[1]: ax25.service: Failed with result ‘exit-code’.
    Jul 06 11:27:22 raspberrypi systemd[1]: Failed to start AX.25 KISS interface.

    martin
    1. Hi martin,

      I am so sorry I’ve read the article once again and it appeared I forgot some important instruction.
      The second file to edit is /etc/default/ax25.
      Apparently you edited ~/ax25systemd/ax25.default which is the “source file”, not the actual copy installed on your system.

      The NOCALL error message is coming from the fact that you did not edit /etc/default/ax25 and it still mentions N0CALL.

      My apologies for the missing information, I updated the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.