2007年3月30日 星期五

quadBRI mini PCI ISDN

http://www.voip-info.org/wiki/index.php?page=BRI


http://www.ciscopress.com/articles/article.asp?p=29737&seqNum=3&rl=1


1.quadBRI mini PCI card. http://www.junghanns.net
2.Download driver : bristuff-0.3.0-PRE-1y-d.tar.gz
3.Download zaptel : zaptel-1.2.16.tar.gz
4.Build zaptel

FIX Makefile for platform and target running kernel

cp bristuff-0.3.0-PRE-1y-d/patches/zaptel.patch .
cd zaptel-1.2.16
patch -p1 < ../zaptel.patch

[gigijoe@localhost zaptel-1.2.16]$ CC=mipsel-linux-gcc AR=mipsel-linux-ar LD=mipsel-linux-ld KVERS=2.4.31 KSRC=../../linux_2_4_31 make
mipsel-linux-gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O4 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" -c -o gendigits.o gendigits.c
mipsel-linux-gcc -o gendigits gendigits.o -lm
./gendigits > tones.h
/bin/sh: ./gendigits: cannot execute binary file
make: *** [tones.h] Error 126
[gigijoe@localhost zaptel-1.2.16]$ gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" -c -o gendigits.o gendigits.c
[gigijoe@localhost zaptel-1.2.16]$ gcc -o gendigits gendigits.o -lm
[gigijoe@localhost zaptel-1.2.16]$ CC=mipsel-linux-gcc AR=mipsel-linux-ar LD=mipsel-linux-ld KVERS=2.4.31 KSRC=../../linux_2_4_31 make ./gendigits > tones.h
mipsel-linux-gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" makefw.c -o makefw
./makefw tormenta2.rbt tor2fw > tor2fw.h
/bin/sh: ./makefw: cannot execute binary file
make: *** [tor2fw.h] Error 126
[gigijoe@localhost zaptel-1.2.16]$ gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" makefw.c -o makefw
[gigijoe@localhost zaptel-1.2.16]$ ./makefw tormenta2.rbt tor2fw > tor2fw.h
Loaded 69900 bytes from file
[gigijoe@localhost zaptel-1.2.16]$ gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" makefw.c -o makefw
[gigijoe@localhost zaptel-1.2.16]$ CC=mipsel-linux-gcc AR=mipsel-linux-ar LD=mipsel-linux-ld KVERS=2.4.31 KSRC=../../linux_2_4_31 make

End up with error, but it's ok.
What we need are zaptel.o and zaptel-base.o

5.Build qozap

cd bristuff-0.3.0-PRE-1y-d/qozap

FIX Makefile for platform and target running kernel
[gigijoe@localhost qozap]$ make
mipsel-linux-gcc -c qozap.c -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -DRELAXED_LOCKING -fomit-frame-pointer -O2 -Wall -I/home/gigijoe/ECS040/linux_2_4_31/include -I../../zaptel-1.2.16 -D__LINUX__ -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -Wall -Wimplicit -Wreturn-type -Wunused -Wswitch -Wcomment -Wparentheses -O2 -G 0 -fno-strict-aliasing -fno-common -fomit-frame-pointer -mno-abicalls -fno-pic -pipe -mips2 -Wa,--trap -Wa,--trap -D__linux__ -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 -D_MIPS_SZINT=32 -D__MIPSEL__ -DUTS_MACHINE='mips' -mlong-calls -DMODVERSIONS -include /home/gigijoe/ECS040/linux_2_4_31/include/linux/modversions.h

Now you have qozap.o

6.Insert modules

/tmp # insmod zaptel.o
Using zaptel.o
Zapata Telephony Interface Registered on major 196
Zaptel Version: 1.2.16
Zaptel Echo Canceller: MG2

/tmp # insmod zaptel-base.o
Using zaptel-base.o
Zapata Telephony Interface Registered on major 196
Zaptel Version: 1.2.16
Zaptel Echo Canceller: MG2

/tmp # insmod qozap.o
Using qozap.o
qozap: S/T ports: 2 [ TE TE ]
qozap: 1 multiBRI card(s) in this box, 0 BRI ports total, bloop 0, pcmslave 0.

7.Build ztcfg

[gigijoe@localhost zaptel-1.2.16]$ CC=mipsel-linux-gcc AR=mipsel-linux-ar LD=mipsel-linux-ld KVERS=2.4.31 KSRC=../../linux_2_4_31 make ztcfg mipsel-linux-gcc -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DZAPTEL_CONFIG=\"/etc/zaptel.conf\" -c -o ztcfg.o ztcfg.c
mipsel-linux-gcc -c -fPIC -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DBUILDING_TONEZONE -o zonedata.lo zonedata.c
mipsel-linux-gcc -c -fPIC -DSTANDALONE_ZAPATA -DBUILDING_TONEZONE -I. -O2 -g -Wall -DBUILDING_TONEZONE -o tonezone.lo tonezone.c
ar rcs libtonezone.a zonedata.lo tonezone.lo
mipsel-linux-gcc -o ztcfg ztcfg.o libtonezone.a -lm

8.Create device node
http://lists.digium.com/pipermail/asterisk-bsd/2005-April/000744.html


http://lists.digium.com/pipermail/asterisk-users/2003-February/000638.html



/tmp # mkdir /dev/zap
/tmp # mknod /dev/zap/ctl c 196 0
/tmp # mknod /dev/zap/channel c 196 254


9.Configure zaptel

/tmp # ./ztcfg -c zaptel.conf.quadBRI -vvvv -d 3 -a
Line 1: loadzone=nl
Line 2: defaultzone=nl
Line 5: span=1,1,3,ccs,ami
Line 6: span=2,2,3,ccs,ami
Line 7: span=3,3,3,ccs,ami
Line 8: span=4,4,3,ccs,ami
Line 10: bchan=1,2
Line 11: dchan=3
Line 12: bchan=4,5
Line 13: dchan=6
Line 14: bchan=7,8
Line 15: dchan=9
Line 16: bchan=10,11
Line 17: dchan=12


Zaptel Configuration
======================

SPAN 1: CCS/ AMI Build-out: 399-533 feet (DSX-1)
SPAN 2: CCS/ AMI Build-out: 399-533 feet (DSX-1)
SPAN 3: CCS/ AMI Build-out: 399-533 feet (DSX-1)
SPAN 4: CCS/ AMI Build-out: 399-533 feet (DSX-1)

Channel map:

Channel 01: Clear channel (Default) (Slaves: 01)
Channel 02: Clear channel (Default) (Slaves: 02)
Channel 03: D-channel (Default) (Slaves: 03)
Channel 04: Clear channel (Default) (Slaves: 04)
Channel 05: Clear channel (Default) (Slaves: 05)
Channel 06: D-channel (Default) (Slaves: 06)
Channel 07: Clear channel (Default) (Slaves: 07)
Channel 08: Clear channel (Default) (Slaves: 08)
Channel 09: D-channel (Default) (Slaves: 09)
Channel 10: Clear channel (Default) (Slaves: 10)
Channel 11: Clear channel (Default) (Slaves: 11)
Channel 12: D-channel (Default) (Slaves: 12)

12 channels configured.

Changing signalling on channel 1 from Unused to Clear channel
Changing signalling on channel 2 from Unused to Clear channel
Changing signalling on channel 3 from Unused to HDLC with FCS check
Changing signalling on channel 4 from Unused to Clear channel
Changing signalling on channel 5 from Unused to Clear channel
Changing signalling on channel 6 from Unused to HDLC with FCS check
Changing signalling on channel 7 from Unused to Clear channel
Changing signalling on channel 8 from Unused to Clear channel
Changing signalling on channel 9 from Unused to HDLC with FCS check
Changing signalling on channel 10 from Unused to Clear channel
Changing signalling on channel 11 from Unused to Clear channel
Changing signalling on channel 12 from Unused to HDLC with FCS check
Registered tone zone 3 (Netherlands)



10.Patch and build libpri-1.2.4
cp bristuff-0.3.0-PRE-1y-e/patches/libpri.patch .
cd libpri-1.2.4
patch -p1 < ../libpri.patch


Edit Makefile for mipsel cross compile


make


[gigijoe@localhost libpri-1.2.4]$ make
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o copy_string.o copy_string.c
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o pri.o pri.c
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o q921.o q921.c
q921.c: In function `__q921_receive_qualified':
q921.c:1429: warning: `tei' might be used uninitialized in this function
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o prisched.o prisched.c
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o q931.o q931.c
mipsel-linux-gcc -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -c -o pri_facility.o pri_facility.c
ar rcs libpri.a copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o
ranlib libpri.a
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o copy_string.lo -c copy_string.c
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o pri.lo -c pri.c
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o q921.lo -c q921.c
q921.c: In function `__q921_receive_qualified':
q921.c:1429: warning: `tei' might be used uninitialized in this function
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o prisched.lo -c prisched.c
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o q931.lo -c q931.c
mipsel-linux-gcc -fPIC -G 0 -mips32 -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -DRELAX_TRB -DRELAXED_TIMERS -o pri_facility.lo -c pri_facility.c
mipsel-linux-gcc -shared -Wl,-hlibpri.so.1.0 -o libpri.so.1.0 copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo
/sbin/ldconfig -n .
ln -sf libpri.so.1.0 libpri.so
ln -sf libpri.so.1.0 libpri.so.1


11.Build zapate


Edit Makefile for mipsel cross compile and zaptel.h


[gigijoe@localhost zapata]$ make
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o goertzel.o goertzel.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o filtros.o filtros.c
In file included from filtros.c:33:
coef_in.h:9:8: warning: no newline at end of file
In file included from filtros.c:43:
coef_out.h:3:4: warning: no newline at end of file
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o demodulador.o demodulador.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o serie.o serie.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o baudot.o baudot.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o dpll.o dpll.c
mipsel-linux-gcc -Wall -Wstrict-prototypes -G 0 -mips32 -O2 -I../zaptel-1.2.16   -c -o tone_detect.o tone_detect.c
ar rcs libzap.a zap.o goertzel.o filtros.o demodulador.o serie.o baudot.o dpll.o tone_detect.o
ranlib libzap.a
mipsel-linux-gcc -shared -Wl,-soname,libzap.so.1 -o libzap.so.1.0 zap.o goertzel.o filtros.o demodulador.o serie.o baudot.o dpll.o tone_detect.o -lc -lm
/sbin/ldconfig -n .
rm -f libzap.so
ln -sf libzap.so.1 libzap.so




2007年3月6日 星期二

ARM gdb howto (轉載)

一.下载gdb-6.4.tar.gz源代码
http://ftp.gnu.org/gnu/gdb/


二.编译 GDB
#tar zxvf gdb-6.4.tar.gz


2.1 编译GDB Server
#cd gdb-6.4
#./configure --target=arm-linux --prefix=/usr/local/arm-gdb
#make
#make install           // 生成/usr/local/arm-gdb/bin


2.2 编译GDB Client
#cd ./gdb/gdbserver
#export PATH=$PATH:/usr/local/arm-gdb/bin
#./configure --target=arm-linux --host=arm-linux
#vi config.h
    //#define HAVA_SYS_REG_H    //注释此句
#make  CC=arm-linux-gcc           //编译用于目标机的stub程序  生成gdbserver是GDB客户端程序,在板子上运行。


三.实战调试
1.编辑文件
# vi gdbtest.c
1 #include <stdio.h>

3 int
4 func(int n){
5     int   sum=0, i;
6     for (i=0; i<n; i++){
7         sum += i;
8     }
9     return sum;
10 }
11
12 int
13 main(void)
14 {
15    int   i;
16    long result = 0;
17    for (i=0; i<=100; i++){
18        result += i;
19    }
20  
21    printf("result[1-100] = %d \n", result);
22    printf("resutl[1-225] = %d \n", func(255));
23
24    return 0;
25 }
#  arm-linux-gcc -g gdbtest.c -o gdbtest          // 交叉编译
2.下载文件到目标板: gdbtest和gdbserver
假设 host pc ip:192.168.1.45
     board   ip:192.168.1.180    
将文件拷贝到目标板上:
先将gdbtest和gdbserver两个文件拷贝到主机的/tftpboot目录下
在目标板的Linux中运行:
#mount 192.168.1.108:/tftpboot /mnt/nfs
#cd /mnt/nfs
#ls
看是否有gdbtest和gdbserver两个文件。
3.运行调试
client board:
#./gdbserver 192.168.1.45:1234 gdbtest  // 目标板上运行gdbtest 监听端口1234


host pc:
#cd /usr/local/arm-gdb/bin/
#copy gdbtest /usr/local/arm-gdb/bin/   // 将前面编译的文件gdbtest拷贝到此目录
#./arm-linux-gdb gdbtest
(gdb) target remote 192.168.1.180:1234   // 连接到开 发板 成功后就可以进行调试               
(gdb)list   or l
(gdb)break func 
(gdb)break 22
(gdb)info br    
(gdb)continue   or c    // 这里不能用 run
(gdb)next   or n
(gdb)print or p    result  
(gdb) finish        // 跳出func函数
(gdb) next
(gdb) quit
建立连接后进行gdb远程调试和gdb本地调试方法相同