物联网的发展,嵌入式节点具备3G无线上网功能是个必不可少的功能,奈何网上的资料多数以WCDMA为主,电信的evdo资料不是很多,笔者经过一番实验,搜寻了一些网站,终于在开发板上,将EVDO模块(中兴MC8630)成功拨号上网,现分享步骤如下:
3G模块的速度非常快,所以普通的UART串口已经不能满足速度,所以会通过芯片的USB口来进行数据交互。硬件连接这里就忽略了,有兴趣的朋友可以买个usb口的3G模块。
在Linux下,我们首先要裁剪内核,是它支持usb功能,并且支持usb转串口功能,因为Linux系统会将这个usb口模拟成三个串口。配置如下:
1.首先我们执行 make at91sam9260ek_defconfig,将它配置成默认的配置。
然后配置选项如下:
完成这些步骤之后,可以进行内核的交叉编译,退出make menuconfig,输入make uImage ARCH=arm CROSS_COMPILE=arm-linux-,编译生成的内核映像文件位于当前内核源代码文件的/arch/arm/boot目录下,将生成的内核映像文件下载到板子上。
内核启动后,会在/dev目录下生成ppp设备节点。如:
ls /dev/ppp -l
crw-rw—- 1 root root 108, 0 Jan 1 00:00 /dev/ppp
2.交叉编译好工作源代码ppp-2.4.4,得到pppd和chat
解压源代码包,进入目录,进行交叉编译,这里所用的板子的交叉编译器是:
#cd /home/ppp-2.4.4
#./configure
#make CC= arm-linux-gcc
拨号所用到的程序就是ppp-2.4.4/pppd下的pppd和ppp-2.4.4/chat下的chat可执行程序,将交叉编译出来的这两个应用程序拷贝到开发板 /usr/sbin目录下,更改其属性为可执行文件。
3.配置拨号的脚文件
拨号上网需要的配置文件有3个:evdo,evdo-chat-connect,evdo-chat-disconnect(存放位置/etc/ppp/peers)
1)evdo配置内容
debug
nodetach
lock
/dev/ttyUSB0
115200
user "CARD"
password "CARD"
crtscts
show-password
usepeerdns
noauth
noipdefault
novj
novjccomp
noccp
defaultroute
ipcp-accept-local
ipcp-accept-remote
connect '/usr/sbin/chat -s -v -f /etc/ppp/evdo-chat-connect'
disconnect '/usr/sbin/chat -s -v -f /etc/ppp/evdo-chat-disconnect'
2)evdo-chat-connect配置内容
TIMEOUT 25
ABORT 'NO CARRIER'
ABORT 'ERROR'
ABORT 'NO DIALTONE'
ABORT 'BUSY'
ABORT 'NO ANSWER'
'' /rATZ
OK-AT-OK ATD#777
CONNECT /d/c
3)evdo-chat-disconnect配置内容
[cpp] view plain copy
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY"\NSending break to modem\n"
""\k"
""++ATH"
SAY "\nGood bay\n"
4.连接硬件测试
执行pppd call evdo & (这里建议后台打开,否则后面无法验证是否上线成功)
出现如下:
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xb30fa866> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <mru 1444> <asyncmap 0x0> <auth chap MD5> <magic 0x15a72540> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <mru 1444> <asyncmap 0x0> <auth chap MD5> <magic 0x15a72540> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xb30fa866> <pcomp> <accomp>]
rcvd [CHAP Challenge id=0x1 <f7357ad7b3aadc5a769b20931f362921>, name = "JSTELECOM"]
sent [CHAP Response id=0x1 <22d4e42eb8bd87eea6bdb2dac3e7cd58>, name = "CARD"]
rcvd [CHAP Success id=0x1 "Welcome to JSTELECOM."]
CHAP authentication succeeded: Welcome to JSTELECOM.
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0 <addr 172.25.11.56>]
sent [IPCP ConfAck id=0x0 <addr 172.25.11.56>]
rcvd [IPCP ConfNak id=0x1 <addr 10.38.136.1> <ms-dns1 61.177.7.1> <ms-dns3 218.2.135.1>]
sent [IPCP ConfReq id=0x2 <addr 10.38.136.1> <ms-dns1 61.177.7.1> <ms-dns3 218.2.135.1>]
rcvd [IPCP ConfAck id=0x2 <addr 10.38.136.1> <ms-dns1 61.177.7.1> <ms-dns3 218.2.135.1>]
local IP address 10.38.136.1
remote IP address 172.25.11.56
primary DNS address 61.177.7.1
secondary DNS address 218.2.135.1
然后执行 ifconfig (拔掉网线,已验证是否上线成功)
ifconfig
eth0 Link encap:Ethernet HWaddr 3A:1F:34:08:54:54
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:1 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:590 (590.0 B)
Interrupt:21 Base address:0x4000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.38.136.1 P-t-P:172.25.11.56 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1444 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:54 (54.0 B) TX bytes:54 (54.0 B)
如果出现了 ppp0 说明上线成功了!
下面我们加DNS,DNS的号码 是上面上线后的 DNS address
vi /etc/resolc.conf,加入内容:
nameserver 61,177.7.1
nameserver 218.2.135.1