Combine uClinux and Asterisk on a Card

Embedding Asterisk on a Digikey Blackfin STAMP card.
A Really Open Hardware/Software Project

This PBX runs open-source software (Asterisk), on an open-source operating system (uClinux). The operating system, drivers and applications are built using a GNU gcc toolchain.

The hardware designs are open and were designed using open-source tools. Schematic entry was performed using gschem, and the PCB layouts were developed using a program called PCB—both included in the gEDA package of open electronic design tools.

Verilog was used to implement some programmable logic on the daughterboard. Verilog is a language used to describe logic in electronic circuits. The Verilog code was developed with Icarus Verilog, also part of the gEDA package.

Figure 3 shows the high-level work flow for the project. As you can see, hardware, software and even the tool used to design the hardware are all open.

Figure 3. The Work Flow Used to Create the Project

Assembling the Hardware

Let's start putting it all together.

The first step is to plug your desired combination of modules in to the daughter card. For example, for a home PBX, you might simply want one FXO and two FXS modules; for an office you might want four FXO modules. In Figure 1, two FXO and two FXS modules are loaded.

The next step is to plug the daughter card/module assembly in to the Blackfin STAMP card. That's pretty much it for the hardware assembly. As a quick test, try applying power to the STAMP, and it should boot without any problems. Not much else will happen yet, as we need to compile and download the software.

Building the Software

The software is built on a Linux host PC, then downloaded to the Blackfin STAMP board using FTP (driven by some shell and Expect scripts). Here are the steps:

Download and install the Blackfin gcc toolchain. Detailed instructions for this step are on the blackfin.uclinux.org Web site.

You need a compiled version of the latest Blackfin STAMP uClinux distribution (uClinux-dist RPM or tarball). Before building it, set up the following configuration using make menuconfig:

  • Kernel hacking: boot param— root=/dev/mtdblock0 rw. This makes the root filesystem read-write, which allows us to add the many files Asterisk requires to the root filesystem.

  • Blackfin options: write back cache—this improves the speed of the DSP-intensive operations, such as the Speex codec, by about 10% per codec instance.

  • Customize vendor/user settings: Flash tools—MTD Utils is switched off, as it breaks the uClinux-dist compilation (at least on my machine).

  • I modified the file: uClinux-dist/vendors/AnalogDevices/BF537-STAMP/rc to set the hostname and enable dhcpcd.

Generic instructions for building uClinux are included in the Blackfin uClinux-dist documentation. Read these and build uClinux. If your build was successful, a uClinux-dist/images directory will be created containing the uClinux images.

Download the uCasterisk tarball, then:

$ tar xvzf uCasterisk-0.1.6.tar.gz
$ cd uCasterisk-0.1.6

In the file .config, check that:

BR2_TOOLCHAIN_DIR="/opt/uClinux/bfin-uclinux/bin"
BR2_KERNEL_SOURCE="/opt/uClinux-dist/linux-2.6.x"

point to your toolchain and target kernel sources.

Then, typing:

$ make

downloads, patches and makes all the different packages you need. See the top-level Makefile for other useful options.

Downloading and Testing

Now, download Asterisk and all the support files to the Blackfin STAMP:

$ ./scripts/install_all stamp

where stamp is the hostname of your STAMP card. There will be a few pauses as the drivers are installed, and the LEDs on the daughterboard should light indicating that the FXS/FXO modules have been auto-detected.

The next step is to configure Asterisk for your combination of FXO and FXS modules. Asterisk configuration is a big subject and can be daunting for the beginner. To help get started, some basic configuration files have been developed.

Let's assume for now that you have loaded two FXS modules and two FXO modules. In that case, run:

$ ./scripts/config_2fxo2fxs stamp

Now, you are ready to start Asterisk. Use Telnet to open a console to the Blackfin STAMP:

$ /var/tmp/asterisk -vc

A lot of text will flash by as Asterisk boots, but eventually, you should be greeted by the Asterisk CLI prompt:

Asterisk Event Logger restarted
Asterisk Ready.
*CLI>

Plug a regular analog telephone in to one of the FXS ports (the FXS ports will have green LEDs). Pick up the phone, and you will hear a dial tone. Try dialing 2000, and you should hear the “Congratulations, you have...” welcome message. You then can try dialing a few of the demo options and make some calls between extensions.

The above procedure needs to be performed every time you power down or reset the STAMP card. For regular use, the PBX can boot Asterisk from the SD card; however, while experimenting, it is often more convenient to download from the host PC.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

blackfin dsp and asterisk?

codentest's picture

I didn't think asterisk supported the dsp functions/instructions of blackfin. Which means using blackfin dsp does not help may infact be less efficent as most of the asterisk codec code is geared towards x86 systems.

Embedded open-source telephony

dpgood's picture

Hugely helpful!

I have been looking everywhere for information on putting together an embedded telephony card to use to build an adjunct telephone box. Although the Asterisk section is overkill for me, I need the FXS/FXO piece, and to be able to do pass-through.

I'll check into the resources you posted as well. Thanks for being so complete -

Dana Good

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix