Android RIL Driver: User Guide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Android RIL Driver

User Guide

LTE/UMTS/HSPA(+)/GSM/GPRS Module Series

Rev. Android_RIL_Driver_User_Guide_V1.8

Date: 2019-03-07

Status: Released

www.quectel.com
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

Our aim is to provide customers with timely and comprehensive service. For any
assistance, please contact our company headquarters:

Quectel Wireless Solutions Co., Ltd.


7th Floor, Hongye Building, No.1801 Hongmei Road, Xuhui District, Shanghai 200233, China
Tel: +86 21 5108 6236
Email: [email protected]

Or our local office. For more information, please visit:


http://www.quectel.com/support/sales.htm

For technical support, or to report documentation errors, please visit:


http://www.quectel.com/support/technical.htm
Or email to: [email protected]

GENERAL NOTES
QUECTEL OFFERS THE INFORMATION AS A SERVICE TO ITS CUSTOMERS. THE INFORMATION
PROVIDED IS BASED UPON CUSTOMERS’ REQUIREMENTS. QUECTEL MAKES EVERY EFFORT
TO ENSURE THE QUALITY OF THE INFORMATION IT MAKES AVAILABLE. QUECTEL DOES NOT
MAKE ANY WARRANTY AS TO THE INFORMATION CONTAINED HEREIN, AND DOES NOT ACCEPT
ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGE OF ANY KIND INCURRED BY USE OF OR
RELIANCE UPON THE INFORMATION. ALL INFORMATION SUPPLIED HEREIN IS SUBJECT TO
CHANGE WITHOUT PRIOR NOTICE.

COPYRIGHT
THE INFORMATION CONTAINED HERE IS PROPRIETARY TECHNICAL INFORMATION OF
QUECTEL WIRELESS SOLUTIONS CO., LTD. TRANSMITTING, REPRODUCTION, DISSEMINATION
AND EDITING OF THIS DOCUMENT AS WELL AS UTILIZATION OF THE CONTENT ARE
FORBIDDEN WITHOUT PERMISSION. OFFENDERS WILL BE HELD LIABLE FOR PAYMENT OF
DAMAGES. ALL RIGHTS ARE RESERVED IN THE EVENT OF A PATENT GRANT OR
REGISTRATION OF A UTILITY MODEL OR DESIGN.

Copyright © Quectel Wireless Solutions Co., Ltd. 2019. All rights reserved.

Android_RIL_Driver_User_Guide 1 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

About the Document

History

Revision Date Author Description

1.0 2015-02-27 Carl YIN Initial

1.1 2015-03-25 Carl YIN Updated supported products

1.2 2015-04-07 Kent XU Added zero packet feature in Section 3.3.3.

1. Added GSM modules in supported products


1.3 2015-07-10 Kent XU
2. Added Android 5.x in supported Android versions
Carl YIN/ 1. Added EC21&EC25 in supported products
1.4 2016-06-21
Neo HOU 2. Added FAQ

1.5 2016-08-23 Kent XU Added EC20 R2.0 in supported products

1. Added RIL driver integration by library in Section 3.5.


2. Deleted how to modify the right of RILD.
1.6 2017-01-05 Macro GAO 3. Added how to configure device permissions in
Section 3.6.2.
4. Added how to enable SELinux in Section 3.6.3.

1.7 2018-07-13 Macro GAO Added Android 8.x in supported Android versions

1. Added Android 9.x in supported Android versions.


2. Added EC21, EC200T, EM06, EM12, EG12, AG36,
UC200T& MC90 in supported products.
1.8 2019-03-07 Macro GAO
3. Updated the description of system configuration in
Chapter 3.
4. Added how to configure SElinux in Chapter 4.

Android_RIL_Driver_User_Guide 2 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

Contents

About the Document ................................................................................................................................... 2


Contents ....................................................................................................................................................... 3
Table Index ................................................................................................................................................... 4
Figure Index ................................................................................................................................................. 5

1 Introduction .......................................................................................................................................... 6
1.1. Applicable Products ..................................................................................................................... 6

2 Overview of Android RIL Driver ......................................................................................................... 7


2.1. Directory Structure ....................................................................................................................... 7
2.2. Supported Functions .................................................................................................................... 8
2.3. Supported Android Versions ........................................................................................................ 8

3 RIL Integration ...................................................................................................................................... 9


3.1. RIL Driver Structure...................................................................................................................... 9
3.2. PPP Configuration in Linux Kernel ............................................................................................ 10
3.3. Driver Installation ....................................................................................................................... 10
3.4. RIL Driver Integration by Library ................................................................................................ 11
3.5. System Configuration ................................................................................................................. 12
3.5.1. Configure init.rc .............................................................................................................. 12
3.5.1.1. Modules Accessed by USB Interface .................................................................... 12
3.5.1.2. Modules Accessed by UART Interface .................................................................. 13
3.5.2. Modify rild.c (Applicable for Android Versions prior to Android 8.0)................................. 14
3.5.3. Add HIDL Description (Applicable for Android 8.0 or Later Versions) ............................. 15

4 Configure SELinux............................................................................................................................. 16
4.1. Configure Service ril-daemon .................................................................................................... 16
4.2. Uncomment the function of switchUser() ................................................................................... 16
4.3. Configure SELinux Rule for RIL ................................................................................................. 17

5 Debugging Method ............................................................................................................................ 18


5.1. Catch Logs ................................................................................................................................. 18
5.2. Common Log Tags ..................................................................................................................... 19

6 FAQs .................................................................................................................................................... 20
6.1. How to Set the APN ................................................................................................................... 20
6.2. Why Quectel RIL Driver Does not Work .................................................................................... 21
6.3. Why Short Messages cannot be Sent or Received ................................................................... 21

7 Appendix A References..................................................................................................................... 22

Android_RIL_Driver_User_Guide 3 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

Table Index

TABLE 1: APPLICABLE MODULES .................................................................................................................... 6


TABLE 2: SUPPORTED FUNCTIONS ................................................................................................................ 8
TABLE 3: SUPPORTED ANDROID VERSIONS ................................................................................................. 8
TABLE 4: COMMON LOG TAGS....................................................................................................................... 19
TABLE 5: RELATED DOCUMENTS .................................................................................................................. 22
TABLE 6: TERMS AND ABBREVIATIONS ........................................................................................................ 22

Android_RIL_Driver_User_Guide 4 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

Figure Index

FIGURE 1: STRUCTURE OF RIL DRIVER PACKAGE ...................................................................................... 7


FIGURE 2: RIL DRIVER STRUCTURE ............................................................................................................... 9
FIGURE 3: EDIT ACCESS POINT .................................................................................................................... 20

Android_RIL_Driver_User_Guide 5 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

1 Introduction
This document mainly introduces how to integrate RIL (Radio Interface Layer) driver into Android OS of
customers’ target devices as well as how to modify the configuration files for starting RIL service.

1.1. Applicable Products

The document is applicable to the following Quectel modules.

Table 1: Applicable Modules

EC2x: includes EC20/EC25/EC20 R2.0/EC20 R2.1/EC21/EC200T


modules
LTE Standard Module Series
EG9x: includes EG91/EG95 modules

Ex06: includes EM06/EP06/EG06 modules


LTE-A Module Series
Ex12: includes EM12/EG12 modules

Automotive Module Series AGxx: includes AG35/AG36 modules

UCxx: includes UC15/UC20/UC200T modules


UMTS/HSPA(+) Module Series
UGxx: includes UG95/UG96 modules

Mxx: includes M66/M72/M80/M85/M95


GSM/GPRS Module Series
MCxx: includes MC60/MC90 modules

Android_RIL_Driver_User_Guide 6 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

2 Overview of Android RIL Driver

2.1. Directory Structure

The file structure of Quectel RIL driver package is shown as below.

Figure 1: Structure of RIL Driver Package

Android_RIL_Driver_User_Guide 7 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

2.2. Supported Functions

Table 2: Supported Functions

Function Support or Not

SMS YES

Voice Call YES

Data Service YES

(U)SIM Tool Kit NO

Phonebook YES

2.3. Supported Android Versions

Presently, Quectel RIL driver supports the following Android versions:

Table 3: Supported Android Versions

Versions Support or not

Android 4.x YES

Android 5.x YES

Android 6.0 YES

Android 7.x YES

Android 8.x YES

Android 9.x YES

Android_RIL_Driver_User_Guide 8 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

3 RIL Integration
The chapter mainly describes the RIL driver structure and procedures of setting up an Android system
with the RIL driver.

3.1. RIL Driver Structure

Android RIL provides the abstract layer between Android telephony service and radio hardware.

The following illustrates the RIL in the context of Android telephony architecture.

Applications Phone Application

Call Tracker SMS Dispatch Service Tracker Data Tracker

Application Phone
Framework Java/android/telephony

RIL
Java/android/telephony/gsm

Unix

Libraries
Radio Daemon (RILD)
(User Space) /commands/rild

Vendor RIL
System/libs/libril-vendor.so

Packet Service
Linux Kernel Linux IP Stack

Voice and
Control
Packet Driver
PPP.for example

Baseband Baseband

Figure 2: RIL Driver Structure

Android_RIL_Driver_User_Guide 9 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

The RIL in Android is located between kernel and application framework. It is divided into two parts: RILD
and Vendor RIL.

RILD is responsible for communications between socket and application framework.

Vendor RIL is responsible for radio communication via AT command channel and data communication
with packet data channel (PDCH).

The java framework of RIL consists of two parts as well. One is RIL module and the other is Phone
module. The RIL module is used to communicate with the lower RILD, and the phone module directly
provides phone function interfaces to application.

3.2. PPP Configuration in Linux Kernel

The kernel needs to be configured to support PPP dial up. For detailed operation procedures, please refer
to Chapter 3.6 in Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide.

3.3. Driver Installation

If customers use EC2x, EG9x, Ex06, Ex12, AGxx, UCxx or UGxx modules, please integrate USB serial
driver, CDC ACM driver, GobiNet driver or QMI WWAN driver in Linux kernel. Otherwise, please skip this
section. For detailed operation procedures, please refer to Chapter 3.2, Chapter 3.3, Chapter 3.4 or
Chapter 3.5 in Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide.

Android_RIL_Driver_User_Guide 10 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

3.4. RIL Driver Integration by Library

Please put the following RIL library files provided by Quectel into the Android system.

1. For Android versions prior to Android 8.0

⚫ For 32-bit Android system

⚫ For 64-bit Android system

2. For Android 8.0 or later versions

⚫ For 32-bit Android system

⚫ For 64-bit Android system

NOTE

If customers use Android 8.0 or later versions, Quectel RIL driver V1.42.08 or later versions should be
used.

Android_RIL_Driver_User_Guide 11 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

3.5. System Configuration

In order to use the RIL driver normally, some configuration files in Android system should be modified.

3.5.1. Configure init.rc

The init.rc can be configured by adding ril-daemon service to it. The relevant lines added to init.rc are
different, depending on the accessing interfaces and the android versions being used.

3.5.1.1. Modules Accessed by USB Interface

If customers’ modules are accessed by USB interface, like EC2x, EG9x, Ex06, Ex12, AGxx, UCxx and
UGxx, please add the following lines to init.rc:

⚫ For Android versions prior to Android 8.0

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
group radio cache inet misc audio sdcard_rw log

⚫ For Android 8.0 or later versions

service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/libreference-ril.so


class main
user root
group radio cache inet misc audio sdcard_rw log

Android_RIL_Driver_User_Guide 12 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

3.5.1.2. Modules Accessed by UART Interface

If customers’ modules are accessed by UART interface, like Mxx modules, please add the following lines
to init.rc:

⚫ For Android versions prior to Android 8.0

service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d <UART port name> –B


<baud rate> –C <hardware flow control>
class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_rw log

⚫ For Android 8.0 or later versions

service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/libreference-ril.so -- -d


<UART port name> –B <baud rate> –C <hardware flow control>
class main
user root
group radio cache inet misc audio sdcard_rw log

Meanwhile, the following parameter needs to be configured accordingly:

⚫ -d <UART port name>

UART port which is currently used. For example: /dev/ttyS1.

It is optional to configure the following two parameters:

⚫ -B <baud rate>

The speed of UART port. For example: 115200bps, 230400bps or 460800bps. The default baud rate is
115200bps.

⚫ -C <hardware flow control>

1: Enable the hardware flow control function


0: Disable the hardware flow control function (default setting)

Android_RIL_Driver_User_Guide 13 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

The location of init.rc file varies with customers’ project settings. The following gives a non-exhaustive list
of file paths which may contain the init.rc file.

⚫ system/core/rootdir/init.rc
⚫ device/fsl/imx6/init.rc
⚫ device/ti/am335xevm_sk/init.am335xevm.rc
⚫ device/generic/x86/init.rc
⚫ device/samsung/smdkv210/init.smdkv210_sdmmc.rc

3.5.2. Modify rild.c (Applicable for Android Versions prior to Android 8.0)

RILD (ril-daemon) requires root privileges, so please comment the function of switchUser() in the file
($Android_src)/hardware/ril/rild/rild.c.

Android_RIL_Driver_User_Guide 14 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

3.5.3. Add HIDL Description (Applicable for Android 8.0 or Later Versions)

On Android 8.0 or later versions, the communication interface between Android phone framework and
ril-daemon service has been changed from socket to HIDL, so please make sure that the manifest.xml
contains the following HIDL description.

<hal format="hidl">
<name>android.hardware.broadcastradio</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IBroadcastRadioFactory</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.radio.deprecated</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IOemHook</name>
<instance>slot1</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.radio</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IRadio</name>
<instance>slot1</instance>
</interface>
</hal>

The location of manifest.xml file varies with customers’ project settings. For example:
device/rockchip/rk3399/manifest.xml.

Android_RIL_Driver_User_Guide 15 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

4 Configure SELinux
If the SELinux installed in customers’ Android devices is enabled and runs in enforcing mode, please
follow the procedures below to make sure that Quectel RIL has full access to SELinux privileges.
Otherwise, customers can skip this chapter.

4.1. Configure Service ril-daemon

To make sure Quectel RIL has full access to Selinux priviledges, the user of service ril-daemon should be
radio, so the user of service ril-daemon indicated in Chapter 3.5.1 should be changed from root to radio.
Besides, capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW should be added to ril-daemon service.
An example, taking Android 8.0 for instance, is shown below.

service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/libreference-ril.so


class main
user radio
group radio cache inet misc audio sdcard_rw log
capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW

4.2. Uncomment the function of switchUser()

To make sure Quectel RIL has full access to Selinux priviledges, the function of switchUser() mentioned in
Chapter 3.5.2 should be uncommented.

Android_RIL_Driver_User_Guide 16 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

4.3. Configure SELinux Rule for RIL

The following definition should be added to ueventd.rc:

#quectel port
/dev/ttyUSB* 0660 radio radio
/dev/cdc-wdm* 0660 radio radio
/dev/qcqmi* 0660 radio radio
/dev/cdc-acm* 0660 radio radio

The following definition should be added to file_contexts:


/dev/ttyUSB[0-9]* u:object_r:tty_device:s0
/dev/ttyACM[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

The following definition should be added to 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;

The locations of ueventd.rc, rild.te and file_contexts may vary with customers’ project settings, but in
general, these files are located in the following paths respectively by default.

⚫ system/core/rootdir/ueventd.rc
⚫ external/sepolicy/rild.te
⚫ external/sepolicy/file_contexts

Android_RIL_Driver_User_Guide 17 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

5 Debugging Method

5.1. Catch Logs

1) Catch the logs of RIL module by typing the following command in Window’s CMD tool:

adb logcat –b radio –v time

2) Catch the logs of Android system by typing the following command in Window’s CMD tool:

adb logcat –v time

3) Sometimes, customers may want to perform tests on lots of devices or for a long time, and it is not
convenient to connect all devices with PC via USB cables. In such case, customers can catch the log
files by following command:

adb shell
logcat –b radio –v time –f <filename> &

The character "&" makes the "logcat" process run in the background, thus customers’ devices can be
disconnected.

4) When customers’ tests are finished, the log files can be fetched from devices to a local directory by
the following command:

adb pull <filename> <local directory>

Android_RIL_Driver_User_Guide 18 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

5.2. Common Log Tags

The following table lists some log tags that are commonly applied.

Table 4: Common Log Tags

RIL /hardware/ril/reference-ril/refereince-ril.c

AT /hardware/ril/reference-ril/atchannel.c

RILD /hardware/ril/rild/rild.c

RILC /hardware/ril/libril/ril.cpp

RILB /frameworks/base/telephony/java/com/android/internal/telephony/BaseCommands.java

RILJ /frameworks/base/telephony/java/com/android/internal/telephony/gsm/RIL.java

GSM /frameworks/base/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java

Android_RIL_Driver_User_Guide 19 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

6 FAQs

6.1. How to Set the APN

If the dialling process is interrupted, it is quite possible that the APN has not been set yet. Please set the
APN in Android UI: Settings → WIRELESS & NETWORKS → … → Mobile Networks → Access Point
Names.

If nothing is found in Access Point Names, it indicates that the APN has not been set. In such case,
customers need to add a new APN to the system. The following is an example shows the access point
editing interface. Please note that the Access Point Name varies with the operators and (U)SIM cards.

Figure 3: Edit Access Point

Android_RIL_Driver_User_Guide 20 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

6.2. Why Quectel RIL Driver Does not Work

There are many reasons that may cause the failure of Quectel RIL operation, some common causes are
listed as below for troubleshooting.

1. RIL Daemon is not running

Use command getprop init.svc.ril-daemon to check RIL daemon status. If non-value, Stopped or
Restarting is returned, rather than Running, it indicates that RIL daemon is not running.

2. RIL library is not loaded correctly

Check the "ril-daemon" service definition in init.rc through command cat /init.rc | grep ril-daemon. The
expected result should be service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so. Check
the arguments, word spelling, blank space, etc. to make sure the RIL library is loaded correctly.

3. Cannot access USB serial port device file

⚫ Use ls -l /dev/ttyUSB* command to check the access right of the device file.
⚫ Use getenforce command to check whether the SELinux has been enabled. If yes, please use
setenforce 0 command to disable the SELinux.

4. The RIL library is not provided by Quectel

Use getprop gsm.version.ril-impl command to check the Quectel RIL version, and the return value
should be started with Quectel_Android_RIL_SR. If not, then it indicates the RIL library is not provided
by Quectel.

6.3. Why Short Messages cannot be Sent or Received

Use getprop telephony.sms.receive command or telephony.sms.send command to check whether the


system has disabled SMS receive/send function.

If the return value is false, it indicates that the SMS receive/send function has been disabled.
If non-value is returned, please check frameworks/base/core/res/res/values/config.xml (the manufacturer
override configure file) and find config_sms_capable. If the config_sms_capable configuration in the
config.xml is false (e.g. <bool name="config_sms_capable">false</bool>), please change it to true.

Android_RIL_Driver_User_Guide 21 / 22
LTE/UMTS/HSPA(+)/GSM/GPRS Module Series
Android RIL Driver User Guide

7 Appendix A References

Table 5: Related Documents

SN Document name Remark

Quectel_WCDMA&LTE_Linux_USB_Driver_User_ Linux USB driver user guide for WCDMA


[1]
Guide and LTE series modules

Table 6: Terms and Abbreviations

Abbreviation Description

GSM Global System for Mobile Communications

MS Mobile Station

PID Product ID

RIL Radio Interface Layer

VID Vendor ID

WCDMA Wideband Code Division Multiple Access

Android_RIL_Driver_User_Guide 22 / 22

You might also like