硬件描述: EC20模块封装成标准的PCIe接口,和系统之家通讯主要通过usb通讯。
系统描述: 此处使用的是Linux 3.0.1。

一、驱动支持

  首先需要对Linux内核驱动做一定的修改,使操作系统能够支持EC20。

1. Add VID add PID

File: [KERNEL]/drivers/usb/serial/option.c

#if 1 //Added by Quectel{ USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */{ USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */{ USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */{ USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25/EC20 R2.0 */{ USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */#endif

2. Add the Zero Packet Mechanism

  As required by the USB protocol, you need to add the mechanism for processing zero packets during bulkout transmission.

File: [KERNEL]/drivers/usb/serial/usb_wwan.c

static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,int dir, void *ctx, char *buf, int len,void (*callback) (struct urb *))
{struct urb *urb;if (endpoint == -1)return NULL;    /* endpoint not needed */urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */if (urb == NULL) {dbg("%s: alloc for endpoint %d failed.", __func__, endpoint);return NULL;}/* Fill URB using supplied data. */usb_fill_bulk_urb(urb, serial->dev,usb_sndbulkpipe(serial->dev, endpoint) | dir,buf, len, callback, ctx);#if 1      // 2017.3.7 add by zhaoxiaodongif (dir == USB_DIR_OUT) {struct usb_device_descriptor *desc = &serial->dev->descriptor;if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))urb->transfer_flags |= URB_ZERO_PACKET;if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))urb->transfer_flags |= URB_ZERO_PACKET;if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))urb->transfer_flags |= URB_ZERO_PACKET;if (desc->idVendor == cpu_to_le16(0x2C7C))urb->transfer_flags |= URB_ZERO_PACKET;}#endif return urb;
}

3. Add Reset Resume

  Some USB host controllers/USB hubs will lost power or be reset when MCU entering into suspend/sleep
mode, and they cannot resume USB devices when MCU exiting from suspend/sleep mode; instead, they
will operate reset-resume. You should add the following statements.

For Linux Kernel Version newer than 3.4:
File: [KERNEL]/drivers/usb/serial/option.c

static struct usb_serial_driver option_1port_device = {
……
#ifdef CONFIG_PM.suspend = usb_wwan_suspend,.resume = usb_wwan_resume,
#if 1 //Added by Quectel.reset_resume = usb_wwan_resume,
#endif
#endif
};

For Linux Kernel Version older than 3.5:
File: [KERNEL]/drivers/usb/serial/ usb-serial.c

static struct usb_driver usb_serial_driver = {.name =     "usbserial",.probe =    usb_serial_probe,.disconnect =   usb_serial_disconnect,.suspend =  usb_serial_suspend,.resume =   usb_serial_resume,#if 1      // 2017.3.7 add by zhaoxiaodong.reset_resume = usb_serial_resume,#endif .no_dynamic_id =    1,.supports_autosuspend = 1,
};

4. Modify Kernel Configuration

 Step 1:

cd <your kernel directory>

 Step 2: Set your environment variables, and import your board’s defconfig. The following is an example
for Raspeberrypi board

export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabimake bcmrpi_defconfig

 Step 3:

make menuconfig

 Step 4: Enable CONFIG_USB_SERIAL_OPTION

[*] Device Drivers →[*] USB Support →[*] USB Serial Converter support →[*] USB driver for GSM and CDMA modems

 Step 5: Configure Kernel to Support PPP

[*] Device Drivers →[*] Network device support →[*] PPP (point-to-point protocol) support

5. 编译内核

make

将编译好的内核下载到开发板。

二、模块测试

  将重新编译好的内核下载到开发板之后,待系统重新启动,肉驱动添加正确,在/dev/目录下会出现如下设备节点:

/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3

  EC20的AT端口是/dev/ttyUSB2,现在你可以使用UART端口工具如“minicom”或“busybox microcom”测试AT功能,结果如下:

#busybox microcom /dev/ttyUSB2
ati;+csub
Quectel
EC20F
Revision: EC20CEFDR02A09M4GSubEdition: V04OK

三、拨号

方案一
通过几个不同的配置文件,在拨号的时候选择相应的配置文件,现将配置文件列举如下:
/etc/ppp/peers/quectel-ppp

# /etc/ppp/peers/quectel-pppd
# Usage:root>pppd call quectel-pppd
#Modem path, like /dev/ttyUSB3,/dev/ttyACM0, depend on your module, default path is /dev/ttyUSB3
/dev/ttyUSB3 115200
#Insert the username and password for authentication, default user and password are test
user "test" password "test"
# The chat script, customize your APN in this file
connect 'chat -s -v -f /etc/ppp/peers/quectel-chat-connect'
# The close script
disconnect 'chat -s -v -f /etc/ppp/peers/quectel-chat-disconnect'
# Hide password in debug messages
hide-password
# The phone is not required to authenticate
noauth
# Debug info from pppd
debug
# If you want to use the HSDPA link as your gateway
defaultroute
# pppd must not propose any IP address to the peer
noipdefault
# No ppp compression
novj
novjccomp
noccp
ipcp-accept-local
ipcp-accept-remote
local
# For sanity, keep a lock on the serial line
lock
modem
dump
nodetach
# Hardware flow control
nocrtscts
remotename 3gppp
ipparam 3gppp
ipcp-max-failure 30
# Ask the peer for up to 2 DNS server addresses
usepeerdns

/etc/ppp/peers/quectel-chat-connect

# /etc/ppp/peers/quectel-chat-connect
ABORT "BUSY"
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
TIMEOUT 30
"" AT
OK ATE0
OK ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2
# Insert the APN provided by your network operator, default apn is 3gnet
OK AT+CGDCONT=1,"IP","3gnet",,0,0
OK ATD*99#
CONNECT

/etc/ppp/peers/quectel-chat-disconnect

# /etc/ppp/peers/quectel-chat-disconnect
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY "\nSending break to the modem\n"
""  +++
""  +++
""  +++
SAY "\nGoodbay\n"

编辑好这几个文件之后,便可以通过pppd进行拨号:

# pppd call quectel-ppp &

如果拨号成功会有以下信息打印出来:

[root@zx64352 peers]# pppd call quectel-ppp
pppd options in effect:
debug           # (from /etc/ppp/peers/quectel-ppp)
nodetach                # (from /etc/ppp/peers/quectel-ppp)
dump            # (from /etc/ppp/peers/quectel-ppp)
noauth          # (from /etc/ppp/peers/quectel-ppp)
user test               # (from /etc/ppp/peers/quectel-ppp)
password ??????         # (from /etc/ppp/peers/quectel-ppp)
remotename 3gppp                # (from /etc/ppp/peers/quectel-ppp)
/dev/ttyUSB3            # (from /etc/ppp/peers/quectel-ppp)
115200          # (from /etc/ppp/peers/quectel-ppp)
lock            # (from /etc/ppp/peers/quectel-ppp)
connect chat -s -v -f /etc/ppp/peers/quectel-chat-connect               # (from /etc/ppp/peers/quectel-ppp)
disconnect chat -s -v -f /etc/ppp/peers/quectel-chat-disconnect         # (from /etc/ppp/peers/quectel-ppp)
nocrtscts               # (from /etc/ppp/peers/quectel-ppp)
modem           # (from /etc/ppp/peers/quectel-ppp)
hide-password           # (from /etc/ppp/peers/quectel-ppp)
novj            # (from /etc/ppp/peers/quectel-ppp)
novjccomp               # (from /etc/ppp/peers/quectel-ppp)
ipcp-accept-local               # (from /etc/ppp/peers/quectel-ppp)
ipcp-accept-remote              # (from /etc/ppp/peers/quectel-ppp)
ipparam 3gppp           # (from /etc/ppp/peers/quectel-ppp)
noipdefault             # (from /etc/ppp/peers/quectel-ppp)
ipcp-max-failure 30             # (from /etc/ppp/peers/quectel-ppp)
defaultroute            # (from /etc/ppp/peers/quectel-ppp)
usepeerdns              # (from /etc/ppp/peers/quectel-ppp)
noccp           # (from /etc/ppp/peers/quectel-ppp)
abort on (BUSY)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
timeout set to 30 seconds
send (AT^M)
expect (OK)
AT^M^M
OK-- got itsend (ATE0^M)
expect (OK)
^M
ATE0^M^M
OK-- got itsend (ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2^M)
expect (OK)
^M
^M
Quectel^M
EC20F^M
Revision: EC20CEFDR02A09M4G^M
^M
SubEdition: V04^M
^M
+CSQ: 14,99^M
^M
+CPIN: READY^M
^M
+COPS: 0^M
^M
+CGREG: 0,0^M
^M
OK-- got itsend (AT+CGDCONT=1,"IP","3gnet",,0,0^M)
expect (OK)
^M
^M
OK-- got itsend (ATD*99#^M)
expect (CONNECT)
^M
^M
CONNECT-- got itScript chat -s -v -f /etc/ppp/peers/quectel-chat-connect finished (pid 785), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB3
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x1f2b413> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd11eadc2> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd11eadc2> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x1f2b413> <pcomp> <accomp>]
rcvd [LCP DiscReq id=0x1 magic=0xd11eadc2]
rcvd [CHAP Challenge id=0x1 <40aedf97298706e7675d614c0cea9175>, name = "UMTS_CHAP_SRVR"]
sent [CHAP Response id=0x1 <1bf312e7aa43615e474c49c28fbbaca5>, name = "test"]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
sent [IPCP ConfReq id=0x2 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfAck id=0x2 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
Could not determine remote IP address: defaulting to 10.64.64.64
local  IP address 10.35.149.45
remote IP address 10.64.64.64
primary   DNS address 218.4.4.4
secondary DNS address 218.2.2.2

此时也会在/etc/ppp/目录下生成resolv.conf文件,存放pppd拨号获取到的DNS,可以将改文件拷贝到/etc/目录下,这样便可以进行DNS解析了,至此开发板也可以通过EC20模块连接到互联网了。

方案二
方案一中的端口号、APN、用户名、密码等都是直接写在配置文件中,这样如果要更换这些内容的话要频繁修改配置文件,既消耗时间,又不太方便。所以便将几个配置文件融合到一个脚本中,并且可以通过传递参数那样修改需要修改的内容,脚本内容如下:

/etc/ppp/peers/quectel-pppd.sh

#!/bin/sh

#quectel-pppd devname apn user password
echo "quectel-pppd options in effect:"
QL_DEVNAME=/dev/ttyUSB3
QL_APN=3gnet
QL_USER=user
QL_PASSWORD=passwd
if [ $# -ge 1 ]; thenQL_DEVNAME=$1  echo "devname   $QL_DEVNAME    # (from command line)"
elseecho "devname   $QL_DEVNAME    # (default)"
fi
if [ $# -ge 2 ]; thenQL_APN=$2  echo "apn       $QL_APN    # (from command line)"
elseecho "apn       $QL_APN    # (default)"
fi
if [ $# -ge 3 ]; thenQL_USER=$3 echo "user      $QL_USER   # (from command line)"
elseecho "user      $QL_USER   # (default)"
fi
if [ $# -ge 4 ]; thenQL_PASSWORD=$4 echo "password  $QL_PASSWORD   # (from command line)"
elseecho "password  $QL_PASSWORD   # (default)"
fiCONNECT="'chat -s -v ABORT BUSY ABORT \"NO CARRIER\" ABORT \"NO DIALTONE\" ABORT ERROR ABORT \"NO ANSWER\" TIMEOUT 30 \
\"\" AT OK ATE0 OK ATI\;+CSUB\;+CSQ\;+CPIN?\;+COPS?\;+CGREG?\;\&D2 \
OK AT+CGDCONT=1,\\\"IP\\\",\\\"$QL_APN\\\",,0,0 OK ATD*99# CONNECT'"pppd $QL_DEVNAME 115200 user "$QL_USER" password "$QL_PASSWORD" \
connect "'$CONNECT'" \
disconnect 'chat -s -v ABORT ERROR ABORT "NO DIALTONE" SAY "\nSending break to the modem\n" "" +++ "" +++ "" +++ SAY "\nGood bay\n"' \
noauth debug defaultroute noipdefault novj novjccomp noccp ipcp-accept-local ipcp-accept-remote ipcp-max-configure 30 local lock modem dump nodetach nocrtscts usepeerdns

拨号

/etc/ppp/peers/quectel-pppd.sh &

输出信息跟方案一输出一样,同样会生成/etc/ppp/resolv.conf文件。

注: 在进行拨号之前一定要确保没有默认网关,如果已经设置了其他网卡的默认网关了,则4G模块没法正常上网,需要删除原来的默认网关,现以网卡eth0为例:

route del default
route del -host 255.255.255.255 dev eth0

Linux下EC20实现ppp拨号相关推荐

  1. linux下GPRS模块ppp拨号上网

     交叉编译器:arm-linux-gcc-4.5.4 Linux内核版本:Linux-3.0 主机操作系统:Centos 6.5 开发板:FL2440 GPRS:SIM900A 在开发SIM900 ...

  2. linux系统如何拨号上网连接,教你在Linux下如何使用ADSL拨号上网

    教你在Linux下如何使用ADSL拨号上网 发布时间:2007-10-29 10:22:09来源:红联作者:demon 一.如果是新手刚开始使用Linxu的话,可用图形界面: 办法:直接在网络里建立新 ...

  3. 第三节 树莓派EC20之PPP拨号上网

    EC20 ppp拨号上网步骤 1. 准备工作 2.安装软件 3.上网测试 树莓派内核现在已集成了EC20的驱动,不需要再去进行驱动移植,虽然没有MiniPcie的接口,但用usb转minipcie也是 ...

  4. linux网卡设置adsl上网,Linux下设置ADSL自动拨号上网

    前段时间下载了红帽的linux,版本为redhat 9.0,整整刻了三张CD.最初是为了体验一下linux下QQ聊天软件的功能,最后因内核太低(官方推荐内核在2.6以上,我下载的版本是2.4)而告终. ...

  5. Linux自动配置asdl脚本,Linux下设置ADSL自动拨号上网

    前段时间下载了红帽的linux,版本为redhat 9.0,整整刻了三张CD.最初是为了体验一下linux下QQ聊天软件的功能,最后因内核太低(官方推荐内核在2.6以上,我下载的版本是2.4)而告终. ...

  6. Linux通过安卓上网,Linux/Android系统通过PPP拨号上网

    嵌入式系统经常需要具备无线上网的功能,但在有的应用场景中无法使用wifi,这时可以通过GPRS模块上网.GPRS模块是基于AT命令进行控制的.对于单片机这类没有复杂操作系统的平台来说,往往要通过应用程 ...

  7. linux 自动务份,Linux下设置ADSL自动拨号上网

    前段时间下载了红帽的linux,版本为redhat 9.0,整整刻了三张CD.最初是为了体验一下linux下QQ聊天软件的功能,最后因内核太低(官方推荐内核在2.6以上,我下载的版本是2.4)而告终. ...

  8. 在linux下使用PPPOE程序拨号连接小区宽带xDSL的方法

    装了linux后,因为不知道怎么连小区宽带而很是头疼,打电话问电信的客服,但是却始终不能给我解决连网的问题,还说我用的不是正常的操作系统他们解决 不了,气得我差点吐血,真是无比的郁闷,好在我不是厌学的 ...

  9. linux ec20 usb驱动移植,linux下EC20 4G模块驱动移植

    之前有移植过ME909s MU609,主要工作就是把4G模块当做USB设备,挂载在linux上,驱动移植主要是能够让板子识别到模块,并产生SUB多个虚拟的节点,用于操作模块,拨号上网 关于内核的配置, ...

最新文章

  1. “元宇宙”概念引发AR/VR新一轮投资潮,去年Q4融资总额达120亿,超过此前2年总和...
  2. 有必要学python吗-让孩子学Python编程有必要吗
  3. linux php5.3 ssh2,Linux 安装php 的 ssh2扩展
  4. oracle基本笔记整理及案例分析2
  5. sql查询无结果返回空_3分钟短文 | Laravel 查询结果检查是不是空,5个方法你别用错...
  6. python绘制散点图的步骤_python如何绘制散点图?
  7. 使用Levmar的L-M算法拟合曲线
  8. TypeScript学习笔记(二):基本数据类型及数据转换
  9. 2.性能之巅 洞悉系统、企业与云计算 --- 方法
  10. 33. secure world对smc请求的处理------invoke command操作在OP-TEE中的实现
  11. unity摄像机带碰撞检测 摄像机碰到带碰撞物体自动拉近
  12. pycharm清华镜像源使用
  13. 江恩 计算机,江恩理论基础篇
  14. VAF,MAF,肿瘤纯度,MCF,CCF的概念和计算方法 (转载)
  15. matlab 表示希腊字母yita,常用希腊字母读法
  16. 管理后台布局-左菜单-右侧内容宽度控制(使用ant design vue)
  17. mysql集群方案PXC_【Mysql】MySQL集群方案之PXC(percona xtradb cluster)
  18. Illegal mix of collations (XXX) and (XXX) for operation ‘XXX’
  19. arcgis软件的问题
  20. HTML5-原声拖放

热门文章

  1. 联想高校AI精英挑战赛西部赛区落幕,西安交大过关斩将拔得头筹
  2. 2014 北京邀请赛 B
  3. 腕品视界:时尚百搭-GS浪琴名匠大嘴
  4. cocos creator 微信小游戏接口
  5. yarn部署及Linux的OOM、clean机制
  6. 通过电影票房预测来一览机器学习一般流程
  7. leetcode专题训练 77. Combinations
  8. BT传统蓝牙和BLE低功耗蓝牙的区别
  9. 5-黑马旅游网-线路查询
  10. 高ROE高息选股策略