• 欢迎大家分享资料!前往留言板评论即可!

合宙4G 模块 安卓RIL驱动

合宙 模组资料网 7个月前 (05-15) 98次浏览 已收录 0个评论 扫描二维码

####CAT4 源码
1.安卓2-7 点击下载安卓2-7.7z
2.安卓8 点击下载安卓8.7z
3.安卓9 点击下载安卓9.7z

CAT1 源码

1.安卓2-7 点击下载
1.安卓8 [点击下载]

##一、 LINUX内核修改
###1. Add VID add PID
File: [KERNEL]/drivers/usb/serial/option.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

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

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

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

/* 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:

    cd <your kernel directory>

Step 2:

“`bash
make menuconfig

<pre><code class="line-numbers">#### Step 3:Enable CONFIG_USB_SERIAL_OPTION
“`bash
[*] Device Drivers →
  [*] USB Support →
    [*] USB Serial Converter support →
      [*] USB driver for GSM and CDMA modems

合宙4G 模块 安卓RIL驱动

Step 4:Configure Kernel to Support PPP

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

合宙4G 模块 安卓RIL驱动

###5.编译内核

make    

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

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

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

# 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系统

#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文件中加入以下代码:

/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文件中加入以下代码:

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(也有可能在其他位置,具体请咨询方案商)

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

改成:

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输出到本地目录。


转载请注明原文链接:合宙4G 模块 安卓RIL驱动
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址