新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > ARM平臺上實現(xiàn)Linux PPP撥號

ARM平臺上實現(xiàn)Linux PPP撥號

作者: 時間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
硬件平臺:億道Liod平臺(基于PXA270)

操作系統(tǒng):嵌入式Linux

本文引用地址:http://2s4d.com/article/201611/316817.htm

下面主要介紹一下如何在Liod平臺上進行ppp撥號,實現(xiàn)GPRS上網(wǎng).
第一步:如果內(nèi)核不支持ppp撥號,則要重新編譯內(nèi)核,添加對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
然后重新燒寫新生成的內(nèi)核映象!

第二步:下載ppp-2.4.1源碼包,交叉編譯生成撥號所需的pppd和chat這兩個程序.
源代碼下載網(wǎng)址: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(這里假設(shè)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程序為了調(diào)試方便,我在CF卡上新建一個目錄pppdial,將pppd和chat這兩個程序拷貝到此目錄下! (開發(fā)板上儲存空間有限,因此這里我用CF卡擴充儲存容量)

第三步:配置撥號腳本:
將 /root/gprs/ppp-2.4.1/scripts/下的ppp-on,ppp-on-dialer,ppp-off這三個腳本修改后拷貝到/mnt/cf/pppdial/下,修改后的腳本如下:
1.ppp-on腳本具體要修改的內(nèi)容:
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用來做調(diào)試串口了,即使通過telnet登錄Liod,而將串口0騰出來用來連接GPRS模塊,撥號也會失敗.因為從串口0會輸出調(diào)試信息,對撥號過程造成干擾.
關(guān)閉默認網(wǎng)絡(luò)設(shè)備: ifconfig eth0 down

在Liod平臺上掛載CF卡,并切換到/mnt/cf/pppdial/下,下面就可以撥號了!
pppd撥號: ./ppp-on
(注意:一定要先關(guān)閉閉eth0再撥號,否則即使撥號能得到IP地址,也會因為路由錯誤而訪問不了外網(wǎng))



關(guān)鍵詞: ARM平臺上LinuxPPP撥

評論


技術(shù)專區(qū)

關(guān)閉