4G模塊Air720系列 android RIL驅動源碼發佈

http://ask.openluat.com/article/95?tdsourcetag=s_pcqq_aiomsg

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

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


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

3. Add Reset Resume

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


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

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


 
  1. /* Driver structure we register with the USB core */
  2. static struct usb_driver usb_serial_driver = {
  3. .name ="usbserial",
  4. .probe =usb_serial_probe,
  5. .disconnect =usb_serial_disconnect,
  6. .suspend =usb_serial_suspend,
  7. .resume =usb_serial_resume,
  8. //+add by airm2m for Air72x
  9. .reset_resume = usb_serial_resume,
  10. //-add by airm2m for Air72x
  11. .no_dynamic_id = 1,
  12. };

4. Modify Kernel Configuration

Step 1:


 
  1. cd <your kernel directory>

Step 2:


 
  1. make menuconfig

Step 3:Enable CONFIG_USB_SERIAL_OPTION


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

Step 4:Configure Kernel to Support PPP


 
  1. [*] Device Drivers →
  2.   [*] Network device support →
  3.     [*] 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. # ril related services
  2. service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so class main
  3. socket rild stream 660 root radio
  4. socket rild-debug stream 660 radio system
  5. user root

64位android系統


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

2. 如果您使用的是物聯網卡(比如46004的SIM卡),可能需要在apns-conf.xml中添加相應的APN

3. 對於android5.0及以上的版本,需要對SELinux相關的配置文件做如下改動:

1). 在external/sepolicy/file_contexts文件中加入以下代碼:


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

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


 
  1. allow rild default_prop:property_service set;
  2. allow rild device:chr_file { read write ioctl open getattr };
  3. allow rild kernel:system module_request;
  4. allow rild net_radio_prop:property_service set;
  5. allow rild ppp_device:chr_file { read write ioctl open };
  6. allow rild ppp_exec:file { read execute open execute_no_trans };
  7. allow rild radio_prop:property_service set;
  8. allow rild self:capability { net_admin setuid };
  9. allow rild shell_exec:file { read execute open execute_no_trans };
  10. allow rild sysfs_wake_lock:file { open read write };
  11. allow rild system_file:file execute_no_trans;
  12. 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輸出到本地目錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章