How is svxlink going…

So far the svxlink on raspi is working stable. It runs several days without problems, no system lockup or svxlink crash.

There is however a problem with the behaviour of svxlink. Besides the “normal” audio delay, svxlink sometimes sits there and does nothing…

The squelch events stop to be  processed and there is no audio output. After a few seconds svxlink seems to catch up an at least a short audio tail is send. After this, everything is back to normal for a few more minutes.

Looking at the cpu usage of svxlink with top, it appears that during those hangs the cpu usage drops down to idle level from the normally higher cpu level associated with processing audio.

I took some strace of the svxlink process during such events, but I’m not familiar with the code enough…

In meanwhile I’m working on the pre-/de-emphasis of the repeater to make echolink/announcements AND repeated audio to sound good.

A recent article on audio processing shows that even low delay audio processing can be done on the raspi  (<= 10ms) ! Have a look at:

http://guitarextended.wordpress.com/2013/01/27/real-time-guitar-effects-with-raspberry-pi-pd-and-arduino/

 

Are you lucky? No USB to serial converter needed!

All model B-V2 (and model A) owners can set-up their svxlink system without the need of an external USB-2-serial converter. All raspi versions offer a built-in serial port, but only the data signals (RXD/TXD) are available on the GPIO header (see http://elinux.org/RPi_Low-level_peripherals). With the arrival of the version 2 boards things improved. A new connector P5 was introduced. It is right next to the extension header P1, but as shipped there are no pins equipped.

Details on the P5 header can be found at http://www.raspberrypi-spy.co.uk/2012/09/raspberry-pi-p5-header/

Of interest to us are the pins 5+6 (GPIO30+GPIO31). The chip on the raspi allows different mappings as can be found at http://elinux.org/RPi_BCM2835_GPIOs . As can be seen there, GPIO30+GPIO31 can be switch to be RTS0/CTS0 in mode “ALT3”.

To use the IO pins we first need to “free” the serial port for our usage. The default configuration of the linux image uses the built in serial port to dump kernel messages and as a way to log into your raspi.

From /boot/cmdline.txt we need to remove the following options:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

We also need to stop the system to spin up a terminal on the serial port. For this we put the following statement in /etc/inittab into comment (add # in front of the line):

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200

OK, the serial port is ours, but we still need a tool to switch the GPIO assignment.

# as pi user, 
cd /home/pi
mkdir rpi-tools
cd rpi-tools/
# if you have not yet installed git, this must be done upfront
# see comments section below on how to do this
git clone https://github.com/rewolff/bw_rpi_tools.git
cd bw_rpi_tools/gpio
# depending on the version or status of the tools you might need to fix the Makefile
# see comments section below
make
sudo make install

We can now check the current pin assignment:

sudo gpio_list

To reassign the pins to the RTS/CTS function we use the following command:

sudo gpio_setfunc 31 ALT3
sudo gpio_setfunc 30 ALT3

To make this restart safe, we put the command into /etc/rc.local:

# enable CTS+RTS on P5 header for onboard serial
/usr/local/bin/gpio_setfunc 31 ALT3
/usr/local/bin/gpio_setfunc 30 ALT3

Bingo. We can now use the built-in serial port in the svxlink configuration by referring to the device: /dev/ttyAMA0 . In svxlink.conf we use:

SERIAL_PORT=/dev/ttyAMA0

Until the advent of direct raspi GPIO support in svxlink above few lines will be of help.

WARNING: When connecting external circuitry to the raspi GPIO pins, please be reminded that the Raspberry Pi only support 3.3V signal level. So in the best interest of your raspi keep this in mind!

Are you up for a challenge… USB and raspi

Unfortunately, there is a variety of problems surrounding the USB ports on the Raspberry Pi.

First there are power related problems, especially on the Model-B-V1 boards. The build-in fuses seem to cause problems with some USB periherals (http://elinux.org/RPi_Hardware#Power_Supply_Problems).

Even after all the improvements that happened in the firmware over last months, there are still problems with various devices and their drivers.

I had problems with a FTDI USB-2-serial converter used for the svxlink TRX interface. It would lock up the raspberry after a few hours :-(   Similar converters based on other chips (using other drivers) appear to be more well behaved.

I will have to add a dedicated post for USB audio, but a similar situation exists with such devices. Many provide choppy audio.

For all above problems there seems to be solution, even though with some limitations…

The USB port speed can be restricted to USB1.1 speeds by adding a kernel command line option. To do this, edit /boot/cmdline.txt and add the following option INTO THE SAME LINE as all the existing options you will find there:

dwc_otg.speed=1

The downside seems to be with USB keyboards. If connected they seem to lock up. This was no issue for me, as I only connect to the system over the network… talking of which – the Ethernet network will also be limited by this change. The 12 Mpbs still provide enough bandwidth for full-duplex audio and an echolink connection😉

Installing svxlink trunk version

For the more ventures girls and guys there is also the possibility to install the development version of svxlink. In my limited testing there was no difference in behaviour between the released and the trunk version.

# install svn support
sudo apt-get install subversion   
# get newer sigc++ lib
sudo apt-get install libsigc++-2.0-dev

# get svxlink trunk
cd /home/pi/svxlink
# taken from http://svxlink.de/?page_id=9
svn co https://svxlink.svn.sourceforge.net/svnroot/svxlink/trunk svxlink-trunk
# Checked out revision 2256.

# cd into source directory and type make....
cd svxlink-trunk/src
make
# the following will overwrite any previous svxlink installation - config files SHOULD be kept
sudo make install

Installing svxlink

The basic description (in German language) can be found in the article by Stefan http://svxlink.de/?page_id=1606 as shown in an earlier post.

Here a brief command summary from my installation:

sudo apt-get install g++ make libsigc++-1.2-dev libgsm1-dev libpopt-dev 
tcl8.5-dev libgcrypt-dev libspeex-dev libasound2-dev alsa-utils

as user pi:
cd /home/pi
mkdir svxlink
wget 
http://sourceforge.net/projects/svxlink/files/svxlink/11.11/svxlink-11.11.1.tar.gz
tar xvzf svxlink-11.11.1.tar.gz
cd svxlink-11.11.1
# make release takes much longer to compile, but reduced CPU load significantly
make release
sudo make install
# get sounds
cd /home/pi/svxlink
mkdir sounds
cd sounds/
# get german sounds
wget http://svxlink.de/download/stimmen-mary.tar.bz2
# get en_US sounds
wget 
http://sourceforge.net/projects/svxlink/files/sounds/11.11/sounds-en_US-heather-11.11.tar.bz2
wget 
http://sourceforge.net/projects/svxlink/files/sounds/11.11/sounds-en_US-heather-16k-11.11.tar.bz2

# unpack desired sound files, for example:
tar -xvjf stimmen-mary.tar.bz2
sudo mkdir /usr/share/svxlink/sounds/
sudo mkdir /usr/share/svxlink/sounds/de_DE
# install 8k female audio
sudo cp -a stimmen-mary/stimmen-mary/8k-female/* /usr/share/svxlink/sounds/de_DE
# and/or english audio files
tar -xvjf sounds-en_US-heather-11.11.tar.bz2
#(if not done before: sudo mkdir /usr/share/svxlink/sounds/ )
sudo mkdir /usr/share/svxlink/sounds/en_US
sudo cp -a en_US-heather/* /usr/share/svxlink/sounds/en_US

Updating kernel and the firmware

Once the initial OS set-up is completed, we want to update the kernel and firmware. A description can be found at https://github.com/Hexxeh/rpi-update

First we need to install a tool to help us with the update :

sudo apt-get install git-core
mkdir ~/software
cd ~/software
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update

As next step we run the update:

sudo rpi-update

A reboot will be required to activate the newly downloaded kernel & firmware.

sysinfo.sh

I haven’t posted any details on overclocking and firmware update yet, and before I do it is possibly a good idea to recommend adding the following script to your system (as can be found e.g. at http://youresuchageek.blogspot.de/2012/09/howto-raspberry-pi-openelec-on.html):

sudo bash
vi /usr/local/bin/sysinfo.sh
#!/bin/sh
echo "\n###############################################"
echo "# RASPBERRY PI SYSTEM INFORMATIONS #"
echo "###############################################"

echo "\nCPU current Frequency: `vcgencmd measure_clock arm`"
echo "CORE current Frequency: `vcgencmd measure_clock core`"
echo "CORE current Voltage: `vcgencmd measure_volts core`"
echo "CPU current Temperature: `vcgencmd measure_temp`"

echo "\nFirmware Version: `vcgencmd version`\n"

echo "Codecs Status:"
echo "`vcgencmd codec_enabled H264`"
echo "`vcgencmd codec_enabled MPG2`"
echo "`vcgencmd codec_enabled WVC1`"

echo

I will use “vi” as editor. Please replace with your favourite linux editor.

We now mark the script as executable:

chmod +x /usr/local/bin/sysinfo.sh

Executing the script will give us information on the system:

oot@raspberrypi:/home/pi# sysinfo.sh

###############################################
# RASPBERRY PI SYSTEM INFORMATIONS #
###############################################

CPU current Frequency: frequency(45)=700000000
CORE current Frequency: frequency(1)=250000000
CORE current Voltage: volt=1.20V
CPU current Temperature: temp=41.2'C

Firmware Version: Oct 25 2012 16:36:25
Copyright (c) 2012 Broadcom
version 346337 (release)

Codecs Status:
H264=enabled
MPG2=disabled
WVC1=disabled

One might add info on the running kernel version using the following command:

uname -a

The output will look like this:

Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l