记gm8180平台实现3g上网,便于后续查阅

来源:互联网 发布:内雕机软件 编辑:程序博客网 时间:2024/06/07 22:16

之前,由于在at9261的平台上走过一遍,心里多少有底。但是没想到在gm8180平台实现的过程中,遇到了不少挫折。因为at9261的编译平台是fc6,交叉编译工具是arm-linux-gcc-3.4.1,而gm8180的编译平台是fc5,交叉编译工具是arm-linux-gcc-3.4.4.因为两个产品都在生产,它们的编译环境还是不动为妙。即使再搭建环境,也一样花时间。且他们也好久没碰内核了,如何搭建平台,也忘了。在此就借用了同事的编译环境。

       首先,要做的还是编译出3g模块底层驱动模块。这一部分在at9261上就很顺畅,因为它的核是linux-2.6.20的.模块驱动中的代码与其也相当的匹配。而在gm8180平台上就相当痛苦了,因为它的核是linux-2.6.14的。其在tty一层有一定的差异。支持信号方式在底层上上锁。而驱动中用的是互斥的方式。并且linux-2.6.14中有些头文件是没有的。过程暂且不表了,最终生成ztemt.ko

加载:insmod ztemt.ko 插上3g模块后

在/sys/bus/usb-serial/device上能发现ttyUSB0~3,如果/dev下没有ttyUSB0~3节点,手动创建

mknod ttyUSB0 c 188 0

mknod ttyUSB1 c 188 1

mknod ttyUSB2 c 188 2

mknod ttyUSB3 c 188 3

 

后台观察: cat ttyUSB0 &

访问  echo at^hdrcsq>ttyUSB0 能观察到确的返回数据。(详见相应的at命令指导书)

接下来就是移植pppd了,奇怪的是在此过程在at9261的平台上相当的流畅。而在gm8180的平台上也遇到挫折了.报了一堆错,说什么 pcap_t未定义什么的.原来是pcap库没有安装,或没有交叉编译的pcap库

下载libpcap-1.0.20041001.tar.gz

./configure --host=arm-linux  --prefix=/usr/arm-linux/

直接出错了

configure: error: pcap type not determined when cross-compiling; use --with-pcap=... 

比较了非交叉编译的log,发现需要加上--with-pcap=linux

./configure --host=arm-linux --prefix=/usr/arm-linux/ --with-pcap=linux

checking Linux kernel version... unknown
configure: error: cannot determine linux version when cross-compiling 

查configure文件if test $ac_cv_linux_vers = unknown ; then
                { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
   { (exit 1); exit 1; }; }

 

原来是交叉编译器无法通过uname获得arm linux 的版本.只能通过cache文件设置了.

先uname -r一下得到版本 linux-2.6.15-1.2054_FC5
echo ac_cv_linux_vers=linux-2.6.15-1.2054_FC5>arm-linux.cache
./configure --cache-file=arm-linux.cache  --host=arm-linux --prefix=/usr/arm-linux/ --with-pcap=linux
make 
make install

这下过了libpcap-1.0.0被安装到了/usr/arm-linux/ 目录下

但是头文件没有放进/usr/arm-linux/include下,

删掉include :rm -f include

建个include 目录  :mkdir /usr/arm-linux/include

重新make

make install

 

2.cross compile ppp-2.4.4
解压ppp-2.4.4

编译 make CC=arm-linux-gcc

options.c:59:18: error: pcap.h: No such file or directory
options.c: In function 'process_option':
options.c:781: warning: dereferencing type-punned pointer will break strict-aliasing rules
options.c: In function 'setpassfilter':
options.c:1458: error: 'pcap_t' undeclared (first use in this function)
options.c:1458: error: (Each undeclared identifier is reported only once
options.c:1458: error: for each function it appears in.)
options.c:1458: error: 'pc' undeclared (first use in this function) 

个人觉得,ppp的Makefile 有问题,没有在configure的时候把 --prefix 所指向的路径作为默认路径.

我的做法有两种
第一种在  pppd/Makefile 文件中

ifdef FILTER
ifneq ($(wildcard /usr/include/pcap-bpf.h),)
LIBS    += -lpcap
#CFLAGS  += -DPPP_FILTER
CFLAGS  += -DPPP_FILTER  -I/usr/arm-linux/include  -L/usr/arm-linux/lib
endif
endif


或者
第二种也是在 pppd/Makefile 文件中

直接disable PPP packet filtering,这样的话libpcap-1.0.0甚至都不用编译

# Uncomment the next line to include support for PPP packet filtering.
# This requires that the libpcap library and headers be installed
# and that the kernel driver support PPP packet filtering.
#FILTER=y

 

两种任一种改完,再运行
make CC=arm-linux-gcc
1、最后得到四个文件

    pppd/pppd 

    pppdump/pppdump 

    chat/chat

    pppstats/pppstats

    全copy到板子上/usr/sbin下

2、将chap-secrets,pap-secrets  copy到板子/etc/ppp下(没有目录自己建)

      以上两个文件就是认证是的用户名和密码

3、再将cdma文件copy到/etc/ppp/peers/下, 内容如下:

  # /etc/ppp/peers/cdma ediy by eric
  # this is ppp script for use chinact's CDMA data service
  #
  /dev/ttyUSB0
  460800
  crtscts
  connect '/usr/sbin/chat -v -f /etc/ppp/chat/cdma'
  debug
  nodetach
  ipcp-accept-local
  ipcp-accept-remote
  persist
  defaultroute
  user card

  #解释一下这里的pppd选项:
  #ttyS0
  #表示CDMA modem连接到串口/dev/ttyS0上;
  #115200
  ##表示串口波特率;
  #crtscts
  #表示采用modem的rts和cts信号线用于流控;
  #connect '/usr/sbin/chat -v -f /etc/ppp/chat/unicom'
  #表示用chat程序完成连接建立的会话过程,会话过程通过/etc/ppp/chat/unicom文件控制
  #debug
  #表示令pppd工作在调试模式
  #nodetach
  #表示不要让pppd启动之后转为后台进程
  #ipcp-accept-local
  #表示接受服务器分配的本机IP地址
  #ipcp-accept-remote
  #表示接受服务器指定的服务器IP地址
  #defaultroute
  #表示把服务器指定的服务器IP地址作为默认路由
  #user card
  #表示认证时的用户为card,pppd据此从/etc/ppp/pap-secrets或者/etc/ppp/chap-secrets文件  中取得card用户对应的口令  

4、再将cdma文件copy到/etc/ppp/chat/下,内容如下:

  # /etc/ppp/chat/unicom
  # this is the chat script for ct
  ABORT "NO CARRIER"
  ABORT "NO DIALTONE"
  ABORT "ERROR"
  ABORT "NO ANSWER"
  ABORT "BUSY"
  TIMEOUT 120
  "" at
  OK atdt#777
  CONNECT

最后删掉/etc/ppp下的options文件

开始拔号上网了: pppd call cdma & 成功没有呵呵

如果没有/dev下没有ppp设备节点要手动创建mknod ppp c 108 0 前提在编译内核时把ppp的驱动勾上。

原创粉丝点击