Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

2008-04-15

Goodbye xorg.conf!

After reading this article on xrandr, I wanted to see how total autoconfiguration works on X Windows.

As a start, I tried removing xorg.conf file completely and restart X. The sky didn't fall down! In fact, I didn't notice any change. Everything from USB hotplug to OpenGL continued to work as before.

The only tweak needed was to the old font system. Unlike fontconfig, the old X font system seems to depend on the "font path" set in xorg.conf. This was a problem for using my custom SUN22x12 font in xterm. After adding the following lines to ~/.fvwm/preferences/Startup, this problem was gone, too.

AddToFunc InitFunction
+ I Exec exec /usr/bin/xset +fp /usr/local/share/fonts

Yes, I use fvwm-crystal, a "polished" version of FVWM. Old school, so what?

Read more...

2008-04-09

Mobitel 3G with Huawei E220 on Debian

Finally I decided to shift my mobile Internet connectivity from GPRS to HSDPA by getting a Mobitel 3G broadband connection.

The package includes a Huawei E220 HSDPA USB modem (Wikipedia article), SIM card and connection, connection fee and first month's bill waived, a Rs 5k deposit which shall be refunded after an year.

Huawai E220 is known to work out of the box on Linux after 2.6.20. However, some of the most recent kernels seems to have a conflict with the USB mass storage driver. It means, the disk drive in the modem with Windows drivers get detected, but not the modem. I am presently running Linux 2.6.24.4, which also exhibits this behavior.

Bud suggested a quick workaround: to start the computer while the USB dongle is plugged in. This worked, and the modem was autodetected as /dev/ttyUSB0.

The sales person at Excel World Mobitel outlet told me that the APN has to be statically set to "mobitel3g" and the number is "*99***1#". It was easy to find the AT commands to do this. I created the following /etc/wvdial.conf file and running "wvdial" afterwards took me to the Internet. Username and password was just to stop wvdial complaining.

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 1843200
Modem Type = Analog Modem
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","mobitel3g"
Dial Command = ATDT
Phone = *99***1#
Username = foo
Password = bar
Stupid Mode = yes

Going with the "get it working, then make it better" philosophy, then I looked at the conflict with the USB disk. There are couple of suggestions to the kernel usb-storage driver discussed on the above thread - which didn't work for me unfortunately, but just running this huaweiAktBbo utility did the trick. So I copied the binary to a standard location.

# apt-get install build-essential libusb-dev   # just to be sure
# cc -o huaweiAktBbo -lusb huaweiAktBbo.c
# cp huaweiAktBbo /usr/local/sbin/

Then I created a small script to initiate the connection:

#!/bin/sh

lock=/tmp/.mobitel.lock
if ln -s $lock $lock
then
    [ -c /dev/ttyUSB0 ] || /usr/local/sbin/huaweiAktBbo
    sleep 3
    if [ -c /dev/ttyUSB0 ]
    then
        cp -f /etc/wvdial.conf.mobitel /etc/wvdial
        /usr/bin/wvdial
    fi
    rm -f $lock
fi

exit 0

Lock can also be created in /var/run, and notice that I have not done a "set -e", because if wvdial stops with an error, we still need to remove the lock. The lock is there to avoid multiple invocations of the script.

Then I created a simple udev rule to automatically connect whenever the E220 is plugged in. You can use "lsusb", among others, to find the vendor ID and product ID. I created a new /etc/udev/rules.d/010_local.rules file with the following line.

ACTION=="add", BUS=="usb", SYSFS{idVendor}=="12d1", \
    SYSFS{idProduct}=="1003", RUN+="/usr/local/sbin/mobitel.sh"

That's it! Now I am on the Internet automatically whenever the device is connected to the computer!

The only remaining "problem" was hal which was still trying to automount the USB disk. As suggested in ArchLinux wiki, creating a file /usr/share/hal/fdi/preprobe/20thirdparty/10-huawei-e220.fdi with the following fixes this:

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
 <device>
   <match key="usb.vendor_id" int="0x12d1">
     <match key="usb.product_id" int="0x1003">
       <merge key="info.ignore" type="bool">true</merge>
     </match>
   </match>
 </device>
</deviceinfo>

The connection is fast and way cheaper than GPRS when it comes to volume. HSDPA costs one rupee per MB, while GPRS costs 20!

Update: I noticed that udev runs the script multiple times, so as a quick fix I have added a test for /dev/ttyUSB0 in a couple of places in the script to make matters better.

Read more...