1.在 linux_src/include/linux/usb.h 中添加如下宏

若部分内核已经添加,则无需添加此部分。详文如下:

#define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \

.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \

| USB_DEVICE_ID_MATCH_VENDOR, \

.idVendor = (vend), \

.bInterfaceClass = (cl), \

.bInterfaceSubClass = (sc), \

.bInterfaceProtocol = (pr)

2.在 linux_src/drivers/usb/serial/option.c 文件中的 static const struct

usb_device_id option_ids[]的 id 列表中增加如下语句,用于匹配设备数据。

{VID,InterfaceClass, InterfaceSubClass, InterfaceProtocol}。

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0xff,

0xff) },

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01,

0x01) },

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01,

0x02) },

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01,

0x03) },

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01,

0x04) },

{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01,

0x05) },

............

3.在option.c中加入定义

增加对 bcdUSB 值的定义:#define HW_bcdUSB 0x0110;

增加对华为 vid 值的定义:#define HUAWEI_VENDOR_ID 0x12d1。

#define HUAWEI_PRODUCT_MU709S            0x1c25 //add by cxy

#define HUAWEI_PRODUCT_ME909             0x15c1 //add by cxy

{ USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_MU709S) },//add by cxy

{ USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ME909) },//add by cxy

4.内核配置

1)USB driver for GSM and CDMA midems

2)ppp拨号 ppp BSD-compres comprossion

3)CDC相关

4.ppp拨号脚本

编译ppp2.2.4  pppd chat 放入文件系统/usr/sbin中

2种方式

1.huawei-ppp-on huawie-ppp-off...

2.evdo   evdo-chat-connect

#!/bin/sh

#

# Script to initiate a ppp connection. This is the first part of the

# pair of scripts. This is not a secure pair of scripts as the codes

# are visible with the 'ps' command.  However, it is simple.

# Modify: fangxiaozhi programName=${0##*/}

# These are the parameters. Change as needed.

#DEVICE=/dev/usb/tts/0

#DEVICE=/dev/ttyACM0                  #The modem file name of the data card

DEVICE=/dev/ttyUSB0                  #The modem file name of the data card

TELEPHONE=*99***1#                             # The telephone number for the connection, by default, it will be *99#

ACCOUNT=""                              # The account name for logon, by default, it  will be null

PASSWORD=""                     # The password for this account, by default, it  will be null

AUTH=""   # Authentic protocol,byi default, it will be null

APN=cmnet

STR_USER="user \"cmnet\""

STR_PASSWD="password \"\""

show_usage(){

echo "usage:"

echo " $programName [--usr=username] [--pwd=password] [--pn=phonenumber][--apn=apn][--auth=authentic protocol]"

echo "[--local_ip=local_ip] [--remote_ip=remote_ip] [--usepeernds=usepeernds]"

echo "username: The account name get from your ISP, by default, it will be null"

echo "password: The password for your account, by default, it will be null"

echo "phonenumber: The phone  number for dialing up, by default, it will be *99#"

echo "apn: access point name"

echo "auth: chap/pap.   for example: --auth=chap"

exit 0

}

#ps -ef |grep cusip_full_is | grep -v grep | wc -l | awk '{ print $1; }'

#ps -ef |                              全格式显示当前所有进程

#grep cusip_full_is             滤出''cusip_full_is''的进程

#grep -v grep                     把''grep''这个进程忽略掉

#wc -l                                 看看有多少个进程

#awk '{ print $1; }'              输出第一列

PID=`ps -ef | grep -v grep | grep "huawei-dial" | grep "pppd" | awk '{ print $2; exit }'`

if test $PID; then

echo "PPP link is active"

exit 1

fi

if [ $# -eq 1 -a "$1" = "--help" ]

then

show_usage

fi

for i in "$@"

do

case $i in

--device=*)

echo "--device*=$i"

DEVICE=${i#--device=}

;;

--usr=*)

echo "--usr*=$i"

ACCOUNT=${i#--usr=}

;;

--pwd=*)

echo "--pwd*=$i"

PASSWORD=${i#--pwd=}

;;

--pn=*)

echo "--pn*$i"

TELEPHONE=${i#--pn=}

;;

--apn=*)

echo "--apn*=$i"

APN=${i#--apn=}

;;

--auth=*)

echo "--auth*=$i"

AUTH=${i#--auth=}

if [ "$AUTH" = "chap" ]; then

AUTH=-pap

fi

if [ "$AUTH" = "pap" ]; then

AUTH=-chap

fi

;;

--local_ip=*)

echo "--local_ip*=$i"

PAR_LOCAL=${i#--local_ip=}

;;

--remote_ip=*)

echo "--remote_ip*=$i"

PAR_REMOTE=${i#--remote_ip=}

;;

--usepeernds=*)

echo "--usepeernds*=$i"

PAR_USEERDNS=${i#--usepeernds=}

;;

*)

echo "*=$i"

esac

done

if [ "$PAR_LOCAL" = "" ]; then

LOCAL_IP=0.0.0.0

else

LOCAL_IP=$PAR_LOCAL

fi

if [ "$PAR_REMOTE" = "" ]; then

REMOTE_IP=0.0.0.0

else

REMOTE_IP=$PAR_REMOTE

fi

if [ ! "$PAR_USEERDNS" = "" ]; then

USEPEERDNS=''

for NAMESERVER in `echo $PAR_USEERDNS | awk -F: '{for (i=1;i<=NF;i++) print $i}'`

do

echo "nameserver $NAMESERVER" >> /etc/ppp/resolv.conf

done

else

USEPEERDNS='usepeerdns'

fi

NETMASK=255.255.255.0# The proper netmask if needed

#

# Export them so that they will be available at 'ppp-on-dialer' time.

export TELEPHONE APN ACCOUNT PASSWORD

#

# This is the location of the script which dials the phone and logs

# in.  Please use the absolute file name as the $PATH variable is not

# used on the connect option.  (To do so on a 'root' account would be

# a security hole so don't ask.)

#

# Initiate the connection

#

# I put most of the common options on this command. Please, don't

# forget the 'lock' option or some programs such as mgetty will not

# work. The asyncmap and escape will permit the PPP link to work with

# a telnet or rlogin connection. You are welcome to make any changes

# as desired. Don't use the 'defaultroute' option if you currently

# have a default route to an ethernet gateway.

#

if [ ! -d "/etc/ppp" ]

then

mkdir /etc/ppp

fi

if [ -f "/etc/ppp/options" ]

then

echo "" >/etc/ppp/options

fi

if [ -f "/etc/ppp/pap-secrets" ]

then

chmod 700 /etc/ppp/pap-secrets

fi

if [ -f "/etc/ppp/chap-secrets" ]

then

chmod 700 /etc/ppp/chap-secrets

fi

if [ ! "$ACCOUNT" = "" ]

then

echo "$ACCOUNT * $PASSWORD *" > /etc/ppp/pap-secrets

echo "$ACCOUNT * $PASSWORD *" > /etc/ppp/chap-secrets

STR_USER="user \"$ACCOUNT\""

STR_PASSWD="password \"$PASSWORD\""

else

echo "* * * *" > /etc/ppp/pap-secrets

echo "* * * *" > /etc/ppp/chap-secrets

fi

chmod 400 /etc/ppp/pap-secrets

chmod 400 /etc/ppp/chap-secrets

if [ "$TELEPHONE" = "*99***1#" ]; then

echo "

TIMEOUT 15

ABORT \"ERROR\"

ABORT \"NO DIALTONE\"

ABORT \"BUSY\"

ABORT \"NO ANSWER\"

'' AT

OK AT+CGDCONT=1,\"IP\",\"$APN\"

OK ATDT$TELEPHONE

CONNECT\"\"

" > /etc/ppp/huawei-chat

fi

if [ "$TELEPHONE" = "#777" ]; then

echo -e "at^pppcfg=\"$ACCOUNT\",\"$PASSWORD\"\r\n" > $DEVICE

echo " ABORT \"NO CARRIER\"

ABORT \"NO DIALTONE\"

ABORT \"ERROR\"

ABORT \"NO ANSWER\"

ABORT \"BUSY\"

TIMEOUT 120

ABORT \"Username/Password Incorrect\"

\"\"   AT

OKATDT#777

CONNECT\"\"

" > /etc/ppp/huawei-chat

fi

if [ ! -d "/etc/ppp/peers" ]

then

mkdir /etc/ppp/peers

fi

echo "$DEVICE

115200

crtscts

modem

debug

nodetach

usepeerdns

noipdefault

defaultroute

$LOCAL_IP:$REMOTE_IP

$STR_USER

$STR_PASSWD

noauth

$AUTH

-mschap

-mschap-v2

ipcp-accept-local

ipcp-accept-remote

connect '/usr/sbin/chat -s -v -f /etc/ppp/huawei-chat'

" > /etc/ppp/peers/huawei-dial

/bin/cp ./ip-up /etc/ppp/ip-up

/bin/cp ./ip-down /etc/ppp/ip-down

exec  /usr/sbin/pppd call huawei-dial&

exit 0

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐