Configure a TNC-Pi for a Raspberry Pi. Linux RPi

Updated 7 Dec 2016

Charles S. Schuman, K4GBB
k4gbb1@gmail.com

If you have not already done so, update your Operating System.
To update your OS -You must have an Internet access - ( either Ethernet or Wireless network connectivity)

 From the command line enter the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Install Ax.25

The ax.25 support must be installed. For help with the installation of  Libax25, Ax25-tools and Ax25-apps go to Install Ax.25

Once Libax25, ax25-tools and ax25-apps are installed.

Create or edit the /etc/ax25/axports file.
It should look like this.

# Port	 Callsign	Baud	PacLen	MaxFram   Descriptions
0	N4TPO-1		19200	256	5	Radio - 145.030 MHz
# (End axports)

TNC-Pi setup for a serial port

The Raspberry Pi is shipped configured to use the single serial port as a Local Terminal.
Use the raspi-config menu to set the serial port so that it releases the serial port.

sudo raspi-config

On the Raspi Config menu -
Go to Advanced Options
choose Serial
select NO

Raspberry B3

You may have heard that the serial port on a RPi B3 will show up as /dev/ttyS0.

The following changes will re-configure the devices so that the serial port will be /dev/ttyAMA0. This keeps the device name constant over all the earlier Raspberries models. The Bluetooth device will then be /dev/ttyS0.

  1. Edit the /boot/config.txt file to change the line:
    enable_uart=0 
         to 
     enable_uart=1
  2. Add following the lines to /boot/config.txt.
    dtoverlay=pi3-miniuart-bt
    core_freq=250
  3. Add the following lines to /lib/systemd/system/hciattach.service.
    Create the /lib/systemd/system/hciattach.service file if it does not exist.

    [Unit]
    ConditionPathIsDirectory=/proc/device-tree/soc/gpio@7e200000/bt_pins
    Before=bluetooth.service
    After=dev-ttyS0.device
    
    [Service]
    Type=forking
    ExecStart=/usr/bin/hciattach /dev/ttyS0 bcm43xx 921600 noflow -
    
    [Install]
    WantedBy=multi-user.target
    
  4. Reboot the Pi to put the changes into effect.

The TNC-PI is shipped with it's NVRAM configured for serial operation. The KISS parms may not be suitable for your operation.

The kissparms utility does not work with the TNC-Pi. To Set the kissparms you will have to use the setparam utility. You only need set them once. The values will be retained in the TNC's NVRAM.

  1. Download the Param tools, extract and place the pitnc_getparams and pitnc_setparams files in the /usr/local/sbin/ dir, and make them executable.

    If you use the Un-official ax25 source you will have to add a link to the RT Library routines.

    sudo ln -s /usr/local/lib/libax25.so.1 /usr/lib/libax25.so.0

  2. On the older versions of the TNC-Pi Jumpers JP 3 & 4 should be installed.
  3. Make sure that /dev/ttyAMA0 is free. It should not be attached or bound to any service.
  4. Read the KISS Parameters.

    At the Raspberry's command line execute the Getparams command.

    sudo /usr/local/sbin/pitnc_getparams 1 0

    The syntax for the pitnc_getparams program is:
    pitnc_getparams <bus> 0
    where -
    bus is the number of the I2C bus.....
    Revision 1 PI boards (without mounting holes) the i2c bus number is zero
        Revision 2 PI boards the i2c bus number is 1

    0 is the device number for the serial port.

    The pitnc_getparams utility output will then list the values for all of the user settable parameters.
    01 TXDelay - Zero means use ADC  00
    02 Persistance                   64
    03 Slottime (in 10 mS)           10
    04 TXTail                         0
    05 Full Duplex - Not used         0
    06 Our Channel (Hex)             00
    07 I2C Address (0 = async) Hex   00
       ADC Value                     28
    8 0 00 40 a 0 0 0 0 1c 74 c0 sum 2
  5. Set the KISS Param.

    The syntax for the pitnc_setparams program is:
    pitnc_setparams <bus> <0> <parm> <value>
    where -
    bus is the number of the I2C bus
    0 is the number for the serial port on that bus.
    Parm is the number of the parameter from the list below.
    Value is the new value to be set.

The Command

sudo pitnc_setparams 1 0 1 250

Sets the TxDelay.
With TNC-Pi you can set the TXDelay either in software or in hardware using R6 on the TNC board.
Setting this parameter to 0 causes the TNC-Pi R6 potentiometer to determine the value.

Parameters

  1. TxDelay
  2. Persistance
  3. Slottime
  4. TxTail
  5. FD - Full duplex (not Used)
  6. Our Channel (Hex)
  7. I2C address ( 0 = async) Hex

    Setting the I2C address to 0 sends data to the serial port (default).
    Values 3 to 119 will enable the TNC to be used with I2C, using (value) as it's address.

  8. Set other KISS parameters as needed.
  9. Restart the TNC once the KISS parameters are set.

    sudo pitnc_setparams <bus> <device> 15 2



Opening an AX25 socket with TNC-Pi as a Serial device

Open an Ax.25 socket with the command.

sudo kissattach /dev/ttyAMA0 <axport> <ip address>

axport = the port name from the /etc/axports file

ip address – An address is required by some versions of kissattach.
The address will prob never be used so use 44.128.1.0 - an AMPR Net test address.

Example:

   kissattach /dev/ttyAMA0 0 44.128.1.0



TNC-Pi setup for the I2C buss.

The TNC-Pi NVRAM comes configured for serial operation. The TNC-Pi may also be configured to communicate with the Raspberry Pi using the I2C protocol.

To configure the TNC-Pi for I2C, you will need the programs pitnc_setparams and pitnc_getparams. The getparams program reads the parameters from the TNC-Pi while the setparams program allows you to set them. These programs are available at: http:// www.tnc-x.com/params.zip

In the Raspberry
re-run the Raspi Config Tool

sudo raspi-config

On the Raspi Config m enu - Go to Advanced Options and choose I2C then select YES to enable the I2C buss and YES to load the I2C module at boot up.

To manually enable the I2C buss make the following changes:
  1. in the /etc/modprobe.d/raspi-blacklist.conf file, remove the line:
    blacklist i2c-bcm2708
  2. in the etc/modules file, add the line:
    i2c-dev

Download the Param tools, extract and move the pitnc_getparams and pitnc_setparams files to the /usr/local/sbin/ dir.
Then make them executable.

sudo wget http://www.tnc-x.com/params.zip
sudo unzip params.zip
sudo mv pitnc_* /usr/local/sbin/
sudo chmod +x /usr/local/sbin/pitnc_*

If you use the Un-official ax25 source you will have to add a link to the RT Library routines.

sudo ln -s /usr/local/lib/libax25.so.1 /usr/lib/libax25.so.0

Configure the TNC-Pi boards one at a time.

  1. Remove the Other TNC boards from atop the Raspberry or remove JP 7 (power) on the other TNCs.
  2. On older TNC-Pi models Jumpers JP 3 & 4 should be installed on the TNC to be configured.
  3. Make sure that /dev/ttyAMA0 is free. It should not be attached or bound to any service.
  4. Read the KISS Parameters.

    At the RPI command line execute the Getparams command.

    sudo /usr/local/sbin/pitnc_getparams 1 0

    The syntax for the pitnc_getparams program is:
    pitnc_getparams <bus> 0
    where -
    bus is the number of the I2C bus.....
    Revision 1 PI boards (without mounting holes) the i2c bus number is zero
        Revision 2 PI boards the i2c bus number is 1

    0 is the device number for the serial port.

    The pitnc_getparams utility output will then list the values for all of the user settable parameters.
    01 TXDelay - Zero means use ADC  00
    02 Persistance                   64
    03 Slottime (in 10 mS)           10
    04 TXTail                         0
    05 Full Duplex - Not used         0
    06 Our Channel (Hex)             00
    07 I2C Address (0 = async) Hex   00
       ADC Value                     28
    8 0 00 40 a 0 0 0 0 1c 74 c0 sum 2
  5. Set the i2c address -

    sudo pitnc_setparams 0 1 7 <i2c-address >

  6. Set the KISS Param.

    The syntax for the pitnc_setparams program is:
    pitnc_setparams <bus> <0> <parm> <value>
    where -
    bus is the number of the I2C bus
    0 is the number for the serial port on that bus.
    Parm is the number of the parameter from the list below.
    Value is the new value to be set.

    The Command

    sudo pitnc_setparams 1 0 1 250

    Sets the TxDelay.
    With TNC-Pi you can set the TXDelay either in software or in hardware using R6 on the TNC board.
    Setting this parameter to 0 causes the TNC-Pi R6 potentiometer to determine the value.

    Parameters

    1. TxDelay
    2. Persistance
    3. Slottime
    4. TxTail
    5. FD - Full duplex (not Used)
    6. Our Channel (Hex)
    7. I2C address ( 0 = async) Hex

      Setting the I2C address to 0 sends data to the serial port (default).
      Values 3 to 119 will enable the TNC to be used with I2C, using (value) as it's address.

  7. Set other KISS parameters as needed.
  8. On the older versions of the TNC-Pi, Remove Jumpers 3 & 4 from the configured TNC-PI.
  9. Reboot.

Running applications with TNC-Pi in I2C mode

The TNC-PI can be used with applications that use the Linux ax.25 stack, or applications that expect to see a KISS TNC on a serial port.
The i2ckiss program which converts i2c to a standard KISS protocol via a virtual serial (pty) port is available at http://www.tnc-x.com/i2ckiss.zip

Download, extract, and move i2ckiss to the /usr/local/sbin/ dir.
Then make the file executable.

sudo wget http://www.tnc-x.com/I2ckiss.zip
sudo unzip I2ckiss.zip
sudo mv i2ckiss /usr/local/sbin/
sudo chmod +x /usr/local/sbin/i2ckiss

To create an AX.25 socket use i2ckiss in place of kissattach.
Run a proc of i2ckiss for each TNC-PI.

sudo i2ckiss <bus> <device> <axport> 44.142.1.1

The parameters to the i2ckiss command are i2c bus, i2c device, followed by the port name (from axports)
and an ip address.

The address probably will not be used for routing so the AMPR Net Test address - 44.128.1.1 may safely be used.
For example:

i2ckiss 0 3 1 44.128.1.1

will create a pty pair, and execute kissattach on the pty side using the 3rd and 4th parameters.