Toggle navigation
首页
(current)
问答
文章
话题
商城
登录
注册
合宙4G 模块 安卓RIL驱动
模块对于安卓来说就是一个上网的部件,一般客户都还是使用ppp 拨号方式上网的,安卓可以通过ril 来适配不同的 模块, 其中ril 就需要我们自己开发了,ril 的作用是将 安卓下发的命令,转化为AT 和模块进行通信,然后将模块的 返回(URC 或者应答)通过不同的通道返回给安卓
####CAT4 源码 1.安卓2-7 [点击下载](https://oldask.openluat.com/file/attachments-2020-06-IameRuU25ef1cb957cf74_%E5%AE%89%E5%8D%931-7.7z "点击下载") 2.安卓8[点击下载](https://oldask.openluat.com/file/attachments-2020-06-RYR2xgvY5eeddb8906899_%E5%AE%89%E5%8D%938.7z "安卓8") 3.安卓9 [点击下载](https://oldask.openluat.com/file/attachments-2020-06-bHdKyJEB5eeddb0c91ed3_%E5%AE%89%E5%8D%939.rar "安卓9") #### CAT1 源码 1.安卓2-8 [点击下载](https://oldask.openluat.com/file/attachments-2020-06-LEs1bgZH5eeddafda3d1c_RIL_trunk_8910_%E5%AE%89%E5%8D%931-8.7z "安卓1-8") ##一、 LINUX内核修改 ###1. Add VID add PID File:
[KERNEL]/drivers/usb/serial/option.c
```c static const struct usb_device_id option_ids[] = { //+add by airm2m for Air72x { USB_DEVICE(0x1782, 0x4e00) }, /* CAT1 系列*/ { USB_DEVICE(0x1286, 0x4e3d) }, /* CAT4 系列*/ //-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
```c 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)) { /* CAT4 系列*/ urb->transfer_flags |= URB_ZERO_PACKET; } if(desc->idVendor == cpu_to_le16(0x1782) && desc->idProduct == cpu_to_le16(0x4e00)) { /* CAT1 系列*/ 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
```c 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)) { /* CAT4 系列*/ urb->transfer_flags |= URB_ZERO_PACKET; } if(desc->idVendor == cpu_to_le16(0x1782) && desc->idProduct == cpu_to_le16(0x4e00)) { /* CAT1 系列*/ 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
```c 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
```c /* 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: ```bash cd
``` #### Step 2: ```bash make menuconfig ``` #### Step 3:Enable CONFIG_USB_SERIAL_OPTION ```bash [*] Device Drivers → [*] USB Support → [*] USB Serial Converter support → [*] USB driver for GSM and CDMA modems ``` ![](http://ask.openluat.com/image/show/attachments-2018-09-UvLI6qjo5b8b7c3fabe04.png) #### Step 4:Configure Kernel to Support PPP ```bash [*] Device Drivers → [*] Network device support → [*] PPP (point-to-point protocol) support ``` ![](http://ask.openluat.com/image/show/attachments-2018-09-0MkDlKPS5b8b7cde500a3.png) ###5.编译内核 ```bash 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系统 ```bash # 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系统 ```bash #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文件中加入以下代码: ```bash /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文件中加入以下代码: ```bash 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(也有可能在其他位置,具体请咨询方案商) ```bash neverallow { domain -unconfineddomain -ueventd -recovery -busybox } device:chr_file { open read write }; ``` 改成: ```bash 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输出到本地目录。
发表于 2020-06-20 17:54
阅读 ( 7250 )
1 推荐
收藏
你可能感兴趣的文章
相关问题
1 条评论
请先
登录
后评论
梁健
软件工程师
11 篇文章
作家榜
»
技术销售Delectate
43 文章
陈夏
26 文章
国梁
24 文章
miuser
21 文章
晨旭
20 文章
朱天华
19 文章
金艺
19 文章
杨奉武
18 文章
×
发送私信
发给:
内容:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!