Asterisk, mISDN, chan_capi and Debian Sarge HOWTO

Michael Dipper 03.11.2005

Please note that this page hasn't been updated for a while and most probably will show outdated information. It is mainly kept here for reference.

This documents briefly describes how to get the Asterisk PBX running based on a CAPI 2.0 stack on top of mISDN drivers together with a stock Debian Sarge installation. The focus is to use debian provided packages as much as possible.

Unfortunately latest mISDN drivers do not run with the stock debian kernel 2.6.8. Therefore we first install an updated kernel from http://www.backports.org.

Add backports.org sources to /etc/apt/sources.list:

deb http://www.backports.org/debian/ sarge-backports main

Deactivate packages to be fetched from backports.org by default, we will selectively choose packets from there. Put in /etc/apt/preferences:

Package: *
Pin: release a=sarge-backports
Pin-Priority: 200

Install the new kernel and reboot (currently it seems to be more stable to use the non-SMP kernel).

apt-get update
apt-get upgrade
apt-get -t sarge-backports install linux-image-2.6.15-1-686
apt-get install linux-source-2.6.15 

Prepare the kernel sources for building mISDN:

cd /usr/src 
tar xvpjf linux-source-2.6.15.tar.bz2 
ln -s linux-source-2.6.15 linux-2.6 
ln -s linux-2.6 linux 
ln -s /usr/src/linux-2.6 /lib/modules/2.6.15-1-686/build 
cd /usr/src/linux 
cp /boot/config-2.6.15-1-686 ./.config 
make oldconfig 
echo -1-686 > .extraversion

Prepare to build mISDN modules and get the latest sources from CVS:

cd /usr/local/src
export CVSROOT=:pserver:guest:readonly@cvs.isdn4linux.de:/i4ldev 
cvs login 
cvs co -r mqueue mISDN 

Now patch the kernel sources:

cd mISDN
./std2kern

Activate the mISDN modules in the kernel config by making the following settings:

cd /usr/src/linux
make prepare
Support modular ISDN driver (MISDN_DRV) [N/m/?] (NEW) m
  Enable memory leak debug for mISDN (MISDN_MEMDEBUG) [N/y/?] (NEW) n
  Support for AVM Fritz!Cards (MISDN_AVM_FRITZ) [N/y/?] (NEW) y
  Support for HFC PCI cards (MISDN_HFCPCI) [N/y/?] (NEW) y
  Support for HFC multiport cards (HFC-4S/8S/E1) (MISDN_HFCMULTI) [N/y/?] (NEW) y
  HFC multiport driver with memory mapped IO (HFCMULTI_PCIMEM) [N/y/?] (NEW) y
  Support for HFC-S USB based TAs (MISDN_HFCUSB) [N/y/?] (NEW) y
  Support for Sedlbauer Speedfax+ (MISDN_SPEEDFAX) [N/y/?] (NEW) y
  Support for Winbond 6692 based cards (MISDN_W6692) [N/y/?] (NEW) y
  Digital Audio Processing of transparent data (MISDN_DSP) [N/y/?] (NEW) y

Build the mISDN modules and install them:

make scripts
make SUBDIRS=drivers/isdn/hardware/mISDN modules
make SUBDIRS=drivers/isdn/hardware/mISDN modules_install

Delete /etc/init.d/misdn. We will load misdn drivers from /etc/default/capiutils

Therefore add to /etc/default/capiutils:

MISDN_MODULES="mISDN_core mISDN_l1 mISDN_l2 l3udss1 mISDN_capi"
MISDN_DRIVER="hfcpci protocol=0x2"

Reboot and check for proper detection and initialization of your card:

mISDNd: kernel daemon started
mISDNd: test event done
mISDN: DSS1 Rev. 1.29.2.12
mISDN_dsp: Audio DSP  Rev. 1.10.2.10 (debug=0xf)
mISDN_dsp: DSP clocks every 64 samples. This equals 8 jiffies.
mISDN Capi 2.0 driver file version 1.14.2.6
mISDN: HFC-PCI driver Rev. 1.39.2.16
mISDN: HFC-PCI card manufacturer: CCD/Billion/Asuscom card name: 2BD0
mISDNStackd started for id(00000100)
mISDNStackd started for id(10010100)
mISDNStackd started for id(10020100)
mISDN: HFC-PCI driver Rev. 1.39.2.16

If you want to run Asterisk as a user “asterisk” (recommended) be sure to fix the permissions on all directories and devices.

chown --recursive asterisk:asterisk /var/lib/asterisk
chown --recursive asterisk:asterisk /var/log/asterisk
chown --recursive asterisk:asterisk /var/run/asterisk
chown --recursive asterisk:asterisk /var/spool/asterisk
chown --recursive asterisk:asterisk /dev/mISDN
chmod --recursive u=rwX,g=rX,o= /var/lib/asterisk
chmod --recursive u=rwX,g=rX,o= /var/log/asterisk
chmod --recursive u=rwX,g=rX,o= /var/run/asterisk
chmod --recursive u=rwX,g=rX,o= /var/spool/asterisk
chmod --recursive u=rwX,g=rX,o= /dev/mISDN
chown --recursive root:asterisk /etc/asterisk
chmod --recursive u=rwX,g=rX,o= /etc/asterisk 

Your ISDN cards are defined in /etc/misdn-init.conf. The following example shows a configuration for two HFC-based cards. The first card is running in TE-mode (for connecting to the ISDN provider), the second one in NT-mode (for connecting phones).

#
# Configuration file for your misdn hardware
#
# Usage: /etc/init.d/misdn-init start|stop|restart|config|scan|help
#
#
# Card Settings
#
# Syntax: card=<number>,<type>[,<option>...]
#
#    <number>   count your cards beginning with 1
#    <type>     either 0x1,0x4 or 0x8 for your hfcmulti hardware,
#               or the name of your card driver module.
#    <option>   ulaw       - uLaw (instead of aLaw)
#               dtmf       - enable DTMF detection on all B-channels
#               pcm_slave  - set PCM bus into slave mode
#
card=1,hfcpci,pcm_slave
card=2,hfcpci

Avoid HiSax modules from being loaded. To achieve this, add the following lines to /etc/hotplug/blacklist.d/capiutils:

hisax
hisax_fcpcipnp

Get the latest chan_capi from http://sourceforge.net/projects/chan-capi. In future versions bristuffed asterisk packages will include chan_capi but currently this is not working properly.

apt-get install capiutils libcapi20-dev
cd /usr/local/src
tar xvpzf chan_capi-cm-0.6.3.tar.gz 
cd chan-capi
make
make install

Do not forget to edit /etc/asterisk/capi.conf <br> Check for correctly loaded capi within asterisk:

asterisk -r
capi info

Now you should be done :) In case you have any additions of corrections to this howto, feel free to contact me!