Raspberry Pi4 Trifecta TNC-Bank Image Companion Documentation

Introduction

A (long winded) demonstration of the setup

Documentation Last Modified

Download

WARNING: Cooling

The use of this image is at own risk. Active (fan) or large area heatsink cooling is required to keep the RPI from overheating. For example, a heat sink case such as this one is sufficient if there is adequate airflow around the unit.

While the image does not by default overclock your RPI4, it is necessary to put the RPI into Performance Mode, which will make it run hotter. Overclocking is highly recommended but is a manual step you must take full responsibility for.

Before You Start

  • Network is handled by DHCP. The SSH system is not running by default and this must be manually activated to generate host keys for the system using the raspi-config tool, documented here.
  • Having the SSH system enabled will let you log in from a remote system (using PuTTY for example) on your own network, making it a lot easier to transfer copy & paste instructions from this document.
  • You will still need a display, a keyboard and a mouse connected for initial setup.
  • This document is not perfect, it is a work in progress.
  • The image is the first of its kind so it isn’t perfect either.
  • This document has already been updated with additional steps that must be taken to make it fully operational.
  • The image requires at least a 16GB SDCard (8.3GB used) and will auto-resize to the full capacity first on boot up. 16GB is recommended because it is quicker to make a backup of should you wish to do so in the future.
  • Download (2.3GB)

Writing The Image to SD Card

Windows

Writing the image to SD Card is usually quite well documented by the general Raspberry Pi online documentation. It is possible to use Windows tools such as the RPI Imager, however the image file you download may need to be decompressed first using a tool such as WinRAR or 7zip.

Linux

You will need to know which device path your SDCard appears as e.g /dev/sda for the dd command. The image is compressed and will need to be unpacked:

gzip -d rpi4-console-dist.img.gz

Send the image to the SD Card using dd: Be sure that /dev/sdb is your SD card and not your internal hard disk!

sudo dd if=/path-to-the-image/rpi4-console-dist.img of=/dev/sdb bs=16M status=progress

First Boot

Upon first boot the image will resize itself to fit the full capacity of the SD card and then auto-restart the system.

Second Boot

Second boot will eventually present a black screen on the display connected (how useful, this will be addressed possibly in an updated image). If there is no signal then you may have the HDMI connector in the wrong port.

Plug in a mouse and hold right-click on the screen to open the pop up menu. From there, open the Terminal Emulator application.

Will this be a desktop system for you?

This install has been created to be as light as possible on the hardware while keeping plenty of tools available, as such there is no toolbar installed by default, so you may want to install the tint2 package if you wish to actually use this system as a desktop.

sudo apt install tint2

Open /home/pi/.config/autostart.sh, it will not exist.

Fill it with the contents:

# tint2 -- provides panel, systray, clock & taskbar
tint2 &

After installing tint2, a reboot is required for it to run at next logon.

Change the Password

Once logged in you should change the default password to something else using the passwd command on a new terminal line and hit enter. You will be prompted through the process. The current login is: pi and the password is: raspberrypi

Enable Secure Shell (SSH)

By default SSH is disabled as host keys need to be generated for your host that are unique and cannot be shared via an image file. So open up the raspi-config tool and navigate to (3) Interface Options, then select (2) SSH and Enable it.

sudo raspi-config

Overclocking

If you do have adequate cooling, it is highly recommended to overclock to get the best performance, editing /boot/config.txt to set it to 2GHz which is from experience so far, safe and stable. Locate the #arm_freq parameter in the config.txt file and add the following below it:

over_voltage=6
arm_freq=2000

Performance Mode

And edit /etc/rc.local to force performance mode at boot:

sudo nano /etc/rc.local

Insert the following one-liner BEFORE the ‘exit 0’ line in /etc/rc.local

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Enable Realtime Thread Priority

Tweaks to the host operating system file /etc/security/limits.conf

@audio - rtprio 95
@audio - memlock 512000
@audio - nice -19

The rtpriosetting is the maximum priority a user of the audio group can run a task. The memlock setting is the maximum amount of memory that a member of the audio group can lock with a realtime task. This should be less than the maximum physical amount of memory, some recommend it to be half. nice is the minimum “nice level” a task can be run as (the willingness of a task to give up it’s cpu time).

ALSA Project (https://www.alsa-project.org/wiki/Low_latency_howto)

If not using ‘pi’ user, ensure that your user ID is in the audio group in /etc/groups

After a reboot, verify that the new limits are working with:

ulimit -r

pi@raspberrypi:~/bin $ ulimit -r
95

VARA and ARDOP realtime Thread Priority

Background: Launch VARA with highest priority (99)- is required to compensate for some since discovered latency issues.

When issued as root, the chrt tool overrides the policy set earlier in the limits.conf, running the process as rt (realtime) which will reflect in the indicated priority listing when displayed in the top process monitor program.

Example:

sudo chrt -p 99 `pgrep VARA.exe`

Will modify the thread priority to realtime, on the fly. Using ‘top’, look at the PRI column and it should now be ‘rt’ instead of default ‘20’.

A modified script that will fork chrt into a background subshell, wait 20 seconds while VARA is launched, and then adjusts the process priority of VARA.exe is required. 

The following script tweak is needed for the RPI4 TNC image for both the ARDOP and VARA TNCs:

File: /home/pi/bin/startvara 

#!/bin/bash
cd /home/pi/bin
DISPLAY=:2
export DISPLAY
(sleep 20; sudo chrt --pid 99 `pgrep VARA.exe` ) &
/usr/local/bin/wine /home/pi/.wine/drive_c/VARA/VARA.exe

File: /home/pi/bin/startardop

!/bin/bash
cd /home/pi/bin/
(sleep 10; sudo chrt --pid 99 `pgrep piardopc` ) &
/home/pi/bin/piardopc 8515 ARDOP2IN ARDOP2OUT

Enable the TNCs

By default, none of the TNCs are started automatically, but can be enabled to do so:

sudo systemctl enable vara
sudo systemctl enable ardop
sudo systemctl enable ardop-gui
sudo systemctl enable qtsm

sudo service vara start
sudo service ardop start
sudo service ardop-gui start
sudo service qtsm start

View the TNCs

To view the running TNCs, attach VNC Viewer to Display “2”.

So long as you have RealVNC client installed on a remote system, such as another Raspberry Pi, or an iPad you can connect to the screen running the TNCs for monitoring purposes. You don’t have to keep the VNC open, they will run happily in the background.

From Terminal: Note: omit the brackets if providing an IP address.

vncviewer [optional IP address]:2 

Login is “pi“, the password is “raspberrypi” unless you have already changed it)

VNC Idle Timeout

By default the VNC will timeout after 3600s (an hour) which can be annoying if you want to leave it open on another desktop to monitor. If you have the tint2 toolbar installed it will be possible to locate annd open the VNC server UI on the desktop and then open up Expert settings to adjust IdleTimeout to 0.

Alternatively, open /home/pi/.vnc/.config.d/Xvnc and append the following line:

IdleTimeout=0

Configuring the QtSoundModem TNC

Due to an oversight on my part, QtSoundModem.ini has the CWID setting enabled with my callsign so you will need to set the timer from 15 minutes to 0. This will be fixed in the next release of the image.

Additionally good info to know beforehand- due to how QtSoundModem GUI config dialog saves settings, the manually configured sound devices do not appear in the dropdown lists because they are “virtual”, therefore the dsnoop/dmix devices that come preconfigured with the image will be overwritten if the dialog is used to change any configuration parameters(!)

The best practice is to edit the ini file in a text editor manually.

To recap, the QtSoundModem.ini file is read-only on purpose. The application tries to write back to the file on each shutdown/closure which causes problems for our special audio sharing setup between the different TNCs, so editing the file must be done by hand, not via the GUI.

With editors like vim, a force-write !wq will write-quit & ignore read-only warning. Easy peasy.

I don’t use nano myself but I know a lot of people do, BUT I don’t know if it i will allow you to do this the same way. If not offered the option when you attempt to overwrite a read-only file, then you can temporarily change the file permission level after stopping the service:

sudo service qtsm stop

cd /home/pi/bin

chmod 644 QtSoundModem.ini

nano QtSoundModem.ini

Make the edits to:

CWIDCall=
CWIDInterval=0

Save and close, then change the permissions back to read-only.

chmod 444 QtSoundModem.ini

Then restart the QtSoundModem’s service:

sudo service qtsm start

TCP Port Defaults

Bear in mind that my ‘defaults’ here are in fact not factory setting defaults.

By default my following ports are set:

QtSoundModem

  • KISS: 7777
  • AGW: 6666

ARDOP

  • 8015

VARA

  • 8300
  • 8301 (data)

Other Included Tools/TODOs

[optional] Disable Paket61 socat for TNC2 emulator

sudo systemctl disable paket
sudo service paket stop

[optional] flrig – Radio Head Control

TODO – building and installing.

The source code is located in /home/pi/src, it is already pre-built, so you can already install it with sudo make install from the flrig-version’s subdirectory.

However, because its an old alpha build by now, a fresh build from new source would be better. If you do go ahead an install the tool, it will begin to auto-start due to the systemd service powering it up as soon as it finds /usr/local/bin/flrig binary.

You can stop/start FLRig with sudo service flrig stop/start

QtTermTCP – Packet Terminal

Edit /home/pi/bin/startqtterm and change the DISPLAY variable to the desktop which you need, usually :0 if a local monitor connected to HDMI, in our use case you can direct the display to the virtual TNC’s desktop which is running on desktop :2.

See QtTermTCP for a tutorial video for setting it up with a node.

You can start the program as a service. If QtTermTCP crashes or you close it, systemd will auto-restart the application.

sudo service qtterm start

To have QtTermTCP auto-start on every boot:

sudo systemctl enable qtterm

This CONCLUDES the TNC Bank setup

Now just go to your BPQ32 node and define all the ports to each of the TNCs with the appropriate drivers for each TNC type. Good luck! If you get stuck, ask on the groups.io, or try this Google magic search keyword term for official documentation:

cantab uz7ho
cantab qtsoundmodem
cantab VARA 

Ok Ok I will get around to making that document soon. Bookmark my website please and also – consider a donation to my beer/host fund if you feel like it. This document took many hours to write and hours of testing and its still not finished!

If you find the articles, or content in general posted here useful, enjoyable or maybe even something else, please consider making a small contribution towards my hosting fund so that I may continue to provide my services for free to as many people as possible.


Also INcluded in the Image

DOSBOX Toys

Not meant for 3rd Parties – provided for educational purposes only.

Please note that there is no toolbar installed, you may want to install the tint2 package if you wish to actually use this system as a desktop.

sudo apt install tint2

How it works

As this image is dual-purpose, this image is also capable of running old packet applications for fun, but due to performance requirements must not be used if running the system as a TNC-bank.

On this image is DOSBOX with various packages preconfigured to use a virtual serial port pipe to the box with a BPQ32 node running on the local network This is downright complicated and because of this, it is not really recommended for 3rd party use but tinkerers might like it.

Each program such as “superpacket” or “winpack” relies on a listening serial device on a remote BPQ32 based node. Each application has a unique TCP port put aside, and reciprocal listeners must be set up for each port on the remote node box.

The TCP listeners direct the traffic to a pseudo serial device that the node is configured to attach to when it is started. It then talks to the socket using KISS mode, and the applications on the other end are doing the same, with a couple of exceptions.

Caveats

If you leave a BPQ32 node with KISS ports enabled linked to socat pseudo serial services, the node will assume traffic is being sent to them and will then wait for responses. If you run the node long enough with the reciprocal applications themselves not running, this will cause that port’s KISS buffer in the node to get full and cause the whole node to stop responding entirely. Eek. So don’t leave the ports configured on the node if you had enough of running the DOS apps!

On the NODE system

Here are some examples for BPQ32:

PORT
        PORTNUM=17                     
        HIDE=0                               
        ID=TCP KISS port 8004      
        TYPE=ASYNC                     
        PROTOCOL=KISS          
        FULLDUP=0                      
        COMPORT=/home/pi/port-8004
        SPEED=19200
        CHANNEL=A                      
        QUALITY=192             ; Quality factor applied to node broadcasts heard on
        MINQUAL=230
                                        ; this port, unless overridden by a locked route
                                        ; entry. Setting to 0 stops node broadcasts
        FRACK=5000                      ; Level 2 timout in milliseconds
        RESPTIME=1000           ; Level 2 delayed ack timer in milliseconds
        RETRIES=5                       ; Level 2 maximum retry value
        MAXFRAME=6                      ; Max outstanding frames (1 thru 7)
        PACLEN=128                      ; Default max packet length for this port.
                                        ; PACLEN is ignored for APRS packets
        L3ONLY=0                        ; 1=No user downlink connects on this port
        DIGIFLAG=1                      ; Digipeat: 0=OFF, 1=ALL, 255=UI Only
        USERS=10                        ; Maximum number of L2 sessions, 0 = no limit
        UIONLY=0                        
ENDPORT
 
PORT
        PORTNUM=18                      
        HIDE=0
        ID=TCP KISS port 8006       
        TYPE=ASYNC                      
        PROTOCOL=KISS           
        FULLDUP=0                      
        COMPORT=/home/pi/port-8006
        SPEED=19200                     
        CHANNEL=A                     
        MINQUAL=10             
        QUALITY=244             ; Quality factor applied to node broadcasts heard on
                                        ; this port, unless overridden by a locked route
                                        ; entry. Setting to 0 stops node broadcasts
        FRACK=8000                      ; Level 2 timout in milliseconds
        RESPTIME=2000           ; Level 2 delayed ack timer in milliseconds
        RETRIES=10                      ; Level 2 maximum retry value
        MAXFRAME=3                      ; Max outstanding frames (1 thru 7)
        PACLEN=100                      ; Default max packet length for this port.
                                        ; PACLEN is ignored for APRS packets
        L3ONLY=0                        ; 1=No user downlink connects on this port
        DIGIPORT=0                      ; Port on which to send digi'd frames (0 = same port)
        USERS=10                        ; Maximum number of L2 sessions, 0 = no limit
        UIONLY=0                        
ENDPORT

The serial port listeners on the node box (remote) are run from some start scripts, for example:

For PORT 17 (tcp 8004):

#!/bin/bash

socat -d -d PTY,raw,echo=0,link=/home/pi/port-8004-stay PTY,raw,echo=0,link=/home/pi/port-8004 &

while true
do

socat -d -d open:/home/pi/port-8004-stay,nonblock,echo=0,raw TCP4-LISTEN:8004,reuseaddr,fork
sleep 1
done

# End

For PORT 18 (tcp 8006):

#!/bin/bash
socat -d -d PTY,raw,echo=0,link=/home/pi/port-8006-stay PTY,raw,echo=0,link=/home/pi/port-8006 &

sleep 3
while true
do

socat -d -d open:/home/pi/port-8006-stay,nonblock,echo=0,raw TCP4-LISTEN:8006,reuseaddr,fork
sleep 1
done

# End

On your DOSBOX System

The image has the reciprocal couplings for each of these tcp ports provided as linux services, these can be turned on automatically.

The following ports with self explanatory service names are available:

port-2704  port-8004  port-8005  port-8006  port-8007  port-8009  port-8011

Each has a script in /home/pi/bin/ and needs modifying to change the IP address to the one of your BPQ32 node box.

The above services corrleate to the the various different preconfigured dosbox packages that I have set up for different packet radio applications.

They all run on different TCP ports so that it is actually possible to interconnect the applications through the node. e.g. connect from Winpack to the node, then from the node connect to the SuperPacket application (if it is also running).

Caveat

It is not wise to configure too many kiss-TNC ports as it can have a detrimental effect on the node, sometimes causing BPQ32 to lock up intermittently if you leave the applications closed for a measure of time.

For the purposes of this document I have limited examples to just two:

Port 17 (tcp 8004) and 18 (tcp 8006) respectively for “superpacket” and “winpack”, but there are others defined in the system services already that can be enabled and used if you chose to add extra ports to the node using Port 17 or 18 as examples to iterate up to maximum of Port 32.

For reference

Serial Port Tunnels (client side) – enable and start syntax:

sudo systemctl enable port-8004
sudo systemctl enable port-8006

Start:

sudo service port-8004 start
sudo service port-8006 start

Monitoring

Each port that is started opens a ‘screen’ session for debugging. Each screen session is easily identifiable using “screen -r”

pi@console:~ $ screen -r
There are several suitable screens on:
	5915.Port8004	(07/23/2022 11:16:56 AM)	(Detached)
	5093.Port8006	(07/23/2022 11:08:14 AM)	(Detached)

To view the console’s output:
Example:

screen -r Port8006

CTRL-A then D will detatch the console.

Applications

Winpack

Winpack is configured to use DOS BPQ as the communications layer, and utilizes the KISS interface to talk to my remote node. The node’s “socat” serial port is listening on TCP port 8006, using the socat setup described above. This allows the DOSBOX instance to communicate with the node that is on a remote host. The nodes talk to each other via NETROM, the example port setup shown earlier in the document demonstrates that NETROM is enabled and is sending as many nodes as possible on that port. When successfully linked, the Winpack terminal should show a lot of NETROM activity from broadcasts.

The schametic is like this:

LinBPQ Node -- [Kiss Port 17] -- [Serial Socat Listener Port 8006] <-network-> [Remote Serial Socat Connector] <—-> [DOSBOX-Staging] <—-> [DOS BPQCODE.DLL] <--> [Windows 3.11] <--> [Winpack 6.80]

To configure your own callsign you must edit the following file:

/home/pi/dosprogs/BPQ/BPQCFG.TXT


When the ‘winpack‘ script is run it will launch DOSBOX and run the BPQCFG.EXE automatically before auto-booting Windows, this converts the configuration TXT into binary for the BPQCODE to use. Winpack is preconfigured to use the resident BPQ node.

Winpack’s own callsign configuration is pretty straight forward and self explanatory.

Superpacket

Superpacket, on the other hand, is a complex RTFM situation, only for those with the edge! You’re on your own. But it is damn near perfect for multitrack train drifting, on packet radio.

The Other Apps

Apps confirmed and preconfigured to work in the image:

  • Paket 6.1 (paket) – requires the TNC2 emulator port setup, see below.
  • Baycom (baycom) – works via a TFPCX KISS emulator TSR
  • Winpack 6.80 (winpack) – uses NETROM, use the examples given in this document.
  • SuperPacket 9.2 (sp) – uses KISS, see the examples given in this document
  • New Packet Generation 2.0 (npg)
  • TST Host (tsthost)
  • BPQ 4.09 (DOS) – is called by Winpack and will require separate configuration.
  • TheDraw has been included to provide access for text drawing.

Take a look in /home/pi/.config/dosbox for the various config files for the applications.

To recap, each DOS application requires a unique BPQ KISS port (or TNC2 emulator) to be configured.

For KISS, see the Ports examples above, they can be used as templates to enable the other applications.

I was able to get Winpack, Superpacket, Baycom, TSTHost, NPG and Paket61 all talking at the same time. It was insane and I am sure the RPI4 cried for mercy.

Enable Paket61 socat for TNC2 emulator

Example TNCPORT for Paket (find a clear spot in the bpq32.cfg configuration file).

TNCPORT
 COMPORT=/home/pi/port-8011
 TYPE=TNC2
 CHANNELS=4
 CONOK=1
 ECHO=0
 AUTOLF=1
ENDPORT

Enable and start the socat services for Paket61

sudo systemctl enable paket
sudo service paket start

Apps That Don’t Work

Some applications dependant on BPQCODE in DOS that have been tested and known to fail:

  • EasyTERM PMS (DOS based frontend for BPQ from circa 1994, not to be confused with UZ7HO software)

If you find the articles, or content in general posted here useful, enjoyable or maybe even something else, please consider making a small contribution towards my hosting fund so that I may continue to provide my services for free to as many people as possible.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s