目录
- 一、开发环境
- 二、连接方式
- 三、4G模组的 VID 和 PID
- 四、Linux kernel 的配置
- 五、ppp的编译
- 六、测试
一、开发环境
开发板:NUC980 iot开发板
4G模块:银尔达 Core-Air724
二、连接方式
micro usb线,一端连接4G模组,一端连接NUC980 iot开发板。
注意: 4G模组还需外接5V或者12V电源。否则回因供电不足导致开发板重启。
三、4G模组的 VID 和 PID
4G模组供电,micro usb线接入电脑,此时电脑会多出一个以太网,右键选择属性 —> 点击 配置 —> 详细信息 页面的 硬件Id
四、Linux kernel 的配置
修改 Linux kernel 的配置
make menuconfig
PPP相关:
USB相关:
USB NET功能
USB GSM、CDMA功能
USB CDC、ACM功能,参考正点原子 需要使能,实际测试不使能也是正常的 。
选中:支持GSM和CDMA模块的USB转串口驱动,这个驱动作用是虚拟出 /dev/ttyUSB0、/dev/ttyUSB1、/dev/ttyUSB2、/dev/ttyUSB3 这几个串口,作用分别是错误诊断、gps信息接口、模块的的通信接口。
修改内核文件,添加 VID和PID,文件位置 NUC980-linux-4.4.y/drivers/usb/serial
修改内容为:
//add for Air72x Air78x
{ USB_DEVICE(0x1782, 0x4e00) },
{ USB_DEVICE(0x19d1, 0x0001) },
//add end
如果使用设备树的话,需要将USB的过流检测取消掉,此时就可以检测usb虚拟的串口了。
五、ppp的编译
编译移植过程可参考 <Arm Linux编译PPP软件包-4G模块联网测试> ,链接网址:
http://t.csdnimg.cn/GGsYd
使用的电信卡,拨号链接 wcdma-chat-connect 文件的内容为:
ABORT "BUSY"
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
TIMEOUT 120
"" AT
OK \rATZ
#联通
#OK \rAT+CGDCONT=1,"IP","3gnet",,0,0
#OK-AT-OK ATDT*99#
#移动
#OK \rAT+CGDCONT=1,"IP","cmnet",,0,0
#OK-AT-OK ATDT*99***1#
# 电信
OK \rAT+CGDCONT=1,"IP",""
#OK-AT-OK ATDT#777
#上条失败了,改为下面的连接成功
OK-AT-OK ATDT*99#
CONNECT \d\c
六、测试
拨号指令:
# ./pppd call wcdma &
启动过程:
# 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 card # (from /etc/ppp/peers/wcdma)
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 /etc/ppp/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect # (from /etc/ppp/peers/wcdma)
disconnect /etc/ppp/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 # (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/peers/wcdma)
usepeerdns # (from /etc/ppp/peers/wcdma)
noccp # (from /etc/ppp/peers/wcdma)
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)
expect (OK)
^M
^MATZ^M^M
OK
-- got it
send (^MAT+CGDCONT=1,"IP",""^M)
expect (OK)
^M
^MAT+CGDCONT=1,"IP",""^M^M
OK
-- got it
send (ATDT*99#^M)
expect (CONNECT)
^M
A^@TDT*99#^M^M
CONNECT
-- got it
send (\d)
Serial connection established.
using channel 3
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB3
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xb62f9135> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x572d05c> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x572d05c> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xb62f9135> <pcomp> <accomp>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [LCP EchoReq id=0x0 magic=0x572d05c]
sent [LCP EchoRep id=0x0 magic=0xb62f9135]
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 [proto=0x8057] 01 01 00 0e 01 0a b4 23 e8 a8 78 45 76 a2
Unsupported protocol 'IPv6 Control Protovol' (0x8057) received
sent [LCP ProtRej id=0x2 80 57 01 01 00 0e 01 0a b4 23 e8 a8 78 45 76 a2]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfRej id=0x1 <ms-dns3 0.0.0.0>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0>]
rcvd [IPCP ConfNak id=0x2 <addr 10.119.141.33> <ms-dns1 219.141.157.113>]
sent [IPCP ConfReq id=0x3 <addr 10.119.141.33> <ms-dns1 219.141.157.113>]
rcvd [IPCP ConfAck id=0x3 <addr 10.119.141.33> <ms-dns1 219.141.157.113>]
local IP address 10.119.141.33
remote IP address 192.168.0.1
primary DNS address 219.141.157.113
查看网卡:
ifconfig
测试是否可上网,先用电脑看下百度的ip。
开发板 ping 百度的 ip。
参考:
https://blog.sina.com.cn/s/blog_7880d3350102wb92.html
https://zhuanlan.zhihu.com/p/114645532
https://doc.openluat.com/wiki/27?wiki_page_id=3329