注意:
本文档不支持热插拔,本文使用GobiNET方式实现4G上网,并没使用PPPD模式。
1、内核部分的移植
1.1 usb串口驱动的修改
修改:
autochips/kernel/drivers/usb/serial/option.c
kernel/drivers/usb/serial/qcserial.c
kernel/drivers/usb/serial/usb_wwan.c
修改:autochips/kernel/drivers/usb/serial/option.c 文件,添加EC20模块的注册时的VID和PID号,以及生成设备阶段的接口4用于网络设备,如下:
static const struct usb_device_id option_ids[] = {
.....................................................................................
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
//EC20 yiyuan 4G LTE module configure
#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
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) },
.........................................................................................
}
static int option_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
struct usb_wwan_intf_private *data;
printk("option_probe, 1\n");
#if 1 //Added by Quectel
//Quectel UC20's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == 0x05C6 && serial->dev->descriptor.idProduct ==
0x9003 && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
//Quectel EC20's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == 0x05C6 && serial->dev->descriptor.idProduct ==
0x9215 && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C) &&
serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
#endif
//end yiyuan
..........................................................
}
static struct usb_serial_driver option_1port_device = {
.driver = {
.owner = THIS_MODULE,
.name = "option1",
},
.description = "GSM modem (1-port)",
.id_table = option_ids,
.num_ports = 1,
.probe = option_probe,
.open = usb_wwan_open,
.close = usb_wwan_close,
.dtr_rts = usb_wwan_dtr_rts,
.write = usb_wwan_write,
.write_room = usb_wwan_write_room,
.chars_in_buffer = usb_wwan_chars_in_buffer,
.set_termios = usb_wwan_set_termios,
.tiocmget = usb_wwan_tiocmget,
.tiocmset = usb_wwan_tiocmset,
.ioctl = usb_wwan_ioctl,
.attach = usb_wwan_startup,
.disconnect = usb_wwan_disconnect,
.release = option_release,
.read_int_callback = option_instat_callback,
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1 //Added by Quectel
//.reset_resume = usb_wwan_resume,
#endif
#endif
};
修改:kernel/drivers/usb/serial/qcserial.c 去掉文件中跟移远4G模块VID和PID相冲突的选项,如下:
static const struct usb_device_id id_table[] = {
......................................................................
{USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */
//for EC20 yiyuan module remove
//{USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
{USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */
.................................................................................
}
修改:kernel/drivers/usb/serial/usb_wwan.c文件,将移远模块在USB串口urb数据上传时使用0数据包处理,数据上行和下行使用USB网络接口,修改如下:
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);
//add for EC20 yiyuan
#if 1//Added by Quectel for Zero Packet
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
//end EC20
return urb;
}
1.2USB网络接口的修改
移远的4G模块使用Gobinet驱动来实现网络数据的上行和下行,方法如下:
将移远提供的驱动包中的文件放到
kernel/drivers/net/usb/GobiUSBNet.c
kernel/drivers/net/usb/QMI.c
kernel/drivers/net/usb/QMI.h
kernel/drivers/net/usb/QMIDevice.c
kernel/drivers/net/usb/QMIDevice.h
kernel/drivers/net/usb/Structs.h
修改kernel/drivers/net/usb/Makefile,添加编译选项,如下:
obj-y += GobiNet.o
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
obj-$(CONFIG_USB_CATC) += catc.o
修改kernel/drivers/net/usb/qmi_wwan.c USB网络接口驱动,添加EC2.1模块的VID和PID,将GobiNet驱动跟USB网络驱动链接到一起,将文件系统接口的ttyUSB访问时转接到GobiNet驱动上,同时去掉接口中针对移远模块的旧的VID、PID配置,修改如下:
static const struct usb_device_id products[] = {
..............................................................................
{QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
//{QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
{QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
...............................................................................
{QMI_GOBI_DEVICE(0x1199, 0x901b)}, /* Sierra Wireless MC7770 */
#if 1//Added by Quectel
//{QMI_GOBI_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
//{QMI_GOBI_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
{QMI_GOBI_DEVICE(0x05c6, 0x9215)}, //For Quectel EC20
{QMI_GOBI_DEVICE(0x2C7C, 0x0125)}, //For Quectel EC20
{QMI_GOBI_DEVICE(0x2C7C, 0x0121)}, //For Quectel EC20
#endif
{ } /* END */
};
1.3 内核配置文件修改
修改:autochips/kernel/arch/arm/configs/ac83xx_defconfig
添加ppp的配置选项:
CONFIG_PPP=y
CONFIG_PPP_BSDCOMP=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPPOE=y
CONFIG_PPPOL2TP=y
CONFIG_PPPOLAC=y
CONFIG_PPPOPNS=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_SLHC=y
USB网络的配置:
CONFIG_USB_USBNET=y ---------->必选
CONFIG_USB_NET_AX8817X=y
CONFIG_USB_NET_CDCETHER=y
CONFIG_USB_NET_CDC_NCM=y
CONFIG_USB_NET_NET1080=y
CONFIG_USB_NET_CDC_SUBSET=y
CONFIG_USB_BELKIN=y
CONFIG_USB_ARMLINUX=y
CONFIG_USB_NET_ZAURUS=y
USB串口配置:
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_WWAN=y
CONFIG_USB_SERIAL_OPTION=y
2、HAL的配置
2.1 删除ATC平台本身自带的与ril层拨号相关的部分
首先删除本身ATC平台之前调试3G模块针对电话网络部分的修改,主要有chat、ip-down、ip-up、rild以及reference-ril,这个几个部分跟EC2.1模块的ril层使用有冲突,不去掉编译将报错误或者在ril层拨号时不成功。删除部分如下:
autochips/hardware/ril/
autochips/external/chat/Android.mk
autochips/external/ppp/android/Android.mk
autochips/device/atc/ac8317/.overlay/hardware/ril/
1)删除autochips/hardware/ril 这个目录
2)删除autochips/device/atc/ac8317/.overlay/hardware/ril 这个目录
3) 修改autochips/external/chat/Android.mk文件,去掉编译选项,如下:
#ifeq ($(TARGET_ARCH),arm)
ifeq ($(TARGET_ARCH), )
....................................
}
或将android.mk修改成android_mk,如下:
autochips/external/chat/Android_mk 去掉自带chat的编译
4) 将autochips/external/ppp/android/Android.mk修改成:
autochips/external/ppp/android/Android_mk.bak
将autochips/external/ppp/android/目录下的文件不编译进系统。
2.2 添加EC2.1模块的ril层代码
2.2.1 如果是源码代码,请按照以下方式
将移远提供的EC2.1模块的ril代码reference-ril文件夹添加到hardware/ril/目录中,替换掉系统中自带的hardware/ril/reference-ril/目录,如下:
hardware/ril/reference-ril_bak/
hardware/ril/reference-ril_bak/Android_mk
hardware/ril/reference-ril/
2.2.2 如果提供的是二进制文件和库,请使用如下方式修改
去掉系统自带的的hardware/ril/reference-ril/目录
hardware/ril/reference-ril_bak/
hardware/ril/reference-ril_bak/Android_mk
在autochips/hardware/ril/目录或者hardware/ril/目录中创建reference-ril目录,将厂家提供的二进制文件放到reference-ril目录中,mtk平台放到autochips/hardware/ril/reference-ril/目录下,其它平台放到hardware/ril/reference-ril/目录下,如下:
autochips/hardware/ril/reference-ril/Android.mk
autochips/hardware/ril/reference-ril/ip-up
autochips/hardware/ril/reference-ril/ip-down
autochips/hardware/ril/reference-ril/chat
autochips/hardware/ril/reference-ril/libreference-ril.so
修改autochips/hardware/ril/reference-ril/Android.mk 内容如下:
LOCAL_PATH := $(call my-dir)
###############################################################
# copy the shell script to etc/ppp
#
###############################################################
include $(CLEAR_VARS)
LOCAL_MODULE := ip-up
#LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ppp
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := ip-down
#LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ppp
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE:= chat
#LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS:= EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
修改autochips/device/atc/ac8317/generic_ac8317.mk文件,添加libreference-ril.so的拷贝方式,如下:
PRODUCT_COPY_FILES := \
$(AUTOCHIPS_DIR)/hardware/ril/reference-ril/libreference-ril.so:system/lib/libreference-ril.so
2.2.3 如果有存在out目录,并且系统之前编译的中间件文件有ip-up、ip-down、chat、libreference-ril.so的条件下,请按如下方式修改
请删除以下文件,否则系统全部编译完成后,
out/target/product/ac8317/system/lib/libreference-ril.so
out/target/product/ac8317/system/bin/chat
out/target/product/ac8317/system/etc/ppp/ip-up
out/target/product/ac8317/system/etc/ppp/ip-down
目录中的文件仍然是之前系统编译生成的中间件文件,删除之前编译生成的中间件文件目录,如下:
out/target/product/ac8317/obj/EXECUTABLES/chat_intermediates/ ---------->删除
out/target/product/ac8317/obj/SHARED_LIBRARIES/libreference-ril*.so_intermediates/ --->删除
out/target/product/ac8317/obj/SHARED_LIBRARIES/libreference-ril_intermediates/ --->删除
out/target/product/ac8317/obj/lib/libreference-ril.so ------>删除
out/target/product/ac8317/obj/ETC/ip-down_intermediates/ ------>删除
out/target/product/ac8317/obj/ETC/ip-up_intermediates / ------>删除
2.2.4 如果保留out目录进行编译,编译完成后请验证输出结果
请在编译完成之后对比客户给的文件跟系统生成的文件是否一致,系统生成的文件如下:
out/target/product/ac8317/system/lib/libreference-ril.so
out/target/product/ac8317/system/bin/chat
out/target/product/ac8317/system/etc/ppp/ip-up
out/target/product/ac8317/system/etc/ppp/ip-down
跟客户给的文件请使用Beyond compare工具对比,如果不一致证明文件拷贝有问题或者中间件文件没删除干净,一致则OK.
2.3 添加移远提供的ril代码中的chat、ip-down、ip-up选项
修改build/target/product/base.mk修改,如下:
PRODUCT_PACKAGES += \
20-dns.conf \
95-configured \
..........................
libreference-ril \
chat \
ip-up \
ip-down \
libreverbwrapper \
..............................
Vold
2.4 修改系统自带的rild
hardware/ril/rild/rild.c 去掉main()函数中用户切换功能,修改如下:
int main(int argc, char **argv)
{
............................................
OpenLib:
#endif
//switchUser();
dlHandle = dlopen(rilLibPath, RTLD_NOW);
.....................................................
}
3 Android os层的配置
3.1 init.rc启动时服务和访问文件权限的配置
修改autochips/build/.overlay/device/atc/ac8317/configs/main/init_for_mmc.rc
autochips/build/.overlay/device/atc/ac8317/configs/new/init_for_mmc.rc
修改如下:
在on post-fs-data标签中添加chat、ip-down、ip-up的权限配置,如下:
on post-fs-data
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
..............................
chmod 0777 /system/bin/switch_usb_mode.sh
chmod 0777 /system/bin/storage_stress_test.sh
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770 root root
# change permissions for ppp
chmod 777 /system/etc/ppp/ip-up
chmod 777 /system/etc/ppp/ip-down
chmod 777 /system/etc/ppp/chat
........................................................
去掉之前的系统的3G模块的服务,更换成EC20 R2.1模块的服务配置,如下:
#service ril-daemon /system/bin/rild -l libmtk-ril.so -- -d /dev/ttyUSB3
# class main
# socket rild stream 660 root radio
# socket rild-debug stream 660 radio system
# user root
# group radio cache inet misc audio log
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so
class main
socket rild stream 660 root radio
socket rild-debug stream 666 radio system
user root
group radio cache inet misc audio sdcard_rw log
3.2 Android Framework层针对电话网络模块的配置
这个部分主要修改:
autochips/build/.overlay/frameworks/base/core/res/res/values/main/config.xml
autochips/build/.overlay/frameworks/base/core/res/res/values/new/config.xml
修改如下:
3.3 APN的配置
这个部分主要修改:
autochips/device/atc/ac8317/data/etc/apns-conf.xml 添加红色字体部分:
mnc="00"
apn="cmnet"
user="*"
server="*"
password="*"
mmsc="null"
/>
.................................................
mnc="16"
apn="mms"
user="tmobilemms"
password="tmobilemms"
server="*"
mmsproxy="010.010.010.011"
mmsport="8080"
mmsc="http://t-mobilemms"
type="mms"
/>
mnc="01"
apn="3gnet"
user=""
server=""
password=""
mmsc=""
/>
mnc="00"
apn="cmnet"
user=""
server=""
password=""
mmsc=""
/>
mnc="02"
apn="cmnet"
user=""
server=""
password=""
mmsc=""
/>
mnc="07"
apn="cmnet"
user=""
server=""
password=""
mmsc=""
/>
mnc="03"
apn="ctnet"
user="[email protected]"
password="vnet.mobi"
proxy="10.0.0.200"
port="80"
type="default,supl"
/>
mnc="11"
user="[email protected]"
password="vnet.mobi"
apn="ctnet"
type="default,supl"
/>
4.默认系统是不在状态栏显示4G图标
默认系统是不在状态栏显示4G图标,请将系统自带的SystemUI、Settings、SettingsProvider这三个APK中的Android.mk打开,然后进入源码目录中,使用mm ./ 单独编译这三个APK,编译完成后保留在另外目录或U盘中。
将编译好的系统进行升级到机器上,之后将/flysystem/app/目录中SystemUI、Settings、SettingsProvider三个APK替换到成系统自带的SystemUI、Settings、SettingsProvider三个APK文件,之后重启系统,插入4G模块之后就有了4G信号显示图标了。
#mount -o remount, rw flysystem/
#cp Settings.apk /flysystem/app/
#cp SettingsProvider.apk /flysystem/app/
#cp SystemUI.apk /flysystem/app/
注意拷贝的时候先替换Settings.apk、SettingsProvider.apk,替换完SystemUI.apk系统会直接重启,所以首先替换Settings.apk、SettingsProvider.apk,后替换SystemUI.apk。
4G模块插入后到看到状态栏有4G图标显示并有4G字样之后,即可打开浏览器上网
同时请修改架构层和APP层打开LTE选项,否则默认是3G网络,没法显示4G图标,修改如下:
修改: frameworks\base\telephony\java\com\android\internal\telephony\RILConstants.java
//int PREFERRED_NETWORK_MODE = NETWORK_MODE_WCDMA_PREF;
int PREFERRED_NETWORK_MODE = NETWORK_MODE_LTE_GSM_WCDMA;
修改:packages\apps\Phone\res\values\config.xml
修改好之后全部编译,将/system/app/Phone.apk push到机器的,flysystem/app/目录下替换机器中的文件。
5.测试并进行验证
修改配置完成后使用
$source selfenv newui
$./selfbuild cpoverlay newui
$./selfbuild
编译整个系统,编译完成后,将system、ramdisk、kernel三个部分做升级包升级到系统中。
插入4G模块,开机启动。之后按照第4章中的说明将Settings.apk、SettingsProvider.apk、SystemUI.apk、Phone.apk 四个APK push到flysystem/app目录中替换掉之前的APK,然后插入4G模块,在设置菜单中选择“更多”---->”移动网络”------>”网络模式”---------->”LTE/CDMA”选项打勾,点击”确定”即可。
插入4G模块之后一会就可以看到 4G图标了。
有问题时抓取radio log。
#adb shell
#logcat -b radio 抓取radio的日志,看是否拨号成功,成功之后,使用ping和netstat看网络状态。
root@android:/ # netstat
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5038 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5040 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7000 0.0.0.0:* LISTEN
tcp6 1 0 ::ffff:10.153.50.37:36212 ::ffff:74.125.204.102:443 SYN_SENT
tcp6 1 1 ::ffff:10.153.50.37:37211 ::ffff:220.181.163.3:80 LAST_ACK
tcp6 0 1 ::ffff:10.153.50.37:55686 ::ffff:183.129.161.214:80 CLOSE_WAIT
root@android:/ # ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39: icmp_seq=1 ttl=53 time=21.9 ms
64 bytes from 14.215.177.39: icmp_seq=2 ttl=53 time=35.2 ms
64 bytes from 14.215.177.39: icmp_seq=3 ttl=53 time=30.1 ms
64 bytes from 14.215.177.39: icmp_seq=4 ttl=53 time=32.7 ms
64 bytes from 14.215.177.39: icmp_seq=5 ttl=53 time=31.9 ms
注意:在4G模块插入的时候会弹出对话框,选择”暂时不用”,否则4G网络会存在不能使用的问题