Sunday, September 21, 2008

making a 3G Huawei 220 USB modem work in Linux 2.6

Context: just received a Huawei 220 3G USB modem [1] (HSDPA/UMTS/EDGE/GPRS/GSM, HSDPA <= 3.6Mbps ), have to make it work in my Linux thinkpad X60 w/ Linux 2.6.20+ , for accessing the Swisscom HSDPA service.

It didn't work out of the box, mainly because of the device's CD emulation storage (windoze drivers :P) interfering with its comm device.

First searches return pointers to a "vodafone-mobile-connect-card-driver-for-linux" [2] package, which is absolute crap: a heavy weight GUI interface that doesn't even work (at least for me).

Hey ... I just want to have my /dev/ttyUSB0 to be able to configure a pppd on it, I found a true, low level solution [3] that manages to make the device behave like the very thing it was born for :)

Here is an excerpt of the mininum required configs to make it work

  • /etc/udev/rules.d/99-huawei.rules

    ## /etc/udev/rules.d/99-huawei.rules
    ##
    ## to enable it, run: udevcontrol reload_rules
    ##
    #
    # udev rule for HUAWEI E220 3G HSDPA Modem
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # (c)opyleft OOZIE < oozie@poczta.fm >
    #
    # This file prevents the pseudo scsi cdrom device from enabling,
    # thus providing a workaround for kernel versions < 2.6.20
    #
    # Minor edition by JuanJo Ciarlante
    ##

    SUBSYSTEM=="block", \
    ACTION=="add", \
    SYSFS{idVendor}=="12d1", \
    SYSFS{idProduct}=="1003", \
    RUN="/sbin/modprobe usbserial vendor=0x12d1 product=0x1003", \
    OPTIONS="ignore_device"


  • /etc/ppp/peers/3g

    # /etc/ppp/peers/3g
    # pppd call 3g nodetach
    # (using Huawei e220 USB modem)
    /dev/ttyUSB0
    #3600000 #irrelevant
    noipdefault
    defaultroute
    user gprs
    password gprs
    #persist
    lock
    noauth
    nodetach
    usepeerdns
    nodeflate
    nobsdcomp
    nopcomp
    noaccomp
    novj
    novjccomp
    nomagic
    #asyncmap 0
    #lcp-echo-failure 10000
    #lcp-echo-interval 1000
    lcp-echo-failure 10
    lcp-echo-interval 30
    connect '/usr/sbin/chat -v -f /etc/ppp/peers/3g.chat'
    debug
    idle 180
    holdoff 10

  • /etc/ppp/peers/3g.chat

    # /etc/ppp/peers/3g.chat
    TIMEOUT 3
    ABORT BUSY
    ABORT 'NO CARRIER'
    ABORT VOICE
    ABORT 'NO DIALTONE'
    ABORT 'NO DIAL TONE'
    ABORT 'NO ANSWER'
    ABORT DELAYED
    "" ATZ
    OK ATQ0V1E1S0=0&C1&D2
    OK AT+CGDCONT=1,"IP","gprs.swisscom.ch","0.0.0.0",0,0
    OK ATDT*99#
    CONNECT ""


1 comment:

Unknown said...

Found a cool reference for AT the command to get/set 3G/GSM selection ( "AT+COPS" ):
http://rendo.info/?m=20080529