华为EC122在HiSi3110E上移植

一、环境

1、  开发板内核:linux kernel 2.6.14

2、  3G卡片:华为EC122

二、相关工具

1、  usb-modeswitch-1.0.2.tar.bz2

Usb_modeswitch是对USB设备的工作模式进行转换一种万能工具,在Linux下我们需要用usb_modeswitch这个工具来进行模式转换,设备模式依赖usbserial模式,所以,在开发板上需要有这种模块的支持,设备并能够正常工作于这两种模式下。

2、  libusb-0.1.12.tar.gz

libusb提供给usb_modeswitch一套系统API

三、交叉编译usb_modeswitch

1、交叉编译libusb

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

[root@libusb-0.1.12]# mkdir install

配置并生成Makefile文件

[root@libusb-0.1.12]# ./configure  --host=arm-uclibc-linux --test=arm-uclibc-linux --prefix=/root/libusb-0.1.12/install

 [root@libusb-0.1.12]# make

[root@libusb-0.1.12]# make install

这样生成一些lib 与include文件

2、 交叉编译usb_modeswitch

(1)、修改Makefile文件

STRIP     = arm-uclibc-linux-strip
CC          = arm-uclibc-linux-gcc
CCFLAGS     = -I /root/libusb-0.1.12/install/include -L  /root/libusb-0.1.12/install/lib -l usb

(2)、make

4、编辑usb_modeswitch-1.1.2目录下的usb_modeswitch.conf文件

 

# Huawei EC122

#

# Contributor: Anders Blomdell, Ahmed Soliman

DefaultVendor= 0x12d1

DefaultProduct= 0x1446

 

TargetVendor= 0x12d1

TargetProduct= 0x140c

 

 

MessageContent="55534243123456780000000000000011060000000000000000000000000000"

 

5、将上面生成的libusb动态库拷贝到开发板的库目录下,将上面生成的usb_modeswitch可执行程序和usb_modeswitch.conf拷贝到文件系统目录下。

 

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

在2.6.10内核源码中没有专门的3G驱动文件,我们在/driver/usb/serial/pl2303.c中加入3G卡片的ID信息:

{USB_DEVICE(HUAWEI_VENDOR_ID),HUAWEI_PRODUCT_ID)}

在/driver/usb/serial/pl2303.h中加入:

#define HUAWEI_VENDOR_ID 0x12d1

#define HUAWEI_PRODUCT_ID 0x140c

Make menuconfig 选中相关选项,可以选择成模块,也可以选择直接编译到内核里,

make内核即可。

五、利用usb_modeswitch进行模式转换

       运行 ./usb_modeswitch -W 切换3G卡片的模式。此时会出现一些信息,这时到/dev/usb/tts/ 下面查看转换后的通道,在这下面会出现 0 1 2 3 4  ttyUSB通道。

 

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

    由于板卡上已移植了pppd拨号工具,在内核里将相关的选项选上即可。下面介绍拨号脚本的编写:

vedo:

debug

nodetach

lock

/dev/usb/tts/0

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 /etc/ppp/evdo-connect-chat'

 

evdo-connect-chat:

TIMEOUT 5

ABORT 'NO CARRIER'

ABORT 'ERROR'

ABORT 'NO DIALTONE'

ABORT 'BUSY'

ABORT 'NO ANSWER'

'' /rATZ

OK-AT-OK ATD#777

CONNECT /d/c

 

ppp-off:

#/etc/ppp/ppp-off
#!/bin/sh
######################################################################
#
# Determine the device to be terminated.
#
if [ "$1" = "" ]; then
 DEVICE=ppp0
 else
  DEVICE=$1
  fi
  ######################################################################
  #
  # If the ppp0 pid file is present then the program is running. Stop it.
  if [ -r /var/run/$DEVICE.pid ]; then
          kill -INT `cat /var/run/$DEVICE.pid`
          #
          # If the kill did not work then there is no process running for this
          # pid. It may also mean that the lock file will be left. You may wish
          # to delete the lock file at the same time.
                  if [ ! "$?" = "0" ]; then
                                  rm -f /var/run/$DEVICE.pid
                                                  echo "ERROR: Removed stale pid file"
                                                                  exit 1
                                                                          fi
                                                                          #
                                                                          # Success. Let pppd clean up its own junk.
                                                                                  echo "PPP link to $DEVICE terminated."
                                                                                          exit 0
                                                                                          fi
                                                                                          #
                                                                                          # The ppp process is not running for ppp0
                                                                                          echo "ERROR: PPP link is not active on $DEVICE"
                                                                                          exit 1

 

 

将vedo 文件拷贝到文件系统/etc/ppp/peer/目录下vedo-connect-chat、ppp-off两个个文件拷贝到

文件系统/etc/ppp/目录下,在/etc/resolv.conf中添加DNS号

nameserver 219.141.136.10

 

由于所用的开发板,文件系统挂载在一个服务器上,其所用的网关,被当做了默认的网关,故拨号后会ping不通网络。

终端查看路由:

# route

Kernel IP routing table

Destination  Gateway       Genmask     Flags  Metric Ref   Use  Iface

192.168.1.0     *        255.255.255.0   U     0      0      0   eth0

default    192.168.1.3      0.0.0.0        UG    0      0      0   eth0

 

修改默认网关

# route del default

 #route add default ppp0

 

拨号后可查看

# route

Kernel IP routing table

Destination   Gateway     Genmask     Flags  Metric  Ref  Use  Iface

localhost       *       255.255.255.255 UH      0      0    0    ppp0

192.168.1.0    *        255.255.255.0   U      0      0    0    eth0

default        localhost      0.0.0.0      UG     0      0    0    ppp0

 

开始拨号

# pppd call evdo&

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

 

查看拨号是否成功

#ifconfig ppp0

如果能分配到IP地址,则拨号成功。

 

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

注:挂在usb设备mount -t usbfs none /proc/bus/usb

 

在这过程中,感谢一个哥们的大力支持,

 

 

参考了叶磊的华为E1750在MD6440上移植文章,http://blog.csdn.net/yel617/archive/2010/05/18/5602934.aspx

 根据这个方法 华为 E1750 在HS3110E我也成功了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值