Welcome to It-Slav.Net blog
Peter Andersson
peter@it-slav.net

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

Background

After succesfully installed my new Linksys WRT160NL with OpenWrt, the next step is to configure it. As the summer is approaching and my need for Internet access in our summer cottage will arrise. The summer cottage is in the middle of nowhere so it would be handy to put a USB dongle and the Wlan router in the spot with best 3G field strength and use the WiFi to connect several computers to the router and Internet.

The 3G USB modem is a Huawei modem I bought for 20 EUR and unlocked using this guide.

I found an excellent guide describing excactly what I wanted todo but it did not work 100% in my environment so I will describe what I did to get it running. Read the guide to get background and deeper explanation of how things are done. This guide assumes that you have read the guide, basic knowledge of OpenWRT, howto edit files in a Linux environment and so on.

 

Installation

The USB hardware and the modem need some extra packages to be installed. I installed the following:

root@WRT160NL:~#opkg install kmod-ar9170 kmod-usb-acm kmod-usb-core kmod-usb-ohci kmod-usb-serial comgt
kmod-usb-serial-option kmod-usb-storage kmod-usb-uhci kmod-usb2  usb-switch

Probably not all of them are necessery but during my tests and fiddeling these are the ones I installed.

 

Configuration

Create /etc/modules.d/60-usb-serial:

usbserial vendor=0x12d1 product=0x1446
 

The vendor and product parameters can be found by attaching the 3G modem and run:

root@WRT160NL:~# cat /proc/bus/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 2.06
S:  Manufacturer=Linux 2.6.32.10 ehci_hcd
S:  Product=Atheros AR91xx built-in EHCI controller
S:  SerialNumber=ar71xx-ehci
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1446 Rev= 0.00
S:  Manufacturer=HUAWEI Technology
S:  Product=HUAWEI Mobile
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usbserial_generic
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usbserial_generic
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 

The parameters are marked in yellow above.

 

 

The next step is to configure usb switch. Create /etc/usb-modeswitch.conf

########################################################
# Huawei E270+  (HSPA+ modem)

DefaultVendor= 0x12d1
DefaultProduct=0x1446

TargetVendor=  0x12d1
TargetProductList="1001,1406,140c,14ac"

CheckSuccess=20

MessageContent="55534243123456780000000000000011060000000000000000000000000000"

I have no clue of the syntax but I copied it from my Ubuntu machine /etc/usb_modeswitch.d/12d1:1446 and it works:-)

 

 

Add the following to /etc/config/network

config 'interface' 'ppp0'
    option 'ifname' 'ppp0'
    option 'proto' '3g'
    option 'device' '/dev/ttyUSB0'
    option 'apn' 'internet.tele2.se'
    option 'pincode' '1234'

The pincode is obvious, the apn is local and given by your local operator. It is handy to configure it to work in Ubuntu and then look at the configuration Ubuntu creates.
 

 

The firewall rules need to be updated and I added ppp0 to the wan section in /etc/config/firewall

config 'zone'
    option 'name' 'wan'
    option 'input' 'REJECT'
    option 'output' 'ACCEPT'
    option 'forward' 'REJECT'
    option 'masq' '1'
    option 'mtu_fix' '1'
    option 'network' 'wan ppp0'

To make the change to take effect run:

root@WRT160NL:~# /etc/init.d/firewall restart
 

 

Start it

Attach the modem and run:

root@WRT160NL:~# usb_modeswitch

Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
 Found default devices (1)
Accessing device 002 on bus 001 ...
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
 OK, driver found ("usbserial_generic")
 OK, driver "usbserial_generic" detached

SCSI inquiry data (for identification)
-------------------------
  Vendor String: HUAWEI 
   Model String: Mass Storage   
Revision String: 2.31
-------------------------

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x01 ...
 OK, message successfully sent
 Device is gone, skipping any further commands

Checking for mode switch (max. 20 times, once per second) ...
 Original device is gone already, not checking
 Searching for target devices ...
 Searching for target devices ...
 Searching for target devices ...
 Searching for target devices ...
 Searching for target devices ...
 Found correct target device

Mode switch succeeded. Bye.
 

 

logread should now give something similiar to:

Jun 12 17:29:11 WRT160NL user.info kernel: generic ttyUSB0: generic converter now disconnected from ttyUSB0
Jun 12 17:29:11 WRT160NL user.info kernel: usbserial_generic 1-1:1.0: device disconnected
Jun 12 17:29:11 WRT160NL user.warn kernel: usb 1-1: usbfs: process 1345 (usb_modeswitch) did not claim interface 0 before use
Jun 12 17:29:11 WRT160NL user.info kernel: usb 1-1: USB disconnect, address 2
Jun 12 17:29:11 WRT160NL user.info kernel: generic ttyUSB1: generic converter now disconnected from ttyUSB1
Jun 12 17:29:11 WRT160NL user.info kernel: usbserial_generic 1-1:1.1: device disconnected
Jun 12 17:29:16 WRT160NL user.info kernel: usb 1-1: new high speed USB device using ar71xx-ehci and address 3
Jun 12 17:29:16 WRT160NL user.info kernel: usb 1-1: configuration #1 chosen from 1 choice
Jun 12 17:29:16 WRT160NL user.info kernel: option 1-1:1.0: GSM modem (1-port) converter detected
Jun 12 17:29:16 WRT160NL user.info kernel: usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
Jun 12 17:29:16 WRT160NL user.info kernel: option 1-1:1.1: GSM modem (1-port) converter detected
Jun 12 17:29:16 WRT160NL user.info kernel: usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
Jun 12 17:29:16 WRT160NL user.info kernel: option 1-1:1.2: GSM modem (1-port) converter detected
Jun 12 17:29:16 WRT160NL user.info kernel: usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
Jun 12 17:29:16 WRT160NL user.info kernel: scsi3 : SCSI emulation for USB Mass Storage devices
Jun 12 17:29:16 WRT160NL user.debug kernel: usb-storage: device found at 3
Jun 12 17:29:16 WRT160NL user.debug kernel: usb-storage: waiting for device to settle before scanning
Jun 12 17:29:16 WRT160NL user.info kernel: scsi4 : SCSI emulation for USB Mass Storage devices
Jun 12 17:29:16 WRT160NL user.debug kernel: usb-storage: device found at 3
Jun 12 17:29:16 WRT160NL user.debug kernel: usb-storage: waiting for device to settle before scanning
Jun 12 17:29:21 WRT160NL user.notice kernel: scsi 3:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
Jun 12 17:29:21 WRT160NL user.debug kernel: usb-storage: device scan complete
Jun 12 17:29:21 WRT160NL user.notice kernel: scsi 4:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
Jun 12 17:29:21 WRT160NL user.notice kernel: sd 4:0:0:0: [sda] Attached SCSI removable disk
Jun 12 17:29:21 WRT160NL user.debug kernel: usb-storage: device scan complete
 

 

Using it

To start using your new configuration:

root@WRT160NL:~# ifup ppp0
SIM ready
PIN set successfully

And now ping a host on Internet

root@WRT160NL:~# ping ftp.sunet.se
PING ftp.sunet.se (194.71.11.69): 56 data bytes
64 bytes from 194.71.11.69: seq=0 ttl=55 time=119.351 ms
64 bytes from 194.71.11.69: seq=1 ttl=55 time=88.978 ms
64 bytes from 194.71.11.69: seq=2 ttl=55 time=88.751 ms
64 bytes from 194.71.11.69: seq=3 ttl=55 time=88.484 ms
64 bytes from 194.71.11.69: seq=4 ttl=55 time=128.257 ms
^C
--- ftp.sunet.se ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 88.484/102.764/128.257 ms
 

Stop your connection:

root@WRT160NL:~# ifdown ppp0

 

Useful links

 

  • Share/Bookmark

15 Responses to “Howto use 3G dongle Huawei E1750 in OpenWrt”

  1. Mutte Says:

    I can’t download usb-switch.
    I have tried to update oplg with no success. Any ideas?

  2. peter Says:

    I do not understand “update oplg”?

    You must have a working internet connection for yor OpenWrt router and must be able to run:
    opkg update

    If that does not work, google is your friend.

  3. Mutte Says:

    Hi
    Sorry about the miss-spelling, my keyboard must have a virus ;) .

    My Router have a working internet connection. But there is no usb-switch download. Do you have any other link?

    Log:

    root@OpenWrt:~# opkg update
    Downloading http://downloads.openwrt.org/backfire/10.03/brcm47xx/packages/Packages.gz.
    Inflating http://downloads.openwrt.org/backfire/10.03/brcm47xx/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/packages.
    root@OpenWrt:~# opkg install usb-swtitch
    Collected errors:
    * opkg_install_cmd: Cannot install package usb-swtitch.
    root@OpenWrt:~#

    /Mutte

  4. peter Says:

    try:
    opkg install usb-switch

    Not
    opkg install usb-swtitch

  5. Mutte Says:

    Sorry, but it give me the same problem. Now I have double-checked the spelling.
    Do you have any binary package link?

    Log:

    root@OpenWrt:~# opkg update
    Downloading http://downloads.openwrt.org/backfire/10.03/brcm47xx/packages/Packages.gz.
    Inflating http://downloads.openwrt.org/backfire/10.03/brcm47xx/packages/Packages.gz.
    Updated list of available packages in /var/opkg-lists/packages.
    root@OpenWrt:~# opkg install usb-switch
    Collected errors:
    * opkg_install_cmd: Cannot install package usb-switch.

  6. peter Says:

    oups, try
    opkg install usb-modeswitch

  7. grqq Says:

    I have a problem. Everything works fine but every time I reboot the device a have to type usb_modeswitch and ifup ppp0 to enable the Internet connection. Is there any way to avoid this and enable this commands automatticly? Please help me.

  8. peter Says:

    Well, It is linux and very flexible so please feel free to implement it. I have not done it because it has not been painfull enough to not have this feature. But a simple startup script should fix it.

  9. grqq Says:

    I’m pretty much linux noob so how I can make this startup script? Can You provide me any examples?

  10. Mutte Says:

    usb-modeswitch is working.

    Thanks!

  11. peter Says:

    @qrqq: Yes, my consultant fee is 100 EUR/h and estimate it to be approx 1 hour dev, including test and documentation.

  12. peter Says:

    @Mutte: No problem, sorry about the typo.

  13. Mutte Says:

    Everything is working now, but I will be back with a automatically start-up script (I hope).

  14. Mutte Says:

    To create a start-up script (I prefer nano):

    Simply edit /etc/rc.local

    # Put your custom commands here that should be executed once
    # the system init finished. By default this file does nothing.

    usb_modeswitch
    sleep 30
    ifup ppp0

    exit 0

  15. grqq Says:

    Thanks everything is working fine now.

Leave a Reply

Filled Under: Cool things, Geek stuff, english




Book reviews
FreePBX 2.5
Powerful Telephony Solutions






Asterisk 1.6
Build a feature rich telephony system with Asterisk






Learning NAGIOS 3.0





Cacti 0.8 Network Monitoring,
Monitor your network with ease!