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
- http://josefsson.org/openwrt/dongle.html The excellent guide that I used as a platform, read it!
- OpenWrt, Linuxbased firmware for routers
September 7th, 2010 at 7:20 am
I can’t download usb-switch.
I have tried to update oplg with no success. Any ideas?
September 7th, 2010 at 10:23 am
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.
September 7th, 2010 at 1:54 pm
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
September 7th, 2010 at 2:51 pm
try:
opkg install usb-switch
Not
opkg install usb-swtitch
September 7th, 2010 at 3:33 pm
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.
September 7th, 2010 at 5:26 pm
oups, try
opkg install usb-modeswitch
September 8th, 2010 at 9:49 am
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.
September 8th, 2010 at 10:00 am
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.
September 8th, 2010 at 11:14 am
I’m pretty much linux noob so how I can make this startup script? Can You provide me any examples?
September 8th, 2010 at 1:43 pm
usb-modeswitch is working.
Thanks!
September 8th, 2010 at 4:50 pm
@qrqq: Yes, my consultant fee is 100 EUR/h and estimate it to be approx 1 hour dev, including test and documentation.
September 8th, 2010 at 4:50 pm
@Mutte: No problem, sorry about the typo.
September 8th, 2010 at 8:55 pm
Everything is working now, but I will be back with a automatically start-up script (I hope).
September 9th, 2010 at 7:06 am
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
September 10th, 2010 at 7:58 am
Thanks everything is working fine now.
December 3rd, 2010 at 12:09 am
[…] Quellen http://www.it-slav.net/blogs/2010/06/12/howto-use-3g-dongle-huawei-e1750-in-openwrt/ http://josefsson.org/openwrt/dongle.html posted by Stephan in Linux, Netzwerk, openwrt and have […]
December 18th, 2010 at 7:03 pm
Whenever I tried to run usb_modeswitch I got the error msg:
“no MessageEndpoint given. Can’t send message. Aborting”
I solved the problem by adding the line:
MessageEndpoint=0x01
to /etc/usb_modeswitch.conf
Thanks for your howto!
December 19th, 2010 at 12:03 am
[…] Credits: Peter Andersson […]
January 8th, 2011 at 6:13 pm
hi I am tring to follow this tutorial using franklin wireless u600 3g/4g modem.
but i get this message
usb.c: new USB bus registered, assigned bus number 1
ehci_hcd 00:03.1: illegal capability!
ehci_hcd 00:03.1: USB 0.0 enabled, EHCI 1.00, driver 2003-Dec-29/2.4
hub.c: USB hub found
hub.c: 2 ports detected
ip_conntrack version 2.1 (5953 buckets, 5953 max) – 352 bytes per conntrack
hub.c: new USB device 00:03.1-1, assigned address 2
hub.c: USB hub found
hub.c: 2 ports detected
hub.c: new USB device 00:03.1-1.2, assigned address 3
hub.c: USB hub found
hub.c: 4 ports detected
hub.c: new USB device 00:03.1-1.2.2, assigned address 4
usb.c: USB device 4 (vend/prod 0x1fac/0x150) is not claimed by any active driver
.
uhci.c: USB Universal Host Controller Interface driver v1.1
usb.c: registered new driver acm
acm.c: v0.21:USB Abstract Control Model driver for USB modems and ISDN adapters
usb.c: registered new driver serial
usbserial.c: USB Serial support registered for Generic
usbserial.c: USB Serial Driver core v1.4
January 10th, 2011 at 8:48 am
I cannot tell anything out of this small piece of information.
March 4th, 2011 at 6:05 pm
Hi I am tring to install my u600 modem .How can i modify the steps or code for this to work?
March 4th, 2011 at 8:09 pm
If you give me a modem I can try to get it running and tell you how.
March 5th, 2011 at 7:16 pm
I am configuring my franklin wireless u600 modem to work on openwrt.
The set up is as follows:
I configured the prod/vendor id :
/etc/modules.d/60-usb-serial
[code]root@OpenWrt:/etc# vi modules.d/60-usb-serial
usbserial vendor=0x1fac product=0x150
[/code]
Next using the configurations in the devices txt, I entered the following in usb-modeswitch.conf:
[code]
########################################################
# Franklin Wireless U210
#
# Contributor: Adam J. Porter
DefaultVendor= 0x1fac
DefaultProduct=0x0150
TargetVendor= 0x1fac
TargetProduct= 0x0151
CheckSuccess=20
MessageContent=”555342431234567824000000800108df200000000000000000000000000000″
##############################################################
[/code]
(This was the only one to match my modem.So changed the default product to 0x0150 as this is what it showed up as -dmesg)
After I entered to following network configurations:
[code]
config interface wan
option proto ‘3g’
option service ‘cdma’
option ‘device’ ‘/dev/ttyUSB0’
option apn ‘internet’
[/code]
After I rebooted the router and entered the usb_modeswitch command:
[code]
root@OpenWrt:/etc# usb_modeswitch
Looking for target devices …
No devices in target mode or class found
Looking for default devices …
Found default devices (1)
Accessing device 004 on bus 001 …
Using endpoints 0x08 (out) and 0x87 (in)
Inquiring device details; driver will be detached …
Looking for active driver …
No driver found. Either detached before or never attached
SCSI inquiry data (for identification)
————————-
Vendor String: Franklin
Model String: Auto-Installer
Revision String: 2.31
————————-
USB description data (for identification)
————————-
Manufacturer: Franklin Wireless Corp.
Product: USB Micro SD Storage
Serial No.: 216169176500
————————-
Setting up communication with interface 0 …
Trying to send the message to endpoint 0x08 …
OK, message successfully sent
Checking for mode switch (max. 20 times, once per second) …
Waiting for original device to vanish …
Original device can’t be accessed anymore. Good.
Searching for target devices …
Searching for target devices …
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.
[/code]
I then did a dmesg and the follwoing showed up saying that usb_modeswitch did not claim the device (vend/prod 0x1fac/0x151)
Also I believe the (vend/prod 0x198f/0x220) is the wimax part.But not concerned with that at the momment.
$dmesg
[code]
…….usbserial.c: Generic converter now disconnected from ttyUSB0
usbdevfs: process 555 (usb_modeswitch) did not claim interface 0 before use
usb.c: USB disconnect on device 00:03.1-1.1.2 address 4
hub.c: new USB device 00:03.1-1.1.1, assigned address 5
usb.c: USB device 5 (vend/prod 0x198f/0x220) is not claimed by any active driver.
hub.c: new USB device 00:03.1-1.1.2, assigned address 6
usb.c: USB device 6 (vend/prod 0x1fac/0x151) is not claimed by any active driver.
[/code]
Maybe this is the wring prod/vendor ids but can you tell me how the fix this thanks.
March 5th, 2011 at 7:24 pm
Does it work with Ubuntu?
If yes, do as I, copy the config files from there.
If no, then I do not have a clue without having the device myself.
May 21st, 2012 at 12:00 pm
Hi
I'm following this guide to the letter, but when I restart the firewall I get
/etc/rc.common: eval: line 1: scan_ppp: not found
/etc/rc.common: eval: line 1: scan_ppp: not found
/etc/rc.common: eval: line 1: scan_ppp: not found
/etc/rc.common: eval: line 1: scan_ppp: not found
Loading defaults
Loading synflood protection
Adding custom chains
Loading zones
… and more lines.
Do you know how to get scan_ppp up and running?