Openwrt 3G拨号上网

一、添加VID、PID

在linux_src/drivers/usb/serial/option.c 文件中的
static const struct usb_device_id option_ids[]的id 列表中增加如下语句:

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },


如何测试驱动不成功,在安装option.ko的情况下,可以直接写入usb-serial 的pid

 echo 05c6 9025 >/sys/bus/usb-serial/drivers/option1/new_id


openwrt-1407在如下位置:
build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620n/linux-3.10.49/drivers/usb/serial/option.c


二、内核的编译配置

包括USB串口驱动和PPP拨号相关的配置项:

1、USB 串口驱动相关的配置项:
   CONFIG_USB_SERIAL=y
   CONFIG_USB_SERIAL_OPTION=y
   CONFIG_USB_SERIAL_WWAN=y

make kernel_menuconfig

Device Drivers --->
  USB support --->
    USB Serial Converter support ---> (默认是M,且不能设为*)

习惯上=y 使得编译进内核而不是作为模块,那么得配置好一些USB相关
<*>  Support for Host-side USB (默认M,选择* 方便USB Serial可以=y)
<*>  USB announce new devices
[*]  Enable USB persist by default
<*>  EHCI HCD(USB 2.0) support
[*]  Root Hub Transaction Translators
[*]  Improved Transaction Translator scheduling
<*>  OHCI HCD support
<*>  USB Modem (CDC ACM) support
<*>  USB Printer support
<*>  USB Wireless Device Management support

USB Serial Converter support --->
  <*>  USB driver for GSM and CDMA modems

退出后保存,git status查看会修改target/linux/ramips/mt7620n/config-3.10 这里便是内核的默认编译配置文件

2、PPP 拨号的相关配置项:
   CONFIG_PPP=y
   CONFIG_PPP_MULTILINK=y
   CONFIG_PPP_FILTER=y
   CONFIG_PPP_ASYNC=y
   CONFIG_PPP_SYNC_TTY=y
   CONFIG_PPP_DEFLATE=y
   CONFIG_PPP_BSDCOMP=y

make kernel_menuconfig

Device Drivers --->
  [*] Network device support --->
      <*> PPP (point-to-point protocol) support
      <*> PPP BSD-Compress compression
      <*> PPP Deflate compression
      [*] PPP filtering
      [*] PPP multilink support
      <*> PPP MPPE compression (encryption)
      [*] PPP multilink support
      <*> PPP over Ethernet
      <*> PPP support for async serial ports
      <*> PPP support for sync tty ports


三、其它配置

make menuconfig

1、界面LuCI配置(web页面管理程序)
LuCI --->
  1. Collections --->
       <*> luci
  3. Applications --->
       <*> luci-app-commands
       <*> luci-app-ddns
       <*> luci-app-ntpc

2、网络配置
Netmowrk --->
  File Transfer --->
    <*> wget
  SSH --->
    <*> openssh-client
    <*> openssh-sftp-server

3、工具配置
Utilities --->
  <*> comgt


四、添加ppp0网络节点

target/linux/ramips/base-files/etc/uci-defaults/02_network

+       m201)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+               ucidef_set_interfaces_3g "ppp0"
+               ;;
+
        ur-336un)

package/base-files/files/lib/functions/uci-defaults.sh

+ucidef_set_interface_ppp0() {
+       local ifname=$1
+       
+       uci batch <<EOF
+set network.ppp0='interface'
+set network.ppp0.ifname='$ifname'
+set network.ppp0.proto='3g'
+set network.ppp0.apn='3gnet'
+set network.ppp0.service='umts'
+set network.ppp0.dialnumber='*99#'
+set network.ppp0.device='/dev/ttyUSB0'
+EOF
+}

+ucidef_set_interfaces_3g() {
+       local ppp0_ifname=$1
+       
+       ucidef_set_interface_ppp0 "$ppp0_ifname"
+}
+

package/network/config/firewall/files/firewall.config

config zone
+       option network          'wan ppp0'

调试的时候可以手动设置(我这里是华为MU709s-2 WCDMA 联通3G):
进入etc/config/修改network,增加一个3G 网络节点

config interface 'ppp0'
        option ifname 'ppp0'
        option proto '3g'
        option apn '3gnet'
        option service 'umts'
        option dialnumber '*99#'
        option device '/dev/ttyUSB0'

注:联通apn:3gnet 电信apn:ctnet 移动apn:cmnet/cmwap
联通dialnumber:3G为*99# 电信:3G为#777 移动为:*99***1# LTE为:*99#


拨号成功:
ifconfig
3g-ppp0   Link encap:Point-to-Point Protocol  
          inet addr:10.229.7.143  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:844 (844.0 B)  TX bytes:854 (854.0 B)

五、参考资料
openwrt官网

Use 3g/UMTS USB Dongle for WAN connection:
http://wiki.openwrt.org/doc/recipes/3gdongle

Wired WAN + 3G dongle:
http://wiki.openwrt.org/doc/howto/wired.wan.with.3g.dongle

Get your WAN interface up using ifup wan (or /etc/init.d/network restart if you changed more stuff; a reboot if you changed even more).



小笔记:

1、使用cat /sys/kernel/debug/usb/devices 看USB的VID, PID

2、gcom -d /dev/ttyUSB0 info 

本例子中上传移柯的4G模块为修改示例


lynq linux下ppp拨号流程V1.2_20161121

链接:http://pan.baidu.com/s/1jHJSBXk 密码:5qdg



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第31章《openwrt开发笔记》讲解了如何在Ubuntu 12.04和OpenWrt 15.05上进行4G拨号上网。在开始之前,我们需要确保Ubuntu安装了相关驱动程序和依赖项。 首先,我们需要在Ubuntu上安装modem-manager和usb-modeswitch。可以使用以下命令来安装: sudo apt-get install modem-manager usb-modeswitch 安装完成后,我们需要在OpenWrt设备上配置4G拨号连接。连接设备到计算机上,然后通过串口或SSH登录到OpenWrt。 首先,我们需要编辑网络配置文件。可以使用以下命令打开配置文件: vi /etc/config/network 然后,将以下配置添加到配置文件末尾: config interface 'wwan' option proto '3g' option device '/dev/ttyUSB0' option service 'umts' 保存并关闭文件。然后,重启网络服务,使配置生效: /etc/init.d/network restart 接下来,我们需要为4G连接配置一个接口。在OpenWrt中,可以使用以下命令: uci set network.wwan=interface uci set network.wwan.proto='3g' uci set network.wwan.device='/dev/ttyUSB0' uci set network.wwan.service='umts' uci commit network /etc/init.d/network reload 完成以上步骤后,我们可以使用以下命令进行拨号并进行4G上网: /usr/sbin/usbmode -s -v 0x12d1 -p 0x1436 /usr/sbin/usbmode -s -v 0x12d1 -p 0x1001 这将启动拨号过程,并将设备连接到4G网络。拨号成功后,我们就可以在OpenWrt设备上访问互联网了。 综上所述,《openwrt开发笔记》第31章介绍了如何在Ubuntu 12.04和OpenWrt 15.05上进行4G拨号上网。这个过程涉及到在Ubuntu上安装相关驱动程序和依赖项,然后在OpenWrt设备上配置和启动4G连接。完成这些步骤后,我们可以成功地进行4G上网了。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值