How to install thelinkbox on raspberry pi - on1arf/echolink-raspi GitHub Wiki

 

Installation procedure for setting up an echolink node on a raspberry pi using thelinkbox.

This document is part of the "build a echolink linknode for less than 100 euro" project and is aimed at people who want to learn more about the raspberry pi or about setting up "infrastructure devices". For this reason, the installation guide considers a very specific hardware setup:

  • raspberry pi as computing device
  • usb audio fob as external interfacing devices
  • (optionally) a USB-to-serial adapter
  • small interface circuit to electrically seperate the computer from the radio. This interface contains no more then 5 components.
  • transceiver (2nd hand handheld)?
 

With minimal changes, this procedure should also apply to other linux devices, like the pandaboard, the beagleboard, the beaglebone black, pcduino, cutieboard or others.

 

Step 1: Basic configuration of the raspberry pi, based on "raspbian weezy" distribution

The installation starts with the basic installation of rasbian wheezy linux distribution on the raspberry pi. This procedure is described on a number of places on the net, like on youtube, instructables or Simon The Pi Man.

 

During the installation procedure ("raspiconfig"), make sure the following steps are done:

  • Do "resize flashcard" to optimise the usage of the flashcard
  • Set the amount of memory for the GPU to the minimum: 16 M
  • change password (VERY important)
 

Afterwards, upgrade the software and the pi to the latest version:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get dist-upgrade
Note that this process can take anything from two up to three hours depending on the speed of the SD cards used. So do make sure you have a good cup of coffee at hand! :-)  

 

Then reboot to activate the updates:

  • sudo reboot
 

 

Step 2: ALSA Sound

Linux -like most computer architectures- has a several different API software interfaces to allow applications to deal with audio. The most important ones are OSS (open sound system), ALSA (Advanced Linux Sound Architecture) and portaudio (cross-platform audio API). The "thelinkbox" application uses OSS.

As the raspian linux distribution that comes with the Raspberry pi by default only contains the ALSA API, the "alsa-oss" must be added to the system. This package is a emulation-layer that allows application to use the OSS API, although in the background the ALSA API is used.

 

Alsa-oss includes some kernel-modules that must be loaded. This is done as follows:

  • Install package:
    sudo apt-get install alsa-tools alsa-oss
  • Load kernel modules:
    sudo modprobe snd-pcm-oss
    sudo modprobe snd-mixer-oss
  • Verify that the OSS audio-devices are found:
    ls -l /dev/dsp*

    This should present two devices:
    /dev/dsp
    /dev/dsp1.

    These two interface are software interfaces pointing to particular hardware devices. /dev/dsp is the device of the onboard audio device of the bcm2835 chip of the raspberry pi. This device is playback only.
    /dev/dsp1 is the device interface for the external USB audio-fob.

  • For the kernel-modules to be loaded at boottime of the raspberry pi, modify the file below: sudo nano -w /etc/modules and add the following lines at the end of the file: snd-mixer-oss
    snd-pcm-oss
    After editing, the file should look like this:
 # /etc/modules: kernel modules to load at boot time.
 #
 # This file contains the names of kernel modules that should be loaded
 # at boot time, one per line. Lines beginning with "#" are ignored.
 # Parameters can be specified after the module name.
 snd-bcm2835
 snd-mixer-oss
 snd-pcm-oss
  • save file (control-o) and exit nano (control-x)
  • Reboot the raspberry pi to verify that the modules are correctly loaded at boottime: sudo reboot
  • After reboot do the following commands to verify that the OSS audio API has correctly detected the audio device:
    ls -l /dev/dsp*
    Again, both /dev/dsp and /dev/dsp1 should be shown.
 

 

Step 3: configuring a fixed ip-address and port forwarding

An echolink node (both in link or a repeater setup) require ipv4 port forwarding to be configured on the router of your network. For that, it is required that the raspberry pi uses a fixed IP address on your LAN network.

The process to configure a fixed IP address on the raspberry pi requires modifying the file /etc/network/interfaces. The process is found on a number of places on the web like: raspberryshake, penguintutor or elinux.

Information on how to set up portforwarding for echolink can be found on the echolink website and on portfward.com

 

Step 4: download source + compile + install "thelinkbox"

Execute the following commands:
  • wget http://download.thelinkbox.net/thelinkbox-0.55.tgz
  • tar zxvf thelinkbox-0.55.tgz
_Erratum_ added: As reported by a number of people, the source-code on "download.thelinkbox.net" does not yet seams to contain the code-changes to add support for GPIO input/output.

For this reason, the following additional commands need to be added to change three files of the source-code of tlb.

    Go to the directory containing the source-code:
  • cd /home/pi/thelinkbox*/linkbox

  • Make a copy of the original files:
  • mv configvars.cpp configvars.cpp.orig
  • mv ports.cpp ports.cpp.orig
  • mv ports.h ports.h.orig

  • Get the new files:
  • wget http://villazeebries.krbonne.net/thelinkbox/configvars.cpp
  • wget http://villazeebries.krbonne.net/thelinkbox/ports.cpp
  • wget http://villazeebries.krbonne.net/thelinkbox/ports.h

End of temporary quick-fix.

  • cd /home/pi/thelinkbox*
  • ./configure
  • make && sudo make install
  • This process takes about 10 to 15 minutes;
 

Step 5: Prepare thelinkbox

Execute the following commands:
  • return to home directory:
    cd
  • create dedicated directory:
    mkdir tlb
    cd tlb

  • copy three sample configuration files:
    cp ../thelinkbox-0.55/tlb.conf.sample tlb.conf
    cp ../thelinkbox-0.55/port.conf.sample port0.conf
    cp ../thelinkbox-0.55/tlb.cmds.sample tlb.cmds

 

Step 6: modify tlb.conf

Modify the configuration file "tlb.conf". This can be done using the text-editor tool nano:
nano tlb.conf

 

The following lines need to be changed in the configuration file:

  • look for the following lines:
    ConferenceCall = W1AW
    Correct this with the correct value: (*)
    ;ConferenceCall = W1AW
    ConferenceCall = ON1ARF-L

  • Line to change:
    WorkingDir = /usr/home/tlb
    Correct line to:
    ; WorkingDir = /usr/home/tlb
    WorkingDir = /home/pi/tlb

  • Line to change:
    include /usr/home/tlb/port0.conf
    include /usr/home/tlb/port1.conf
    Replace as follows:
    ; include /usr/home/tlb/port0.conf
    include /home/pi/tlb/port0.conf

  • Line to change:
    ;ConfEnable = 0
    Remove ";" to activate this option: as we are a leafnode, there is no need to act as conference between users
    ConfEnable = 0
  • Line to change:
    ConferencePass = CW
    Replace with your password:
    ConferencePass = MyEcholinkPassword (if that happens to be your password :-) )

  • Line to change:
    ConferenceQth = Newington, Ct.
    Replace with your location:
    ConferenceQth = MyQTH, MyCountry

  • Line to change:
    EmailAdr = [email protected]
    Replace with the email-address the Echolink administrators can use to contact you.
    EmailAdr = [email protected]

  • Line to change:
    ;RunAsUser = tlb
    Change to:
    RunAsUser = pi

  • Line to change:
    ;ConfAudioTimeout = 800
    Replace with higher value (especially is the pi is connected behind a wireless lan network):
    ConfAudioTimeout = 3000
  • save file:
    do control-o control-x
 

(*) Methode to modify text using nano:
use arrows to place cursor at correct line
press "control-K" to delete the line
press "control-U" TWICE to undelete the line + and create an additional line
place cursor at the beginning of the first line
type ";" to convert line into comment
place cursor at 2nd line, replace value "W1AW" with correct value

In the end, the line should look like this:
; ConferenceCall = W1AW
ConferenceCall = ON1ARF-L
Although it is not strictly necessary, it is usually a good idea, when modifying a configuration file, to keep a copy of the lines for later reference. Adding a ';' in front of the linux will invalidate it.

 

Step 7: modify port0.conf

Modify the configuration file "port0.conf". This can be done using the text-editor tool nano:
nano port0.conf

The following lines need to be changed in the configuration file:
  • Line to change:
    TxKeyMethod = 3Change to GPIO keying (*)
    TxKeyMethod = 7

  • Add this line to select GPIO port 17 for PTT switching:
    GpioSysClassId = 17
(*) for using a USB-to-serial adapter for PTT switching, see below. (bottom of the document).
  • Line to change
    RxCosMethod = 5
    Change to "vox":
    RxCosMethod = 0

  • Line to change:
    AudioDevice = /dev/dsp
    Change to:
    AudioDevice = /dev/dsp1

  • Line to change:
    ;PCMRate = 48000
    Remove leading ';' to activate:
    PCMRate = 48000
  • Line to change:
    CWId = de w1aw
    Change to the CW "id" message you would to be send, e.g. your callsign:
    CWId = ON1ARF

  • Line to change:
    ;VoxThreshold = 4000
    Change to:VoxThreshold = 500

  • Line to change:
    ;VoxHoldTime = 1250
    Change to:
    VoxHoldTime = 2250

  • Save file:
    do "control-o control-x"
 

 

Step 8: starting thelinkbox

To start thelinkbox in debug code:
/usr/local/libexec/tlb -f /home/pi/tlb/tlb.conf -d -d

To start thelinkbox in normal (daemon) mode:

/usr/local/libexec/tlb -f /home/pi/tlb/tlb.conf

 
automatic start tlb after rebooting the raspberry pi:
(to be written)

 

 

Step 9: controlling thelinkbox:

Thelinkbox contains an application to issues commands to the tlb daemon process: tlbcmd.
Some commands that can be used are:
  • help
  • connect CALLSIGN-R: connect to repeater via echolink
  • connect CALLSIGN-L: connect to link
  • connect *ECHOTEST*: connect to a echolink conference
  • users: provide list of active connections
  • disconnect CALLSIGN
  • disconnect last
  • disconnect all
  • set TxKeyMethod=0: disable PTT switching.
  • set TxKeyMethod=7: enable PTT switching
  • shutdown (stop tlb)
 

Thelinkbox can also be controlled using DTMF. See the file "tlb.cmds" for a list of commands as have been configured by default on thelinkbox.

 

 

Step 10: setting audio-levels

Setting the audio-levels of the echolink node is very important. It must be set sufficiently high for the vox-controlled carrier-sense mechanism to work correctly. Setting it too high will result in distorted audio.

 

To allow linknodes to set the audio-level correctly, the echolink network provides the ECHOTEST conference.

This is the procedure to follow:

  • start up thelinkbox (see above)
  • Connect to the ECHOTEST conference:
    Either use tlbcmd: tlbcmd "connect *ECHOTEST*"
    Or use DTMF code "9999" on your radio

  • Use alsamixer to set audio volume correct:
    do alsamixer
    press F6 to select correct audio device
    press <TAB> twice to select both "capture" and "playback" in one screen
    use arrow-keys to select correct slider
    Transmit using a radio: listen to returned audio

  • When the audio-level is correct, save audio-settings:
    press <ESC> to exit from alsamixer
    do "sudo alsactl store"

  • Disconnect from the ECHOTEST conference:
    or using tlbcmd "disconnect *ECHOTEST*"
    or via DTMF command "*"
 

Using standard handheld radios and off-the-shelf USB audio-fob devices, it is not uncommon to have to set up gain and volume parameters very low. Tests using a wouxum handheld radio showed these values as good working parameters:

  • volume setting on the radio set to 2 out of a scale of 1 to 10
  • alsamixer capture gain set to to 5 (out of a scale of 0 to 100)
  • alsamixer playback ("pcm") set to 25
 

Especially DTMF decoding seams to require very sensitive to the volume settings of the radio and capture gain. Setting the volume of the transceiver too high can result in very bad performance for DTMF decoding.

 

 

DONE!!!

After all this, the link-node is read to use.

Some other things that might be interesting:

  • Check the file "tlb.cmds" for DTMF commands that can be used. This file can be manually addapted to add, remove or change other commands. Don't forget to stop and restart thelinkbox to activate the changed
  • Check the two configuration files (tlb.conf and port0.conf) for other options that can be set or changed. Some other interesting options include APRS to put your node on aprs.fi, using "speech-to-voice" application to play our messages, and others.
  • Check the "hosts" file (/home/pi/hosts) that is created automatically when login into the echolink server. It contains a list of all echolink nodes. Especially interesting are the "converence-servers". Some of them are dedicated for discussions in a certain language, some are more generic chat / net-conferences and others are more technical oriented.
 

For more information and discussions on thelinkbox or echolink in general, there are two mailinglists on yahoo that are quite interesting:

  • http://groups.yahoo.com/group/thelinkbox/
  • http://groups.yahoo.com/group/echolink/
 

 

Hardware interface to connect Raspberry pi to the transceiver

Connecting the radio to the raspberry pi can be done in a number of different ways. Most of them are similar to the interfaces using for "digital mode" communication (RTTY, PSK, ...) on HF or for the "c2gmsk project".

 

Different options are:

  • The isolation of the audio-signal between the radio and the RPi can be done using capacitors or via coils
  • Switching the PTT of the radio can be done via the serial interface or via a GPIO pin of the RPi.
 

Find below an example of a basic interface-board using DC-blocking capacitors and the GPIO pins of the Raspberry pi. See here for more info on the GPIO pins on the RPi.

 

 

-> Audio in Dongle   -----||----- audio out radio ->
                          C
-> audio out dongle  -----||----- audio in  radio ->
                          C

C = DC-blocking capacitor
RPi GND (P01-06)         ---------------- gnd

                                    / PTT radio
                                   /
RPi GPIO18 (P01-12)  --|>|--|==|--|
                        D    R    T\
                                    >---------- gnd
D = Diode
R = Resistor (33 K)
T = Transistor (NPN)

 

 

Using a USB-to-serial adapter

If switching the PTT of the transceiver is done via one of the control-signals of a serial adapter (an approach very common in commercial, the following changes need to be done:

  • In the configuration file "port0.conf", "TxKeyMethod" must be set to 3 (RTS)
  • In the configuration file "port0.conf", "DevName" must be set to the serial device used for PTT switching. When using a USB-to-serial adapter, that device will be called "/dev/ttyUSB0".
  • In the hardware interface circuit mentioned above, the connection "RPi GND (P01-06)" should be replaced by "GND (RS232 DB9 pin 5)"
  • In the hardware interface circuit mentioned above, the connection "RPi GPIO18 (P01-12)" should be replaced by "RTS (RS2332 DB9 pin 7)"
More information about the pin-layout of the DB9 connector for RS232 can be found here.

 

Have fun!!!

73 Kristoff - ON1ARF

(document version 20130511)

⚠️ **GitHub.com Fallback** ⚠️