Embedding Asterisk on a Digikey Blackfin STAMP card. david rowe
This article describes how to build an embedded Asterisk IP-PBX with four analog (FXO or FXS) ports. Total parts cost is about $500 US, which is competitive with PC/PCI-card based Asterisk solutions. Embedded solutions have the advantage of small size, low power and no moving parts. Figure 1 is a photo of the PBX hardware in action.
The PBX is built around a Blackfin STAMP development card, available off the shelf from Digi-Key for around $225 US. The Blackfin is a powerful DSP chip that runs uClinux. Sitting on top of the Blackfin STAMP card is a daughterboard, which contains interface hardware and the SD card socket. Into the daughterboard plugs FXO or FXS modules, one for each port. In this example, there are two FXS modules on the left and two FXO modules on the right. The color of each LED indicates the type of module inserted. Here's a brief review of telephony jargon:
■ FXO ports connect to telephone lines and the exchange.
■ FXS ports connect to analog telephone handsets.
Figure 2 is a block diagram of the PBX hardware and software components. SIP phones or analog phones can be used for handsets (extensions), which are connected via a LAN to the IP PBX. External calls can be routed over the Internet or through the analog FXO ports. Internal calls between IP phones are routed over the LAN.
The PBX supports most of the features of Asterisk running on an x86 PC. As there is no hard disk, an SD card is used for voice-mail storage.
Why Port Asterisk to uClinux/Blackfin?
I have a history of developing computer telephony hardware and have always wanted to build a small embedded box that combines a host processor, DSP, line interface hardware and software. It's an itch I've needed to scratch!
There are some very cool things about the Blackfin processor chip:
1. The problem with most embedded processors is that they are not very powerful. The Blackfin is a powerful host processor and a DSP—that is, it can run uClinux, Asterisk and codecs like G729 on the same processor at the same time. A standard 500MHz Blackfin runs at around 1,000 DSP-MIPs, which is plenty for codecs, echo cancellation and so forth.
2. A lot of effort and hardware cost is usually required to interface telephony hardware to the host processor (typically a PC), such as PCI bridge chips. The Blackfin makes it easy, as it has a lot of nice interfaces built in, such as serial ports, SPI and DMA controllers, which are all tightly integrated with the core processor.
Daughter Jioard EFS37 STAMP Bwri
Daughter Jioard EFS37 STAMP Bwri
3. The Blackfin chips are good value for the money, ranging from $4.95 US each (BF531 in 10k volume), which makes low-cost embedded telephony hardware a real possibility. This makes it possible to build an IP PBX including analog or E1/T1 line interfaces for far less than comparable PC-PCI card solutions.
4. Best of all there is an Open Source community that has developed GPL hardware (the family of STAMP boards).
The hardware designs for this project are open—the schematics and PCB layouts are freely available for anyone to download, copy and modify. The hardware designs have been released under the GPL.
Although there is some debate over how defensible the GPL is when applied to hardware, the key ideas are similar to open-source software—the hardware designs are free as in speech, and a community exists that is working together on extending and enhancing the designs. Intellectual Property (IP) is shared for the mutual benefit of all.
The community is loosely organised under the Free Telephony Project, and it consists of private hackers, researchers and several companies who are donating time and other resources to the project. A series of hardware designs are being developed, for example, analog and ISDN interface hardware, and DSP motherboard designs. Significant software development work is also occurring, for example, open echo cancellation software and drivers for the hardware.
The outputs of the project are high-quality, professionally designed telephony hardware, freely available for all. Hardware development is a little different from software—hardware design/test cycles are much longer (for example, a bug might mean a new board needs to be manufactured), and, of course, it costs money to make a "copy" of a hardware design. However, the benefits of open hardware are similar to open software:
■ Peer review is a wonderful way to trap bugs early, leading to big savings in development time.
■ Re-use of open designs enables innovative products to be developed quickly and with a very small number of bugs.
■ Discussion and contributions from people all over the world lead to a much higher-quality product than a product developed by one company in its own lab.
■ Using open hardware, an individual or small company can build sophisticated telephony products without needing large company resources.
■ The part I like best—you get to work with a community of talented hardware and software people! Some of the best and brightest minds out there seem to migrate naturally to open projects.
Business models are being developed that function within the open-hardware environment. For example, one company sponsoring our efforts has a service model based around low-cost telephony hardware—maintaining ownership of the hardware IP is not a critical part of its business plan.
Open hardware is also great for small, localised businesses and allows developing countries to build their own products locally—overcoming tariff barriers and building a local high-technology industry.
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.
Assemble Prototype Hardware v
Debug and Test Hardware
Integrate and Test system
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.
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.
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
Was this article helpful?
Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.