Skip to content

Instantly share code, notes, and snippets.

@silveraid
Last active January 18, 2021 11:46
Show Gist options
  • Save silveraid/6b91a0e716c6bc9f6b525d407bf9c544 to your computer and use it in GitHub Desktop.
Save silveraid/6b91a0e716c6bc9f6b525d407bf9c544 to your computer and use it in GitHub Desktop.
Asterisk

Debian 9 + Dahdi 2.11 + libpri 1.6 + Wanpipe 7 + Asterisk 13

1. Installing pre-requisites

1.1. Installing dev packages

apt-get update
apt-get install -y build-essential flex bison libreadline-dev libssl-dev gettext libtiff-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev doxygen libncurses-dev libtool automake autoconf linux-headers-4.9.0-4-amd64 linux-headers-4.9.0-4-common linux-kbuild-4.9 wget vim

1.2. Creating a combined Linux kernel header folder

Sangoma driver needs this, is Debian a supported OS?

cd /usr/src
ln -s linux-headers-4.9.0-4-common linux
cd /usr/src/linux
ln -s /usr/src/linux-headers-4.9.0-4-amd64/.config .
ln -s /usr/src/linux-headers-4.9.0-4-amd64/.kernelvariables .
ln -s /usr/src/linux-headers-4.9.0-4-amd64/Module.symvers .
ln -s /usr/src/linux-headers-4.9.0-4-amd64/include/config include/.
ln -s /usr/src/linux-headers-4.9.0-4-amd64/include/generated include/.
ln -s /usr/src/linux-headers-4.9.0-4-amd64/arch/x86/kernel arch/x86/.
ln -s /usr/src/linux-headers-4.9.0-4-amd64/arch/x86/include/generated arch/x86/include/.

2. Compiling Dahdi 2.11.1 from source

2.1. Download the source

wget -c http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.11.1+2.11.1.tar.gz

... or alternatively ...

wget -c http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

2.2. Compile and Install

tar -xf dahdi-linux-complete-2.11.1+2.11.1.tar.gz -C /usr/src
cd /usr/src/dahdi-linux-complete-2.11.1+2.11.1
make -j4
make install

3. Compiling libpri 1.6.0 from source

3.1. Download the source

wget -c http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.6.0.tar.gz

... or alternatively ...

wget -c http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz

3.2. Compile and Install

tar -xf libpri-1.6.0.tar.gz -C /usr/src
cd /usr/src/libpri-1.6.0
make -j4
make install

4. Compiling Asterisk LTS 13.18.2 from source

4.1. Download source

wget -c http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.18.2.tar.gz

... or alternatively ...

wget -c http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz

4.2. Compile and Install

tar -xf asterisk-13.18.2.tar.gz -C /usr/src
cd /usr/src/asterisk-13.18.2
./configure
# optional: make menuselect
make -j4
make install

4.3. Install init scripts

make config

5. Compiling Sangoma driver (wanpipe) from source

5.1. Getting the source code

wget -c ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-7.0.24.tgz
tar -xf wanpipe-7.0.24.tgz -C /usr/src

5.2. Patch wancfg_dahdi

cd /usr/src/wanpipe-7.0.24
vim util/wancfg_zaptel/wancfg_dahdi

Update at the end from

./wancfg_zaptel.pl --dahdi  --conf_dir=$WAN_BASE $ARGS

to

/usr/bin/perl -I ${WAN_HOME}/wancfg_zaptel ./wancfg_zaptel.pl --dahdi  --conf_dir=$WAN_BASE $ARGS

5.3. Compile and Install

./Setup install

Tips:

  • Specify /usr/src/linux as your kernel source folder ...
  • Don't worry about the kernel version mismatch ...
  • Visually verify the compilation ...
  • If kernel module does not load check output of dmesg ...

5.4. Configure card

wancfg_dahdi

... follow steps on the screen, make sure asterisk restarted at the end ...

6. First commands in Asterisk (for rookies)

asterisk -r
pri show spans
dahdi show channels

Tab completion works in the asterisk cli shell ...

@information-security
Copy link

information-security commented Jun 27, 2019

I could have never find out how to do the "combined Linux kernel header folder" part! How did you come up with that anyway?
Thank you. I spent 2 days on it with no progress until I saw this.

I have another problem now. WANPIPE LibSangoma API and generally Wanpipe Utilities fail to compile complaining about:

                !!! WANPIPE Tools Compilation Failed !!!
        Possible solution:
                 Wanpipe header files were not installed properly

BTW, I am seeing a warning before that:

WARNING: The Linux source in /usr/src/linux has not been configur
         Please proceed to configure the source before compiling
         wanpipe utilities (ex: make menuconfig and make dep).

Any idea?

UPDATE

Running make dep in /usr/src/linux gives:

scripts/Makefile.build:44: scripts/basic/Makefile: No such file or directory
make[2]: *** No rule to make target 'scripts/basic/Makefile'.  Stop.
Makefile:444: recipe for target 'scripts_basic' failed
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target 'dep'.  Stop.

@silveraid
Copy link
Author

I could have never find out how to do the "combined Linux kernel header folder" part! How did you come up with that anyway?
Thank you. I spent 2 days on it with no progress until I saw this.

The kernel header files used to be under one folder, but then distributions started to split it up into different packages based on architecture by some reason so they ended up in different subfolders. These links just reunite the folders again, I guess there is a better way of doing it, but it did the job.

I have another problem now. WANPIPE LibSangoma API and generally Wanpipe Utilities fail to compile complaining about:

                !!! WANPIPE Tools Compilation Failed !!!
        Possible solution:
                 Wanpipe header files were not installed properly

BTW, I am seeing a warning before that:

WARNING: The Linux source in /usr/src/linux has not been configur
         Please proceed to configure the source before compiling
         wanpipe utilities (ex: make menuconfig and make dep).

Any idea?

UPDATE

Running make dep in /usr/src/linux gives:

scripts/Makefile.build:44: scripts/basic/Makefile: No such file or directory
make[2]: *** No rule to make target 'scripts/basic/Makefile'.  Stop.
Makefile:444: recipe for target 'scripts_basic' failed
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target 'dep'.  Stop.

make dep is history, it used to calculate the dependencies required to compile the kernel after the linux kernel's configuration was done. You can try make menuconfig and then save and exit without touching anything. It will pickup the proper values from the .config file which was already linked.

@information-security
Copy link

information-security commented Jul 1, 2019

The kernel header files used to be under one folder, but then distributions started to split it up into different packages based on architecture by some reason so they ended up in different subfolders. These links just reunite the folders again, I guess there is a better way of doing it, but it did the job.

There are really no documentation regarding these kind of changes on structure of kernel header files or at least I'm unable to find if there's any. However what you did is more than enough. I spent two days and I couldn't find anything near to a solution until I came across your gist.

make dep is history, it used to calculate the dependencies required to compile the kernel after the linux kernel's configuration was done. You can try make menuconfig and then save and exit without touching anything. It will pickup the proper values from the .config file which was already linked.

I was wondering why wanpipe is complaining about a not configured kernel source while I am having only kernel headers installed and as far as I know kernel headers suffice for wanpipe build. Anyway, It turned out that I was missing autoconf and automake dependencies. After installing them Wanpipe Utilities successfully built despite the warning about a not configured kernel source.

Afterward, I encountered another problem with the Wanpipe kernel module which was not copied to /lib/modules/4.9.0-9-amd64 directory and instead it was placed in /lib/modules/4.9.168 causing them not possible to be loaded into kernel (Symlink didn't help either). I fixed this problem by running two following commands in addition to yours:

rm /lib/modules/`uname -r`/build
ln -s /usr/src/linux /lib/modules/`uname -r`/build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment