------------------------------------------------------------------------------------------------------------------------------
交叉編譯器:arm-linux-gcc-4.5.4
Linux內核版本:Linux-3.0
主機操作系統:Centos 6.5
開發板:FL2440
GPRS:SIM900A
在開發SIM900模塊之前,開發板已經加載了linux內核以及文件系統,並且開發板串口已經使能。並且一定要注意的是:要有一張沒有欠費的電話卡!不要笑,這是個很嚴肅的問題!
------------------------------------------------------------------------------------------------------------------------------
所需源碼:
ppp-2.4.4.tar.gz http://download.chinaunix.net/download.php?id=35208&ResourceID=8334
注:個人覺得這是一個比較典型又比較簡單的移植問題。
大體步驟:添加內核ppp上網的支持-->編譯ppp-2.4.4生成一些可執行文件(pppd, chat, pppdump, pppstats)放到開發板的/usr/sbin/目錄下-->將可執行腳本放在開發板的指定位置(/etc/ppp/peers/gprs, /etc/ppp/chat-gprs-connect),並執行pppd命令。
一、添加內核支持
Linux-3.0以上的版本中,rt3070的驅動已經加入了內核源碼中去了,本篇用的是Linux-3.0的內核,只需要在內核的make menuconfig中選擇ppp上網的支持就可以了。
修改如下:
Device Drivers --->
[*] Network device support --->
<*> PPP (point-to-point protocol) support
[*] PPP multilink support (EXPERIMENTAL)
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> SLIP (serial line) support
[*] CSLIP compressed headers
二、編譯ppp-2.4.4
# tar -xzf ppp-2.4.4.tar.gz
# ./configure
# make CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc (交叉編譯器)
如果編譯成功,則會在pppd, chat, pppdump, pppstats下分別生成可執行程序pppd, chat, pppdump, pppstats。將其拷貝到開發板的/usr/sbin目錄下。
三、開發板的配置
# vi /etc/ppp/peers/gprs
1 # Usage: root>pppd call gprs 2 3 #set seriral 4 /dev/ttyS1 5 6 # set baudrate 7 115200 8 9 # set flowdate 10 nocrtscts 11 12 connect '/usr/sbin/chat -v -f /etc/ppp/gprs-connect-chat' 13 14 #set debug ,send message to /var/log/messages 15 debug 16 17 #To keep pppd on the terminal 18 nodetach 19 20 #hide-password 21 22 # Accept the peer's idea of our local IP address 23 ipcp-accept-local 24 # Accept the peer's idea of its (remote) IP address 25 ipcp-accept-remote 26 27 #dial up connetion as the default route 28 defaultroute 29 30 usepeerdns
# vi /etc/ppp/chat-gprs-connect
1 #Copyright (c) 2016 guanlei 995318056@qq.com 2 # This is second part of the ppp dial script. It will perform the connection 3 # 4 ABORT 'BUSY' 5 ABORT 'NO ANSWER' 6 ABORT 'NO CARRIER' 7 ABORT 'NO DIALTONE' 8 ABORT 'ERROR' 9 ABORT '\nRING\r\n\r\nRING\r' 10 TIMEOUT 20 11 '' \rAT 12 #set apn 13 OK AT+CGDCONT=1,"IP","cmnet" 14 # ............ 15 OK ATDT*99***1# //這里要改成相應的運行商的設置 16 SAY " + requesting data connection\n" 17 CONNECT '' 18 SAY " + connected\n"

使能pppd:
# pppd call gprs & (&表示后台運行)
配置完就可以了,現在可以測試一下上網功能了:
# ping www.baidu.com
PING www.baidu.com (103.235.46.39): 56 data bytes
64 bytes from 103.235.46.39: seq=0 ttl=48 time=555.719 ms
64 bytes from 103.235.46.39: seq=1 ttl=48 time=273.481 ms
--- www.baidu.com ping statistics ---
3 packets transmitted, 2 packets received, 33% packet loss
round-trip min/avg/max = 273.481/414.600/555.719 ms
# ifconfig
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.110.1.110 P-t-P:192.200.1.21 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:686 (686.0 B) TX bytes:557 (557.0 B)
