Compiling Dahdi Modules on Linode

Happy New Years everyone! This holiday I decided to work on setting up Asterisk, which is an open source pbx system. I had some issues where I wasn't getting any audio and it became apparent that I needed to compile the dahdi_dummy kernel module for a timing source. Since my VPS account is hosted at Linode, where they run Xen, I'm able to build my own kernel modules and my own kernel images if I wanted.

I was using the 2.6.18.8 kernel and everything built fairly easily under that, but modprobe had a segmentation fault when I loaded the dahdi_dummy module. Linode recently made the 2.6.28 kernel available, so I decided to give that a try instead.  I prefer to use the kernels that Linode provides for the stability and support.  Linode makes the kernel source available from which the kernels are built.  I did run into a few glitches though.  The first was that the dahdi modules were looking for bounds.h, which did exist.  It seems that "make clean" removes some of the generated header files.  Running "make prepare" solves that quickly (thanks caker).  I then found that the scripts/genksyms/genksyms binary was compiled for 64bit Linux.  Since I'm using a 32bit distribution, that didn't work out so well.  That part of the kernel tree needs to get cleaned and rebuilt in order to compile the dahdi modules.  After messing around awhile, I ended up rebuilding the entire kernel just to get a few small files.  I decided it's be best to write a small script to only clean the sections I need and make this easier next time around.

The script I used is below.

#!/bin/bash
#
# Script to clean genksyms in the kernel source and prepare the source to be
# used when compiling modules for things like asterisk.  This was needed to
# remove binaries in the scripts tree because the Linode kernels are built on
# a 64bit server and my Linode is using a 32bit distribution.
#
# Copyright (c) 2009 Patrick Hennessy
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#

# Set this to where your kernel source is placed.  I usually have a symlink
# for both of the locations below.
#
# KSOURCE=/lib/modules/$(uname -r)/build
#
KSOURCE=/usr/src/linux

# Simple test for the Makefile.
#
if [ ! -e $KSOURCE/Makefile ]; then
        echo "Can't find $KSOURCE/Makefile.  Make sure $KSOURCE exists."
        exit
fi

# Patch the Makefile to clean the scripts tree when doing clean.
#
patch -d $KSOURCE << END
--- ../2.6.28-linode15.orig/Makefile    2008-12-29 15:36:08.000000000 -0500
+++ Makefile    2009-01-01 03:08:19.000000000 -0500
@@ -1174,7 +1174,7 @@
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs      := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation)
+clean-dirs      := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation scripts)

 PHONY += $(clean-dirs) clean archclean
 $(clean-dirs):
@@ -1194,7 +1194,7 @@
 #
 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
-mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook scripts)
+mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook)

 PHONY += $(mrproper-dirs) mrproper archmrproper
 $(mrproper-dirs):
END

# Run make targets to prepare the tree.
#
make -f $KSOURCE/Makefile clean
make -f $KSOURCE/Makefile oldconfig
make -f $KSOURCE/Makefile scripts/genksyms/
make -f $KSOURCE/Makefile prepare

This should be useful for other Linode users building dahdi or other kernel modules under 32bit Linux distributions.

[2009-Jan-01 EDIT:  The reason I didn't do "make mrproper" or "make distclean" is that I needed the Module.symvers file, which is created during the kernel compile.  That file appears to be used to add symbols when building modules.  Even while using difference force options, I was getting "no symbol version for struct_module" errors.  Once that Module.symvers file was present, I was able to build and load the modules as expected.]

[2009-Jan-02 EDIT: You may be using a different version of gcc than what the Linode kernel was compiled with. In that case, you'll need to pass the "--force-vermagic" option to modprobe when loading the module.]

[2009-Jan-02 EDIT: Updated the script to run oldconfig after the clean stage.]

Tags: , , ,

11 Responses to “Compiling Dahdi Modules on Linode”

  1. Timur I. Alhimenkov Says:

    Great! Thank you very much!
    I always wanted to write in my site something like that. Can I take part of your post to my blog?
    Of course, I will add backlink?

    Regards, Reader

  2. glorious Says:

    I don't have good exprince with asterisk yet I am using asterisk vps to call host my family phone system, I think your script is just for me, yet I don't know how to use it. I will be glad if you explain what I need to do to use your script.
    thanks

  3. path Says:

    I just tried this with the 2.6.29-linode18 kernel source and the script generated a few errors (with the make commands, not the patch part). I ran the make commands by hand and it worked fine. Maybe I had to be in the /usr/src/linux directory.

  4. box2 Says:

    you are seriously a hero among men. thank you very much.

  5. box2 Says:

    oh, also worth noting: default Linode installs now come with gcc 4.3 while the kernels were compiled with gcc 4.2, so downgrading gcc was necessary for me to make the modules compatible.

  6. Andrew Says:

    On CentOS 5.5 I am getting.

    [root@vici 2.6.32.12-linode25]# ./linode-kernel-prep.sh
    patching file Makefile
    patch: **** malformed patch at line 8: Documentation)

  7. Andrew Says:

    It worked whats on this page but now stuck with:

    #service dahdi start

    xpp_usb: FATAL: Module xpp_usb not found.
    [FAILED]

    /usr/share/dahdi/waitfor_xpds: Missing astribank_is_starting
    No hardware timing source found in /proc/dahdi, loading dahdi_dummy
    Running dahdi_cfg: Notice: Configuration file is /etc/dahdi/system.conf
    line 0: Unable to open master device '/dev/dahdi/ctl'

  8. path Says:

    Andrew, that post is about a year and a half old. It also was for 2.6.28, not 2.6.32. I'm not even sure if it's needed anymore. To be honest, I've been running Asterisk without the Dahdi modules (no need for conferencing and whatnot). So, I haven't messed with this stuff in quite a bit.

  9. Andrew Says:

    Hey path - thanks for the response. It's still needed and seems to work (partially that is). I am trying to install and configure a ViciDial server on Linode - for which either DAHDI or Zaptel are required.

    http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=47032

    I got passed my initial compile error DAHDI gave me but ran into my next issues. Zaptel is still a mess.

  10. mike Says:

    got it working for 2.6.32.16-linode28 with your directions. THANKS!

    one glitch with my dahdi distribution was that building dahdi_dummy was commented out in the Kbuild file. Just remove the comment and dummy builds and installs.

  11. shah Says:

    hey mike can you tell me how did get able to install dahdi. did this script worked for you ? plz answer I need to install vicidial on linode very badly.

Leave a Reply


css.php