华为3G网卡E1750在omap3530上移植(一)

一、环境

1、  开发板内核:linux-2.6.28-omap

2、  3G卡片:华为E1750

二、相关工具

1         usb-modeswitch-1.0.2.tar.bz2

usb_modeswitch这个工具来进行3G模式转换

2  libusb-0.1.12.tar.gz

libusb提供给usb_modeswitch一套系统API

三、交叉编译

1.交叉编译libusb

解压并进入libusb-0.1.12目录,建立子目录install用于存放最后生存的库文件与头文件。

[[email protected]]# mkdir install

配置并生成Makefile文件

[[email protected]]# ./configure --build=i686-linux --host=arm-none-linux-gnueabi --prefix=/home/libusb-0.1.12/install

 [[email protected]]# make

[[email protected]]# make install

(我的交叉编译器是arm-none-linux-gnueabi,你的可能是arm-linux

2. 交叉编译usb_modeswitch

1)修改Makefile文件

      CC = arm-none-linux-gnueabi

2)将libusb里的库头文件拷到交叉编译器的includelib目录下

3make

4)修改usb_modeswitch-1.0.2目录下的usb_modeswitch.conf文件

# Huawei E1750

DefaultVendor= 0x12d1

DefaultProduct= 0x1446

 

TargetVendor= 0x12d1

TargetProduct= 0x1001

 

# only for reference and 0.x versions

MessageEndpoint=0x01

MessageContent="55534243123456780000000000000011060000000000000000000000000000"

HuaweiMode=0

3. 将上面生成的libusb动态库拷贝到文件系统的库目录下,将上面生成的usb_modeswitch可执行程序和usb_modeswitch.setup拷贝到文件系统/usr/sbin/etc目录下。

四、交叉编译3G卡片驱动

2.6.28内核源码中驱动/driver/usb/serial/ option.c中加入3G卡片的ID信息:

#define HUAWEI_PRODUCT_E1750      0x1446

Make menuconfig 选上编译这个文件的选项

修改文件drivers/usb/storage/unusual_devs.h,去掉对移植网卡ID的屏蔽,关于此官方是这样说的:

Kernel related issues

In some newer kernels, certain device families (some Option, some Huawei, some ZTE as mentioned above) get a special treatment in the usb-storage code to enable switching right away. You would not need USB_ModeSwitch anymore for these specific dvices; on the other hand you have no choice of accessing the "CD-ROM" part of your device. Plus, there were cases when the special treatment brought no results and furthermore prevented USB_ModeSwitch to work properly afterwards (happened with ZTE devices, error "-2").

In case of trouble, look into "unusual_devs.h" in the "drivers/usb/storage" folder of your kernel source. If your default ID (vendor and product ID of the storage part) can be found there and you get errors when running USB_ModeSwitch, try first to blacklist "usb-storage".
If that helps, you should consider rebuilding your kernel with the entry in "unusual_devs.h" deactivated. The only thing that will happen is that usb-storage works in the default way afterwards.
I found a tip in the Russian Gentoo wiki to do exactly what I just suggested for the
ZTE MF626.

修改完内核后执行make uImage生成内核镜像文件

五、利用usb_modeswitch进行模式转换

移植完usb_modeswitchlibusb,更新内核后执行命令进行模式转换

# ./usb_modeswitch –c usb_modeswitch.conf

执行后正常的话在/dev下生成了ttyUSB0ttyUSB1ttyUSB2等节点。执行lsusb命令就可以发现ID0x1446变为0x1001.

六、交叉编译pppd拨号工具,并编写拨号脚本

1. 移植pppd拨号工具,并在内核里将相关的选项选上。

 a)      下载编译ppp-2.4.5解压

b)      进入chat目录, 编译chat: make –f Makefile.linux --host=arm-none-linux-gnueabi,生成chat

c)      进入pppd目录, 编译pppd: make –f Makefile.linux --host=arm-none-linux-gnueabi,生成pppd,可能会出现找不到pcap.h需要交叉编译libpcap后面有说明

d)       chatpppd拷贝到/usr/sbin/目录

e) 当服务器要求pppd给出用户身份认证信息的时候,如果协商采用PAP认证方式,pppd将到/etc/ppp/pap-secrets文件中取得用户口令;如果协商采用CHAP认证方式,则pppd将到/etc/ppp/chap-secrets文件中取得用户口令。因此需要对/etc/ppp/pap-secrets/etc/ppp/chap-secrets做修改,修改PAP认证所需要的用户名密码,在文件/etc/ppp/pap-secrets中添加

card  *  card  *

修改CHAP认证协议所需的用户名和口令,在文件/etc/ppp/ chap-secrets中添加

card  *  card  *

下面介绍拨号脚本的编写:

wcdma

nodetach

#lock

/dev/ttyUSB0

#115200

460800

#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 /etc/ppp/peers/chat-wcdma-connect'

#persist

#disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-disconnect'

chat-wcdma-connect:

ABORT 'NO CARRIER'

ABORT 'ERROR'

ABORT 'NO DIALTONE'

ABORT 'BUSY'

ABORT 'NO ANSWER'

'' /rAT

OK /rATZ

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

OK-AT-OK ATDT*99#

CONNECT /d/c

chat-wcdma-disconnect:

ABORT "ERROR"

ABORT "NO DIALTONE"

 

SAY "/nSending break to the modem/n"

'' "/K"

'' "+++ATH"

SAY "/nGoodbay/n"

wcdmachat-wcdma-connectchat-wcdma-disconnect三个文件拷贝到

/home/filesys/etc/ppp/peers 目录下,在/etc/resolv.conf中添加DNS

Nameserver 202.106.46.151

修改/etc/network/interfacds文件,设置网卡的工作模式如下:

Auto eeth0

  iface eth0 inet static

  address 192.168.1.42

  network 192.168.1.0

  netmask 255.255.255.0

  broadcast 192.168.1.255

  gateway  192.168.1.1

开始拨号

[email protected]:/opt/3g# pppd call wcdma&

拨号成功后会获得自动分配的IP地址

Serial connection established.

usb 1-1: pppd timed out on ep0out

Using interface ppp0

Connect: ppp0 <--> /dev/ttyUSB0

PAP authentication succeeded

Could not determine remote IP address: defaulting to 10.64.64.64

Cannot determine ethernet address for proxy ARP

local  IP address 172.25.125.70

remote IP address 10.64.64.64

ping www.sina.com 如能ping通,则说明移植成功。

[email protected]:/opt/3g# ping www.sina.com

PING libra.sina.com.cn (202.108.33.73) 56(84) bytes of data.

64 bytes from 202.108.33.73: icmp_seq=1 ttl=54 time=367 ms

64 bytes from 202.108.33.73: icmp_seq=2 ttl=54 time=320 ms

64 bytes from 202.108.33.73: icmp_seq=3 ttl=54 time=300 ms

64 bytes from 202.108.33.73: icmp_seq=4 ttl=54 time=310 ms

64 bytes from 202.108.33.73: icmp_seq=5 ttl=54 time=330 ms

 

你可能感兴趣的:(嵌入式linux,驱动,华为,makefile,authentication,编译器,工具,reference)