4G模块Air720系列 android RIL驱动源码发布!(2019/2/25更新)

#2019/4/16 更新说明
###1、 加快联网速度
###2、 修改部分客户ppp 拨号后需要设置成默认路由才可以上网的问题
###3、 增加版本信息打印
###4、 增加主动上报信号
###5、 优化联网稳定性
##2019/4/16发布的RIL驱动下载地址:
AIRM2M_RIL_1.0.4

##关于首选关闭移动数据的说明:
###1、由于某些设备会自动下发关闭移数据的命令导致无法上网,所以默认关闭了这个功能,如果需要请在Reference-ril.c 将ALLOW_CLOSE_PPP 设置为1
##关于自动设置默认路由的说明:
###1有些机器ppp 拨号成功后却无法上网,请将编译后的linux out 目录下的 ./obj/EXECUTABLES/ip-up_intermediates/LINKED/ip-up 文件push 到 /etc/ppp/ip-up

#2019/2/25 更新说明
###1、 解决信号强度显示不准的问题
###2、 解决SIM卡未准备就绪之前查询不到IMEI的问题
###3、 优化联网速度
###4、 关闭首选网络类型功能,默认首选网络类型始终为4G LTE优先
###5、 修复android各版本的兼容性问题

##关于首选网络类型的说明:
####1. 首选网络类型是指网络制式的选择(LTE、3G、2G), 用户可以通过设置->移动网络->首选网络类型进行操作。
####2. 由于720系列模块自带了网络制式的选择功能(默认LTE优先,当LTE信号不理想时,会自动切换到3G或者2G网络模式),而且目前很少有客户需要此功能,所以此次发布的版本关闭了首选网络类型功能。
####3. 虽然关闭了首选网络类型功能,但对用户来讲是透明的,对用户体验不会造成影响。
####4. 如果客户需要这个功能,请自行在Reference-ril.c文件中加入以下代码:#define RIL_SET_PREFERRED_NETWORK_SUPPORTED
##2019/2/25发布的RIL驱动下载地址:RIL_VERSION_18_2_25

#2018/11/15 更新说明
###1、此次更新兼容了android2.3.4、android4、android5、android6、 android7版本
###2、修复了相关BUG
###3、模块软件版本需要同步更新至AirM2M_720_V446_LTE_AT或者更高版本
###4、此版本已在RK、全志平台各CPU上验证通过。
###5、RIL代码与以下厂商调试通过:
####深圳市三全视讯科技有限公司 http://www.3qvideo.com/
####深圳市雍慧电子科技有限公司 微信公众号:雍慧电子
####深圳市启明云端科技有限公司 http://www.wireless-tag.cn/
####深圳市群智信息技术有限公司 http://www.alagroup.cn/
####深圳市众云世纪科技有限公司 http://www.zysj-sz.com/
####深圳音诺恒科技有限公司 http://www.innohi.com.cn/
####深圳市国睿智能技术有限公司 http://www.gruio.com/

##RIL驱动下载地址:ril_release_1115.tar.gz

##一、 LINUX内核修改
###1. Add VID add PID
File: [KERNEL]/drivers/usb/serial/option.c

1
2
3
4
5
6
7
8
9
static const struct usb_device_id option_ids[] = {
//+add by airm2m for Air72x
{ USB_DEVICE(0x1286, 0x4e3d) },
//-add by airm2m for Air72x
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },

###2. Add the Zero Packet Mechanism
⦁For linux Kernel Version newer than 2.6.34:
File: [KERNEL]/drivers/usb/serial/usb_wwan.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback) (struct urb *))
{
struct usb_serial *serial = port->serial;
struct urb *urb;
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
if (!urb)
return NULL;
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
//+add by airm2m for Air72x
if(dir == USB_DIR_OUT){
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if(desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))
{
urb->transfer_flags |= URB_ZERO_PACKET;
}
}
//-add by airm2m for Air72x
return urb;
}

⦁For linux Kernel Version older than 2.6.35:
File: [KERNEL]/drivers/usb/serial/option.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback)(struct urb *))
{
......
/* Fill URB using supplied data. */
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
//+add by airm2m for Air72x
if(dir == USB_DIR_OUT)
{
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if(desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))
{
urb->transfer_flags |= URB_ZERO_PACKET;
}
}
//-add by airm2m for Air72x
return urb;
}

###3. Add Reset Resume
⦁For linux Kernel Version newer than 3.4:
File: [KERNEL]/drivers/usb/serial/option.c

1
2
3
4
5
6
7
8
9
10
11
12
13
static struct usb_serial_driver option_1port_device = {
.driver = {
.owner = THIS_MODULE,
.name = "option1",
},
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#endif
//+add by airm2m for Air720
.reset_resume = usb_wwan_resume,
//-add by airm2m for Air720
};

⦁For linux Kernel Version older than 3.5:
File: [kernel]/drivers/usb/serial/usb-serial.c

1
2
3
4
5
6
7
8
9
10
11
12
/* Driver structure we register with the USB core */
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,
//+add by airm2m for Air72x
.reset_resume = usb_serial_resume,
//-add by airm2m for Air72x
.no_dynamic_id = 1,
};

###4. Modify Kernel Configuration
####Step 1:

1
cd <your kernel directory>

Step 2:

1
make menuconfig

Step 3:Enable CONFIG_USB_SERIAL_OPTION

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

Step 4:Configure Kernel to Support PPP

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

###5.编译内核

1
make    

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

##二、android修改和编译
###1. 请将附件中的代码包(reference-ril_release_1115.tar.gz)下载并解压缩。
###2. 将解压后的refrence-ril目录下的所有文件覆盖到android代码的hardware/ril/refrence-ril目录下
###3. 在rild.c文件中, 注释掉 switchUser(); 这一行代码。
###4. 输入touch hardware/ril/* 强制让ril目录下所有的文件参与编译
###5. 开始编译android

##三、配置
###1. 在init.rc文件中加入如下代码:
#####32位android系统

1
2
3
4
5
# ril related services
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root

#####64位android系统

1
2
3
4
5
#ril related services
service ril-daemon /system/bin/rild -l /system/lib64/libreference-ril.so class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root

###2. 如果您使用的是物联网卡(比如46004的SIM卡),可能需要在apns-conf.xml中添加相应的APN
###3. 对于android5.0及以上的版本,需要对SELinux相关的配置文件做如下改动:
####1). 在external/sepolicy/file_contexts文件中加入以下代码:

1
2
3
4
5
6
/dev/ttyUSB[0-9]* u:object_r:tty_device:s0
/system/bin/rild u:object_r:rild_exec:s0
/system/socket/rild u:object_r:rild_socket:s0
/system/socket/rild-debug u:object_r:rild_debug_socket:s0
/system/bin/pppd u:object_r:pppd_exec:s0
/dev/ppp u:object_r:ppp_device:s0

####2).在external/sepolicy/rild.te文件中加入以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
allow rild default_prop:property_service set;
allow rild device:chr_file { read write ioctl open getattr };
allow rild kernel:system module_request;
allow rild net_radio_prop:property_service set;
allow rild ppp_device:chr_file { read write ioctl open };
allow rild ppp_exec:file { read execute open execute_no_trans };
allow rild radio_prop:property_service set;
allow rild self:capability { net_admin setuid };
allow rild shell_exec:file { read execute open execute_no_trans };
allow rild sysfs_wake_lock:file { open read write };
allow rild system_file:file execute_no_trans;
allow rild system_prop:property_service set;

####3).修改external/sepolicy/domain.te(也有可能在其他位置,具体请咨询方案商)

1
neverallow { domain -unconfineddomain -ueventd -recovery -busybox } device:chr_file { open read write };

改成:

1
neverallow { domain -unconfineddomain -ueventd -recovery -busybox -rild } device:chr_file { open read write };

#####请注意:每个厂商提供的domain.te不一定如上所示。找到类似于neverallow {domain -XXXX -XXXX -XXXX} device:chr_file { open read write };格式的地方,加上-rild即可

##四、调试
###如果在调试过程中遇到了问题,我们可能需要您提供相关的LOG。
###使用adb工具抓取相应的LOG的方法:
####1. 使用命令 adb logcat –b radio –v time ,可以将LOG显示在命令行窗口
####2. 在linux/windows+cygwin环境下,可以使用命令 adb logcat –b radio –v time > 本地文件,将LOG输出到本地目录。

上次更新 2021-01-28