ARM平台上实现Linux PPP拨号
操作系统:嵌入式Linux
下面主要介绍一下如何在Liod平台上进行ppp拨号,实现GPRS上网.
第一步:如果内核不支持ppp拨号,则要重新编译内核,添加对ppp的支持,
<*> PPP (point-to-point protocol) support
[*] PPP multilink support (EXPERIMENTAL)
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> PPP Deflate compression
<*> PPP BSD-Compress compression
然后重新烧写新生成的内核映象!
第二步:下载ppp-2.4.1源码包,交叉编译生成拨号所需的pppd和chat这两个程序.
源代码下载网址:http://samba.org/ftp/ppp/(旧的站点,目前好像不能用了ftp://ftp.samba.org/pub/ppp/)
解压源代码包,进入目录,进行交叉编译,这里所用的交叉编译器是arm-linux-gcc(version 3.3.2)
#cd /root/gprs/ppp-2.4.1(这里假设ppp解压在/root/gprs/目录下)
#./configure
#make CC=arm-linux-gcc
拨号所用到的程序就是/root/gprs/ppp-2.4.1/pppd/下的pppd,和/root/gprs/ppp-2.4.1/chat/下的chat程序为了调试方便,我在CF卡上新建一个目录pppdial,将pppd和chat这两个程序拷贝到此目录下! (开发板上储存空间有限,因此这里我用CF卡扩充储存容量)
第三步:配置拨号脚本:
将 /root/gprs/ppp-2.4.1/scripts/下的ppp-on,ppp-on-dialer,ppp-off这三个脚本修改后拷贝到/mnt/cf/pppdial/下,修改后的脚本如下:
1.ppp-on脚本具体要修改的内容:
TELEPHONE=*99***1# # The telephone number for the connection
ACCOUNT= # The account name for logon (as in George Burns)
PASSWORD= # The password for this account (and Gracie Allen)
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
# Export them so that they will be available at ppp-on-dialer time.
export TELEPHONE ACCOUNT
DIALER_SCRIPT=/mnt/cf/pppdial/ppp-on-dialer
# Initiate the connection
exec /mnt/cf/pppdial/pppd debug lock nocrtscts /dev/ttyS1 19200 /
asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP /
noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT usepeerdns
2.修改ppp-on-dialer脚本:
#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
exec /sbin/chat -v /
TIMEOUT 5 /
ABORT /nBUSY/r /
ABORT /nNO ANSWER/r /
ABORT /nRINGING/r/n/r/nRINGING/r /
AT+CGDCONT=1,IP,CMNET /
OK AT /
OK-+++/c-OK ATH0 /
TIMEOUT 30 /
OK ATDT$TELEPHONE /
CONNECT
3.在Liod板上/etc/ppp/resolv.conf文件中加上
nameserver 211.136.20.203
nameserver 211.136.18.171
第四步:连接gprs
gprs模块通过串口连接到板子上的蓝牙串口(/dev/ttyS1),因为Liod板的FFUART用来做调试串口了,即使通过telnet登录Liod,而将串口0腾出来用来连接GPRS模块,拨号也会失败.因为从串口0会输出调试信息,对拨号过程造成干扰.
关闭默认网络设备: ifconfig eth0 down
在Liod平台上挂载CF卡,并切换到/mnt/cf/pppdial/下,下面就可以拨号了!
pppd拨号: ./ppp-on
(注意:一定要先关闭闭eth0再拨号,否则即使拨号能得到IP地址,也会因为路由错误而访问不了外网)
ARM平台上LinuxPPP拨 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)