OpenWrt操作系统移植SIM7600CE驱动及调试

1、开发环境
操作系统:OpenWrt
客户机:MT7688
拨号方式:NDIS------>wwan0

2、配置文件及参数
(1)USB Serial 的内核配置支持
在 linux 内核配置中,请确保
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_WWAN=y
CONFIG_USB_SERIAL_OPTION=y
CONFIG_USBNET=y
(2) 修改驱动代码增加 SIM7500_SIM7600 的 VID/PID 并且跳过 Interface 5
找到内核源码文件 option.c(一般情况下,路径在 drivers/usb/serial/option.c)Smart Machine Smart Decision
 如果是较新的内核版本(V3.2 以上)
#define SIMCOM_SIM7600_VID 0x1E0E
#define SIMCOM_SIM7600_PID 0x9001
//for SIM7600 modem for NDIS
static const struct option_blacklist_info simcom_sim7600_blacklist = {
.reserved = BIT(5),
};
在 option_ids 列表中增加
… …
//for SIM7600 modem for NDIS
{ USB_DEVICE(SIMCOM_SIM7600_VID, SIMCOM_SIM7600_PID),
.driver_info = (kernel_ulong_t)& simcom_sim7600_blacklist
},
… …
 如果是较低的内核版本,
#define SIMCOM_SIM7600_VID 0x1E0E
#define SIMCOM_SIM7600_PID 0x9001
在 option_ids 列表中增加
{ USB_DEVICE(SIMCOM_SIM7600_VID, SIMCOM_SIM7600_PID)}, /*SIM7600 /
并且在 option_probe 里过滤掉 interface 5
/
sim7600 */
if (serial->dev->descriptor.idVendor == SIMCOM_SIM7600_VID &&
serial->dev->descriptor.idProduct == SIMCOM_SIM7600_PID &&
serial->interface->cur_altsetting->desc.bInterfaceNumber == 5 )
return -ENODEV;
(3)内核调试信息打印
如果驱动正确编译到内核,内核开机找到模块后,会打印如下信息
usb 1-1: new high speed USB device using rt3xxx-ehci and address 2
option 1-1:1.0: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
option 1-1:1.1: GSM modem (1-port) converter detectedSmart Machine Smart Decision
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
option 1-1:1.2: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
option 1-1:1.3: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
option 1-1:1.4: GSM modem (1-port) converter detected
usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
dev/ttyUSB0~4 就会生成,上层应用就可以通过这些设备和模块交互了(发送
AT 命令等)

将sim7500_sim7600_wwan.c 放在 drivers/net/usb 目录下,并且修改 Makefile
obj-$(CONFIG_USB_USBNET) += usbnet.o sim7500_sim7600_wwan.o
驱动正确编译到内核,内核开机后连到模块会打印如下信息
sim7500_sim7600_wwan 1-1:1.5 wwan0: register ’ sim7500_sim7600_wwan’ at
usb-0000:02:03.0-1, SIMCOM wwan/QMI device, 8af6:67:ce:1b

使用 ifconfig 查看网卡信息,默认处于 down 状态。
wwan0 Link encap:Ethernet HWaddr D6:D8:6C:10:B0:0E
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

编译,将固件烧录到客户机上;

3、拨号上网
客户机开机
输入

minicom -D /dev/ttyUSB2

根据下表初始化SIM7600配置

最后输入

AT$QCRMCALL=1,1

拨号成功
按下Ctrl+A,然后X退出minicom

输入

udhcpc –i wwan0

获取到IP
wwan0 Link encap:Ethernet HWaddr D6:D8:6C:10:B0:0E
inetaddr:10.47.77.207 Bcast:10.47.77.223 Mask:255.255.255.224
inet6 addr: fe80::d4d8:6cff:fe10:b00e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:612 (612.0 B) TX bytes:1642 (1.6 KiB)

最后ping www.baidu.com
如果ping通了 ,说明成功了

你可能感兴趣的:(Linux)