4G模块使用pppd拨号调试记录

1、配置linux内核

执行make menuconfig

  1. 使能USB GSM配置
    在这里插入图片描述
  2. 使能所有ppp协议相关配置

在这里插入图片描述在这里插入图片描述
然后编译后的内核烧到板子中。

2、交叉编译移植ppp拨号程序

下载路径:https://download.samba.org/pub/ppp/
下载最新版本的源码。解压后进入目录 使用交叉编译工具编译:make CC=XXX/arm-linux-gcc (xxx为交叉编译工具的路径)。编译后将./pppd/pppd 、./chat/chat 和
./pppdump/pppdump拷贝到linux板子的/bin路径下。

3、编写pppd配置脚本

新建/etc/ppp/peers 目录
在/etc/ppp 目录下新建gprs-chat-connect文件
TIMEOUT 15
ABORT ‘\nDELAYED\r’ //有以下几条命令出现 中断连接 (ABORT)
ABORT ‘\nBUSY\r’
ABORT ‘\nERROR\r’
ABORT ‘\nNO DIALTONE\r’
ABORT ‘\nNO CARRIER\r’
TIMEOUT 40
‘’ \rAT
OK AT+CPIN?
OK AT+CSQ
OK AT+COPS?
OK AT+CGATT?
OK ATS0=0
OK AT+CREG?
OK ATE0V1
OK AT+CGDCONT=1,“IP”,“CMNET”
OK ATD99**1#
CONNECT
在/etc/ppp/peers目录下新建gprsdial文件:
/dev/ttyUSB0 // 根据实际情况写上相应的设备名
115200
nocrtscts
modem
debug
nodetach
local
usepeerdns
noipdefault
defaultroute
user “cmnet”
0.0.0.0:0.0.0.0
connect ‘/bin/chat -s -v -f /etc/ppp/gprs-chat-connect’

然后执行pppd call gprsdial &
结果如下:
timeout set to 15 seconds
abort on (\nDELAYED\r)
abort on (\nBUSY\r)
abort on (\nERROR\r)
abort on (\nNO DIALTONE\r)
abort on (\nNO CARRIER\r)
timeout set to 40 seconds
send (MATM)
expect (OK)
^M
OK
– got it
send (AT+CPIN?^M)
expect (OK)
^M
^M
+CPIN: READY^M
^M
OK
– got it
send (AT+CSQ^M)
expect (OK)
^M
^M
+CSQ: 30,99^M
^M
OK
– got it
send (AT+COPS?^M)
expect (OK)
^M
^M
+COPS: 0,0,“CHINA MOBILE”,7^M
^M
OK
– got it
send (AT+CGATT?^M)
expect (OK)
^M
^M
+CGATT: 1^M
^M
OK
– got it
send (ATS0=0^M)
expect (OK)
^M
^M
OK
– got it
send (AT+CREG?^M)
expect (OK)
^M
^M
+CREG: 0,1^M
^M
OK
– got it
send (ATE0V1^M)
expect (OK)
^M
^M
OK
– got it
send (AT+CGDCONT=1,“IP”,“CMNET”^M)
expect (OK)
^M
^M
OK
– got it
send (ATD
99**1#^M)
expect (CONNECT)
^M
^M
CONNECT
– got it
Script /bin/chat -s -v -f /etc/ppp/gprs-chat-connect finished (pid 1137), status = 0x0
Serial connection established.
using channel 5
Using interface ppp0
Connect: ppp0 <–> /dev/ttyUSB0
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xe0fe878> ]
rcvd [LCP ConfReq id=0xc <asyncmap 0x0> <magic 0x15f10999> ]
sent [LCP ConfAck id=0xc <asyncmap 0x0> <magic 0x15f10999> ]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xe0fe878> ]
rcvd [LCP DiscReq id=0xd magic=0x15f10999]
rcvd [CHAP Challenge id=0x1 <9fd2a447617e9bd6861c135e6a7ab964>, name = “UMTS_CHAP_SRVR”]
Warning - secret file /etc/ppp/chap-secrets has world and/or group access
sent [CHAP Response id=0x1 <09d515be4ae4ad3763be463a8ce1bcbe>, name = “cmnet”]
rcvd [CHAP Success id=0x1 “”]
CHAP authentication succeeded
CHAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [LCP ProtRej id=0xe 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for ‘Compression Control Protocol’ (0x80fd) received
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfNak id=0x2 <addr 10.83.11.4> <ms-dns1 211.136.17.107> <ms-dns2 211.136.20.203>]
sent [IPCP ConfReq id=0x3 <addr 10.83.11.4> <ms-dns1 211.136.17.107> <ms-dns2 211.136.20.203>]
rcvd [IPCP ConfAck id=0x3 <addr 10.83.11.4> <ms-dns1 211.136.17.107> <ms-dns2 211.136.20.203>]
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing existing default route via 192.168.0.1
local IP address 10.83.11.4
remote IP address 10.64.64.64
primary DNS address 211.136.17.107
secondary DNS address 211.136.20.203
Script /etc/ppp/ip-up started (pid 1142)
Script /etc/ppp/ip-up finished (pid 1142), status = 0x0

看到分配到IP地址就说明拨号成功。
这时候只能ping通127.0.0.1本地ip,无法ping通外网(如:114.114.114.114)。这是没有将ppp0的网关地址添加到路由中。执行命令: route add default gw 10.64.64.64就可将其添加到路由中。IP地址可从ifconfig中获得: 在这里插入图片描述
此时还需再添加dns就可ping通公网域名了。
在这里插入图片描述
至此可算告一段落。PPP协议以及拨号相关的流程后续再慢慢学习。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值