Differences

This shows you the differences between two versions of the page.

doc:recipes:3gdongle [2012/12/08 22:49]
ajo
doc:recipes:3gdongle [2014/03/24 00:14] (current)
valentt ppp0 line commented
Line 2: Line 2:
| FIXME: REDUNDANT with [[doc/howto/wired.wan.with.3g.dongle]] | | FIXME: REDUNDANT with [[doc/howto/wired.wan.with.3g.dongle]] |
-| FIXME: Is the kmod-usb-serial-option really needed? | 
This recipe explains how to setup and configure OpenWrt for using a USB 3g/UMTS-modem for WAN connection. You may want to checkout the ''[[doc:uci:multiwan]]'' package to use this simultaneously with other connections to the internet. This recipe explains how to setup and configure OpenWrt for using a USB 3g/UMTS-modem for WAN connection. You may want to checkout the ''[[doc:uci:multiwan]]'' package to use this simultaneously with other connections to the internet.
Line 14: Line 13:
:!: If you have the Leadtek FlashOFDM card (Flarion) from T-Mobile in Slovakia and the Asus WL-500g Premium, you may use the image on [[http://www.accalio.com/index.php?id=301]]. If you wish to get more information, or another distribution with the driver, please contact Accalio [[http://www.accalio.com]] :!: If you have the Leadtek FlashOFDM card (Flarion) from T-Mobile in Slovakia and the Asus WL-500g Premium, you may use the image on [[http://www.accalio.com/index.php?id=301]]. If you wish to get more information, or another distribution with the driver, please contact Accalio [[http://www.accalio.com]]
 +
 +:!: You must not install **usb-modeswitch** onto your wrt device if you cure your 3g-usb modem from the so called **'NO-CD'** feature. Plug it into a desktop PC with usb-modeswitch and have a look at [[http://3g-modem.wetpaint.com/page/Huawei+AT-commands]]. I was able to fix 3 modems with **a simple AT-command**. Plugged in, they just show up the serial lines (ttyUSB0-2) and the sd-card reader. Very nice!
 +
 +:!: Some sticks provide an usb-ethernet-device. (E.g. E303) In that case usb-modeswitch and [[doc:howto:usb.tethering|usb tethering]] will help.
===== Preparations ===== ===== Preparations =====
==== Required Packages ==== ==== Required Packages ====
First install required packages: First install required packages:
-  *//comgt// [[http://linux.die.net/man/1/comgt|manpage for comgt]]+  *//comgt// [[http://dev.man-online.org/man1/comgt/|manpage for comgt]]
  *Appropriate host controller interface for your USB hardware (precompiled images will most likely already contain the correct one)   *Appropriate host controller interface for your USB hardware (precompiled images will most likely already contain the correct one)
    *//kmod-usb2// (aka EHCI)     *//kmod-usb2// (aka EHCI)
Line 31: Line 34:
  *modeswitching tools, if your modem initially presents itself as a storage device - one of the following, depending on your modem:   *modeswitching tools, if your modem initially presents itself as a storage device - one of the following, depending on your modem:
    *//usb-modeswitch// and //usb-modeswitch-data// (//recommended//) A mode switching tool for controlling "flip flop" (multiple device) USB gear.     *//usb-modeswitch// and //usb-modeswitch-data// (//recommended//) A mode switching tool for controlling "flip flop" (multiple device) USB gear.
 +Note: as of [[https://dev.openwrt.org/changeset/36812|r36812]], usb-modeswitch package  had been under major overhaul from ordinary draisberghof usb_modeswitch found in many linux distributions. Its data is included in the package, with the new json format.
    *//sdparm// - utility to send SCSI commands (needed on Ovation MC935D)     *//sdparm// - utility to send SCSI commands (needed on Ovation MC935D)
  * //luci-proto-3g// for proper support in luci in RC6 and later   * //luci-proto-3g// for proper support in luci in RC6 and later
Line 43: Line 47:
===== Installation ===== ===== Installation =====
 +First install needed packages:
 +<code>
 +opkg update
 +opkg install comgt kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch
 +</code>
 +
Now plug your USB Dongle to the USB port and restart the router. Now plug your USB Dongle to the USB port and restart the router.
Line 80: Line 90:
insmod /lib/modules/`uname -r`/usbserial.ko vendor=0x<vid> product=0x<pid> insmod /lib/modules/`uname -r`/usbserial.ko vendor=0x<vid> product=0x<pid>
</code> </code>
 +Alternatively, you can also use option GSM driver on your dongle. Option driver is more reliable, as it can distinguish between serial port and storage port.
 +<code>
 +insmod option #skip this if option driver is loaded already
 +echo '<vid> <pid> ff' > /sys/bus/usb-serial/drivers/option1/new_id
 +</code>
 +
 +To automate the process of attaching option serial driver on boot, just edit ''/etc/rc.local'' and place ''echo '<vid> <pid> ff' > /sys/bus/usb-serial/drivers/option1/new_id'' before ''exit 0''.
 +
 +Adding the above to hotplug instead of rc.local:
 +You can easily integrate this into hotplug in the following way - in this example we will use a TP-Link MA260 HSPA+ Dongle:
 +
 +Create and edit the file /etc/hotplug.d/usb/22-tplink_ma260:
 +<code>
 +#!/bin/sh                                                                     
 +...
 +                                                                               
 +TPLINKMA260_PRODID="2357/9000/0"                                               
 +if [ "${PRODUCT}" = "${TPLINKMA260_PRODID}" ]; then                           
 +        if [ "${ACTION}" = "add" ]; then                         
 +...           
 +                echo '2357 9000 ff' > /sys/bus/usb-serial/drivers/option1/new_id
 +...
 +</code>
 +
 +If your modem's switched product id is 2357:9000, the above will work.
 +So for your modem you will have to replace all appearances of the variable TPLINKMA260_PRODID and all appearance of "2357" and "9000" in the above example with your matching product's name, vendor and product id.
 +
 +For the [[TP-Link MA260]] please note, that there are some issues, which will be described later. See [[doc:recipes:3gdongle#TP-Link MA260|Workaround for TP-Link MA260]].
 +Similar may apply to TP-Link MA180.
Check dmesg again for: Check dmesg again for:
Line 91: Line 130:
usbcore: registered new interface driver usbserial_generic usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core usbserial: USB Serial Driver core
 +</code>
 +Also check kernel USB debug for loaded drivers
 +<code>
 +root@OpenWrt:~# cat /sys/kernel/debug/usb/devices
 +
 +T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
 +D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
 +P:  Vendor=1c9e ProdID=9800 Rev= 0.00
 +S:  Manufacturer=USB Modem
 +S:  Product=USB Modem
 +S:  SerialNumber=1234567890ABCDEF
 +C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA
 +I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
 +E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 +E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
 +I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
 +E:  Ad=82(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
 +E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 +E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
 +I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
 +E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 +E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
 +I:* If#= 3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
 +E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 +E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
</code> </code>
Line 100: Line 164:
Now your USB Dongle should create logs in dmesg. If it doesn't, try <code>usb_modeswitch -c /etc/usb_modeswitch.d/<file></code> where ''<file>'' represents the modem's combined vendor/product id, e.g. 19d2:0083 for a ZTE MF190. Obviously, that file must exist in the forementioned directory. Now your USB Dongle should create logs in dmesg. If it doesn't, try <code>usb_modeswitch -c /etc/usb_modeswitch.d/<file></code> where ''<file>'' represents the modem's combined vendor/product id, e.g. 19d2:0083 for a ZTE MF190. Obviously, that file must exist in the forementioned directory.
 +For instance, with the DX 7.2M HSDPA 3G SIM Card USB Item# 80032, the reported scsi ID is 12d1:1001; running "usb_modeswitch  -v 12d1 -p 1001" results in 4 ttyUSB devices:
 +<code>
 +[426955.836000] option 1-1.2:1.0: GSM modem (1-port) converter detected
 +[426955.844000] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
 +[426955.860000] option 1-1.2:1.1: GSM modem (1-port) converter detected
 +[426955.868000] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
 +[426955.884000] option 1-1.2:1.2: GSM modem (1-port) converter detected
 +[426955.892000] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
 +[426955.908000] option 1-1.2:1.3: GSM modem (1-port) converter detected
 +[426955.916000] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB3
 +[426955.936000] scsi17 : usb-storage 1-1.2:1.4
 +[426956.940000] scsi 17:0:0:0: CD-ROM            HSDPA    CDROM Storage    2.31PQ: 0 ANSI: 2
 +[426956.948000] scsi 17:0:0:0: Attached scsi generic sg0 type 5
 +[426956.960000] scsi 17:0:0:1: Direct-Access    HSDPA    MMC Storage      2.31PQ: 0 ANSI: 2
 +[426956.968000] sd 17:0:0:1: Attached scsi generic sg1 type 0
 +[426956.992000] sd 17:0:0:1: [sda] Attached SCSI removable disk
 +</code>
 +
 +As of [[https://dev.openwrt.org/changeset/36812|r36812]], OpenWrt made significant changes with ''usb-modeswitch'' as part of ''procd'' system init daemon. The new ''usb-modeswitch'' package includes binary usbmode with json-based configuration instead of classic usb_modeswitch binary. Supported modems should switch automatically as long as usbmode service is active.
 +The ''/etc/usb-mode.json'' configuration file looks partially like below.
 +<code>
 +{
 + "messages" : [
 + "555342431234567800000000000006d0000000000000000000000000000000",
 + "5553424312345678000000000000061b004600000000000000000000000000",
 +],
 +"devices" : {
 + "03f0:002a": {
 + "*": {
 + "t_class": 7,
 + "msg": [ 0 ],
 + "response": true
 + }
 + },
 + "0408:f000": {
 + "*": {
 + "t_vendor": 1032,
 + "t_product": [ 53257 ],
 + "msg": [ 1 ]
 + }
 + },
 + }
 +}
 +</code>
 +FIXME As long as I understand, ''03f0:002a'' is default vendor and product in hexadecimal as appears on ''lsusb'' or kernel usb debug, ''msg'' is numbered message starting from 0, ''t_vendor'' is target vendor in decimal notation, ''t_product'' is target product in decimal notation. If you want to know more, look at the file /etc/usb-mode.json
 +
 +Note: the json file is generated automaticallly from ordinary usb_modeswitch data files during build process using perl script named ''convert-modeswitch.pl''.
 +For diagnostics purpose, you can create ''usb-mode-custom.json'' with defined message and devices part and launch the command
 +<code>
 +usbmode -l
 +usbmode -s -v -c /path/to/usb-mode-custom.json
 +</code>
If your device doesn't work with usb_modeswitch, try the sdparm method. If your device doesn't work with usb_modeswitch, try the sdparm method.
Line 119: Line 235:
<code> <code>
sdparm --eject /dev/sg0 sdparm --eject /dev/sg0
 +</code>
 +
 +For Attitude Adjustment try:
 +<code>
 +sdparm --command=eject /dev/sg0
</code> </code>
Line 141: Line 262:
| ''config interface wan | ''config interface wan
-        option ifname  ppp0+#        option ifname  ppp0 # on some carriers enable this line
        option pincode 1234         option pincode 1234
        option device  /dev/ttyUSB0         option device  /dev/ttyUSB0
Line 626: Line 747:
{{tag>USBrelated}} {{tag>USBrelated}}
 +
 +===== Workarounds =====
 +==== TP-Link MA260 ====
 +If you plug the MA260 into the USB Port of a compatible OpenWRT device running attitude adjustment, you will notice certain issues, similar to those described in the Ubuntu Forum: [TP Link MA260, Ubuntu 12.04 LTS[http://ubuntuforums.org/showthread.php?t=2197164]], e.g. missing modeswitch routines missing hotplug etc.
 +
 +Create and edit the file /etc/hotplug.d/usb/21-tplink_ma260 with the following content:
 +
 +<code>
 +#!/bin/sh                                                                                                                                     
 +BINARY="/usr/bin/usb_modeswitch"                                                                                                               
 +                                                                                                                                               
 +TPLINKMA260_PRODID1="2357/f000/0"                                                                                                             
 +TPLINKMA260_PRODID2="2357/9000/0"                                                                                                             
 +                                                                                                                                               
 +# switch from storage mode to modem mode                                                                                                       
 +if [ "${PRODUCT}" = "${TPLINKMA260_PRODID1}" ]; then                                                                                           
 +        if [ "${ACTION}" = "add" ]; then                                                                                                       
 +                # give the storage some time to finish mounting                                                                               
 +                sleep 15                                                                                                                       
 +                # issue the modeswitch and change the product id.                                                                             
 +                ${BINARY} -v 2357 -p f000 -V 2357 -P 9000 -W -I -n \                                                                           
 +                -M '5553424312345678000000000000061e000000000000000000000000000000' \                                                         
 +                -2 '5553424312345678000000000000061b000000020000000000000000000000'                                                           
 +                logger -t HOTPLUG "${TPLINKMA260_PRODID1} plugged in."                                                                         
 +        fi                                                                                                                                     
 +        if [ "${ACTION}" = "remove" ]; then                                                                                                   
 +                logger -t HOTPLUG "${TPLINKMA260_PRODID1} was removed."                                                                       
 +        fi                                                                                                                                     
 +fi                                                                                                                                             
 +                                                                                                                                               
 +if [ "${PRODUCT}" = "${TPLINKMA260_PRODID2}" ]; then                                                                                           
 +        if [ "${ACTION}" = "add" ]; then                                                                                                       
 +                #register usbserial and option device driver with the modem mode id:                                                           
 +                echo '2357 9000 ff' > /sys/bus/usb-serial/drivers/option1/new_id                                                               
 +                logger -t HOTPLUG "${TPLINKMA260_PRODID2} plugged in."                                                                         
 +        fi                                                                                                                                     
 +        if [ "${ACTION}" = "remove" ]; then                                                                                                   
 +                logger -t HOTPLUG "${TPLINKMA260_PRODID2} was removed."                                                                       
 +        fi                                                                                                                                     
 +fi
 +</code>
 +In order to work correctly the package usb_modeswitch needs to be installed.

Back to top

doc/recipes/3gdongle.1355003343.txt.bz2 · Last modified: 2012/12/08 22:49 by ajo