Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of Linux 4G Communication experiment

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "Experimental Analysis of Linux 4G Communication". In daily operation, I believe that many people have doubts about the experimental analysis of Linux 4G communication. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "Experimental Analysis of Linux 4G Communication". Next, please follow the editor to study!

For embedded Linux, 4G network connection is a relatively easy function, most 4G module interfaces are MiniPCIE interfaces, but after a deep understanding, we will find that the communication interface of 4G module is USB, so the driver of 4G module is USB driver. As long as the USB driver is normal, 4G module can communicate normally on hardware. Let's take a look at the hardware schematic of the 4G module:

In the schematic, U25 is the MiniPCIE interface of the 4G module, and then the communication pin will be connected to the HUB chip of the U15, so the 4G module will be recognized as the USB device, and the CON5 is the SIM card interface. When using the 4G module, the SIM card needs to be inserted first. The EC20 4G module used on the i.MX6UL Terminator development board is shown in figure 56.1.3:

56.2 EC20 4G module configuration

56.2.1 add USB device information

To use the EC20 4G module, you first need to add the USB information of EC20 to the Linux kernel, so that after the kernel starts, it can correctly identify

EC20 4G module. Open the drivers/usb/serial/option.c file under the Linux kernel and add the following information:

1809 / * add support EC220 4G Module * /

1810 {USB_DEVICE (0x05C6, 0x9090)}, / * Quectel UC15 * /

1811 {USB_DEVICE (0x05C6, 0x9003)}, / * Quectel UC20 * /

1812 {USB_DEVICE (0x05C6, 0x9215)}, / * Quectel EC20 * /

1813 {USB_DEVICE (0x2C7C, 0x0125)}, / * Quectel EC25/EC20 R2.0 * /

1814 {USB_DEVICE (0x2C7C, 0x0121)}, / * Quectel EC21 * /

1815 / * end add * /

Line 1813 is the USB information for the EC20 4G module.

56.2.2 Linux kernel configuration

After adding the USB information for the EC20 4G module, you need to modify the Linux kernel configuration to support the USBNET feature. The specific configuration is as follows:

Device Drivers->

Network device support->

USB Network Adapters->

Multi-purpose USB Networking Framework

The configuration is shown in figure 56.2.2.1:

Next, we also need to enable USB serial port GSM and CDMA drivers. The configuration path is as follows:

Device Drivers->

USB support->

USB Serial Converter support->

USB driver for GSM and CDMA modems

The configuration is shown in figure 56.2.2.2:

Then configure ppp. The configuration path is as follows:

Device Drivers->

Network device support->

PPP (point-to-point protocol) support

PPP BSD-Compress compression

PPP Deflate compression

PPP filtering

PPP MPPE compression (encryption)

PPP multilink support

PPP over Ethernet

PPP support for async serial ports

PPP support for sync tty ports

The configuration is shown in figure 56.2.2.3:

After the configuration is complete, recompile the kernel, and then use the new kernel to start the development board. If the configuration is successful, the development board will print the information as shown in figure 56.2.2.4 after startup:

It can be seen that the EC20 4G module is identified successfully, and five USB devices are virtual, which are ttyUSB0~ttyUSB4.

56.3 EC20 4G module networking test

56.3.1 compilation of PPP package

First copy ppp-2.4.4.tar.gz to Ubuntu, and then execute the following command to extract:

Tar-xvf ppp-2.4.4.tar.gz

Decompress to get the ppp-2.4.4 directory, and enter the ppp-2.4.4 directory as shown in figure 56.3.1.1:

Use configure for configuration, with the following command:

. / configure

The result is shown in figure 56.3.1.2:

After the configuration is complete, compile using the following command:

Make CC=arm-linux-gnueabihf-gcc

"CC=arm-linux-gnueabihf-gcc" specifies the compiler, which uses the same compiler as the Linux kernel of the development board.

The compilation is completed as shown in figure 56.3.1.3:

After the compilation is completed, the executable files of chat, pppd, pppdump and pppstats are generated in the four directories of chat, pppd, pppdump and pppstats respectively, which are used in the following 4G module networking testing.

56.3.2 EC20 4G module networking test

First install the EC20 4G module, antenna and SIM card, as shown in figure 56.3.2.1:

When the development board is ready, start the Linux system. After the system starts, enter the / etc directory, and then create the ppp directory. The specific commands are as follows:

Cd / etc / / enter the etc directory

Mkdir ppp / / create a ppp directory

After the directory is created, use the U disk to copy the four executable files chat, pppd, pppdump, and pppstats compiled in the previous section to the / etc/ppp directory, as shown in figure 56.3.2.2:

Then create the pap-secrets file under the / etc/ppp directory, using the following command:

Touch pap-secrets / / create a pap-secrets file

Vi pap-secrets / / Open the pap-secrets file

Enter the following:

# Secrets for authentication using PAP

# client server secret IP addresses

Card * card *

When the 4G signal is communicating, there is a password comparison, and if the password is right, you can communicate. It shows that the user is card and the password is card.

Then create a new folder, peers, and command "mkdir peers".

Go to the peers folder and create the wcdma file with the following command:

Touch wcdma

Vi wcdma

Enter the following:

# / etc/ppp/peers/wcdma

# This is pppd script for China liantong

# Usage: root > pppd call wcdma

Hide-password

Noauth

Connect' / etc/ppp/chat-s-v-f / etc/ppp/peers/wcdma-chat-connect'

Disconnect' / etc/ppp/chat-s-v-f / etc/ppp/peers/wcdma-chat-disconnect'

Debug

/ dev/ttyUSB2

115200

Defaultroute

Noipdefault

Novj

Novjccomp

Noccp

Ipcp-accept-local

Ipcp-accept-remote

Local

Lock

Dump

Nodetach

User "card"

Password "card"

Crtscts

Remotename 3gppp

Ipparam 3gppp

Usepeerdns

It is important to note that the / dev/ttyUSB2 device node file is used.

"user" card "" and "password" card "" correspond to the user name and password in the pap-secrets file.

Create a wcdma-chat-connect file:

Touch wcdma-chat-connect

Vi wcdma-chat-connect

The contents are as follows:

ABORT "BUSY"

ABORT "NO CARRIER"

ABORT "NO DIALTONE"

ABORT "ERROR"

ABORT "NO ANSWER"

TIMEOUT 120

"" AT

OK\ rATZ

OK\ rAT+CGDCONT=1, "IP", "3gnet", 0jin0

OK-AT-OK ATDT*99#

CONNECT\ d\ c

Here OK\ rAT+CGDCONT=1, "IP", "3gnet", 0jin0

OK-AT-OK ATDT*99#

These two sentences will change according to Mobile Unicom or Telecom, where Mobile 4G is used.

Create a wcdma-chat-disconnect file:

Touch wcdma-chat-disconnect

Vi wcdma-chat-disconnect

The contents are as follows:

ABORT "ERROR"

ABORT "NO DIALTONE"

SAY "INSending break to the modem\ n"

""\ k "

"" + ATH "

SAY "\ nGood bye\ n"

Once the required files have been created, you are ready for networking testing.

First turn off the eth0 device because of a conflict with the EC20 4G module and only one device can be used at the same time. The command is as follows:

Ifconfig eth0 down

Then enter the instruction in the / etc/ppp directory:

. / pppd call wcdma &

The result is shown in figure 56.3.2.3:

The figure above shows that the IP address after successful networking is 10.47.135.182. Use the ifconfig command to view the result as shown in figure 56.3.2.4:

At this point, use the ping command to see if you can ping the public network, as follows:

Ping 202.108.22.5-c 4

The "- c" option specifies the number of ping networks. "202.108.22.5" is the IP address of Baidu. The result is shown in figure 56.3.2.5:

Found that ping can not be connected to the public network, willing to be because DNS is not set up, there is a file resolv.conf under etc. This file is used to put DNS. This is the domain name that is not set up correctly. However, it is mandatory to copy this file to 192.168.1.1 in eth0's run script. As a result, even if you set the correct DNS in the file here, you will find that it already contains 192.168.1.1 when you turn it on. This is because eth0 is self-booting.

Let's create a new file resolv.conf_back in the / etc directory:

Touch resolv.conf_back

Vi resolv.conf_back

Enter the following:

Nameserver 202.99.160.68

Nameserver 221.130.33.52

Nameserver 221.130.33.60

Nameserver 192.168.1.1

Then create a new script file ppp0:

Touch ppp0

Vi ppp0

Enter the following:

#! / bin/sh

Ifconfig eth0 down

Cp / etc/resolv.conf_back / etc/resolv.conf

/ etc/ppp/pppd call wcdma&

Modify the execution permissions of the ppp0 file:

Chmod 777 ppp0

The first step here is to turn off eth0, the second step is to overwrite our DNS file on resolv.conf, and the third step is to run it. Then reboot and execute the ppp0 script with the following command:

/ etc/ppp0

After the script executes successfully, reuse the ping command, and the result is shown in figure 56.3.2.6:

The picture shows the IP address that can ping Baidu normally. At this point, the EC20 4G module can be used normally.

At this point, the study of "Experimental Analysis of Linux 4G Communication" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report