Detailed solution for 3G cards on the Development Board (applicable to most 3g cards)

Source: Internet
Author: User

Address: http://blog.csdn.net/ipromiseu/article/details/5154004

 

Detailed solution for 3G cards on the Development Board (applicable to most 3g cards)

Anson Luo/gray Luo (Luo Guohui)

I. Environment

1.Development Board kernel: Linux kernel 2.6.14

2.3G card: e1750

2. Download related tools and library files

1. usb_modeswitch-1.0.6.tar.bz2Http://www.draisberghof.de/usb_modeswitch)

We recommend that you download a newer version. If you are in trouble, download the same version as me.

Usb_modeswitch is a versatile tool for converting the working mode of USB devices. Of course, this kind of tool can only play a huge role in Linux. With the development of mobile communication and wireless communication, more and more devices are made into USB interfaces, such as some wireless network adapters and 3G data cards. Manufacturers of these devices generally provide drivers in windows. When these devices are plugged in for the first time, they are in the CDROM + flash mode, from which drivers can be installed, after the driver is installed, the driver will be converted to the 3G mode, and a usb modem device will appear. Currently, all 3g cards are like this, which is called "zerocd ".

In Linux, we do not have such a good deal. manufacturers generally do not provide us with drivers under Linux, and the current kernel cannot automatically identify and drive. Therefore, we need to use the usb_modeswitch tool for mode conversion. The device mode depends on the USB-storage and USB serial modes. Therefore, we need the support of these two modules on the Development Board, the device works in both modes.

2.usb_modeswitch-current_data.tar.bz2Http://www.draisberghof.de/usb_modeswitch)

This package contains the driver information provided to udev and the parameters that need to be configured when many devices use usb_mdoeswitch for the conversion mode. Download it for reference.

3. libusb-1.0.6.tar.bz2Http://sourceforge.net/projects/libusb/files/libusb-1.0)

Libusb is our real backbone. It provides a set of system APIs for usb_modeswitch. Therefore, if you want to work with the contractor usb_modeswitch, you must not leave the libusb worker to serve it.

4.libusb-compat-0.1.3.tar.bz2 (http://www.linuxfromscratch.org/blfs/view/svn/general/libusb-compat.html)

Libusb is divided into version 0.1 and Version 1.0. Version 1.0 is significantly different from version 0.1 and is not backward compatible. libusb-compat must be used.

Iii. Cross-compile usb_modeswitch

1. Cross-compile libusb

A. Unzip and enter the libusb-1.0.6 directory, create a subdirectory install to store the final survival library file and header file.

[Anson@libusb-1.0.6] # mkdir install

B. Configure and generate the MAKEFILE file

[Anson@libusb-1.0.6] #./configure -- Build = i686-linux -- Host = arm-Linux -- prefix =/home/Anson/libusb-1.0.6/install

C. [Anson@libusb-1.0.6] # Make

D. [Anson@libusb-1.0.6] # make install

2. Set the pkg_config_path environment variable so that the libusb library can be found smoothly in subsequent compilation.

A. Set Environment Variables

[Anson@libusb-1.0.6] # export pkg_config_path =/home/Anson/libusb-1.0.6/install/lib/pkgconfig: $ pkg_config_path

B. Check whether the settings are correct.

[Anson@libusb-1.0.6] # echo $ pkg_config_path

3. Cross-compile lib_compat

Similar to the above method for compiling libusb:

A.[Anson@libusb-compat-0.1.3] #. mkdir install

B.[Anson@libusb-compat-0.1.3] #./configure -- Build = i686-linux -- Host = arm-Linux -- prefix =/home/Anson/libusb-compat-0.1.3/install

C.# Make

D.[Anson@libusb-compat-0.1.3] # make install

NOTE: If errors such as "-wno-pointer-sign" and "-fvisibility = hidden" occur at this time, they are not supported because the compiler version is too low, you can delete these compilation options directly in makefile and libusb/makefile.

4. Cross-compile usb_modeswitch

A. Modify the MAKEFILE file.

Modify strip and CC options:

Strip = arm-xxx-Linux-strip

Cc = arm-xxx-Linux-gcc

B. You can copy the above libusb and libusb-compat libraries and header files to the lib and include directories of the cross compiler, or directly add the path of the compilation option command library as follows:

Export dedir =/home/Anson // libusb-1.0.6/install/include/libusb-1.0

Libdir =/home/Anson/libusb-1.0.6/install/lib

$ (Prog): $ (objs)

$ (CC) $ (ccflags)-I $ (includedir)-L $ (libdir)-o $ (Prog) $ (objs)

The USB. h here is in the libusb-compat directory. If there is no USB. H, the usb_modeswitch cannot be compiled.

C. Make

5. Edit the usb_modeswitch.conf file in the usb_modeswitch directory and add the following content:


Defaultvendor = 0x12d1

Defaultproduct = 0x1446

Targetvendor = 0x12d1

Targetproduct = 0x1001

Messagecontent = "55534243000000000000000000000011060000000000000000000000000000"

Messageendpoint = 0x01

Checksuccess = 5

Export weimode = 0 (pay special attention to this parameter. The trouble I encountered on the Development Board lies in this parameter)

6. Copy the libusb dynamic library generated above to the library directory of the Development Board, and download the generated usb_modeswitch executable program and usb_modeswitch.conf configuration file to a directory on the Development Board.

4. Cross-Compilation of 3G Card Drivers

1. Compile the driver option. Ko of the 3G Module

Find the USB 3g driver file driver // USB/serial/option. c In the kernel source package, and add the required wei_vendor_id 0x12d1 and required wei_product_e1750 0x1446 of the 3G card. Then modify kconfig to compile the option into a module. Download the compiled option. Ko to the Development Board and load it using insmod.

5. Load driver

1. Mount the USB Virtual File System: Mount-T usbfs USB fs/proc/bus/USB/

2. Pop Up The cdrom of the 3G card:Eject/dev/CDROMs/cdrom0

3.Now you can use usb_modeswitch-w-C ~ /Usb_modeswitch.conf switch the 3G card mode. At this time, some information will appear, and you will see several serial port information after converting to 3G mode, ttyusb0, ttyusb1, ttyusb2, as shown below:

 

Option 1-1:1. 0: Option 3G data card converter Detected
USB 1-1: Option 3G data card converter now attached to ttyusb0
Option 1-1:1. 1: Option 3G data card converter Detected
USB 1-1: Option 3G data card converter now attached to ttyusb1
Option 1-1:1. 2: Option 3G data card converter Detected
USB 1-1: Option 3G data card converter now attached to ttyusb2

 

If udev is not used, these nodes are not automatically generated, so you need to manually create these character nodes.

Mknod/Dev/USB/Ttyusb0 C 188 0

Mknod/Dev/USB/ttyusb1 C 188 1

Mknod/Dev/USB/ttyusb2 C 188 2

 

In this case, you can find three nodes generated under/dev/USB/tts: 1, 2, 3. if the release version is used on the PC, udev is usually used as the node under/dev, so that you can directly run/etc/udev/rules. d/Add the corresponding device information and processing information below. However, because the Development Board does not have udev, it will have too many device nodes in the ecosystem, which is a great waste of embedded development resources. Here, according to the prompts, the driver finds the Y1 device at the X1 address, and the node under/Dev is Z1. Therefore, we need to create it manually. I mean this node has already registered the corresponding ioctl, but the device node has not been generated. Therefore, manual creation is completely correct.

 

4. Use the serial port test tool to send the AT command to test whether several serial ports are available.

6. Compile the pppd dialing tool and write the dialing script.

1. Cross-compile pppd dial-up tool (For details, refer to the details in subsequent articles)

2. Write a dialing script, similar to the GPRS dialing script.

A. China Unicom Co., WCDMA-HSDPA:

(1) WCDMA:


Debug

Nodetach

Lock

/Dev/ttyusb0

115200

User "card"

Password "card"

Crtscts

Show-Password

Usepeerdns

Noauth

Noipdefault

Novj

Novjccomp

Noccp

Defaultroute

Ipcp-Accept-Local

Ipcp-Accept-remote

Connect '/usr/sbin/chat-S-v-F chat-WCDMA-connect'

Disconnect '/usr/sbin/chat-S-v-F chat-WCDMA-Disconnect'

(2) chat-WCDMA-Connect:


Timeout 5

Abort 'no carrier'

Abort 'error'

Abort 'no dialtone'

Abort 'busy'

Abort 'no ancer'

''/Rat

OK/Ratz

OK/rat + cgdcont = 1, "ip", "3 GNET", 0, 0

OK-at-OK atdt * 99 #

Connect/D/C

(3) chat-WCDMA-Disconnect


Abort "busy"

Abort "error"

Abort "No dialtone"

Say "/nsending break to the modem/N"

''"/K"

''" ++ Ath"

Say "/ngoodbay/N"

B. Mobile TD-CDMA

(1) TD:


Debug

Logfile/var/log/pppd. Log

Lock

/Dev/ttyusb0

115200

User "card"

Password "card"

Crtscts

Connect '/usr/sbin/chat-v-T3-f td-connect-chat'

Disconnect '/usr/sbin/chat-S-v-f td-Disconnect-chat'

Show-Password

Usepeerdns

Noauth

Noipdefault

Novj

Novjccomp

Noccp

Defaultroute

Ipcp-Accept-Local

Ipcp-Accept-remote

(2) TD-connect-chat:


Abort 'no carrier'

Abort 'error'

Abort 'no dialtone'

Abort 'busy'

Abort 'no ancer'

''/Ratz

OK-at-OK ATD #777

Connect/D/C

(3) TD-Disconnect-chat:


Abort "busy"

Abort "error"

Abort "No dialtone"

Say "/nsending break to the modem/N"

''"/K"

''" ++ Ath"

Say "/ngoodbay/N"

C. China Telecom CDMA 1X

(1) CDMA 1x:


Debug

Nodetach

Lock

/Dev/ttyusb0

115200

User "card"

Password "card"

Crtscts

Show-Password

Usepeerdns

Noauth

Noipdefault

Novj

Novjccomp

Noccp

Defaultroute

Ipcp-Accept-Local

Ipcp-Accept-remote

Connect '/usr/sbin/chat-S-v-F cdma1x-connect-chat'

Disconnect '/usr/sbin/chat-S-v-F cdma1x-disconnect-chat'

(2) cdma1x-connect-chat:


Timeout 5

Abort 'no carrier'

Abort 'error'

Abort 'no dialtone'

Abort 'busy'

Abort 'no ancer'

''/Ratz

OK/rat/^ prefmode = 2

OK-at-OK ATD #777

Connect/D/C

(3) cdma1x-disconnect-chat:


Abort "busy"

Abort "error"

Abort "No dialtone"

Say "/nsending break to the modem/N"

''"/K"

''" ++ Ath"

Say "/ngoodbay/N"

D. Telecom CDMA2000-EVDO

(1) evdo:


Debug

Nodetach

Lock

/Dev/ttyusb0

115200

User "card"

Password "card"

Crtscts

Show-Password

Usepeerdns

Noauth

Noipdefault

Novj

Novjccomp

Noccp

Defaultroute

Ipcp-Accept-Local

Ipcp-Accept-remote

Connect '/usr/sbin/chat-S-v-F evdo-connect-chat'

Disconnect '/usr/sbin/chat-S-v-F evdo-Disconnect-chat'

(2) evdo-connect-chat:


Timeout 5

Abort 'no carrier'

Abort 'error'

Abort 'no dialtone'

Abort 'busy'

Abort 'no ancer'

''/Ratz

OK-at-OK ATD #777

Connect/D/C

(3) evdo-Disconnect-chat:


Abort "busy"

Abort "error"

Abort "No dialtone"

Say "/nsending break to the modem/N"

''"/K"

''" ++ Ath"

Say "/ngoodbay/N"

3. Use pppd Dialing: pppd file TD (WCDMA/evdo/CDMA 1X)

4.At this time, the port set in the script will be used for dialing. If it succeeds, the IP address will be obtained. The 3G card of China Telecom obtains the Internet IP address, while the other is the obtained Intranet IP address, add the obtained DNS/Etc/Resolv.Conf. And use route to add a default route. Ping the Internet address. If the route can be pinged, it indicates that the work in this article has been completed, ping is disabled on China Unicom's network, so ping fails. Therefore, you need to use your own test tool to send TCP/UDP packets to determine whether the job is successfully completed.

7. refer to the following articles:

1.Http://blog.chinaunix.net/u3/106318/showart_2110454.html

2.Http://blog.chinaunix.net/u3/106318/showart_2102540.html

 

 

Postscript: many friends sent me emails to discuss some issues, but many netizens did not perform step-by-step operations in strict accordance with the methods described in this article, and some skipped some steps, some of the latest software versions are used. Here I will explain that the above methods are only limited to the software version I use. If you use the latest version, you may need to debug it yourself, this article can only be used as a reference. I have not tested the latest version. Therefore, if you want to save time, please strictly use the software versions in my article. When your work is in trouble, please do not rush to ask for help, but first confirm the problem, and then read my article carefully again. If you follow my article completely, there should be no problems. Thank you for your attention!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.