一、工具准备
ppp拨号下载
https://download.samba.org/pub/ppp/ppp-2.4.7.tar.gz
gsmmuxd下载:
gsmmuxd是一个多路复用的开源协议,下面这个gsmmuxd的一些介绍。
https://blog.csdn.net/hanmengaidudu/article/details/52692238
gsmmuxd可以在github上下载,然后修改makefile之后进行交叉编译
https://github.com/ya-jeks/gsmmux
二、内核配置
linux配置如下
配置内核支持PPP
Device Drivers —>
[] Network device support —>
< > Universal TUN/TAP device driver support / 选中 /
< > PPP (point-to-point protocol) support / 选中 /
< > PPP BSD-Compress compression / 选中 /
< > PPP Deflate compression / 选中 /
[ ] PPP filtering / 选中 /
< > PPP MPPE compression (encryption) / 选中 /
[ ] PPP multilink support / 选中 /
< > PPP over Ethernet / 选中 /
< > PPP support for async serial ports / 选中 /
< > PPP support for sync tty ports / 选中 /
< > SLIP (serial line) support / 选中 /
[ ] CSLIP compressed headers / 选中 */
三、pppd交叉编译
cd /work/ppp-2.4.7
./configure
make CC=arm-none-linux-gcc
四、配置
4.1 将编译得到的pppd下的pppd,chat下的chat放入sbin并给予执行权限。
4.2 拨号上网需要的配置文件有3个:ppp-on 、ppp-off 、ppp-dial-on,这三个文件可以在 ppp-2.4.4/script 文件夹内找到,将其放入开发板中(根据需要放入任意位置)
修改ppp-on
可参考下面文章中的修改
https://blog.csdn.net/ysh1042436059/article/details/86665619
下面这篇文章对ppp-on中pppd拨号参数部分进行了比较详细的解释,可以参考一下
https://www.cnblogs.com/liushuhe1990/articles/11271119.html
我的参数如下
exec /sbin/pppd debug logfile /dev/console lock modem -chap nocrtscts $PPP_TTY 115200 \
asyncmap 0 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \
user $ACCOUNT password $PASSWORD noipdefault defaultroute netmask $NETMASK defaultroute connect $DIALER_SCRIPT
ppp-dial-on也需要修改,下面标红的地方需要注意。
我的修改如下:
exec /sbin/ppp/chat -s -v \
TIMEOUT 6 \
ABORT '\nBUSY\r' \
ABORT '\nNO ANSWER\r' \
ABORT '\nRINGING\r\n\r\nRINGING\r' \
ABORT '\n+CME ERROR: 100\r' \
'' AT \
'OK-+++\c-OK' AT \
TIMEOUT $PPP_ON_TIMEOUT \
OK AT+CGDCONT=1,\"IP\",\"CMNET\" \
OK ATDT$TELEPHONE \
CONNECT '' \
到此修改完成,开始拨号测试,我使用的是有方的N720,卡为移动公网卡。中途出现了一些问题,但最后都算解决,能够拨号成功,ping通百度。
expect (OK)
AT^M^M
OK
-- got it
send (AT^M)
timeout set to 20 seconds
expect (OK)
^M
AT^M^M
OK
-- got it
send (AT+CGDCONT=1,"IP","CMNET"^M)
expect (OK)
^M
AT+CGDCONT=1,"IP","CMNET"^M^M
OK
-- got it
send (ATDT*99***1#^M)
expect (CONNECT)
^M
ATDT*99***1#^M^M
CONNECT
-- got it
send (^M)
Script /pemt/ppp/script/ppp-on-dialer finished (pid 502), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS5
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x982ab88d> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xb8170da2> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xb8170da2> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x982ab88d> <pcomp> <accomp>]
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>]
rcvd [LCP ProtRej id=0x2 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 TermAck id=0x1]
rcvd [IPCP ConfReq id=0x1 <addr 192.168.0.1>]
sent [IPCP ConfAck id=0x1 <addr 192.168.0.1>]
rcvd [IPV6CP ConfReq id=0x1 <addr fe80::f860:8c5b:be82:1a55>]
Unsupported protocol 'IPv6 Control Protocol' (0x8057) received
sent [LCP ProtRej id=0x2 80 57 01 01 00 0e 01 0a f8 60 8c 5b be 82 1a 55]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0>]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x2 <addr 10.54.208.255>]
sent [IPCP ConfReq id=0x3 <addr 10.54.208.255>]
rcvd [IPCP ConfAck id=0x3 <addr 10.54.208.255>]
local IP address 10.54.208.255
remote IP address 192.168.0.1
ping 百度ip
root@123:/123/ppp/script# ping 220.181.38.251
PING 220.181.38.251 (220.181.38.251): 56 data bytes
64 bytes from 220.181.38.251: seq=0 ttl=47 time=285.367 ms
64 bytes from 220.181.38.251: seq=1 ttl=47 time=130.517 ms
64 bytes from 220.181.38.251: seq=2 ttl=47 time=118.967 ms
ping 网址
root@123:/123/ppp/script# 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=44 time=79.350 ms
64 bytes from 103.235.46.39: seq=1 ttl=43 time=97.516 ms
64 bytes from 103.235.46.39: seq=2 ttl=43 time=89.816 ms
问题记录:
1.拨号失败
send (AT+CGDCONT=1,"IP","CMNET"^M)
timeout set to 20 seconds
expect (OK)
^M
AT+CGDCONT=1,"IP","CMNET"^M^M
OK
-- got it
send (ATDT*99***1#^M)
expect (CONNECT)
^M
ATDT*99***1#^M^M
ERROR^M
解决办法:
在ppp-dial-on中,chat中增加下面一条。
OK AT+CGDCONT=1,“IP”,“CMNET”
2.无法ping通baidu域名
在/etc中创建resolv.conf文件,添加下面一条语句,然后重启网络。重新拨号之后,即可ping百度域名
nameserver 8.8.8.8
ps:gsmMuxd 的使用方法
参数的意义如下:
把真是串口ttyS3 虚拟出波特率为115200,类型类似/dev/mux的两个虚拟串口,分别为/dev/mux0 /dev/mux1
gsmMuxd -p /dev/ttyS3 -w -b 115200 -s /dev/mux /dev/ptmx /dev/ptmx
options:
-p <serport> : Serial port device to connect to [/dev/modem]
-f <framsize> : Maximum frame size [32]
-d : Debug mode, don't fork
-m <modem> : Modem (mc35, mc75, generic, ...)
-b <baudrate> : MUX mode baudrate (0,9600,14400, ...)
-P <PIN-code> : PIN code to fed to the modem
-s <symlink-prefix> : Prefix for the symlinks of slave devices
(e.g./dev/mux)
-w : Wait for deamon startup success/failure
-h : Show this help message