嵌入式Linux下3G模块的驱动和应用_第1页
嵌入式Linux下3G模块的驱动和应用_第2页
嵌入式Linux下3G模块的驱动和应用_第3页
嵌入式Linux下3G模块的驱动和应用_第4页
嵌入式Linux下3G模块的驱动和应用_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、嵌入式Linux下3G模块的驱动和应用1、开发资源1.1、硬件资源:ZTE-mf637u (中国联通)ZTE-mu351 (中国移动)1.2、软件资源:1.2.1、usb-modeswitch-1.1.3libusb-0.1.12.tar.gzusb-modeswitch-1.1.3.tar.bz21.2.2、ppp-2.4.4libpcap-0.9.8.tar.gzppp-2.4.4.tar.gz1.2.3、wvdial1.2.3.1、wvdial-1.54.0(arm-linux-gcc 3.4.1)zlib-1.2.5.tar.bz2ope nssl-0.9.7g.tar.gzope n

2、ssl-0.9.7g-fix_ma npages-1.patchwvstreams-4.0.1.tar.bz2wvstreams-4.0.1-tcl84-1.patchwvdial-1.54.0.tar.gz123.2、wvdial_1.60.4(arm-linux-gcc 4.2.2)zlib-1.2.5.tar.bz2ope nssl-0.9.8 n.tar.gzope nssl-0.9.8 n-fix_ma npages-1.patchwvstreams-4.6.1.tar.gzwvdial_1.60.4.tar.gz2、Linux开发环境2.1、主机环境2.1.1、主机linux系统F

3、edora Core 62.1.2、主机编译环境2.1.2.1、gcc -vUsing built-i n specs.Target: i386-redhat-li nuxCon figured with: ./c on figure -prefix=/usr -ma ndir=/usr/share/ma n-i nfodir=/usr/share/info -e nable-shared -e nable-threads=posix-en able-check in g=release -with-system-zlib -enable-_cxa_atexit-disable-libunwi

4、nd-exceptions -enable-libgcj-multifile-en able-la nguages=c,c+,objc,obj-c+,java,fortra n, ada -e nable-java-awt=gtk-disable-dssi -enable-plugin -with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre -with-cpu=ge neric -host=i386-redhat-l inuxThread model: posixgcc version 4.1.1 20061011 (Red Hat 4.

5、1.1-30)2.1.2.2、/usr/local/arm/3.4.1/bin/arm-linux-gcc -vReadi ng specs from /usr/local/arm/3.4.1/lib/gcc/arm-li nu x/3.4.1/specsCon figured with:/work/crosstool-0.27/build/arm-li nu x/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/co nfigure -target=arm-li nux -host=i686-host_pc-li nu x-g nu -prefix=/usr/local/arm

6、/3.4.1 -with-headers=/usr/local/arm/3.4.1/arm-li nux/i nclude -with-local-prefix=/usr/local/arm/3.4.1/arm-linux -disable-nls -enable-threads=posix -en able-symvers=g nu -enable-_cxa_atexit -e nable-la nguages=c,c+ -e nable-shared -en able-c99 -e nable-l on g-l ongThread model: posixgcc version 3.4.1

7、2.1.2.3、/usr/local/arm/4.2.2/usr/bin/arm-linux-gcc -vUsing built-i n specs.Target: arm-unknown-I inu x-g nu eabiCon figured with:/home/scsuh/workplace/coffee/buildroot-20071011/toolchain_build_arm/gcc-4.2.2/co nfigu re -prefix=/usr -build=i386-pc-li nu x-g nu -host=i386-pc-li nu x-g nu-target=arm-u

8、nknown-li nu x-g nu eabi -e nable-la nguages=c,c+-with-sysroot=/usr/local/arm/4.2.2-eabi/-with-build-time-tools=/usr/local/arm/4.2.2-eabi/usr/arm-u nknown-li nu x-g nu eabi/bin -disable-_cxa_atexit -e nable-target-optspace -with-g nu-Id -e nable-shared-with-gmp=/usr/local/arm/4.2.2-eabi/gmp -with-mp

9、fr=/usr/local/arm/4.2.2-eabi/mpfr -disable-nls -enable-threads -disable-multilib -disable-largefile -with-arch=armv4t -with-float=soft -e nable-cxx-flags=-msoft-floatThread model: posixgcc version 4.2.22.2、开发板环境2.2.1、CES-6410 开发平台Samsu ng S3C6410X, ARM1176JZF-S128MB, Mobile DDR SDRAMUSB HOST :个 USB

10、HOST 接口,USB2.0 全速(12Mbits/s )3、Linux应用软件的编译3.1、usb-modeswitch-1.1.3rootlocalhost cdma# tar xzf libusb-0.1.12.tar.gzrootlocalhost cdma# cp libusb-0.1.12 libusb-0.1.12-armrootlocalhost cdma# cd libusb-0.1.12-armrootlocalhost libusb-0.1.12-arm#./c on figure -prefix=/works/cdma/i nstall-host=arm-li nux

11、CC=arm-li nu x-gcc CXX=arm-l inu x-g+rootlocalhost libusb-0.1.12-arm# make in stallrootlocalhost libusb-0.1.12-arm# makerootlocalhost libusb-0.1.12-arm# cd .rootlocalhost cdma# tar xjf usb-modeswitch-1.1.3.tar.bz2rootlocalhost cdma# cp usb-modeswitch-1.1.3 usb-modeswitch-1.1.3-armrootlocalhost cdma#

12、 cd usb-modeswitch-1.1.3-armrootlocalhost usb-modeswitch-1.1.3-arm#修改 MakefileCC= gcc改为CC= arm-l inu x-gccCFLAGS += -Wall -l usb改为CFLAGS += -Wall -l usb -l/works/cdma/in stall/i nclude -L/works/cdma/i nstall/lib 修改 usb_modeswitch.c/readC on figFile("/etc/usb_modeswitch.setup");改为readC on f

13、igFile("/etc/usb_modeswitch.setup");rootlocalhost usb-modeswitch-1.1.3-arm# makerootlocalhost usb-modeswitch-1.1.3-arm# make in stallrootlocalhost cdma#rootlocalhost usb-modeswitch-1.1.3-arm# cd .3.2、ppp-2.4.4rootlocalhost cdma# tar xzf libpcap-0.9.8.tar.gzrootlocalhost cdma# cp libpcap-0.

14、9.8 libpcap-098-armStop.rootlocalhost libpcap-0.9.8-arm# ./con figure -prefix=/works/cdma/i nstall -host=arm-li nux -with-pcapmake: * No rule to make target 'pcap-yes.o', n eeded by 'libpcap.a'.修改 MakefilePSRC = pcap-yes.c改为PSRC = pcap-li nux.crootlocalhost libpcap-0.9.8-arm# makeroo

15、tlocalhost libpcap-0.9.8-arm# make in stallrootlocalhost libpcap-0.9.8-arm# cd .rootlocalhost cdma# tar xzvf ppp-2.4.4.tar.gzrootlocalhost cdma# cd ppp-2.4.4rootlocalhost ppp-2.4.4# ./con figure -host=arm-li nuxvi pppd/MakefileLIBS += -lpcapCFLAGS += -DPPP_FILTER改为LIBS += -Ipcap -L././libpcap-0.9.8C

16、FLAGS += -DPPP_FILTER -I././libpcap-0.9.8rootlocalhost ppp-2.4.4# make CC=arm-l inu x-gcc3.3、wvdial3.3.1、wvdial-1.54.0rootlocalhost wvdial-1.54.0# export PATH=/usr/local/arm/3.4.1/bi n:$PATHrootlocalhost wvdial-1.54.0# tar xjf zlib-1.2.5.tar.bz2rootlocalhost wvdial-1.54.0# cd zlib-1.2.5rootlocalhost

17、 zlib-1.2.5#./configure -prefix=/works/wvdial-1.54.0/install修改 MakefileCC = arm-l inu x-gccCPP=arm-l inu x-gcc -EAR=arm-l inu x-ar rcRANLIB=arm-li nu x-ra nlibrootlocalhost zlib-1.2.5# makerootlocalhost zlib-1.2.5# make in stallrootlocalhost wvdial-1.54.0# tar xzf ope nssl-0.9.7g.tar.gzrootlocalhost

18、 wvdial-1.54.0# cd ope nssl-0.9.7grootlocalhost openssl-0.9.7g# patch -Np1-i ./ope nssl-0.9.7g-fix_ma npages-1.patchrootlocalhost openssl-0.9.7g#./Configure -prefix=/works/wvdial-1.54.0/install os/compiler:arm-l inu x-gccrootlocalhost ope nssl-0.9.7g# makerootlocalhost ope nssl-0.9.7g# make in stall

19、rootlocalhost openssl-0.9.7g# cd .rootlocalhost wvdial-1.54.0# tar xjf wvstreams-4.0.1.tar.bz2rootlocalhost wvdial-1.54.0# cd wvstreams-4.0.1rootlocalhost wvstreams-4.0.1# patch -Np1 -i ./wvstreams-4.0.1-tcl84-1.patch修改 con figurewith_ope nssl=no改为with_ope nssl=yes(有两处)rootlocalhost wvstreams-4.0.1#

20、 ./c on figure -prefix=/works/wvdial-1.54.0/i nstall -host=arm-linux CFLAGS=-l/works/cdma/install/include LDFLAGS=-L/works/cdma/i nstall/lib/ -with-zlib=/works/cdma/zlib-1.2.5-with-ope nssl=/works/cdma/ope nssl-0.9.8 n -without-dbus -with-pam=no -with-tcl=no -with-qt=norootlocalhost wvstreams-4.0.1#

21、 makelinking libwvutils.so./usr/lib/libz.so: could not read symbols: In valid operati oncollect2: ld retur ned 1 exit statusmake: * libwvutils.so Error 1rootlocalhost wvstreams-4.0.1# arm-li nu x-gcc -L./xplc -L/works/cdma/i nstall/lib/ -L./xplc -L. -g -Wl,-s on ame,libwvutils.so.4.0 -shared -o libw

22、vutils.so utils/strcrypt.o utils/verstri ng.o utils/wvaudioe ncoder.o utils/wvbase64.o utils/wvbdbhash.o utils/wvcrash.o utils/wvdiriter.o utils/wvgzip.o utils/wvhashtable.o utils/wvhex.o utils/wvmagiccircle.o utils/wvmatrix.o utils/wvqdbmhash.o utils/wvrateadjust.o utils/wvserialize.o utils/wvshmz

23、on e.o utils/wvstri ngtable.o utils/wvsubproc.o utils/wvtest.o utils/wvwordwrap.o libwvbase.so-lsupc+ -lgcc_ehrootlocalhost wvstreams-4.0.1# makerootlocalhost wvstreams-4.0.1# vi wvrules.mkXX_LIBS := $(XX_LIBS) $(shell $(CC) -lsupc+ -lgcc_eh 2>&1 | grep -q "undefined reference" &

24、;& echo " -lsupc+ -lgcc_eh")改为XX_LIBS := $(XX_LIBS) $(shell $(CC) -lsupc+ -lgcc_eh 2>&1 | grep -q "undefined reference" && echo " -lz -lcrypt -lsupc+ -lgcc_eh")rootlocalhost wvstreams-4.0.1# makecompil ing crypto/wvtripledes.o.crypto/wvtripledes.cc: I

25、n member function 'virtual boolWvTripleDESE ncoder:_e ncode(WvBuf&, WvBuf&, bool)':crypto/wvtripledes.cc:108: error: cannot con vert 'const un sig ned char*' to un sig ned char (*)8' for argume nt、1' to 'void DES_ecb3_e ncrypt( un sig nedchar (*)8, un sig ned char

26、 (*)8, DES_key_schedule*, DES_key_schedule*,DES_key_schedule*, i nt)'make: * crypto/wvtripledes.o Error 1解决方法:crypto/wvtripledes.cc修改#if OPENSSL_VERSION_NUMBER >= 0x0090705FL改为#if 0compil ing crypto/wvx509.o.crypto/wvx509.cc: In member fun cti on 'WvStri ng WvX509Mgr:get_exte nsi on (i nt

27、)':crypto/wvx509.cc:1168: error: in valid conversion from、un sig ned char*' to 'const un sig ned char*'crypto/wvx509.cc:1171: error: in valid conversion from、un sig ned char*' to 'const un sig ned char*'make: * crypto/wvx509.o Error 1解决方法:crypto/wvx509.ccif (method->it

28、)ext_data = ASN1_item_d2i(NULL, & ext->value->data.ext->value->le ngth,ASN1_ITEM_ptr(method->it);elseext_data = method->d2i(NULL, & ext->value->data,ext->value->le ngth);改为if (method->it)ext_data = ASN1_item_d2i(NULL, (co nst un sig ned char*)&ext->val

29、ue->data,ext->value->le ngth,ASN1_ITEM_ptr(method->it);elseext_data = method->d2i(NULL, (const un sig ned char*)&ext->value->data,ext->value->le ngth);compili ng streams/wvpam.o.streams/wvpam.cc: In member fun ctio n 'bool WvPam:authe nticate(c onstWvFastStri ng&am

30、p;, const WvFastStri ng&, const WvFastStri ng&)':streams/wvpam.cc:71: error: 'fail' un declared (first use this fun cti on)streams/wvpam.cc:71: error: (Each un declared ide ntifier is reported only oncefor each function it appears in.)make: * streams/wvpam.o Error 1解决方法:return fa

31、il;改为return false;rootlocalhost wvstreams-4.0.1# make in stallrootlocalhost wvstreams-4.0.1# cp libwvutils.so ./in stall/lib/libwvutils.so.4.0 -arootlocalhost wvstreams-4.0.1# cd .rootlocalhost wvdial-1.54.0# tar xzf wvdial-1.54.0.tar.gzrootlocalhost wvdial-1.54.0# cd wvdial-1.54.0rootlocalhost wvdi

32、al-1.54.0# cp/works/wvdial-1.54.0/i nstall/in clude/wvstreams/*.h .rootlocalhost wvdial-1.54.0# vi MakefilePREFIX=/usr/local改为PREFIX=/works/wvdial-1.54.0/i nstallPPPDIR=/etc/ppp/peers改为PPPDIR=$PREFIX/etc/ppp/peersXPATH=. ./wvstreams/i nclude $(PKGINC)改为XPATH=/works/wvdial-1.54.0/in stall/i nclude/wv

33、streamsLIBS += -L./wvstreams -lwvutils -lwvstreams改为LIBS += -L/works/wvdial-1.54.0/i nstall/lib -lwvutils -lwvstreams -lwvbase -lzrootlocalhost wvdial-1.54.0# vi wvrules.mk增加CC = arm-l inu x-g+CXX = arm-li nu x-g+rootlocalhost wvdial-1.54.0# makerootlocalhost wvdial-1.54.0# make in stall3.3.2、wvdial

34、-1.60.4export PATH=/usr/local/arm/4.2.2-eabi/usr/bi n:$PATHtar xjf zlib-1.2.5.tar.bz2cd zlib-1.2.5./con figure -prefix=/works/cdma/i nstall-4.2.2修改 MakefileCC = arm-l inu x-gccCPP=arm-l inu x-gcc -EAR=arm-l inu x-ar rcldshared= arm-linux-gcc .RANLIB=arm-li nu x-ra nlibmakemake in stallope nssl-0.9.8

35、 npatch -N -p1 -i ./ope nssl-0.9.8 n- fix_ma npages-1.patch./Con figure -prefix=/works/cdma/i nstall-4.2.2os/compiler:arm-li nu x-gccmakemake in stallwvstreams-4.6.1修改 con figurewith_zlib=no改为with_zlib=yes(有两处)with_ope nssl=no改为with_ope nssl=yes(有两处)./con figure -prefix=/works/cdma/i nstall-4.2.2 -h

36、ost=arm-li nuxCPPFLAGS=-l/works/cdma/i nstall-4.2.2/i ncludeLDFLAGS=-L/works/cdma/zlib-1.2.5-4.2.2 CFLAGS=-I/works/cdma/zlib-1.2.5-4.2.2-with-zlib=/works/cdma/zlib-1.2.5-4.2.2/-with-ope nssl=/works/cdma/ope nssl-0.9.8 n-4.2.2 -without-dbus -with-pam=no-with-tcl=no -with-qt =no -without-valgri ndmake

37、如果出现 undefined referenee to "EVP_MD_size"错误将出现错误的语句returnEVP_MD_size(evp_md_st *)evpmd; 改成 return (evp_md_st *)evpmd)->md_size;即可make in stallwvdial-1.60.4修改 Makefileprefix=/usr/local改为prefix=/works/cdma/i nstall-4.2.2PPPDIR=/etc/ppp/peers改为PPPDIR=$prefix/etc/ppp/peersPC_CFLAGS=$(shell

38、pkg-co nfig -cflags libwvstreams)改为PC_CFLAGS=-I/works/cdma/i nstall-422/i nclude/wvstreamsPC_LIBS=$(shell pkg-config -libs libwvstreams)PC_LIBS=-L/works/cdma/in stall-4.2.2/lib -lwvstreams -lwvutils -lwvbase修改 wvrules.mkWVLINK_CC = gcc改为WVLINK_CC = arm-li nux-g+CC = arm-l inu x-g+CXX = arm-li nu x-g

39、+makemake in stall4、Linux内核的配置与修改4.1、linux内核配置make menuconfigDevice Drivers->* Network device support -><M> PPP (po in t-to-po int protocol) support*PPP multili nk support (EXPERIMENTAL)*PPP filteri ng<M> PPP support for async serial ports<M> PPP support for sync tty ports<

40、;M> PPP Deflate compressio n<M> PPP MPPE compressio n (en cryptio n) (EXPERIMENTAL)<M> PPP over Ethernet (EXPERIMENTAL)* USB support-><M> USB Modem (CDC ACM) supportUSB Serial Con verter support-><M> USB driver for GSM and CDMA modems4.2、linux内核修改drivers/usb/serial/o

41、pti on.cstatic struct usb_device_id opti on _ids = ;在这个数组中添加两项 USB_DEVICE(0x19d2, 0x0031), USB_DEVICE(0x19d2, 0x0034) ,4.3、linux内核编译make zImagemake modules5、3G模块的使用5.1、加载内核模块in smod opti on.koin smod cdc-acm.koin smod slhc.koin smod ppp_ge neric.koin smod pppox.koin smod pppoe.koin smod ppp_s yn ctt

42、y.koin smod ppp_deflate.koin smod crc-ccitt.koin smod ppp_as yn c.koin smod sha1_ge neric.koin smod ppp_mppe.ko5.2、加载USB文件系统mount -t usbfs usbfs /proc/bus/usb5.3、ZTE-mf637u (中国联通)的使用5.3.1、配置文件 /etc/usb_modeswitch.setup# Con figurati on for the usb-modeswitch package, a mode switchi ng tool for# USB

43、devices providi ng multiple states or modes# This file is evaluated by the wrapper script "usb_modeswitch" in /lib/udev# To en able an optio n, set it to "1", "yes" or "true" (case does n't matter)# Everyth ng else counts as "disable"# Disable au

44、tomatic mode switch ing globally (e.g. to access the origi nal# in stall storage)DisableSwitchi ng=0# En able loggi ng (results in a exte nsive report file in /var/log, n amed# "usb_modeswitch_<i nterface-name"En ableLoggi ng=0If If If If If If If If If If If If If If If If If If If If

45、If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If If IfII II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II# ZTE MF622 (aka "Ond

46、a MDC502HS")# ZTE MF626# ZTE MF628+ (tested version from Telia / Swede n)# ZTE MF633# ZTE MF636 (aka "Telstra / BigPond 7.2 Mobile Card")# ZTE MF637# Con tributor: Joakim Wenn ergre n and othersDefaultVe ndor=0x19d2DefaultProduct= 0x2000TargetVe ndor=0x19d2TargetProduct= 0x0031Message

47、Co nten t="5553424312345678000000000000061b0000000200000000000 00000000000"MessageCo nten t2="5553424312345678000000000000061b000000030000000000 000000000000"NeedResp on se=15.3.2、配置文件 /etc/wvdial.confDialer DefaultsModem = /dev/ttyUSB2In it1 = ATZInit3 = ATE0V1Init5 = ATSO=OInit

48、6 = AT+CGDC0NT=1,"IP","u nin et"In it7 = AT+CFUN=1Modem Type = USB ModemBaud = 460800New PPPD = yesISDN = 0Pho ne = *99*1#Password = anyUsern ame = anyStupid Mode = 1533 ZTE-mf637u(中国联通)的操作步骤5.331、设置环境变量export PATH= /works/wvdial-1.54.0/in stall/bi n: /works/cdma/i nstall/bin :$P

49、ATHexport LD_LIBRARY_PATH= /works/wvdial-1.54.0/i nstall/lib:/works/cdma/i nstall/lib:$LD_LIBRARY_PATH5.3.3.2、 插入ZTE-mf637u(中国联通)无线网卡5.3.3.3、等待 5 秒钟左右、运行 usb-modeswitch -W5.3.3.4、运行 wvdial-> WvDial: In ternet dialer version 1.54.0-> Cannot ope n /dev/ttyUSB2: Cannot get in formatio n for seria

50、l port.-> Cannot ope n /dev/ttyUSB2: Cannot get in formatio n for serial port.-> Cannot ope n /dev/ttyUSB2: Cannot get in formatio n for serial port. 解决:(两种方法)5.3.3.4.1 将 wvstreams-4.0.1/streams/wvmodem.cc#if HAVE_LINUX_SERIAL_H改为#if 05.3.342. wvstreams-4.0.1的配置命令增加 ac_cv_header_l in ux_serial

51、_h=no即./configure -prefix=/works/wvdial-1.54.0/install -host=arm-linuxCFLAGS=-l/works/cdma/in stall/i nclude LDFLAGS=-L/works/cdma/i nstall/lib/-with-zlib=/works/cdma/zlib-1.2.5 -with-openssl=/works/cdma/openssl-0.9.8n-without-dbus -with-pam=no -with-tcl=no -with-qt=no ac_cv_header_li nu x_serial_h=

52、no 重新编译。5.4、ZTE-mu351(中国移动)的使用5.4.1、配置文件 /etc/wvdial.confModem = /dev/ttyACM2In it1 = ATZIn it3 = ATE0V1Init5 = ATS0=0Init6 = AT+CGDCONT=1,"IP","cmn et"Init7 = AT+CFUN=1Modem Type = USB ModemBaud = 460800New PPPD = yesISDN = 0Pho ne = *99*1#Password = anyUsern ame = anyStupid Mode = 1542、ZTE-mu351 (中国移动)的操作步骤542.1、设置环境变量export PATH=/roo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论