With the boom in 3G mobile phones, many of our company's embedded mobile products are also planning to add wireless Internet access and telephone functions. Recently, the company appointed me to take charge of
6.0 projects that integrate the functions of mobile phones, wireless Internet access, and SMS sending and receiving. But what I did not think of was that this project made me suffer from repeated debugging.
The reason is that this is in WinCE
6.0 systems developed on the platform often encounter problems such as missed calls or signals that cannot be called out, abnormal sending and receiving of text messages, or automatic interruption of calls and intermittent calls. At the beginning, I suspected it was because of signal quality.
As a result of the problem, it took a lot of time and effort on hardware, such as antennas and gsm rf communication modules. But later I found that I was in win
CE does not optimize the RIL interface driver. I would like to share with you some of the experiences and lessons learned in this process.
I. Analysis on Causes of phone missed connections in the wince System
In wireless mobile communication, the missed connection means that the device is connected, but the device does not respond. Generally, this fault may occur at two levels: first, the baseband part of gsm rf communication is not delivered.
(2) The wince system does not respond to incoming messages of the GSM module.
(1) No incoming message is sent from the hardware.
The first reason for missed connection may be that the baseband part of the gsm rf communication has not sent any incoming message, which is mainly because the GSM hardware has encountered a problem and the system has no input signal. For example
But when the phone number cannot be dial out, it is likely that there is a problem with the GSM signal quality. The signal quality problem is that the signal strength received under normal circumstances is significantly lower than the normal standard
Hardware-related faults. Therefore, I concentrated both time and effort on Antenna reception and GSM RF communication hardware, such as replacing enhanced antennas and using tested GSM RF chips and Baseband Processing Chips.
However, after many hardware debugging and replacement, I found that this problem persists. Later, I decided to eliminate the possibility of faults in the GSM hardware.
(2) The wince system does not respond to incoming call messages.
The second possible cause of missed connections is that the wince system does not respond to incoming call signals. Later, after many debugging, I found that the problem was actually caused by wince.
6.0 system software. In professional terms, it is in the RIL module of the communication interface layer (that is, the radio interface
Layer, wireless interface layer) and priority processing problems. This RIL layer is mainly used to communicate between the wince System and the GSM communication module, and to make appropriate response to the behavior of the GSM communication module.
Actions, such as starting data connection and sending
SMS
Messages. In other words, when the problem occurs in the wince software module, even if the GSM signal strength increases, the missed connection will still be missed, and the hanging link will still be hung up.
Ii. Detailed analysis of Wince 6.0 RIL interface driver
(1) New Telephone functions added by wince 6.0
Generally, there are two ways to enable wireless communication functions (such as dial-up surfing, dialing, and sending and receiving text messages) on the product based on the wince platform: one is to enable the user to access the external mobile phone module; 2. embedded
Integrate the mobile phone module on the product. If it is an external mobile phone module, the mobile phone only serves to receive and send data during browsing on the Internet. If it is an embedded device integrated with the mobile phone module, it can be very convenient
All functions of wireless communication.
Therefore, in order to achieve better wireless communication for embedded devices, WinCE 6.0 provides the interface functions required to connect to the mobile phone network. For example, WinCE 6.0
The cellcore. dll component is provided. This Dynamic Link Library Extends Win32
API functions are used to support various mobile phone services, such as starting data connections and sending SMS messages. Another important component is the RIL driver at the wireless interface layer.
RIL. dll. This component provides a low-level interface for the connection between the application layer and the mobile phone hardware. In earlier versions of wince, direct dialing and sending are not supported.
SMS text message. Therefore, before building a mobile phone on WinCE, OEMs must develop their own interface layers. However, this is not easy. Now with this RIL interface
Building a mobile phone program on the wince platform does not require the OEM to develop the corresponding interface layer. This function also greatly inspires the OEM to build a mobile phone program on the wince platform.
Tide.
(2) What is the RIL (radio interface layer) component?
The RIL wireless interface layer added in wince 6.0 is originally a Windows
In mobile, it is mainly used to connect the wince operating system and telephone module. RIL is mainly used to maintain and associate the status and event messages of the wireless GSM communication module. Microsoft Help
The Manual introduces RIL in this way. As a very important component of wireless communication, rIL makes various wireless voice and data applications possible and runs on wince.
The software on 6.0 can be seamlessly integrated with GSM/GPRS or CDMA 2000 1x through RIL
MODEM communication. RIL is located on the protocol stack of the GSM wireless baseband system, and is located under the cellcore layer of the wince system. RIL communicates with the upper layer in two ways,
One is to send and receive messages through socket, and the other is to directly access the shared
Memory for RPC calling. This method is mainly used in data mode. Therefore, the RIL component can hide some details of the GSM wireless baseband hardware, so that the OEM can
Different models of wireless modem must be integrated into their products.
Simply put, as long as the RIL driver module and the underlying GSM communication module are used, the wince system has the mobile phone function. First, rIL provides voice, data, SMS,
SIM card management and STK application functions, including extapi, dial-up, and other mobile phone functions. Second, from the software point of view, rIL works in the PPP, TCP/IP Association
In the meantime, we can send AT commands and parse response responses, and transmit data reliably. In addition to network protocol support, rIL also supports SMS and voice
Call and other functions.
(3) Structure Analysis of the RIL driver
From the features of the RIL component, we can see that the development of a mobile phone is an effective development of the RIL driver. Because the RIL Driver provides wireless communication-related servers for Applications
Service, including call control, short message, GPRS, and other functions. In addition, for upper-layer applications, the RIL driver can also be abstracted as a logical device. It only needs to communicate with the RIL driver.
Obtain the required services. Therefore, the RIL interface layer driver can follow the stream-driven stream
I/O specifications. The advantage of this is that applications can regard devices as files and access RIL through file interfaces.
In the wince system, an loaded driver is usually divided into two parts: hardware-related PDD layer and hardware-independent MDD layer. MDD implements platform-independent functions, which describe
A general driver framework, and PDD is composed of hardware and platform-related code. MDD calls a specific interface in PDD to obtain hardware-related information. Therefore, when using a hierarchical driver
Generally, you only need to modify the PDD program for specific hardware based on similar sample drivers. The framework established by MDD can continue to be used.
According to the suggestions in Microsoft's help manual, RIL
The basic framework of the driver should preferably adopt the MDD + PDD structure. In general, Microsoft provides many MDD samples for general-purpose drivers in wince, so the key lies in debugging the PDD layer. Because no
The implementation of the PDD layer of the GSM/GPRS communication module is different. For example, the hierarchical model ril_xxx is provided to devicemanger.
Stream interface. At the RIL service layer, dispather will
Distribute to the corresponding function, such as sending SMS messages. Then the SMS function sends a message to RIL.
Device to send a request to GSM in the form of an AT command
Modem. That is to say, the common MDD part has been completed. Now we only need to develop different PDD drivers for different GSM modules, which can greatly improve the development efficiency.
(4) How does wince implement the telephone function through RIL?
Now we can observe the RIL workflow from the perspective of the wince thread. RIL mainly includes two parts: RIL stub and rIL driver. RIL
Stub and rIL driver
All have their own thread named rilthread. The workflow for an application to call the RIL driver is as follows: ① the application process is in its own process space to call the RIL
Send the request using proxy. ② RIL proxy sends the request to Device Manager in IPC mode. ③ Device mananger
Distribute requests to the corresponding RIL Driver Based on the operation code. ④ After receiving the operation code, rIL stub performs context switching based on the PID, and then forwards the request to RIL
Driver. ⑤ Finally, the RIL driver corresponding to the context of the user process starts to process the operation code. For example, RIL
The driver sends the AT command to the GSM Modem and waits for the response.
Therefore, from the above workflow, the performance of the RIL driver module will directly affect all software related to wireless communication applications, whether the driver design is optimized affects the RIL driver.
Yes.
Iii. Key points for priority processing
(1) What is priority processing?
In general, the mobile phone design on the wince system has not been optimized for the phone like Symbian, or even does not take into account the particularity of the GSM communication module, but simply regard it as
Scalable hardware modules. That is to say, the priority of the GSM communication module is the same as that of the common hardware module. Therefore, the RIL connected to the GSM communication module is equal to the other drivers.
The CPU cycle, or equal scheduling, and even the same priority. However, there are several major differences between the GSM communication module and other extended hardware: First, it requires the wince system
Second, some ongoing communication tasks must not be preemptible, at least not suspended for a long time, which is similar to the requirements of real-time systems.
Such a priority processing method will lead to missed calls on the wince platform. For example, when a mobile phone calls an incoming call, a thread is initiated with a higher priority than the RIL driver.
During this period, the CPU processing right is taken away, and rIL cannot get back the time slice in time before it exits, because the priority processing of Wince is far inferior to that of win
NT is complex and flexible, so there may be cases where high-priority threads fully control the CPU, resulting in low-priority threads starved to death, which will "lose" this call message, this is due to missed connections. Or in
A high-priority thread is generated during a call. It also takes control of the CPU from the RIL driver, which may lead to a disconnection in the middle of the call. In addition, many practices have proved that
The vast majority of the stability problems are in priority processing. In addition, the wince system itself often has bugs in task scheduling. As a result, high-priority threads often fail to get the problem from low-priority threads.
Time slice, leading to priority system failure.
(2) Improper priority processing will lead to the false death of the RIL driver
In addition to the priority issue, there may also be "false positives" for the RIL driver ".
Many practices have proved that most of the current "False-dead" Problems of RIL drivers are caused by software problems rather than hardware problems. In fact, it is not surprising that this problem occurs on the wince system, because
The reason for "false positives" is mainly because of the entry point function, registration key, and
The GSM module does not perform proper interaction. The reason is that the RIL driver program is well written varies from person to person. After all, the RIL driver layer is customized by the user,
Not Implemented by Microsoft.
(3) usage of the RIL-driven com serial port
When designing RIL driver ports, many developers often ignore the problem of serial port occupation. After all, the underlying layer of the RIL driver is still operated by at, such as issuing commands,
Response Parsing. This is due to the historical reasons of the modem of the GSM module, because the AP has always interacted with BB through the AT command based on the serial port. Including some existing edge,
Or 3G modules, or AP/BP integrated chips like OMAP, most of them still use analog serial port mechanisms to use at commands. In addition, the serial port is not reusable, so it must be
Avoid serial port occupation.
Finally, we should pay special attention to the problem of serial access conflict. As long as the RIL driver is loaded when the wince system is started, it will occupy this serial port, and other applications cannot directly access
Ask about the serial port, no matter how high the application priority is.