Combine uClinux and Asterisk on a Card
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.
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 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:
downloads, patches and makes all the different packages you need. See the top-level Makefile for other useful options.
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.