概述
刚学习时查阅各种资料,感觉还是一头雾水,网上各种资料太乱还有错误,整理资料记录总结自己的学习过程。
参考官方链接: Building image with support for 3g/4g and usb tethering
官方文档翻译:【OpenWRT】添加3G/4G支持的图形化配置
一、模块配置
make menuconfig 进入图形界面配置
1、内核模块配置
Kernel modules >>
USB Support >>
<*> Kmod -usb-core
-*-Kmod -usb-net
-*- kmod-usb-net-cdc-ether//【可选】
<*> kmod-usb-net-cdc-mbim
-*- kmod-usb-net-cdc-ncm
<*> kmod-usb-net-cdc-subset//【可选】
<*>kmod-usb-net-qmi-wwan
<*>Kmod-usb-ohci //这个选项一定要勾选,否则可能无法在系统中查看设备
<*>Kmod-usb-serial
<*>Kmod-usb-serial-option
<*>Kmod-usb-serial-wwan
<*>kmod-usb-uhci
<*>Kmod-usb2
2、网络模块配置
NetWork >>
<*>wwan //
<*>chat //建立串行通行需要
<*>ppp //支持标准的点对点协议(point-to-point protocol)
<*>uqmi //支持qmi接口
<*>umbim //一些加密狗用mbim协议
3、其他配置
Utilities
<*>comgt
<*>usb-modeswitch //自动模式更改,将设备置于USB调制解调器模式 @该处勾选之后编译报错、原因未知@
<*>usbutils//【可选,可查看usb设备】
4、Luci界面配置
Luci
1. Collections
<*> luci
3. Applications
<*> luci-app-multiwan (optional to support multiple 3g dongles) 可选,以支持多个3g加密狗
<*> luci-app-qos (optional to provide QOS support) 可选,以提供QOS支持
6. Protocols
<*> luci-proto-3g
-*- luci-proto-ppp
二、EC20驱动移植
1、清理内核
make target/linux/clean V=99
2、拷贝内核补丁
3、应用内核补丁
将内核应用所有 patch 并生成最新代码到 build_dir 目录下
make target/linux/prepare V=99
可以看到补丁已经应用成功了:
4、移植 EC20R2.0 拨号程序 quectel-CM(见附件:已经移植好了的驱动文件)
把 ec20/quectel 文件夹放置在 openwrt/package 目录下
5、选中 quectel 软件包
Utilities --->
<*>prince --->
<*>quectel
三、测试EC20上网
1、编译与升级固件
make V=s 全编译后更新固件,注意不要勾选“保留配置”
2、接上了4G模块后启动LOG会有以下信息
3、查看设备有 cdc-wdm0 则证明添加成功,且检测到4G模块了。
root@LoRaGateway:~# ls /dev/
audio mtd0 mtdblock0 random
autofs mtd0ro mtdblock1 regopt
bus mtd1 mtdblock2 shm
cdc-wdm0 mtd1ro mtdblock3 snd
console mtd2 mtdblock4 spidev32766.1
cpu_dma_latency mtd2ro mtdblock5 tty
dsp mtd3 mtdblock6 ttyS0
full mtd3ro network_latency ttyS1
i2c-0 mtd4 network_throughput ttyS2
kmsg mtd4ro null urandom
log mtd5 port watchdog
mem mtd5ro ppp watchdog0
memory_bandwidth mtd6 ptmx zero
mixer mtd6ro pts
4、设置自动连接网络与连接状态查看:
uqmi -d /dev/cdc-wdm0 --get-data-status //查看连接状态
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect //使网卡自动连接网络,让开发板重启后同样有效。
5、查询或否获取到 IP 地址:
udhcpc -i wwan0
或者
ifconfig wwan0
6、ping 百度的 IP 地址成功:
7、ping 百度的域名失败,需要添加DNS解析地址:
ping www.baidu.com
解决:在 /etc/resolv.conf 文件添加DNS:
vi /etc/resolv.conf
新增以下内容:
nameserver 114.114.114.114
nameserver 8.8.8.8
修改后文件内容:
再次ping成功:
四、Luci界面添加新网卡接口
1、登陆 openwrt 配置页面,打开“网络” -> “接口” -> “添加新接口”。
2、输入接口名称“4G" - 协议”DHCP客户端“ - 接口”以太网适配器 wwan0“
3、"防火墙设置 "配置成”wan“模式
4、保存&应用,接口创建成功
5、查看网络配置文件
(1)/etc/config/network
root@LoRaGateway:~# cat /etc/config/network
可以看到新增了”config interface '4G'“ 的配置
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fda3:4d40:0f83::/48'
config interface 'lan'
option ifname 'eth0.1'
option force_link '1'
option macaddr '8c:88:2b:00:06:b3'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.8.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option ifname 'eth0.2'
option force_link '1'
option macaddr '8c:88:2b:00:06:b1'
option proto 'dhcp'
config interface 'wan6'
option ifname 'eth0.2'
option proto 'dhcpv6'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '1 2 3 4 6t'
config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0 6t'
config interface '4G'
option proto 'dhcp'
option ifname 'wwan0'
(2)/etc/config/firewall
cat /etc/config/firewall
可以看到 option network 'wan wan6 wwan 4G' 项增加了4G的配置
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option network 'lan'
config zone
option name 'wan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
option network 'wan wan6 wwan 4G'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option src_ip 'fe80::/10'
option src_port '547'
option dest_ip 'fe80::/10'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config include
option path '/etc/firewall.user'
config rule
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'
config rule
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
五、其他
1、插拔4G模块,会提示注册成功:
root@LoRaGateway:~# [ 198.540000] usb 1-1: USB disconnect, device number 2
[ 199.000000] usb 1-1: new high-speed USB device number 5 using ehci-platform
[ 199.160000] hub 1-1:1.0: USB hub found
[ 199.170000] hub 1-1:1.0: 4 ports detected
[ 209.610000] usb 1-1.1: new high-speed USB device number 6 using ehci-platform
[ 209.740000] qmi_wwan 1-1.1:1.4: cdc-wdm0: USB WDM device
[ 209.750000] qmi_wwan 1-1.1:1.4: Quectel EC21&EC25&EC20 R2.0work on RawIP mode
[ 209.770000] qmi_wwan 1-1.1:1.4 wwan0: register 'qmi_wwan' at usb-101c0000.ehci-1.1, WWAN/QMI device, 8a:64:a0:62:5a:79
2、quectel-CM 拨号
CONNET 为连接成功:
quectel-CM
或者
quectel-CM &
没有天线的效果:
root@LoRaGateway:~# quectel-CM
[11-02_11:35:43:740] Quectel_Linux_ConnectManager_SR01A01V21
[11-02_11:35:43:740] quectel-CM profile[1] = (null)/(null)/(null)/0, pincode = (null)
[11-02_11:35:43:741] Find qmichannel = /dev/cdc-wdm0
[11-02_11:35:43:741] Find usbnet_adapter = wwan0
[11-02_11:35:43:752] cdc_wdm_fd = 7
[11-02_11:35:43:836] Get clientWDS = 18
[11-02_11:35:43:868] Get clientDMS = 1
[11-02_11:35:43:900] Get clientNAS = 3
[11-02_11:35:43:932] Get clientUIM = 1
[11-02_11:35:43:964] Get clientWDA = 1
[11-02_11:35:43:996] requestBaseBandVersion EC20CEHCR06A03M1G
[11-02_11:35:44:060] requestGetSIMStatus SIMStatus: SIM_READY
[11-02_11:35:44:092] requestGetProfile[1] cmnet///0
[11-02_11:35:44:124] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:35:44:155] requestQueryDataCall ConnectionStatus: DISCONNECTED
[11-02_11:35:44:220] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:35:49:276] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:35:54:332] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:35:59:388] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:36:04:444] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:36:09:500] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:36:14:556] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW
[11-02_11:36:16:412] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: UNKNOW
[11-02_11:36:16:476] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: UNKNOW
[11-02_11:36:18:108] requestSetupDataCall WdsConnectionIPv4Handle: 0x845172e0
[11-02_11:36:18:172] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[11-02_11:36:18:203] requestQueryDataCall ConnectionStatus: CONNECTED
[11-02_11:36:18:236] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[11-02_11:36:18:268] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[11-02_11:36:18:344] udhcpc (v1.23.2) started
[11-02_11:36:18:399] Sending discover...
[11-02_11:36:18:405] Sending select for 10.131.75.183...
[11-02_11:36:18:409] Lease of 10.131.75.183 obtained, lease time 7200
[11-02_11:36:18:414] udhcpc: ifconfig wwan0 10.131.75.183 netmask 255.255.255.240 broadcast +
[11-02_11:36:18:422] udhcpc: setting default routers: 10.131.75.184
有天线的效果:
root@LoRaGateway:~# quectel-CM
[11-02_14:04:23:118] Quectel_Linux_ConnectManager_SR01A01V21
[11-02_14:04:23:118] quectel-CM profile[1] = (null)/(null)/(null)/0, pincode = (null)
[11-02_14:04:23:119] Find qmichannel = /dev/cdc-wdm0
[11-02_14:04:23:119] Find usbnet_adapter = wwan0
[11-02_14:04:23:129] cdc_wdm_fd = 7
[11-02_14:04:23:204] Get clientWDS = 18
[11-02_14:04:23:236] Get clientDMS = 1
[11-02_14:04:23:268] Get clientNAS = 3
[11-02_14:04:23:300] Get clientUIM = 1
[11-02_14:04:23:332] Get clientWDA = 1
[11-02_14:04:23:364] requestBaseBandVersion EC20CEHCR06A03M1G
[11-02_14:04:23:428] requestGetSIMStatus SIMStatus: SIM_READY
[11-02_14:04:23:460] requestGetProfile[1] cmnet///0
[11-02_14:04:23:492] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[11-02_14:04:23:524] requestQueryDataCall ConnectionStatus: DISCONNECTED
[11-02_14:04:23:588] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[11-02_14:04:23:620] requestSetupDataCall WdsConnectionIPv4Handle: 0xe17cb050
[11-02_14:04:23:684] requestQueryDataCall ConnectionStatus: CONNECTED
[11-02_14:04:23:725] udhcpc (v1.23.2) started
[11-02_14:04:23:736] Sending discover...
[11-02_14:04:23:741] Sending select for 10.131.75.183...
[11-02_14:04:23:744] Lease of 10.131.75.183 obtained, lease time 7200
[11-02_14:04:23:749] udhcpc: ifconfig wwan0 10.131.75.183 netmask 255.255.255.240 broadcast +
[11-02_14:04:23:758] udhcpc: setting default routers: 10.131.75.184
附件:
ec20驱动包(包含patch文件)
最后
以上就是漂亮枫叶为你收集整理的MT7628学习笔记(25)——OpenWRT添加 2G/3G/4G(含CAT1)模块上网(EC20)一、模块配置二、EC20驱动移植三、测试EC20上网四、Luci界面添加新网卡接口五、其他的全部内容,希望文章能够帮你解决MT7628学习笔记(25)——OpenWRT添加 2G/3G/4G(含CAT1)模块上网(EC20)一、模块配置二、EC20驱动移植三、测试EC20上网四、Luci界面添加新网卡接口五、其他所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复