在ARM-linux上实现4G模块PPP拨号上网

搞了3、4天4G模块,从毫无头绪到可以ping通外网,着实不轻松。用的是一不知名品牌EC20,

技术支持很少,资料很乱,然后自己搜集资料,一步一步调试,才搞通。

环境:

ubuntu12.04.02

gcc:arm-2009q3

主要步骤:

1、配置内核

menuconfig:
1)、USB驱动配置
Device Drivers---→
USB support---→
<*>USB SerialConverter support--→
[*]USB Generic Serial Driver//未配置,待测试

<*>USB driver for GSM and CDMA modems

在ARM-linux上实现4G模块PPP拨号上网_第1张图片

在ARM-linux上实现4G模块PPP拨号上网_第2张图片

2)、添加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
<*> PPP Deflate compression

<*> PPP BSD-Compress compression

在ARM-linux上实现4G模块PPP拨号上网_第3张图片

3)、编译、烧写
make zImage
2、文件系统
2.1交叉编译好工作源代码 ppp-2.4.4,得到 pppd 和 chat:
配置好文件:4G 配置\已配置好\linux最小文件系统
下载ppp-2.4.4.tar.gz
编译:
#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 目录下,更改其属性为可执行文件。
2.2配置拨号的脚文件:
拨号上网需要的配置文件有 3 个: wcdma,wcdma-chat-connect,wcdma-chat-disconnect(存放位置/etc/ppp/peers)。
2.3拨号测试
1)连接好硬件设备。
2)执行 pppd call wcdma & 出现附件1信息则拨号成功,记录获取到的两个DNS
primary   DNS address 211.138.30.66
secondary DNS address 211.138.24.66
3) 查看ip,出现网卡ppp0信息证明4G网卡拨号成功
ifconfig
ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.226.133.174  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:52 (52.0 B)  TX bytes:58 (58.0 B)
4)配置 DNS 服务器地址
vi /etc/resolc.conf,加入内容:nameserver 211.138.30.66
4)ping外网测试
输入命令: ping -I ppp0 202.108.22.5 (百度),有包回应证明外网连接成功



附录1: ppp拨号信息 pppd call wcdma &
[root@iTOP-4412]# pppd call wcdma &
[root@iTOP-4412]# pppd options in effect:
debug           # (from /etc/ppp/peers/wcdma)
nodetach                # (from /etc/ppp/peers/wcdma)
dump            # (from /etc/ppp/peers/wcdma)
noauth          # (from /etc/ppp/peers/wcdma)
user password           # (from /etc/ppp/peers/wcdma)
remotename 3gppp                # (from /etc/ppp/peers/wcdma)
/dev/ttyUSB3            # (from /etc/ppp/peers/wcdma)
115200          # (from /etc/ppp/peers/wcdma)
lock            # (from /etc/ppp/peers/wcdma)
connect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect               # (from /etc/ppp/peers/wcdma)
disconnect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect         # (from /etc/ppp/peers/wcdma)
crtscts         # (from /etc/ppp/peers/wcdma)
local           # (from /etc/ppp/peers/wcdma)
hide-password           # (from /etc/ppp/peers/wcdma)
novj            # ([  399.363200] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
from /etc/ppp/peers/wcdma)
novjccomp               # (from /etc/ppp/peers/wcdma)
ipcp-accept-local               # (from /etc/ppp/peers/wcdma)
ipcp-accept-remote              # (from /etc/ppp/peers/wcdma)
ipparam 3gppp           # (from /etc/ppp/peers/wcdma)
noipdefault             # (from /etc/ppp/peers/wcdma)
defaultroute            # (from /etc/ppp/pe[  399.395202] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
ers/wcdma)
usepeerdns              # (from /etc/ppp/peers/wcdma)
noccp           # (from /etc/ppp/peers/wcdma)
Removed stale lock on ttyUSB3 (pid 2406)
abort on (BUSY)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
timeout set to 120 seconds
send (AT^M)
expect (OK)
AT^M^M
OK
 -- got it


send (^MATZ^M)
[  399.491145] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
expect (OK)
^M
ATZ^M^M
OK
 -- got it


send (^MAT+CGDCONT=1,"IP","3gnet",,0[  399.555135] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
,0^M)
[  399.587138] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
expect (OK)
^M
AT+CGDCONT=1,"IP","3gnet",,0,0^M^M
OK
 -- got it


send (ATDT*99#^M)
[  399.907166] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
expect (CONNECT)
^M
ATDT*99#^M^M
CONNECT
 -- got it


send (\d)
[  400.003174] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
[  400.035196] option_instat_callback: line=1420(status OK).161, 32, 0, 3, 2
Serial connection established.
using channel 3
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB3
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfReq id=0x0 ]
No auth is possible
sent [LCP ConfRej id=0x0 ]
rcvd [LCP ConfAck id=0x1 ]
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [LCP DiscReq id=0x2 magic=0x452ddaa5]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 ]
rcvd [IPCP ConfNak id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfAck id=0x2 ]
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing existing default route via 192.168.1.1
local  IP address 100.93.9.126
remote IP address 10.64.64.64
primary   DNS address 211.138.30.66
secondary DNS address 211.138.24.66



你可能感兴趣的:(linux,4g)