Tuesday, 08 March 2016 01:40

Freeswitch 1.7 + Raspberry Pi 2 = VoIP Sip Server

Written by 
Rate this item
(3 votes)

FreeSWITCH 1.7 Installed on Raspberry Pi 2

Installing, Compiling and running FreeSWITCH on the Pi 2

The long and awaited for... FreeSWITCH 1.7 running on a Raspberry Pi 2 guide.

We'll be using the latest (at the time of this writing) Raspbian image 2015-11-21-raspbian-jessie.img on a Raspberry Pi 2.  Thanks to the awesome Freeswitch team at https://freeswitch.org/ especially Brian West, Ken Rice, and William King for all of their efforts with the Freeswitch project and also helping me to get this working.

 

Raspbian running on your Pi

You'll first need to have the Raspbian image running on your Raspberry Pi.  You can follow my tutorials on setting up the SD Card (Windows) or (Linux) and then proceed to the initial setup to get your Pi running on your network in this guide: Raspberry Pi setup without a Monitor.

 

Installing Dependencies

In order to compile FreeSWITCH and it's modules, you need to install some dependencies.

Update your Pi packages

sudo apt-get update && sudo apt-get upgrade

The following packages were installed and I was able to successfully compile Freeswitch with the default modules in the modules.conf file, that were selected when I cloned the git master branch.  My default modules.conf of enabled modules is located at the bottom of this page for reference.  Note, If you enable/uncomment other modules in the modules.conf that gets created after running ./bootstrap.sh -j command below, you may require some additional dependencies.

sudo apt-get install autoconf automake devscripts gawk libjpeg-dev libncurses5-dev libtool-bin python-dev libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libedit-dev libldns-dev libpq-dev libsndfile1-dev libopus-dev liblua5.1-0-dev

pi 2 freeswitch install 01

These packages are required, but were already installed on my Raspbian (here for reference)

sudo apt-get install g++ git-core make pkg-config

These packages are required, but Installed by other packages. (here for reference)

sudo apt-get install libjpeg62-turbo-dev libtool

 

Setting Static IP to the Pi

FreeSWITCH requires a routable IP address in order for it to work properly.  It is HIGHLY recommended that you assign a static IP address to your Pi.  If not, starting FreeSWITCH at boot will not bind to the correct IP address as this process happens before the DHCP handshake has completed.

Make a copy of /etc/network/interfaces

sudo cp /etc/network/interfaces /etc/network/interfaces.old

Next we edit the network configuration file

sudo nano /etc/network/interfaces

You should have the default /etc/network/interfaces file that will look like this

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

We will change the above file to this.  Replace the section labelled under eth0 with the static IP information for your network, the new file should look like this

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.42
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8

dns-nameservers 8.8.4.4

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

Reboot

sudo reboot

 

Clone git FreeSWITCH Repo

You can clone to any directory, but we'll use the directory /usr/local/src and need to make it r/w to our user ($USER is a system variable, which will = the current user, pi in our case)

sudo chown $USER /usr/local/src

change to that directory

cd /usr/local/src

Clone the git repo (master branch)

git clone https://freeswitch.org/stash/scm/fs/freeswitch.git

 

Compile FreeSWITCH on the Raspberry Pi 2

Goto the FreeSWITCH source directory

cd /usr/local/src/freeswitch/

Confirm master branch

git checkout master

   Returned: Already on 'master' Your branch is up-to-date with 'origin/master'.

Build config files

./bootstrap.sh -j

Now we're at the point where you can enable/disable custom modules to compile along with the Freeswitch framework.  In this build, I left all the modules in modules.conf default (My enabled modules in modules.conf file is located below for reference).  You can always compile additional modules at a later point when they are needed.  I recommend leaving the modules.conf file alone if this is your first time compiling, you can read more about it below in the section Enabling additional Modules in modules.conf

Run configure

./configure -C

*Note: From Tom noted in the comments section below, "Also, if you want to apply fusionpbx AND use postgresql as the database, change the configure -C step to ./configure --enable-core-pgsql-support or else your sip profiles will not work. I haven't tried it with sqlite, but that is also an option."

 

Make (use jobs flag -j set to 4) in attempt to speed things up (this took ~30 minutes).  *Note: It's been reported that using -j4 may cause issues with compiling, use a maximum of -j3.  (You can even use -j2 to be safer to minimize compile failure, the lower number will only cause the compile process to be a little slower)

make -j3

Success!

pi 2 freeswitch install 02

Install FreeSWITCH

sudo make install

The FreeSWITCH binary is now located in the /usr/local/freeswitch/bin directory.

 

Compile sounds for FreeSWITCH

sudo make cd-sounds-install cd-moh-install

 

Auto Run FreeSWITCH at boot

We'll add freeswitch as a user, change a few permissions, copy the startup script and test the auto start of FreeSWITCH.

 

Create FreeSWITCH user, add password and set permissions

sudo adduser --quiet --gecos "FreeSWITCH Voice Platform" --ingroup daemon freeswitch

Set permissions on directories

sudo chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/*
sudo chmod -R ug=rwx,o= /usr/local/freeswitch/

sudo chown -R freeswitch:daemon /usr/local/freeswitch

Create link from source build to expected locations

sudo ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/freeswitch
sudo ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
sudo mkdir /etc/freeswitch
sudo ln -s /usr/local/freeswitch/conf/freeswitch.xml /etc/freeswitch/freeswitch.xml
sudo chmod ug=rwx,o= /etc/freeswitch
sudo chown freeswitch:daemon /etc/freeswitch
sudo cp /usr/local/src/freeswitch/debian/freeswitch-sysvinit.freeswitch.default /etc/default/freeswitch
sudo chown freeswitch:daemon /etc/default/freeswitch

Create working log directory

sudo mkdir /var/log/freeswitch
sudo chmod -R ug=rwx,o= /var/log/freeswitch
sudo chown freeswitch:daemon /var/log/freeswitch

Copy the start-up script to /etc/init.d/ directory and change permissions

sudo cp /usr/local/src/freeswitch/debian/freeswitch-sysvinit.freeswitch.init  /etc/init.d/freeswitch
sudo chmod u=rwx,g=rx,o= /etc/init.d/freeswitch
sudo update-rc.d freeswitch defaults

FreeSWITCH will now auto start when the Raspberry Pi boots up

Reboot to confirm everything is working

sudo reboot

Check the status of FreeSWITCH

sudo /etc/init.d/freeswitch status

pi 2 freeswitch install 05

 

 

You may also want to confirm FreeSWITCH is listening on port 5060 (for troubleshooting)

netstat -ln

pi 2 freeswitch install 08

 

Register to Extension 1000

FreeSWITCH has a few default extensions.  As a simple test to see if FreeSWITCH is working, we'll register a sip client to extension 1000, with the default password is 1234.

Log into FreeSWITCH command line to assist in troubleshooting (type /exit to exit the freeswitch command line)

su freeswitch
fs_cli

Using your favorite SIP client on the same network as the Freeswitch server, register with extension 1000

  • SIP Proxy/Server = <raspberry-pi-ip-address>
  • SIP Port = 5060
  • User ID/Name = 1000
  • Password/Authentication = 1234

While you are logged into the fs_cli, turn on sip trace debug

sofia global siptrace on

Then from your SIP client, attempt to register, viewing the SIP trace can greatly assist in troubleshooting.

pi 2 freeswitch install 06

Once you are registered, try to call some test extensions

  • 9198 = tetris music
  • 9197 = mw tone
  • 9196 = echo test
  • 5000 = Default IVR (FYI screaming monkeys are DEAD!, not really, currently routes to a dead external number, you can dial ***This email address is being protected from spambots. You need JavaScript enabled to view it. if you need your monkey fill)
  • 9664 = Music on Hold

 

9198 was called from a sip client

pi 2 freeswitch install 07

 

Enabling additional Modules in modules.conf

WORK IN PROGRESS....This is more of an advanced section that you would do after you run ./bootstrap.sh -j command. If this is your first time compiling FreeSWITCH, I recommend to skip over this step, until you have successfully compiled and installed FreeSWITCH using the default modules.conf.  You can then come back to this section to enable additional modules and recompile.  Keep in mind each module may require one or more dependencies which may or may not be available for your distribution.  It's also a good idea to clean out your working git clone directory before re-compiling (git clean -d -x -f), I ran into errors compiling some modules if I didn't.  Note that this will delete all files and directories, and you will need to start at running bootstrap.sh -j again.

You may need to enable/uncomment some additional modules in modules.conf to meet your Freeswitch needs.   

nano /usr/local/src/freeswitch/modules.conf

There are many modules available, below are a few I wanted to experiment with, along with the dependencies that were required to be installed to allow the module to compile.

- asr_tts/mod_flite

Requires at least libflite-dev which is not available in the Raspbian repository, couldn't get to compile, disapointing....

- formats/mod_shout

Requires libshout3-dev libmpg123-dev libmp3lame-dev

sudo apt-get install libshout3-dev libmpg123-dev libmp3lame-dev

- mod_portaudio

...todo

- mod_portaudio_stream

...todo

codecs/mod_siren

...todo

- mod_python

...todo

- mod_vlc

..todo libvlc version 1.2 or later for mod_vlc to work

- mod_h323

..todo  requires many...not likely...

- mod_sonar

...todo

- mod_curl

...todo

 

Conclusion

FreeSWITCH 1.7 does compile and run on the Raspberry Pi 2.  I have not done any extensive testing yet, but FreeSWITCH is running, and I was able to register SIP endpoints and make calls between them. 

 

Defualt modules.conf file

default modules.conf (for reference) (this only shows modules that are enabled)

applications/mod_commands
applications/mod_conference
applications/mod_db
applications/mod_dptools
applications/mod_enum
applications/mod_esf
applications/mod_expr
applications/mod_fifo
applications/mod_fsv
applications/mod_hash
applications/mod_httapi
applications/mod_sms
applications/mod_spandsp
applications/mod_valet_parking
applications/mod_voicemail
codecs/mod_amr
codecs/mod_b64
codecs/mod_g723_1
codecs/mod_g729
codecs/mod_h26x
codecs/mod_opus
dialplans/mod_dialplan_asterisk
dialplans/mod_dialplan_xml
endpoints/mod_loopback
endpoints/mod_rtc
endpoints/mod_skinny
endpoints/mod_sofia
endpoints/mod_verto
event_handlers/mod_cdr_csv
event_handlers/mod_cdr_sqlite
event_handlers/mod_event_socket
formats/mod_local_stream
formats/mod_native_file
formats/mod_png
formats/mod_sndfile
formats/mod_tone_stream
languages/mod_lua
loggers/mod_console
loggers/mod_logfile
loggers/mod_syslog
say/mod_say_en
xml_int/mod_xml_cdr
xml_int/mod_xml_rpc
xml_int/mod_xml_scgi

 

References:

Raspberry Pi Model:

Raspberry Pi 2 Model B

Raspberry Pi Image:

2015-11-21-raspbian-jessie.img

cat /etc/*-release:

Raspbian GNU/Linux 8 (jessie)

Kernel (uname -ro):

4.1.19-v7+ GNU/Linux

FreeSWITCH Version:

FreeSWITCH Version 1.7.0+git~20160310T230555Z~566cc41908~32bit (git 566cc41 2016-03-10 23:05:55Z 32bit)

 

Clean Git Folder (bring back to last commit state, deletes all untracked files, directories)

git clean -d -x -f

Get commit hash (only here for reference, on the specific commit that I used for compiling)(run in the git directory ie: /usr/local/src/freeswitch/)

git log -1 --format="%H"

   Returned: 566cc41908390307e9bc49a049e81f48a33fd8e3

 Manually start FreeSWITCH (for reference)

sudo /etc/init.d/freeswitch start

https://freeswitch.org/confluence/display/FREESWITCH/Debian+7

 

 

Read 18077 times Last modified on Tuesday, 26 April 2016 13:43
Algis Salys

Creator and owner of algissalys.com.  Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.