Around a week ago I started experimenting with running Asterisk on my FRITZ!Box 7270 to replace my DECT phone, which has been getting a bit long in the tooth, with a SIP client running on my new
Motorola Milestone HTC Desire cell phone so that when I am at home and my cell phone is signed in to my WLAN I can use it as a mobile handset for calls arriving on my landline.
As it turned out it is a little bit tricky to get Asterisk to compile for the FRITZ!Box, so this posting is supposed to summarize the steps I had to take and also comes with a neat helper script, which should automate most of the required preparation and compilation steps.
This guide assumes that you are running some Linux derivate that comes with a complete gcc toolchain for your host platform. You will also need a current Freetz version (I used 1.1.x as well as trunk as of revision 5752) to build the cross-compilation toolchain, which we will use to build the Asterisk binaries for the FRITZ!Box. If you have not yet done so, grab a copy of Freetz from its Subversion repository using:
svn co http://svn.freetz.org/branches/freetz-stable-1.1
By default, Freetz uses a pre-compiled toolchain, which we do not want to use. Instead, we will build our own toolchain. To enable this feature of the Freetz build, change to the freetz-stable-1.1 directory and type:
Also make sure you have the “bash” package (listed under “Package selection” -> “Testing”) is selected. Under “Advanced options” -> “Compiler options” -> “Toolchains” select “Build toolchain (requires 4GB diskspace)”.
Next, enable the compilation of libresolv by selecting the respective checkbox at “Advanced options” -> “Shared libraries” -> “uClibc” -> “libresolv-0.9.2x.so”. Update: You will also need to select “Advanced options” -> “Shared libraries” -> “ncurses” -> “ncurses (libncurses.so)” and [Update2:] “Advanced options” -> “Shared libraries” -> “CAPI 2.0 (libcapi20.so)”.
Build a new Freetz image and toolchain by issuing
on the command line.
Update: If some of the options mentioned above were not selected when you last built and flashed Freetz to your FRITZ!Box you will have to do so before starting Asterisk later as it will otherwise not find some of its dependencies.
You will also need an USB memory stick attached to your FRITZ!Box, which has been formatted with the ext3 file system (so file attributes and symlinks are correctly preserved). I have not tried whether a FAT32-formatted stick works. If so, please leave a comment.
The build script itself needs the fakeroot package in addition to the usual development packages.
Now that the cross-compilation toolchain has been built we can start looking into actually building Asterisk for the FRITZ!Box. This tutorial will focus on building Asterisk
188.8.131.52 184.108.40.206 with chan_capi 1.1.4 1.1.5, but can be easily adapted to newer versions.
First, you will need to download the Asterisk-Freetz compilation helper, which is available for download at:
Extract the file into a directory of your choice:
tar xvzf ginkel-asterisk-freetz-build-v0.5-0-gdc9f7c2.tar.gz
Next, edit the build-asterisk.sh script and point the FREETZ_TOOLCHAIN variable to the directory hosting your Freetz cross-compiler toolchain. Usually, this is the “toolchain/target” directory below the main Freetz directory. Save your changes.
Finally, start the build by issuing the following command:
If everything works out correctly you will end up with a file named “asterisk-220.127.116.11+chan_capi-1.1.5-freetz.tar.bz2″ after the completion of the build. It contains the complete runtime environment for Asterisk (except for the Asterisk configuration files). Copy the file to the USB memory stick attached to the FRITZ!Box, log on to your FRITZ!Box and extract it to a directory of your choice.
For my Freetz installation the USB memory stick is mounted as /var/media/uStor01, so I have to issue the following commands to perform the installation (assuming that asterisk-18.104.22.168+chan_capi-1.1.5-freetz.tar.bz2 is located in the USB memory stick’s root directory):
tar xjf asterisk-22.214.171.124+chan_capi-1.1.5-freetz.tar.bz2
Before starting Asterisk for the first time you will want to populate the “etc/asterisk” directory with some sensible configuration files.
After doing that it is time to start Asterisk. Let’s assume you extracted the distribution .tar.gz file into the root directory of your USB memory stick (/var/media/uStor01). Then, you would be able to start it using the following command while logged in to the FRITZ!Box shell:
This will start Asterisk through the
safe_asterisk script, which will make sure that Asterisk is re-spawned in case it terminates irregularly. This is probably not what you want while still debugging your Asterisk configuration, so if you prefer a non-respawning invocation with debug messages sent to the console, use
Once you are comfortable with your Asterisk configuration it is time to configure Freetz so that it will automatically start when the FRITZ!Box reboots. To do so, sign in to the Freetz configuration web UI (usually located at http://fritz.box:81/) and add the start-asterisk command to rc.custom.
Now you have Asterisk running on your FRITZ!Box. Enjoy!