華為E1750在DM6446上的移植

來源:互聯網
上載者:User

原文地址::http://blog.csdn.net/yel617/article/details/5602934

 

 

一、環境

1、  開發板核心:linux kernel 2.6.10

2、  3G卡片:華為E1750

二、相關工具

1、  usb-modeswitch-1.1.2.tar.bz2

Usb_modeswitch是對USB裝置的工作模式進行轉換一種萬能工具,當然這種工具,只有在linux下才能體現其巨大的作用。隨著移動通訊,無線通訊的發展,越來越多的裝置被製作成USB介面,像一些無線網卡,3G數據卡等等。這些裝置的廠家一般都會提供windows 下驅動,這些裝置在第一次插上機子的時候,它們處於CDROM+快閃記憶體模式,可以從中提供驅動程式安裝驅動,在驅動程式安裝完成後,驅動會轉換成3G模式,此時就會出現usb modem裝置,目前的3G卡片全都是這樣,這就是所謂的“ZeroCD”。

而在linux下我們可沒有那麼好的待遇,廠家一般不會給我們提供linux下面的驅動,而目前的核心還不能自動識別並驅動。所以我們需要用usb_modeswitch這個工具來進行模式轉換,裝置模式依賴usb-storage和usbserial模式,所以,在開發板上需要有這兩種模組的支援,裝置並能夠正常工作於這兩種模式下。

2、  libusb-0.1.12.tar.gz

libusb提供給usb_modeswitch一套系統API

三、交叉編譯usb_modeswitch

1、交叉編譯libusb

解壓並進入libusb-1.0.6目錄,建立子目錄install用於存放最後生存的庫檔案與標頭檔。

[root@libusb-0.1.12]# mkdir install

配置並產生Makefile檔案

[root@libusb-0.1.12]# ./configure --build=i686-linux --host=arm-linux --prefix=/home/libusb-0.1.12/install

 [root@libusb-0.1.12]# make

[root@libusb-0.1.12]# make install

2、設定PKG_CONFIG_PATH環境變數,以使我們後面的編譯能夠順利找到libusb庫

[root@libusb-0.1.12]# export

PKG_CONFIG_PATH=/home/Anson/libusb-0.1.12/install/lib/pkgconfig:$PKG_CONFIG_PATH

    查看是否設定正確

[root@libusb-0.1.12]# echo $PKG_CONFIG_PATH

3、 交叉編譯usb_modeswitch

(1)、修改Makefile檔案

      CC = arm_v5t_le-gcc

(2)、將libusb裡的庫標頭檔拷到交叉編譯器的include和lib目錄下,或者直接在Makefile檔案裡直接加上編譯選項指令庫的路徑即可如下:

$(PROG):&(OBJS)

      &(CC) –o $(PROG) &(OBJS) &(CFLAGS) –I /home/libusb-0.1.12/install/include –L /home/libusb-0.1.12/install/lib

(3)、make

4、編輯usb_modeswitch-1.1.2目錄下的usb_modeswitch.setup檔案

 

# Huawei E1750

#

# Contributor: Anders Blomdell, Ahmed Soliman

DefaultVendor= 0x12d1

DefaultProduct= 0x1446

 

TargetVendor= 0x12d1

TargetProduct= 0x1001

 

# only for reference and 0.x versions

MessageEndpoint=0x01

MessageContent="55534243123456780000000000000011060000000000000000000000000000"

HuaweiMode=0

5、將上面產生的libusb動態庫拷貝到開發板的庫目錄下,將上面產生的usb_modeswitch可執行程式和usb_modeswitch.setup拷貝到檔案系統目錄下。

四、交叉編譯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 0x1001

Make menuconfig 選中相關選項,make uImage 即可。

五、利用usb_modeswitch進行模式轉換

在/dev目錄下建立字元節點

mknod /dev/ttyUSB0 c 188 0

mknod /dev/ttyUSB1 c 188 1

mknod /dev/ttyUSB2 c 188 2

運行 ./usb_modeswitch 切換3G卡片的模式。此時會出現一些資訊,你會看到轉換成3G模式後的幾個串口資訊,ttyUSB0, ttyUSB1, ttyUSB2,如下:

pl2303 1-1:1.0: PL-2303 converter detected

usb 1-1: PL-2303 converter now attached to ttyUSB0

pl2303 1-1:1.1: PL-2303 converter detected

usb 1-1: PL-2303 converter now attached to ttyUSB1

pl2303 1-1:1.2: PL-2303 converter detected

usb 1-1: PL-2303 converter now attached to ttyUSB2

六、交叉編譯pppd撥號工具,並編寫撥號指令碼

    由於板卡上已移植了pppd撥號工具,在核心裡將相關的選項選上即可。下面介紹撥號指令碼的編寫:

wcdma:

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'

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"

 

將wcdma、chat-wcdma-connect、chat-wcdma-disconnect三個檔案拷貝到

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

Nameserver 202.106.46.151

由於所用的DM6446開發板,檔案系統掛載在一個伺服器上,其所用的網關,被當做了預設的網關,故撥號後會ping不通網路。 

root@192.168.1.2:/# 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

修改/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

修改預設閘道

root@192.168.1.2:/# route del default

撥號後可查看

root@192.168.1.2:/opt/3g# 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

 

開始撥號

root@192.168.1.2:/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通,則說明移植成功。

root@192.168.1.2:/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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.