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

Driver of 3G Wireless Network Card under embedded Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Kernel: the following modules are required: option usbserial usbstorage

The main thing is to select the

[*] 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

[*] USB support->

USB Modem (CDC ACM) support

[*] USB support->

USB Serial Converter support->

USB driver for GSM and CDMA modems

Modify linux-2.6.21.x/drivers/usb/serial/option.c

# define HUAWEI_WENDIR_ID 0x12d1

# define HUAWEI_PRODUCT_ECxx 0x14ef

{USB_DEVICE (HUAWEI_WENDIR_ID,HUAWEI_PRODUCT_ECxx)} / * HUAWEI xxx*/

# make modules / / compile plug-in module

# make modules_install / / install the module

# usbserial.ko,option.ko

After the module has been compiled, copy it to the development board and execute the following command, otherwise the modules.dep will not be found.

# depmod-a / / create a link to the module

# modprobe usbserial.ko

# modprobe option.ko

4 softwares: libusb, usb_modeswitch, pppd, usb-modeswitch-data (cross-compilation)

# lsusb, usb_modeswitch, (lib folder), chat, pppd, etc. are migrated to the development board.

This packet contains the configuration files of all 3G network cards supported by usb_modeswitch.

1. Insert the 3G network card into the USB port on the development board.

two。 Entering lsusb on the development board will produce the following results, indicating that the development board is physically connected to the hardware of the 3G network card. Write down the number 12d1:14ef and use it later.

# lsusb

Bus 004 Device 002: ID 12d1:14ef HUAWEI XXXX (omitting several)

If there is no lsusb command here, you can check the response device information under / proc/bus/usb/devices. Where:

# cat / proc/bus/usb/devices

Vendor=12d1 ProdID=14ef

3. Edit the usb_modeswitch.conf file in the usb_modeswitch directory

# T-Mobile NL (Huawei xxx)

#

# Contributor: Alex Hermann

DefaultVendor= 0x12d1

DefaultProduct=0x14ef

TargetVendor= 0x12d1

TargetProduct= 0x1506

MessageContent= "55534243123456780000000000001106200000010000000000000000000000000000"

CheckSuccess=5

4. Execute usb_modeswitch to convert the 3G network card USB disk mode to modem mode.

#. / usb_modeswitch-c / etc/usb_modeswitch/usb_modeswitch.conf

Looking for target devices...

No devices in target mode or class found

Looking for default devices...

Found matching product ID

Adding device

Found device in default mode, class or configuration (1)

Accessing device 003 on bus 001...

Getting the current device configuration...

OK, got current device configuration (1)

Using first interface: 0x00

Using endpoints 0x08 (out) and 0x87 (in)

Inquiring device details; driver will be detached...

Looking for active driver...

OK, driver found ("usb-storage")

OK, driver "usb-storage" detached

SCSI inquiry data (for identification)

-

Vendor String: HUAWEI

Model String: Mass Storage

Revision String: 2.31

-

USB description data (for identification)

-

Manufacturer: HUAEI TECHNOLOGIES

Product: HUAWEI Mobile

Serial No.: not provided

-

Setting up communication with interface 0

Using endpoint 0x08 for message sending...

Trying to send message 1 to endpoint 0x08...

OK, message successfully sent

Resetting response endpoint 0x87

Could not reset endpoint (probably harmless):-145

Resetting message endpoint 0x08

Could not reset endpoint (probably harmless):-19

Device is gone, skipping any further commands

Checking for mode switch (max. 20 times, once per second).

Searching for target devices...

Found target device, now opening

Found correct target device

Mode switch succeeded. Bye.

The screen will display a pile of mode conversion information, followed by a successful display.

Check whether the conversion is successful, execute lsusb, and find that the 14ef changes to 1506, indicating that the conversion is successful.

5. Check to see if there is a device node under / dev

# ls / dev/ttyUSB*

# / dev/ttyUSB0 / dev/ttyUSB1 / dev/ttyUSB2 / dev/ttyUSB3 / dev/ttyUSB4

Here, according to the reminder after switching, the corresponding device node is established.

6. Now that the hardware problems are solved, let's start dialing: (the dialing script of China Telecom, Unicom and Mobile should change, please google)

First file: wcdma (path / etc/ppp/peer/)

/ dev/ttyUSB0

115200

Nodetach

User "card"

Password "card"

Crtscts

Show-password

Usepeerdns

Noauth

Noipdefault

Novj

Novjccomp

Noccp

Defaultroute

Ipcp-accept-local

Ipcp-accept-remote

Connect 'chat-s-v-f / etc_ro/ppp/chat/wcdma-connect-chat'

Disconnect 'chat-s-v-f / etc_ro/ppp/chat/disconnect-chat'

Second file: wcdma-connect-chat (path / etc/ppp/chat/)

ABORT'NO CARRIER'

ABORT 'ERROR'

ABORT'NO DIALTONE'

ABORT 'BUSY'

ABORT'NO ANSWER'

''\ rAT

OK\ rATZ

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

OK-AT-OK ATDT*99***1#

CONNECT\ d\ c

Telecom script

TIMEOUT 5

ABORT "DELAYED"

ABORT "BUSY"

ABORT "ERROR"

ABORT "NO DIALTONE"

ABORT "NO CARRIER"

"" AT

"OK-+++\ c-OK" ATH0

TIMEOUT 40

"" AT

OK ATDT#777

CONNECT ""

The third file: disconnect-chat

ABORT "BUSY"

ABORT "ERROR"

ABORT "NO DIALTONE"

SAY "/ nSending break to the modem/n"

'' "/ K"

'' "+ ATH"

SAY "/ nGoodbye/n"

Perform a script dialing test

# pppd call gprs

Abort on (NO CARRIER)

Abort on (ERROR)

Abort on (NO DIALTONE)

Abort on (BUSY)

Abort on (NO ANSWER)

Send (^ Matt ^ M)

Expect (OK)

^ MT ^ M ^ M

OK

-- got it

Send (^ Matz ^ M)

Expect (OK)

^ M

^ Matz ^ M ^ M

OK

-- got it

Send (^ MAT+CGDCONT=1, "IP", "cmnet", 0,0 ^ M)

Expect (OK)

^ M

^ MAT+CGDCONT=1, "IP", "cmnet", 0,0 ^ M ^ M

OK

-- got it

Send (ATDT*99***1# ^ M)

Expect (CONNECT)

^ M

ATDT*99***1# ^ M ^ M

CONNECT

-- got it

Send (\ d)

Serial connection established.

Using interface ppp0

Connect: ppp0 / dev/ttyUSB0

CHAP authentication succeeded: Welcome!!

CHAP authentication succeeded

Could not determine remote IP address: defaulting to 10.64.64.64

Local IP address 10.109.28.39

Remote IP address 10.64.64.64

Primary DNS address 211.137.130.18

Secondary DNS address 211.137.130.20

At this time, the representative has dialed successfully, and you can see a ppp0 through the ifconfig command, indicating that the job is done.

Try ping www.baidu.com, and it should work.

7.PPPD script sharing

1. CHAT script

A simple chat script has the following structure:

"" AT

OK ATDT dialnumber

CONNECT ""

A chat script is made up of string pairs. The preceding string is the expected string, followed by the sent string. The specific meaning of each item in this script is as follows:

1) MODEM expects an empty string. The direct meaning of this sentence is that no matter what string MODEM receives, send out the string AT first.

2) expect to receive the string "OK", and then send the string "ATDT dialnumber"

3) if "CONNECT" is received, it is no longer sent and the data link is considered to be connected.

Such a chat script is the simplest. If you need timeout control, you can add the following fields:

TIMEOUT 10

If you want to increase the handling of special cases, add the following fields:

ABORT BUSY

ABORT NO ANSWER

ABORT RINGING

These three lines mean that if you receive the strings "BUSY", "NO ANSWER" and "RINGING", you will exit execution.

So a CHAT script that configures a PPP connection can look like this, considering a variety of special cases:

TIMEOUT 30

ABORT BUSY

ABORT NO ANSWER

ABORT RINGING

"" AT

OK ATDT dialnumber

CONNECT ""

2.OPTIONS script

The content of the OPTIONS script, which specifies the device used for the PPP connection, the control character transfer rate used, hardware acceleration, overflow control, and so on.

For example, the following options script:

TtyS0-specify the device used for the connection, such as ttyS0, ttyS1, etc.

57600-set the control character transfer rate used by the connection, which can be set to 57600, 115200, etc.

Debug-if you need to add debugging information, add the parameter debug

Logfile / var/ ppplog-enter the information during the connection into a file

Mtu 1500

-detach

Noipdefault-you can add parameter noipdefault without using the default IP

Defaultroute

Usepeerdns-using the DNS negotiated by the server, you can set the parameter usepeerdns

Lcp-echo-failure 4-when the LCP echo request is not received four times in a row, it is assumed that the server side is no longer responding and exits execution. The number of failures here can be determined flexibly.

-ccp-do not use compression control protocol

-vj-turn off IP head compression

-chap-do not use chap authentication

-mschap-v2-do not use mschap authentication

User

Hide-password

Connect "/ usr/bin/chat-v-T6-f / var/ chat"-specifies the location of the chat script to be used. Plus the parameter-v tells the chat command to copy all its output / input to the system record (usually / var/log/messages). -t 6 specifies that the time to execute the chat command is 6s. The location of the chat script can be in the / etc/ directory or / var, which can be set up more flexibly.

Persist-permanent link (automatic redial)

Crtscts-tell ppp to use the hardware flow control of modem

Modem-enable ppp to use DCD signals to determine whether the connection is normal and whether there is a drop

Deflate-enable pppd to use defalte compression

Idle-set a time limit to disconnect when there is no data transfer within 300 seconds

Lock-create a lock file, and other programs will know that the corresponding serial port has been used after discovering the existence of the file.

Demond-the parameter tells pppd to stay in the background, monitor network data, connect to the network immediately as soon as required, and disconnect after timeout, but pppd still stays in the background waiting for the next data transfer.

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

Servers

Wechat

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

12
Report